Dynamic Replacement of a source element in pipeline

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic Replacement of a source element in pipeline

lorenzo.m
Hi,
I trying to implement a working example for this use case:

given a simple pipeline of this kind:

uridecodebin -> videoconvert -> autovideosink

(where uridecodebin source pads are dynamically linked thru callback on
"pad-added" events), i would like to replace the uridecodebin element, when
it reaches EOS, with a new one (with a different uri) in the current running
pipeline.

What i've tried to do is:
1) adding a blocking pad probe on first uridecodebin source pad:
gst_pad_add_probe (new_pad, GST_PAD_PROBE_TYPE_BLOCK |
      GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, eos_probe, data, NULL);

2) in probe code:
* pause pipeline
* unlink first uridecodebin src pad from videoconvert, set its state to
NULL, remove it from pipeline bin
* create new uridecodebin, set its uri property and add it to pipeline bin
* register pad-added handler on new uridecodebin element (to dynamic link it
to videoconvert)
* set the pipeline in playing state


but as soon as the pipeline is set again in playing mode it goes in EOS.

what i'm doing wrong?

Thanks,

Ps. i can also post my code










--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Replacement of a source element in pipeline

Pascal Jacquemart-3
These are two different problems.

I think if the pipeline terminates and goes to null state, then it is possible to change the uri property on uridecodebin. And the pipeline remains untouched.

Otherwise, when you add a new decodebin, the running time of your pipeline is still incrementing whereas the new decodebin buffers restart at zero. In this case you need to set an offset on new incoming pads.

Cheers,    Pascal

> On 12 Sep 2019, at 03:11, lorenzo.m <[hidden email]> wrote:
>
> Hi,
> I trying to implement a working example for this use case:
>
> given a simple pipeline of this kind:
>
> uridecodebin -> videoconvert -> autovideosink
>
> (where uridecodebin source pads are dynamically linked thru callback on
> "pad-added" events), i would like to replace the uridecodebin element, when
> it reaches EOS, with a new one (with a different uri) in the current running
> pipeline.
>
> What i've tried to do is:
> 1) adding a blocking pad probe on first uridecodebin source pad:
> gst_pad_add_probe (new_pad, GST_PAD_PROBE_TYPE_BLOCK |
>      GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, eos_probe, data, NULL);
>
> 2) in probe code:
> * pause pipeline
> * unlink first uridecodebin src pad from videoconvert, set its state to
> NULL, remove it from pipeline bin
> * create new uridecodebin, set its uri property and add it to pipeline bin
> * register pad-added handler on new uridecodebin element (to dynamic link it
> to videoconvert)
> * set the pipeline in playing state
>
>
> but as soon as the pipeline is set again in playing mode it goes in EOS.
>
> what i'm doing wrong?
>
> Thanks,
>
> Ps. i can also post my code
>
>
>
>
>
>
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Replacement of a source element in pipeline

lorenzo.m
Hi Pascal,
thank you for your reply.
I've tried two different paths to achieve this (limiting the example to the
video part / audio is completely discarded) starting from a common approach:

the common approach consists on dynamic linking the new created uridecodebin
element to the rest of the pipeline capturing the pad-added singals on this
element; as soon as the element adds a pad of type video/x-raw this is
linked to the sink pad of the videoconvert element and if the link is
successful:

1 - Pipeline seeking:
seeking to 0 doing
gst_element_seek(pipeline,1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
                         GST_SEEK_TYPE_SET, 0,
                         GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)

this works as expected, but is pushing the pipeline back to 0.

2 - Setting the offset on the pad just added:

      gst_pad_set_offset(new_pad,0);

this is not working at all.

What I'm missing?
Thanks in advance,

Kind Regards
Lorenzo




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Replacement of a source element in pipeline

Pascal Jacquemart

Ok but it does not make sense to set 0 as pad offset
You should set the offset as the running time of the pipeline instead

Otherwise, if it does not work, you might be able to use the
input-selector element. This element has some capabilities to
synchronise various inputs to the same running time.

On Tue, 17 Sep 2019 04:22:05 -0500 (CDT)
"lorenzo.m" <[hidden email]> wrote:

> Hi Pascal,
> thank you for your reply.
> I've tried two different paths to achieve this (limiting the example
> to the video part / audio is completely discarded) starting from a
> common approach:
>
> the common approach consists on dynamic linking the new created
> uridecodebin element to the rest of the pipeline capturing the
> pad-added singals on this element; as soon as the element adds a pad
> of type video/x-raw this is linked to the sink pad of the
> videoconvert element and if the link is successful:
>
> 1 - Pipeline seeking:
> seeking to 0 doing
> gst_element_seek(pipeline,1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
>                          GST_SEEK_TYPE_SET, 0,
>                          GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)
>
> this works as expected, but is pushing the pipeline back to 0.
>
> 2 - Setting the offset on the pad just added:
>
>       gst_pad_set_offset(new_pad,0);
>
> this is not working at all.
>
> What I'm missing?
> Thanks in advance,
>
> Kind Regards
> Lorenzo
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Replacement of a source element in pipeline

Daniel Sperka
I've had success setting the offset on the sink pad, not the src pad. Splice the new pads into the appropriate sink pads, but at each of those SINK pads, set the offset. 

On Tue, Sep 17, 2019 at 9:19 PM Pascal Jacquemart <[hidden email]> wrote:

Ok but it does not make sense to set 0 as pad offset
You should set the offset as the running time of the pipeline instead

Otherwise, if it does not work, you might be able to use the
input-selector element. This element has some capabilities to
synchronise various inputs to the same running time.

On Tue, 17 Sep 2019 04:22:05 -0500 (CDT)
"lorenzo.m" <[hidden email]> wrote:

> Hi Pascal,
> thank you for your reply.
> I've tried two different paths to achieve this (limiting the example
> to the video part / audio is completely discarded) starting from a
> common approach:
>
> the common approach consists on dynamic linking the new created
> uridecodebin element to the rest of the pipeline capturing the
> pad-added singals on this element; as soon as the element adds a pad
> of type video/x-raw this is linked to the sink pad of the
> videoconvert element and if the link is successful:
>
> 1 - Pipeline seeking:
> seeking to 0 doing
> gst_element_seek(pipeline,1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
>                          GST_SEEK_TYPE_SET, 0,
>                          GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)
>
> this works as expected, but is pushing the pipeline back to 0.
>
> 2 - Setting the offset on the pad just added:
>
>       gst_pad_set_offset(new_pad,0);
>
> this is not working at all.
>
> What I'm missing?
> Thanks in advance,
>
> Kind Regards
> Lorenzo
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


--
Daniel J. Sperka, Ph. D.
UC Davis Center for Neuroscience

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel