0

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;
}
Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
darkwind
  • 43
  • 3
  • 1
    Are you sure you can call `gst_init()` from a non-main thread? If it fails, are there any errors in the console or logs? Note that there's also a `gst_init_check()` for graceful failures and that you probably don't want to call `gst_init()` on every call of `play()`. – Georg Fritzsche Aug 06 '13 at 13:04
  • I've ever try to call gst_init() in main thread, another thread, and child process (by fork()), but all failed. no, I do not want to call gst_init() on every calll of play(), here just a test to see whether it can do successfully. – darkwind Aug 07 '13 at 01:19
  • And I just test this plugin in Chrome and Firefox which is release version , I can only catch the plugin log except browser log. – darkwind Aug 07 '13 at 01:20
  • If you run the browsers from a terminal, i'd expect you get error output before gst_init() aborts. Alternatively try gst_init_check() for its out error parameter. – Georg Fritzsche Aug 07 '13 at 09:29
  • **I got the broswer log** symbol lookup error: /home/darkwind/testplugin/libplayerplugin.so: undefined symbol: gst_init **do you have any ideas? :)** – darkwind Aug 07 '13 at 10:03
  • Sounds like you haven't linked your plugin against gstreamer? – Georg Fritzsche Aug 07 '13 at 12:23
  • uh... I use the 'pkg-conf --cflags --libs gstreamer-1.0' as the gcc options, if linked failed, it never throw some compiling errors to me ? is there any other reasons will make linking failed ? and I compile that by this way as an executable binary file and run it in command line successfully. I can't understand why. – darkwind Aug 08 '13 at 01:21
  • Even I use the 'pkg-conf --cflags --libs gstreamer-1.0' as the gcc options, but when I use [ldd] to check the .so file, there's no [libgstreamer-1.0.so.0] in the list, it's really strange... – darkwind Aug 08 '13 at 07:32
  • I've resolved this problem , thanks for your suggestions! :) – darkwind Aug 08 '13 at 09:11
  • Great, can you post your solution as an answer? That way other people landing with a similar problem might be helpd. – Georg Fritzsche Aug 08 '13 at 11:02
  • I've Done that, really a awkward problem. – darkwind Aug 14 '13 at 09:11

1 Answers1

0

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.

darkwind
  • 43
  • 3