This tutorial introduces a new way to create pipeline-created in the run, rather than at the end of a one-time creation before running.
Introduced
The pipeline in this tutorial are not all created before the run is complete. Relax, there's no problem with this. If we do not do more in-depth processing, then the data will be dropped at the end of the pipeline, of course, we will certainly do in-depth processing ...
In this example, we will open a file that already contains the audio and video (Container files). The element responsible for opening such a container file is called demuxer, and our common container formats include MKV, QT, MOV, OGG, ASF, WMV, WMA, and more.
In a container that may contain multiple streams (e.g., one video, two audio), Demuxer will separate them and send them out from different outputs. This allows different branches of the pipeline to handle different data.
There is a term in GStreamer that describes such interface--pad (Gstpad). The pad is divided into sink pad--data from here into a element--and source pad--data from which the element flows out. Naturally, the source element contains only the source Pad,sink element, which contains only the sink pad, and both the filter pad.
A demuxer contains a sink pad and multiple source pad, data from the sink pad input and then each stream has a source pad.
For the sake of completeness, give a schematic diagram with a demuxer and two branches, one processing audio processing video. Please note that this is not a schematic of the tutorial pipeline.
The main complication here is that demuxer cannot determine what needs to be done until the container file is seen, and cannot generate the corresponding content. In other words, Demuxer starts with no source pad for other element connections.
The solution is to build pipeline, connect source and Demuxer, and start running. When the demuxer receives the data, it has enough information to generate the source pad. At this point we can continue to connect the other parts to the newly generated pad of demuxer to create a complete pipeline.
For simplicity, in this example, we're just connecting the audio pad instead of the pad that handles the video.
Dynamic Hello World
[OBJC] view plain copy #include <gst/gst.h> /* Structure to contain all our information, so we can pass it to callbacks */ typedef struct _customdata { gstelement *pipeline; GstElement *source; gstelement *convert; GstElement *sink; } customdata; /* handler for the pad-added signal */ static void pad_added_handler (Gstelement *src, gstpad *pad, customdata *data); Int main (int argc, charchar *argv[]) { CustomData data; GstBus *bus; Gstmessage *msg; GstStateChangeReturn ret; gboolean terminate = FALSE; /* initialize gstreamer */ gst_init (&ARGC,&NBSP;&ARGV); /* Create the elements */ data.source = gst_ element_factory_make ("Uridecodebin", "source"); data.convert = gst _element_factory_make ("Audioconvert", "Convert"); data.sink = gst_ element_factory_make ("Autoaudiosink", "sink"); /* Create the empty pipeline */ data.pipeline = gst_ pipeline_new ("Test-pipeline"); if (!data.pipeline | | ! data.source | | !data.convert | | !data.sink) { g_printerr ("not all elements could be created.\n "); return -1; } /* build the pipeline. note that we are NOT linking the source at this * point. we will do it later. */ gst_bin_add_many (GST _bin (Data.pipeline), data.source, data.convert , data.sink, null); if (!gst_element_link (data