Note that there are some explanatory texts on larger screens.

plurals
  1. POGStreamer caps filtering issue when converting from command line to C code
    primarykey
    data
    text
    <p>I am having issues converting my working GStreamer pipeline from a command line version to C code. From the command line the following command will successfully play my headerless mu-law audio file:</p> <pre><code>gst-launch filesrc location=test.ulaw ! audio/x-mulaw, rate=8000, channels=1 ! mulawdec ! audioconvert ! audioresample ! autoaudiosink </code></pre> <p>However, my issues are arising when trying to add in the "audio/x-mulaw, rate=8000, channels=1" bit into my C program. The program started off playing wav files (using wavparse in place of mulawdec) so that I know my base C code works, and it must just be that I am misinterpreting how the caps bit needs to be added in to make it work with mu-law files. </p> <p>I am creating the caps, then using the gst_element_link_filtered to use this:</p> <pre><code>GstCaps *gstMuLawCaps = gst_caps_from_string("audio/x-mulaw, rate=8000, channels=1"); gst_element_link_filtered(gstFileSource, gstMuLawDecoder, gstMuLawCaps); </code></pre> <p>But this is not working, and running the program produces the following output:</p> <pre><code>&gt;gst-mulaw.exe test.ulaw Playing. Error: Internal data flow error. Playback Finished. </code></pre> <p>I would be grateful if anyone is able to help shed some light on what I am doing wrong. The full code is given below:</p> <pre><code>#include &lt;gst/gst.h&gt; #include &lt;glib.h&gt; static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) { GMainLoop *loop = (GMainLoop *) data; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: g_print ("End of stream\n"); g_main_loop_quit (loop); break; case GST_MESSAGE_ERROR: { gchar *debug; GError *error; gst_message_parse_error (msg, &amp;error, &amp;debug); g_free (debug); g_printerr ("Error: %s\n", error-&gt;message); g_error_free (error); g_main_loop_quit (loop); break; } default: break; } return TRUE; } static void on_pad_added (GstElement *gstSourceElement, GstPad *gstSourcePad, gpointer data) { g_print("Linking dynamic pad.\n"); GstPad *gstSinkPad; GstElement *gstSinkElement = (GstElement *) data; gstSinkPad = gst_element_get_static_pad (gstSinkElement, "sink"); gst_pad_link (gstSourcePad, gstSinkPad); gst_object_unref (gstSinkPad); } int main (int argc, char *argv[]) { GMainLoop *loop; GstElement *gstPipeline, *gstFileSource, *gstMuLawDecoder, *gstAudioConvert, *gstAudioResample, *gstAudioSink; GstBus *bus; // GStreamer initialisation. gst_init (&amp;argc, &amp;argv); loop = g_main_loop_new (NULL, FALSE); // Check input arguments. if (argc != 2) { g_printerr ("Usage: %s &lt;mu-law File&gt;\n", argv[0]); return -1; } // Create the GStreamer elements. gstPipeline = gst_pipeline_new ("player"); gstFileSource = gst_element_factory_make ("filesrc", "filesource"); gstMuLawDecoder = gst_element_factory_make ("mulawdec", "mulawdecoder"); gstAudioConvert = gst_element_factory_make ("audioconvert", "audioconverter"); gstAudioResample = gst_element_factory_make ("audioresample", "audioresampler"); gstAudioSink = gst_element_factory_make ("autoaudiosink", "audiosink"); if (!gstPipeline || !gstFileSource || !gstMuLawDecoder || !gstAudioConvert || !gstAudioResample || !gstAudioSink) { g_printerr ("An element could not be created. Exiting.\n"); return -1; } // Linke the filesrc object to that passed on the command line. g_object_set (G_OBJECT (gstFileSource), "location", argv[1], NULL); // Setup the GStreamer bus. bus = gst_pipeline_get_bus (GST_PIPELINE (gstPipeline)); gst_bus_add_watch (bus, bus_call, loop); gst_object_unref (bus); // Add the objects to the pipeline. gst_bin_add_many (GST_BIN (gstPipeline), gstFileSource, gstMuLawDecoder, gstAudioConvert, gstAudioResample, gstAudioSink, NULL); // Link the elements together. GstCaps *gstMuLawCaps = gst_caps_from_string("audio/x-mulaw, rate=8000, channels=1"); gst_element_link_filtered(gstFileSource, gstMuLawDecoder, gstMuLawCaps); gst_caps_unref(gstMuLawCaps); gst_element_link_many (gstAudioConvert, gstAudioResample, gstAudioSink, NULL); g_signal_connect (gstMuLawDecoder, "pad-added", G_CALLBACK (on_pad_added), gstAudioConvert); // Set the pipeline to state playing, and run the main loop. g_print ("Playing.\n"); gst_element_set_state (gstPipeline, GST_STATE_PLAYING); g_main_loop_run (loop); // Finished playback, cleanup. g_print ("Playback Finished.\n"); gst_element_set_state (gstPipeline, GST_STATE_NULL); gst_object_unref (GST_OBJECT (gstPipeline)); return 0; } </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload