Stream swithcing dynamically

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

Stream swithcing dynamically

DeepakRohan
Hi,

       I have written an test application, where I for a gstreamer-1.0 pipeline.
The scenario is when I am playing a file which has 3 audio streams. Now while the
playback is going on, I would like to switch to a different audio stream.
      Say if I was playing audio#0, then I would want to switch to audio#2.
      So is there any way for me to do so without using input selector between decoder
and the audiosink. Instead I should be able to remove the audio#0's parser and decoder
and then able to include the audio#2's parser and decoder without altering the playback state.
That is suppose I do a stream switch say at 10 second then the playback for audio#2 after
the switching must start from 10 seconds (not from the beginning).

If the above is possible, then how can I do the above mentioned logic and also to
make sure that only audio#0;s elements are removed not the whole pipeline and
audio#2's elements are successfully added and the playback resumes from correct position.


Before Switch:
gst-launch-1.0 filesrc location=In_file.aac ! audio#0_elements ! ... ! alsasink

After Switch:
gst-launch-1.0 filesrc location=In_file.aac ! audio#2_elements ! ... ! alsasink

I could not think/understand in the above mentioned way.
Though the totem and playbin applications use the input selector between audio decoders and the
audiosink, I would like to implement something in the above mentioned way. Because I cannot use
playbin for my assignment.

Thank You In Advance
Reply | Threaded
Open this post in threaded view
|

Re: Stream swithcing dynamically

Sebastian Dröge-3
On So, 2016-06-05 at 20:18 -0700, DeepakRohan wrote:

> Hi,
>
>        I have written an test application, where I for a gstreamer-1.0
> pipeline.
> The scenario is when I am playing a file which has 3 audio streams. Now
> while the playback is going on, I would like to switch to a different audio stream.
>       Say if I was playing audio#0, then I would want to switch to audio#2.
>       So is there any way for me to do so without using input selector
> between decoder
> and the audiosink. Instead I should be able to remove the audio#0's parser
> and decoder
> and then able to include the audio#2's parser and decoder without altering
> the playback state.
> That is suppose I do a stream switch say at 10 second then the playback for
> audio#2 after the switching must start from 10 seconds (not from the beginning).
>
> If the above is possible, then how can I do the above mentioned logic and
> also to make sure that only audio#0;s elements are removed not the whole pipeline
> and audio#2's elements are successfully added and the playback resumes from
> correct position.
You can't do this with gst-launch but have to write actual code for
implementing this behaviour, and in there you would make sure that what
you describe above happens.

You would basically do the switching at the earliest pipeline part
where you have the multiple streams, e.g. at the demuxer. And then make
sure together with pad probes that all pipelines changes are happening
in the correct order.


Alternatively you could also use an input-selector (on the encoded
data) after the demuxer, and only have a pad probe at its source pad to
ensure that downstream is changed to different parser/decoder if the
caps between the different streams are actually changing. Or if they
are never going to change in an incompatible way you would get away
with just an input-selector.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

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

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Stream swithcing dynamically

DeepakRohan
Thanks Sebastian for the quick reply.

So from your reply itseems like changing the audio parsers and decoders for multiple audio stream case is impossible if I use gst-launch-1.0 filesrc location=..... pipeline.
But at the last part of the reply, did you mean that if I use pad-probe at the demuxer's source pad then it will make sure that the downstream elements are updated.

Say like
audio#0 is MP3 - 32Khz, Layer3
audio#1 is AAC - 48KHz, 2 channels, MAIN PROFILE
audio#2 is AAC - 44.1Khz, 2 channels, LC PROFILE

So if I change from audio#0 to audio#2 then the input-selector after demuxer
followed by a pad-probe at the input selectors source pad then all the downstream
elements will change from mpegaudioparse-mp3dec to aacparse-aacdec.
And the playback will resume from the time when stream change was requested,
say that the stream change request time is 15 seconds.

Am I right in my understanding form the above paragraph.
Reply | Threaded
Open this post in threaded view
|

Re: Stream swithcing dynamically

Sebastian Dröge-3
On Mo, 2016-06-06 at 00:51 -0700, DeepakRohan wrote:
> multiple audio stream case is impossible if I use gst-launch-1.0

gst-launch has no feature to dynamically change pipelines.

> So if I change from audio#0 to audio#2 then the input-selector after
> demuxer 
>
> followed by a pad-probe at the input selectors source pad then all the
> downstream
> elements will change from mpegaudioparse-mp3dec to aacparse-aacdec.
> And the playback will resume from the time when stream change was requested,
> say that the stream change request time is 15 seconds.
>
> Am I right in my understanding form the above paragraph.
No, a pad probe is just a way for you to get a callback in your code
when something happens on a pad. Your code would then have to change
the pipeline downstream from one parser/decoder combination to another.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Stream swithcing dynamically

DeepakRohan
Hi,

     I tried with pad probe with the idle flag, but sometime we do not receive the callback function.
So can you please help me out about how to use the pad probe with necessary flags and other things
so that I can be sure that the callback happens every time.
Reply | Threaded
Open this post in threaded view
|

RE: Stream swithcing dynamically

Natanael Mojica
In reply to this post by DeepakRohan

Hi..

Do you want to do differents paths and encoding settings for each audio stream??and then select between  then for feeding the audio sink??
If it is the case, audio mixer is a good option, you can set the mute property dinamically..


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

Re: Stream swithcing dynamically

Kyle Pennington
Try using blocking pad probes to block on the source or sink corresponding to the audio source you want to enable/disable.  These can be installed and removed during runtime when using C or python based pipelines.  

I use something like gst_pad_add_probe(<src_or_sink_pad>, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, <audio_probe_cb>, NULL, NULL); in my application.

On Mon, Jun 6, 2016 at 2:17 PM, Natanael Mojica <[hidden email]> wrote:

Hi..

Do you want to do differents paths and encoding settings for each audio stream??and then select between  then for feeding the audio sink??
If it is the case, audio mixer is a good option, you can set the mute property dinamically..


_______________________________________________
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: Stream swithcing dynamically

Sebastian Dröge-3
In reply to this post by DeepakRohan
On Mo, 2016-06-06 at 03:46 -0700, DeepakRohan wrote:
> Hi,
>
>      I tried with pad probe with the idle flag, but sometime we do
> not receive the callback function.
> So can you please help me out about how to use the pad probe with
> necessary flags and other things so that I can be sure that the
> callback happens every time.

IDLE probes are called the next time a pad is actually idle. Maybe that
never happens in your case and the pad is blocking in its streaming
thread forever? You'll have to debug that, e.g. by checking what
happens in all threads (with gdb) after you added the IDLE probe
without it ever being called.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment