我可以運行這樣的命令行非常簡單的管道下水:某些GStreamer管道不被認爲是垃圾箱?
gst-launch-1.0 videotestsrc ! ximagesink
,並從gst-inspect-1.0
的ximagesink
似乎支持GstVideoOverlay
接口,這樣我可以把它綁定到特定的Gtk部件。
但是,當從一些代碼中嘗試做到這一點時,我碰巧找到了網絡,看起來流水線不被認爲是一個bin(因此,widget ID沒有被賦予它)。
做如下,首先創建管道,並設置了捕捉總線消息的代碼:
Gst.Element playbin = Gst.Parse.Launch("videotestsrc ! ximagesink");
Gst.Bus bus = playbin.Bus;
bus.AddSignalWatch();
bus.Message += MsgCallback;
然後實際處理總線消息:
private void MsgCallback(object o, MessageArgs args) {
// Only care about window ID binding requests.
Gst.Message msg = args.Message;
if (! Gst.Video.Global.IsVideoOverlayPrepareWindowHandleMessage(msg))
return;
// Get source of message.
Gst.Element src = msg.Src as Gst.Element;
if (src == null)
return;
// Find element supporting interface and notify it to bind.
Gst.Element ov = null;
if (src is Gst.Bin) {
ov = ((Gst.Bin) src).GetByInterface(VideoOverlayAdapter.GType);
VideoOverlayAdapter ad = new VideoOverlayAdapter(ov.Handle);
ad.WindowHandle = windowXId;
}
}
現在,由於某種原因,src is Gst.Bin
是錯誤的,這意味着windowXId
(我以前設置的小部件ID)從未傳達給GStreamer。但是,如果我提供了一個playbin
管道(如果您有興趣,可以使用playbin uri=XYZZY videosink='videoconvert ! videoflip method=none ! videoconvert ! autovideosink'
),它可以正常工作。
據我可以從文檔告訴了Gst.Parse.Launch()
,它應該給我一個管道是一個箱的特殊情況下,如每here(後固定殘暴語法):
返回成功的新元素,
NULL
失敗。如果管道描述指定了多個頂層元素,則將所有元素放入GstPipeline
,然後返回。
我敢肯定,videotestsrc
和ximagesink
是兩個獨立的頂級元素,但是,當我添加以下代碼,在檢查後爲src
是null
:
Console.WriteLine("is bin " + (src is Gst.Bin));
Console.WriteLine("is element " + (src is Gst.Element));
Console.WriteLine("is pipeline " + (src is Gst.Pipeline));
Console.WriteLine(type is " + src.GetType());
我看到:
is bin False
is element True
is pipeline False
type is Gst.Element
對於有問題的videotestsrc
管道和以下爲好playbin
一:
is bin True
is element True
is pipeline False
type is Gst.Bin
因此,儘管文檔中提到了什麼,但一切都指向給出元素而不是bin的問題。
我在這裏錯過了什麼?這兩種管道之間會有什麼不同會導致不同的行爲?