Question

I am going to call gstreamer functions in NPAPI plugin, but what I found is when I invoke method "gst_init" in plugin, it always failed! no matter I call it in a new thread or a child process, it can not get passed. so I'm wonder how can I call the gst_init function in the correct way? :)

for example :

Javascript code: obj.play();

obj is the plugin NPObject.

static void* play(void *) {

    GMainLoop *loop;
    GstElement *pipeline,*source,*decoder,*sink;
    GstBus *bus;


    gst_init(NULL, NULL);
    ...
}

bool plugin_invoke(NPObject *obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result) {
    NPUTF8 *name = sBrowserFuncs->utf8fromidentifier(methodName);
    if (strcmp(name, plugin_method_name_gs) == 0) {
        ...

        pthread_t tid = 0;
        int ret = 10000;
        ret = pthread_create(&tid, NULL, play, NULL);


        ...
        return true;
    }

    sBrowserFuncs->memfree(name);
    return false;
}
Was it helpful?

Solution

In fact, this is a linking problem, in Ubuntu 12.04 64bits, we should compile it by using

gcc xxx.c `pkg-config --cflags --libs gstreamer-xxx` -o output_file 

(the src file name must followed with command gcc/g++ , some people must met this bug ever.), but I embed this code into a Qt project, I create the makefile by qmake, it can not put the src file name behind gcc/g++ automatic, so when I use ldd to check the share libs, it is not correct.

as I know in Ubuntu 32bits doesn't met this bug.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top