lundi 25 février 2019

Get gstreamer bus messages using non-static message handler

I have created a program using gstreamer which listens to different ports (say 5) for rtp packets.

Now I have created a class (say GstClass) which creates the pipeline, and has a Callback function which listens to the bus messages (I need this message system to shut down the pipeline after a certain timeout).

The main function looks like this - 2 threads are created with 2 objects and the GstFunc is called in both threads. The first function would listen to port 5000 and the second would listen to port 5008

int main() {

    char filepath1[ ]= "/home/rohan/Tornado1.raw";
    char filepath2[ ]= "/home/rohan/Tornado2.raw";
    unsigned int port1 = 5000;
    unsigned int port2 = 5008;

    GstClass GstObj1;
    GstClass GstObj2;

    boost::thread thrd1 { &GstClass::GstFunc, &GstObj1, filepath1, &port1 };
    boost::thread thrd2 { &GstClass::GstFunc, &GstObj2, filepath2, &port2 };

    thrd1.join();
    thrd2.join();

    return 0;
}

the class GstClass looks like this -

class GstClass {
protected:
    //some other variables...
    GMainLoop *msLoop;

public:

    gboolean bus_call(GstBus *bus, GstMessage *message,
        gpointer data);

    void GstFunc(char *filepath, unsigned int *port);

};

For detailed function view please look at this example. Replace the function int main (int argc, char *argv[]) with void GstFunc(char *filepath, unsigned int *port) with appropriate changes.

Now the dilemma I am facing is with the static function (in example) bus_call(...).

Since I am creating 2 pipelines in 2 different threads which are listening to 2 different ports, I cannot have this function as static (shared between the objects). how can I make these 2 pipelines dis-joint from each other? Or how can I get this static bus_call(...) to become non-static?

simply removing static keyword didn't help and giving this error

error: invalid use of non-static member function ‘gboolean GstClass::bus_call(GstBus*, GstMessage*, gpointer)‘

Aucun commentaire:

Enregistrer un commentaire