Gstreamer: Pausing/resuming video in RTP streams

后端 未结 1 1472
小蘑菇
小蘑菇 2021-01-06 23:45

I\'m constructing a gstreamer pipeline that receives two RTP streams from an networked source:

  1. ILBC Audio stream + corresponding RTCP stream
  2. H263 Vide
相关标签:
1条回答
  • 2021-01-06 23:49

    I present a simple function for pause resume by changing bins. In the following example I provide the logic to change destination bin on the fly dynamically. This shall not completely stop the pipeline which is what you seek I believe. A similar logic could be used for src bins. Here you may remove your network source bin and related decoder/demux bins and add videotestsrc bins.

    private static void dynamic_bin_replacement(Pipeline pipe, Element src_bin, Element dst_bin_new, Element dst_bin_old) {
    pipe.pause();
    src_bin.unlink(dst_bin_old);                     
    pipe.remove(dst_bin_old);
    pipe.add(dst_bin_new);
    dst_bin_new.syncStateWithParent();
    src_bin.link(dst_bin_new);
    pipe.ready();                    
    pipe.play();
    }
    

    The other logic you may want to try is "PADLOCKING". Please take a look at the following posts

    http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-block.txt

    and

    http://web.archiveorange.com/archive/v/8yxpz7FmOlGqxVYtkPb4

    and

    Adding and removing audio sources to/from GStreamer pipeline on-the-go

    UPDATE

    1. Try output-selector and input-selector bins as they seem to be better alternative. I found them most reliable and have had immense luck with them. I use fakesink or fakesrc respectively as the other end of the selector.

    2. valve bin is another alternative that I found doesn't even need fakesink or fakesrc bins. It is also extremely reliable.

    Also the correct state transition order for media file source

    NULL -> READY -> PAUSED -> PLAYING (Upwards)

    PLAYING -> PAUSED -> READY -> NULL (Downwards)

    My order in the above example should be corrected where ready() should come before pause(). Also I would tend to think un-linking should be performed after null() state and not after pause(). I haven't tried these changes but theoretically they should work.

    See the following link for detailed info

    http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-states.txt?h=BRANCH-RELEASE-0_10_19

    0 讨论(0)
提交回复
热议问题