简体   繁体   English

gStreamer-Sharp动态垫未链接

[英]gStreamer-Sharp Dynamic pads not linking

EDIT: I forgot to mention this is working with an axis encoder. 编辑:我忘了提到这与轴编码器一起工作。

I've recently started using gStreamer-sharp and I can get a video playing with playbin but I need my video to be live, thus a need to set the latency. 我最近开始使用gStreamer-sharp,可以用playbin播放视频,但是我需要实时播放视频,因此需要设置延迟。 but I have come across this error: 但是我遇到了这个错误:

    GST_ELEMENT_PADS gstelement.c:722:gst_element_add_pad:<Source> adding pad 'recv_rtp_src_0_219678342_96'
0:00:11.033000000 13088   05418DA0 INFO                 basesrc gstbasesrc.c:2519:gst_base_src_loop:<udpsrc1> pausing after gst_pad_push() = not-linked
0:00:11.033000000 13088   05418DA0 WARN                 basesrc gstbasesrc.c:2582:gst_base_src_loop:<udpsrc1> error: Internal data flow error.
0:00:11.033000000 13088   05418DA0 WARN                 basesrc gstbasesrc.c:2582:gst_base_src_loop:<udpsrc1> error: streaming task paused, reason not-linked (-1)
0:00:11.214000000 13088   05418DA0 INFO        GST_ERROR_SYSTEM gstelement.c:1931:gst_element_message_full:<udpsrc1> posting message: Internal data flow error.
0:00:11.214000000 13088   05418DA0 INFO        GST_ERROR_SYSTEM gstelement.c:1954:gst_element_message_full:<udpsrc1> posted error message: Internal data flow error.

Which has lead me to believe it's a problem with the pad's my code is as following: 这使我相信垫的问题在于我的代码如下:

    Gst.Video.VideoSink videoSink;
    Pipeline m_Pipeline;
    Element m_Source, m_Demux, m_Decoder, m_Space;

    private void OnVideoPadAdded(object sender, Gst.PadAddedArgs args)
    {
        Gst.Element.Link(m_Demux, m_Decoder);
    }

    private void CreatePipeline()
    {

        m_Pipeline = new Pipeline("video player");
        m_Source = Gst.ElementFactory.Make("rtspsrc", "Source");
        m_Source["location"] = @"rtsp://root:root@192.168.8.159:554/axis-media/media.3gp"; 


        m_Demux = Gst.ElementFactory.Make("rtph264depay", "Depay");
        m_Decoder = Gst.ElementFactory.Make("ffdec_h264", "Decoder");            
        m_Space = ElementFactory.Make("ffmpegcolorspace", "Space");
        videoSink = Gst.ElementFactory.Make("directdrawsink", "Output") as Gst.Video.VideoSink;
        videoSink["force-aspect-ratio"] = true;


        m_Pipeline.Add(m_Source, m_Demux, m_Decoder, m_Space, videoSink);

        m_Pipeline.SetState(Gst.State.Ready);            
        m_Source.Link(m_Demux);
        m_Demux.PadAdded += new Gst.PadAddedHandler(OnVideoPadAdded);
        m_Decoder.Link(m_Space);
        m_Space.Link(videoSink);

        var overlay = new Gst.Interfaces.XOverlayAdapter(videoSink.Handle);
        overlay.XwindowId = (ulong)videoPanel.Handle;

        m_Pipeline.SetState(Gst.State.Paused);
        m_Pipeline.SetState(State.Playing);

    }

Any help is appreciated. 任何帮助表示赞赏。

Solution was pretty simple in the end. 最后,解决方案非常简单。

Needed to add the handler: 需要添加处理程序:

m_Source.PadAdded += new Gst.PadAddedHandler(OnVideoPadAdded);

then handle the sink correctly by getting the static pad in the handler: 然后通过在处理程序中获取静电垫来正确处理水槽:

Pad sinkpad = m_Demux.GetStaticPad("sink"); 
            args.Pad.Link(sinkpad); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM