mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
basic-tutorial-3: Add audioresample
If whatever is in autoaudiosink doesn't do resampling, and 48000 isn't its configured rate, the tutorial will fail.
This commit is contained in:
parent
8bf5f60c47
commit
218157ffcf
2 changed files with 11 additions and 6 deletions
|
@ -6,6 +6,7 @@ typedef struct _CustomData
|
|||
GstElement *pipeline;
|
||||
GstElement *source;
|
||||
GstElement *convert;
|
||||
GstElement *resample;
|
||||
GstElement *sink;
|
||||
} CustomData;
|
||||
|
||||
|
@ -28,12 +29,14 @@ main (int argc, char *argv[])
|
|||
/* Create the elements */
|
||||
data.source = gst_element_factory_make ("uridecodebin", "source");
|
||||
data.convert = gst_element_factory_make ("audioconvert", "convert");
|
||||
data.resample = gst_element_factory_make ("audioresample", "resample");
|
||||
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) {
|
||||
if (!data.pipeline || !data.source || !data.convert || !data.resample
|
||||
|| !data.sink) {
|
||||
g_printerr ("Not all elements could be created.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -41,8 +44,8 @@ main (int argc, char *argv[])
|
|||
/* 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.convert, data.sink)) {
|
||||
data.resample, data.sink, NULL);
|
||||
if (!gst_element_link_many (data.convert, data.resample, data.sink, NULL)) {
|
||||
g_printerr ("Elements could not be linked.\n");
|
||||
gst_object_unref (data.pipeline);
|
||||
return -1;
|
||||
|
|
|
@ -93,6 +93,7 @@ typedef struct _CustomData {
|
|||
GstElement *pipeline;
|
||||
GstElement *source;
|
||||
GstElement *convert;
|
||||
GstElement *resample;
|
||||
GstElement *sink;
|
||||
} CustomData;
|
||||
|
||||
|
@ -112,20 +113,21 @@ int main(int argc, char *argv[]) {
|
|||
/* Create the elements */
|
||||
data.source = gst_element_factory_make ("uridecodebin", "source");
|
||||
data.convert = gst_element_factory_make ("audioconvert", "convert");
|
||||
data.resample = gst_element_factory_make ("audioresample", "resample");
|
||||
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) {
|
||||
if (!data.pipeline || !data.source || !data.convert || !data.resample || !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.convert, data.sink)) {
|
||||
gst_bin_add_many (GST_BIN (data.pipeline), data.source, data.convert, data.resample, data.sink, NULL);
|
||||
if (!gst_element_link_many (data.convert, data.resample, data.sink, NULL)) {
|
||||
g_printerr ("Elements could not be linked.\n");
|
||||
gst_object_unref (data.pipeline);
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue