Playing/pausing/swapping separate bins/elements within a running pipeline - pause problem

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

Playing/pausing/swapping separate bins/elements within a running pipeline - pause problem

Nick Daniels
Hi there,

I was hoping someone may be able to help me on this...I'm rather stuck!

I have managed to successfully swap out bins (I found these posts particularly useful for this: http://n4.nabble.com/Dynamically-adding-and-removing-branches-of-a-tee-td973635.html, http://n4.nabble.com/Any-ways-to-add-remove-branches-to-from-a-running-pipeline-td973959.html#a973959) however I'm having a small problem playing/pausing/swapping the seperate bins.

I've pasted a diagram of the test pipeline at http://pastebin.com/f15fc14a4 to make it easier to see. It's basically made up of two bins linked into the videomixer element outputting to a xvimagesink. The bins are made up of a filesrc, decodebin with a tee leading to a preview xvimagesink and the bin's ghost src pad (which then leads to the videomixer).

What I want to be able to do is disconnect bin1 from the videomixer, pause it, play it etc (without affecting bin2 still connected to the videomixer) and then swap it back into the videomixer.

I have managed to disconnect bin1 and pause it, but when I start playing it plays from where the video would have been if I hadn't paused, not from where it was paused (I assume this is because it is using the pipeline's clock for playback which is still running for the remaining, unpaused bin???). What do I have to do to make sure it plays back from the correct place? I've detailed the method I used to disconnect bin1 and pause/play it below.

Any insight into what's going on would be very helpful :)

Many thanks,
Nick

=============================================================

This is my method to disconnect bin1 from the videomixer:

1. Block bin1's source pad
     pad = gst_element_get_static_pad (bin1, "src");
     gst_pad_set_blocked(pad,TRUE);

2. Unlink bin1 and videomixer and release videomixer's request pad
     gst_element_unlink (bin1, mixer);
     gst_element_release_request_pad(mixer, mixerpad);

3. Add fakesink to pipeline and set state to READY
     gst_bin_add (GST_BIN (pipeline), fakesink);
     gst_element_set_state (fakesink, GST_STATE_READY);

4. Link fakesink to bin1 and set state to PLAYING
     gst_element_link (bin1, fakesink);
     gst_element_set_state (fakesink, GST_STATE_PLAYING);

5. Unblock bin1's ghost pad
     gst_pad_set_blocked(pad,FALSE);

This works fine, no problems.

Ok now I want to pause bin1 so I do:

     gst_element_set_state (fakesink, GST_STATE_PAUSED);
     gst_element_set_state (bin1, GST_STATE_PAUSED);

Great it's paused. Now the problem...I want to play it again.

     gst_element_set_state (fakesink, GST_STATE_PLAYING);
     gst_element_set_state (bin1, GST_STATE_PLAYING);

Instead of continuing playing from when I paused it, it plays from where it would have been if I hadn't paused it (it skips forward). I assume this is because its using the pipeline's (or the other bin's?) clock? Is this a bug? Is there a way to make sure this bin plays back from where it was paused?

I've also tried putting it to the READY state instead of PAUSED. This works, but when I set it to PLAYING again the following error appears in the console 21 times, and the video plays back at a very fast rate.
     (test:5682): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GstElement'
     (test:5682): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GObject'
     (test:5682): GLib-GObject-CRITICAL **: g_object_get: assertion `G_IS_OBJECT (object)' failed


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playing/pausing/swapping separate bins/elements within a running pipeline - pause problem

Donny Viszneki
I don't think what you're trying to do is supported by the API

On Sun, Jan 31, 2010 at 11:40 AM, Nick Daniels
<[hidden email]> wrote:

> Hi there,
>
> I was hoping someone may be able to help me on this...I'm rather stuck!
>
> I have managed to successfully swap out bins (I found these posts
> particularly useful for this:
> http://n4.nabble.com/Dynamically-adding-and-removing-branches-of-a-tee-td973635.html,
> http://n4.nabble.com/Any-ways-to-add-remove-branches-to-from-a-running-pipeline-td973959.html#a973959)
> however I'm having a small problem playing/pausing/swapping the seperate
> bins.
>
> I've pasted a diagram of the test pipeline at http://pastebin.com/f15fc14a4
> to make it easier to see. It's basically made up of two bins linked into the
> videomixer element outputting to a xvimagesink. The bins are made up of a
> filesrc, decodebin with a tee leading to a preview xvimagesink and the bin's
> ghost src pad (which then leads to the videomixer).
>
> What I want to be able to do is disconnect bin1 from the videomixer, pause
> it, play it etc (without affecting bin2 still connected to the videomixer)
> and then swap it back into the videomixer.
>
> I have managed to disconnect bin1 and pause it, but when I start playing it
> plays from where the video would have been if I hadn't paused, not from
> where it was paused (I assume this is because it is using the pipeline's
> clock for playback which is still running for the remaining, unpaused
> bin???). What do I have to do to make sure it plays back from the correct
> place? I've detailed the method I used to disconnect bin1 and pause/play it
> below.
>
> Any insight into what's going on would be very helpful :)
>
> Many thanks,
> Nick
>
> =============================================================
>
> This is my method to disconnect bin1 from the videomixer:
>
> 1. Block bin1's source pad
>      pad = gst_element_get_static_pad (bin1, "src");
>      gst_pad_set_blocked(pad,TRUE);
>
> 2. Unlink bin1 and videomixer and release videomixer's request pad
>      gst_element_unlink (bin1, mixer);
>      gst_element_release_request_pad(mixer, mixerpad);
>
> 3. Add fakesink to pipeline and set state to READY
>      gst_bin_add (GST_BIN (pipeline), fakesink);
>      gst_element_set_state (fakesink, GST_STATE_READY);
>
> 4. Link fakesink to bin1 and set state to PLAYING
>      gst_element_link (bin1, fakesink);
>      gst_element_set_state (fakesink, GST_STATE_PLAYING);
>
> 5. Unblock bin1's ghost pad
>      gst_pad_set_blocked(pad,FALSE);
>
> This works fine, no problems.
>
> Ok now I want to pause bin1 so I do:
>
>      gst_element_set_state (fakesink, GST_STATE_PAUSED);
>      gst_element_set_state (bin1, GST_STATE_PAUSED);
>
> Great it's paused. Now the problem...I want to play it again.
>
>      gst_element_set_state (fakesink, GST_STATE_PLAYING);
>      gst_element_set_state (bin1, GST_STATE_PLAYING);
>
> Instead of continuing playing from when I paused it, it plays from where it
> would have been if I hadn't paused it (it skips forward). I assume this is
> because its using the pipeline's (or the other bin's?) clock? Is this a bug?
> Is there a way to make sure this bin plays back from where it was paused?
>
> I've also tried putting it to the READY state instead of PAUSED. This works,
> but when I set it to PLAYING again the following error appears in the
> console 21 times, and the video plays back at a very fast rate.
>      (test:5682): GLib-GObject-WARNING **: invalid uninstantiatable type
> `<invalid>' in cast to `GstElement'
>      (test:5682): GLib-GObject-WARNING **: invalid uninstantiatable type
> `<invalid>' in cast to `GObject'
>      (test:5682): GLib-GObject-CRITICAL **: g_object_get: assertion
> `G_IS_OBJECT (object)' failed
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>



--
http://codebad.com/

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playing/pausing/swapping separate bins/elements within a running pipeline - pause problem

Nick Daniels
In reply to this post by Nick Daniels
Hi Donny,

> I don't think what you're trying to do is supported by the API

Thanks for the reply, I'm probably wrong but I'm really tempted to think it's possible as it's so close to working...

I'm able to:
   1. Disconnect the bin from the videomixer and attach it instead to a fakesink.
   2. Set the bin to Paused (and it pauses)
   3. Set the bin to Playing (and it plays, although as mentioned before from the wrong place)
   4. Disconnect the bin from the fakesink and reconnect it to the videomixer.

This all works while the videomixer continues to output the video from the second bin with no gliches. Almost perfect..! The only thing that isn't working is the paused bin resumes from where it would have been had you not paused it (ie. it's like we've just frozen the image and the video is still playing in the background). 

Why would this be? I don't think I understand the internals of GStreamer well enough, but I assume its because when it resumes it resumes referencing the pipelines clock which is still incrementing. I suppose a hack would be to add an offset to that bin's clock or something, although I suppose that could cause problems when re-attaching it to the videomixer. 

A nudge in the right direction would be great though.
Nick


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel