c# - Certain GStreamer pipelines not considered to be a bin? -


i can run simple launch pipeline command line thus:

gst-launch-1.0 videotestsrc ! ximagesink 

and, gst-inspect-1.0, ximagesink appears support gstvideooverlay interface can bind specific gtk widget.

however, when trying within code happened find lying around on net, seems pipeline not considered bin (and hence, widget id not being given it).

the code follows, first create pipeline , set capture bus messages:

gst.element playbin = gst.parse.launch("videotestsrc ! ximagesink"); gst.bus bus = playbin.bus; bus.addsignalwatch(); bus.message += msgcallback; 

then process bus messages:

private void msgcallback(object o, messageargs args) {     // care window id binding requests.      gst.message msg = args.message;     if (! gst.video.global.isvideooverlaypreparewindowhandlemessage(msg))         return;      // source of message.      gst.element src = msg.src gst.element;     if (src == null)         return;      // find element supporting interface , notify bind.      gst.element ov = null;     if (src gst.bin) {         ov = ((gst.bin) src).getbyinterface(videooverlayadapter.gtype);         videooverlayadapter ad = new videooverlayadapter(ov.handle);         ad.windowhandle = windowxid;     } } 

now, reason, src gst.bin false, meaning windowxid (the widget id i've set) never being communicated gstreamer.

however, if provide playbin pipeline (playbin uri=xyzzy videosink='videoconvert ! videoflip method=none ! videoconvert ! autovideosink', if you're interested), works fine.

as far can tell documentation gst.parse.launch(), should give me pipeline special case of bin, per here (after fixing atrocious grammar):

returns new element on success, null on failure. if more 1 top level element specified pipeline description , elements put gstpipeline, returned.

i'm pretty videotestsrc , ximagesink 2 separate top-level elements but, when add following code, after check src being null:

console.writeline("is bin      " + (src gst.bin)); console.writeline("is element  " + (src gst.element)); console.writeline("is pipeline " + (src gst.pipeline)); console.writeline(type      " + src.gettype()); 

i see:

is bin      false element  true pipeline false type     gst.element 

for problematic videotestsrc pipeline , following playbin one:

is bin      true element  true pipeline false type     gst.bin 

so points problematic 1 giving element rather bin, despite documentation states.

what missing here? difference between 2 pipelines cause different behaviour?

okay, turns out gst.parse.launch function is returning pipeline. can seen if copy checking statements after bin creation:

gst.element playbin = gst.parse.launch("videotestsrc ! ximagesink"); console.writeline("is bin      " + (playbin gst.bin)); console.writeline("is element  " + (playbin gst.element)); console.writeline("is pipeline " + (playbin gst.pipeline)); console.writeline(type      " + playbin.gettype()); 

and see:

is bin      true element  true pipeline true type     gst.pipeline 

it's that, when message in callback, source seems set element instead. haven't figured out why message source coming through element (or element is) @ least have workaround, partly advanced intelligence sneaky @ way banshee :-)

turns out callback can access bin directly rather trying out of source. works in case since have 1 video stream (bin) per instance. if have multiples, may little more difficult.

to achieve this, first make playbin member variable (if isn't already), , can modify callback thus:

private void msgcallback(object o, messageargs args) {     // care window id binding requests.      gst.message msg = args.message;     if (! gst.video.global.isvideooverlaypreparewindowhandlemessage(msg))         return;      // instance bin, interface element, notify bind.      gst.bin src = (gst.bin)(this.playbin);     if (src == null) return;      gst.element ov = src.getbyinterface(videooverlayadapter.gtype);     if (ov == null) return;      videooverlayadapter ad = new videooverlayadapter(ov.handle);     if (ad == null) return;      ad.windowhandle = windowxid; } 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -