[gst-devel] handoff calling C++ object member function

Mathrick mnews2 at wp.pl
Tue Jan 6 11:34:02 CET 2004

W liście z wto, 06-01-2004, godz. 20:06, Quan Nguyen pisze: 
> I am having a problem with calling a C++ object's member function from
> a handoff.  I want to be able to call a member function of an object
> from a listener handoff function.  I assume that I will have to pass
> to the handoff function a pointer to that object, but I do not know
> how to do it.  Here is some sample code of what I am trying to do.
> ...
> g_signal_connect (G_OBJECT (listener), "handoff", G_CALLBACK
> (cb_manipulate), NULL);
> ...
> }
> static void cb_manipulate (GstElement *element, GstData *data)
> {
> ...
>    some_object->useful_func();
> ...
> }
> I want to be able to call useful_func() for some_object.  My question
> is how do I pass more parameters to the handoff function?

Use the last param for g_signal_connect, so it should look like:

MyDataType *my_data = // ... fill my_data

g_signal_connect (G_OBJECT (listener), "handoff", G_CALLBACK
(cb_manipulate), my_data);
static void cb_manipulate(GstElement *elem, MyDataType *data)
  // ...
  // data is my_data you passed earlier on
  some_object->useful_func(data->param1, data->param2)
  // ...

Also, is there any specific reason to declare cb_manipulate as static?
You want to keep it private for file or some other one?

"Tautologizm to coś tautologicznego"
   Maciej Katafiasz <mnews2 at wp.pl>

More information about the gstreamer-devel mailing list