What the best way for mix two streams, when they may start/stop independent from each other

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

What the best way for mix two streams, when they may start/stop independent from each other

Dmitry Valento
Hello
I couldn’t find out the easiest way for control mixing of two streams. Pipeline looks like:
 --------------               --------------     -----------     -----------
| audiotestsrc |------------>| audiodynamic |-->| equalizer |-->| sink_0    |
 --------------               --------------     -----------    |           |
                                                                |     adder |-->
 ---------     ----------     --------------     -----------    |           |
| filesrc |-->| wavparse |-->| audiodynamic |-->| equalizer |-->| sink_1    |
 ---------     ----------     --------------     -----------     -----------
In most cases, audio flows from audiotestsrc and WAV-files are played periodically.
There are three major moments during the pipeline work:
1) start wav-file playing when audiotestsrc is already running
2) stop wav-file playing manually
3) normal wav-file playing finishing (EOS)
4) play another wav-file when previous file isn’t finished yet

I’ve already implemented next logic:
0) on application start-up all elements are created, but elements related to WAV-playing aren’t added to BIN
1) upon request of start wav-file playing, elements related to WAV-playing are added to BIN, linked with each other, probe is added to sink_1 (element adder) for catch EOS
2) on manual stop, filesrc is set to NULL state, elements related to WAV-playing are moved outside BIN (not removed completely), pad sink_1 is removed (element adder)
3) on EOS, the probe is removed from sink_1 and a EOS message sent to BUS - in another procedure (seems like in another thread) the message is caught and the step 2 is started
4) on start playing another file when a previous isn’t finished yet, the filesrc is set to NULL state, location is changed and finally filesrc is set to PLAYING state.

Advantages of this logic: settings of audiodynamic and equalizer (and another filters) aren’t lost.
Disadvantages: it needs to store in private struct pointers to elements related to WAV-playing and it needs to move these elements to/outside BIN and relink all pads.

I suppose, there is should be more elegant solution for realize these requirements, but I don’t know how. May be it is possible to create some “fake” source element which will replace filesrc when wav-files aren’t played. I’ve tried to use fakesrc element, but couldn’t find out how to configure it properly.
Could you please give me suggestions about how to make logic more elegant?

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: What the best way for mix two streams, when they may start/stop independent from each other

Carl Karsten-2
Watch the 2 videos.

If I understand your question, it isn't an easy problem



On Mon, Nov 21, 2016 at 10:46 AM, Dmitry Valento <[hidden email]> wrote:
Hello
I couldn’t find out the easiest way for control mixing of two streams.
Pipeline looks like:

In most cases, audio flows from audiotestsrc and WAV-files are played
periodically.
There are three major moments during the pipeline work:
1) start wav-file playing when audiotestsrc is already running
2) stop wav-file playing manually
3) normal wav-file playing finishing (EOS)
4) play another wav-file when previous file isn’t finished yet

I’ve already implemented next logic:
0) on application start-up all elements are created, but elements related to
WAV-playing aren’t added to BIN
1) upon request of start wav-file playing, elements related to WAV-playing
are added to BIN, linked with each other, probe is added to sink_1 (element
adder) for catch EOS
2) on manual stop, filesrc is set to NULL state, elements related to
WAV-playing are moved outside BIN (not removed completely), pad sink_1 is
removed (element adder)
3) on EOS, the probe is removed from sink_1 and a EOS message sent to BUS -
in another procedure (seems like in another thread) the message is caught
and the step 2 is started
4) on start playing another file when a previous isn’t finished yet, the
filesrc is set to NULL state, location is changed and finally filesrc is set
to PLAYING state.

Advantages of this logic: settings of audiodynamic and equalizer (and
another filters) aren’t lost.
Disadvantages: it needs to store in private struct pointers to elements
related to WAV-playing and it needs to move these elements to/outside BIN
and relink all pads.

I suppose, there is should be more elegant solution for realize these
requirements, but I don’t know how. May be it is possible to create some
“fake” source element which will replace filesrc when wav-files aren’t
played. I’ve tried to use fakesrc element, but couldn’t find out how to
configure it properly.
Could you please give me suggestions about how to make logic more elegant?

Thank you.



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/What-the-best-way-for-mix-two-streams-when-they-may-start-stop-independent-from-each-other-tp4680810.html
Sent from the GStreamer-devel mailing list archive at 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: What the best way for mix two streams, when they may start/stop independent from each other

Dmitry Valento
Carl Karsten-2 wrote
quick answer:   https://github.com/voc/voctomix#contact

Watch the 2 videos.

If I understand your question, it isn't an easy problem
Thank you for your advise.
Seems like the "voctomix" is use another approach to mix several streams:
- if needs to change a pipeline structure, the pipeline removes all elements and recreate entire pipeline from scratch.
- a pipeline isn't often changed - in most cases it is created at application start after scanning of sources. Then pipeline runs without changes (if no one error occurs) till the end of application.

Unfortunately, according to requirements for my application, there is couldn't be delays in audio streaming during sources changing. Therefore entire pipeline recreation isn't allowed at all.