gstreamergstreamer-1.0multimediagstreamer-0.10

Why doesn't gStreamer demuxer create its source pad initially


I'm newbie in gStreamer framework and multimedia in general, I'm following the official third tutorial at here, the goal is to create and run a pipeline to stream an audio using uridecodebin as a source element, it says:

We create the elements as usual. uridecodebin will internally instantiate all the necessary elements (sources, demuxers and decoders) to turn a URI into raw audio and/or video streams. It does half the work that playbin does. Since it contains demuxers, its source pads are not initially available and we will need to link to them on the fly.

My question is, why doesn't demuxer create its source pad initially like other elements?

I tried to change a little bit in the example provided to understand why demuxers wait a while in order to create the source pad, I expected the demuxer to be linked directly using gst_element_link_many or gst_element_link


Solution

  • The documentation in your posted link explains it to you:

    The main complexity when dealing with demuxers is that they cannot produce any information until they have received some data and have had a chance to look at the container to see what is inside. This is, demuxers start with no source pads to which other elements can link, and thus the pipeline must necessarily terminate at them.

    The solution is to build the pipeline from the source down to the demuxer, and set it to run (play). When the demuxer has received enough information to know about the number and kind of streams in the container, it will start creating source pads. This is the right time for us to finish building the pipeline and attach it to the newly added demuxer pads.