Handling multiple bins dynamically

Stirling Westrup swestrup at gmail.com
Wed Jul 2 11:07:35 PDT 2014


On Thu, Jun 26, 2014 at 6:03 AM, Lee Matthews <lma at spaceapplications.com>
wrote:

> Hi,
>
> I'm streaming video and I wish to be able to record that video on
> receiving a command. I'm currently looking at setting up two bins, one for
> the stream and the other for recording.
>
> The streaming bin has a tee in it which I need to connect to the recording
> bin dynamically. I also need to be able to disconnect the recording bin
> when I need to stop recording.
>
> Here are my bins :
>
> bin_stream = gst_parse_launch ("v4l2src name=v4l2src device=/dev/video0 !
> video/x-raw,format=(string)YUY2,width=(int)320,height=(int)240,
> depth=(int)8, framerate=(fraction)20/1 ! videoconvert  ! vp8enc deadline=1
> threads=3 token-partitions=2 cpu-used=1 end-usage=cbr
> target-bitrate=4096000 ! webmmux streamable=true ! tee name=tee tee. !
> queue name=stream", &err);
>
> bin_videoRecord = gst_parse_launch ("queue name=record ! filesink
> name=filesink
> location=/data/data/com.mobinet.mobinetbootapp/files/test.webm", &err);
>
> A few questions :
>
> 1) Do both of these bins need to go into the same pipeline ?
>
Yes.


>
> 2) In order to link the record bin to the stream bin, do I need to create
> ghostpads within the bins, ie one for tee (src) and another for queue
> (sink) ?
>

That depends on how you go about it. You can nest bins inside each other,
and its possible to just ask two bins to link, if the linking is
straightforward (ie, ghost pads can be automatically made for you).

Thus, if you were to put bin_videoRecord inside bin_stream, you could
probably just issue an element link command to link "tee" with the
bin_videoRecord.

If you prefer to keep them separate then yes, you'll need to at least
create a ghost pad for a newly created tee source, and then link
bin_videoRecord to that.



>
> 3) To add the record bin to the stream bin, do I ?
>
> A) Request a pad from tee on the stream bin
> B) Set it to blocked
> C) Link the tee to the queue
> D) Set the record bin to playing
> E) Remove the pad-block on the stream bin tee
>

There is no need to block newly created pads, as they set themselves to
flushing mode until they've been connected. So, assuming you're going with
non-nested bins, your set of operations is more like this:

A) Request a pad from tee on the stream bin
B) Create a ghost pad for the bin and attach it to the new tee pad.
C) Link the Record Bin to the ghost pad on the Stream Bin
D) Set the record bin to playing


4) To remove the link from record bin to the stream bin and correctly close
> the file, do I ?
>
> A) Set the stream bin's tee src pad that sends data to record bin, to
> blocked
> B) Send an EOS event to the record bin
> C) Wait for the EOS message on the record bin bus
> D) Remove the stream bin tee pad used to provide video to the record bin
>

This I have less experience with, but I think you have this correct.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140702/0a481c50/attachment.html>


More information about the gstreamer-devel mailing list