[gst-devel] How to dynamically add and remove branch to a "tee" element?

Peter Cai newptcai at gmail.com
Mon Nov 9 18:10:42 CET 2009


Oh, it took me a whole day on this.  It's not the problem of state any more.

The pipeline is like this :

appsrc ! decodin

ffmpegcsp ! tee !  3 sinks.

Something wrong happens when decodebin notify new pad is added.

In the callback of "new-decoded-pad", I tried to link decodebin and
ffmpegcsp so that all the elements in the pipeline is linked.

But it could never finish link appsrc and ffmpegcsp.

The log shows after gst_base_transform_getcaps is called, it never returned.

0:00:09.803216000  2300   00A0F6E0 DEBUG        basetransform
gstbasetransform.c:620:gst_base_transform_getcaps:<ffmpegcsp0:sink>
peer caps  0ABE4DE0
0:00:09.803216000  2300   00A0F6E0 DEBUG        basetransform
gstbasetransform.c:624:gst_base_transform_getcaps:<ffmpegcsp0:sink>
our template  058598C0

Some debugging shows it because gst_capsIntersect is doing a huge loop
that wouldn't be possible to finish in short time.  That because
caps2->structs->len is too large to be correct.

The most strange thing is that when 2 sink is attached to tee, everything is OK.

So, this is totally out of my ability and I really appreciate your help!

GstCaps *
gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2)
{
  ....
  for (i = 0; i < caps1->structs->len + caps2->structs->len - 1; i++) {
....
    while (k < caps2->structs->len) {
....
    }
  }
  return dest;
}




On Fri, Nov 6, 2009 at 10:51 PM, Uday Verma <uday.karan at gmail.com> wrote:
> In my experience, the bin/elements/branch you're trying to attach to one of
> the src%d pads should be in the PLAYING state before you link it.  This is
> because as the tee tries to push a buffer to its src pads, if any of the
> pads is linked to a non-PLAYING element, the buffer push method returrn a
> wrong-state value which propagates all the way to the source and pauses
> everything, GST_DEBUG=4 will show you this.
> Also, like you mentioned, gst_pad_link is how you would link a tee's src%d
> to the branch.
> While unlinking, I first unlink the pad and then take care of the disposing
> the branch.  Ideally, however, we should block data on the pad and then
> unlink it, but that hasn't work for me so far.
> HTH
>
> On Fri, Nov 6, 2009 at 8:37 AM, Peter Cai <newptcai at gmail.com> wrote:
>>
>> After a lot of search, I found this is not quite simple as I used to
>> think.  The coding following only work when 2 sink is linked to the
>> tee.
>> When the 3rd comes, all 3 sink doesn't work.
>>
>> What is the correct way to add and remove branch to a "tee"?
>> On IRC, I was told to try these
>>
>> 1. setting sink "asycn = FALSE"
>> 2. add a queue between tee and sink
>> 3. use pad instead of gst_element_link
>>
>> None of them works.
>>
>>         GstElement* dd = gst_element_factory_make("directdrawsink", NULL);
>>         g_object_set(dd, "async", FALSE, NULL);
>>         gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(dd), (gulong)handle);
>>
>>         gst_element_set_state (dd, GST_STATE_PAUSED);
>>         gst_bin_add(GST_BIN (self->priv->pipeline), dd);
>>
>>         if(!gst_element_link (self->priv->tee, dd))
>>         {
>>             vivs_warning("Can not link tee to directdrawsink");
>>         }
>>
>>         if(self->priv->sink_num == 1)
>>             gst_element_set_state (self->priv->pipeline,
>> GST_STATE_PLAYING);
>>         else
>>             gst_element_set_state (dd, GST_STATE_PLAYING);
>>      self->priv->sink_num += 1
>>
>>
>> --
>> look to the things around you,the immediate world around you, if you
>> are alive,it will mean something to you ——Paul Strand
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>



-- 
look to the things around you,the immediate world around you, if you
are alive,it will mean something to you ——Paul Strand




More information about the gstreamer-devel mailing list