Re: [Vala] GStreamer Gst.Pad



On Sat, Sep 26, 2009 at 08:51:17 +0000, John - wrote:

Hi,

I am doing some test with GStreamer and Vala.

In other program language, i usually use Gst.Pad.add_buffer_probe method but in Vala i don't know how to 
use it.

I try to do :

Pad.add_buffer_probe.connect(test_buffer()); 

That is syntax for signals. This is not a signal, but a method taking
a callback.

And also i try :

Pad.add_buffer_probe(test_buffer()); 

It wants a callback, so you must pass a function, not result of one. So
something like

    Pad.add_buffer_probe(this.test_buffer);

or, if it's a method of different object, it might be

    Pad.add_buffer_probe(instance.test_buffer);

Where the test_buffer method must be declared to match the
BufferProbeCallback, so like

    bool test_buffer (Gst.Pad pad, Gst.Buffer buffer) { ... }

Doing it as instance method is recommended -- the instance is what is passed
via the user_data you normally have in C.

Most recent vala also supports closures, so you could than also use

   Pad.add_buffer_probe((pad, buffer) => boolean-expression);

or

   Pad.add_buffer_probe((pad, buffer) => { test-code; return result; });

The syntax is supported for long time already, but only since valac 0.7.6 you
can refer to variables of enclosing scope there and you may still encounter
some problems with that in 0.7.6. Jürg already talked about releasing 0.7.7
yesterday, so it should be in a day or two. Closures should be well usable
there.

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



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