Re: new to g_signal_connect

Hi Charles,

On Sat, 2008-10-11 at 14:59 +0800, Charles wrote:
> Hi guys,
> I'm always confused of the function g_signal_connect. In your project,
> I find in file cheese-webcam.c there is a
> g_signal_connect (G_OBJECT (priv->photo_sink),
> 			    "handoff",
> 			    G_CALLBACK (cheese_webcam_photo_data_cb),
> 			    webcam);
> in function cheese_webcam_take_photo and the prototype of
> cheese_webcam_photo_data_cb is
> static void
> cheese_webcam_photo_data_cb (GstElement *element, GstBuffer *buffer,
>                              GstPad *pad, CheeseWebcam *webcam);
> My problem is I want to make use of this function as a regular function
> rather than a callback while I don't know where is this GstBuffer *buffer
> from. I see that the function makes extensive use of this buffer.
I just did some quick googling on fakesink, and it seems there's no
other way to get the contents of buffer other than to use this callback.
The GstBuffer object is passed from the code of the sink object, using
the g_signal_emit function. Long story short, after going through a few
steps, the callback gets called by the sink every time it receives a
frame from the camera. At this stage, the sink is getting ready to get
rid of the buffer, but it's giving you a chance to do something with it,
in our case take a picture, before it gets rid of it. 

If I may ask, what exactly are you planning to do here? If all you want
to do is write code to take a picture, that's pretty easy. All you have
to do is connect your handler to the handoff signal when you're ready to
snap it, and then disconnect as soon as you've done what you need to do
with it. 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]