Reading "wav" file in "C"

aft aftnix at gmail.com
Wed Feb 5 05:00:22 PST 2014


On Wed, Feb 5, 2014 at 6:34 PM, Adrien Schwartzentruber
<adrien.schwartzentruber at gmail.com> wrote:
>   gst_element_link(src,parse);
>   gst_element_link(dec,sink);
>
> Try to replace by :
>   gst_element_link_many(src, parse, dec, NULL);
>
> The callback pad_added is never called because this element isn't linked to
> the parser.

Well the src pad of wavparse is not available always, that's i why
i've not linked them.

I've solved the issue. The problem was in this line :
g_signal_connect (dec, "pad-added", G_CALLBACK (on_pad_added), dec);

I should have connected to "parse" element whose src template is
created "on the fly". If i put "parse" there, it works fine.

>
> Also, use the environment variable GST_DEBUG to get more debug informations.
> http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-checklist-debug.html
>
> Another good way to debug, is to generate dot file of the pipeline. See :
> http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstInfo.html#GST-DEBUG-BIN-TO-DOT-FILE:CAPS
>

Thanks for the debugging tips.

>
> On Wed, Feb 5, 2014 at 12:46 PM, aft <aftnix at gmail.com> wrote:
>>
>> Hi,
>>
>> I'm trying to implement the following pipeline in 'C':
>>
>>     arif at dev:~/GS_samples/cmd_GS$gst-launch-0.10 filesrc
>> location="../sample_media/M1F1-Alaw-AFsp.wav" ! wavparse ! alawdec !
>> autoaudiosink
>>
>>
>> Here is the implementation which i have written
>>
>>     #include <gst/gst.h>
>>
>>     void on_pad_added(GstElement *src_element, GstPad *src_pad, gpointer
>> data);
>>     static gboolean bus_cb(GstBus *bus, GstMessage *message, gpointer
>> data);
>>
>>     static GMainLoop *loop;
>>
>>     int main(int argc, char **argv) {
>>
>>     GstElement *pipeline;
>>     GstElement *src;
>>     GstElement *dec;
>>     GstElement *parse;
>>     GstElement *sink;
>>     GstBus *bus;
>>
>>     gst_init(&argc, &argv);
>>
>>     loop = g_main_loop_new (NULL, FALSE);
>>
>>     pipeline = gst_pipeline_new("wav_player");
>>
>>     src = gst_element_factory_make("filesrc","src");
>>     sink = gst_element_factory_make("autoaudiosink","sink");
>>     parse = gst_element_factory_make("wavparse","parse");
>>     dec = gst_element_factory_make("alawdec", "dec");
>>
>>     gst_bin_add_many (GST_BIN(pipeline), src,parse,dec,sink, NULL);
>>     g_object_set( G_OBJECT (src) , "location",argv[1], NULL);
>>
>>     gst_element_link(src,parse);
>>     gst_element_link(dec,sink);
>>     g_signal_connect (dec, "pad-added", G_CALLBACK (on_pad_added), dec);
>>
>>     bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
>>     gst_bus_add_watch (bus, bus_cb, NULL);
>>     gst_object_unref(bus);
>>     gst_element_set_state(pipeline, GST_STATE_PLAYING);
>>     g_main_loop_run(loop);
>>     return 0;
>>
>>     }
>>
>>     void on_pad_added (GstElement *src_element, GstPad *src_pad, gpointer
>> data)
>>     {
>>     g_print ("linking dynamic pad ...\n");
>>
>>     GstElement *sink_element = (GstElement *) data;
>>     GstPad *sink_pad = gst_element_get_static_pad(sink_element, "sink");
>>     gst_pad_link (src_pad, sink_pad);
>>     gst_object_unref(sink_pad);
>>
>>     }
>>
>>     static gboolean bus_cb(GstBus *bus, GstMessage *message, gpointer
>> data)
>>     {
>>       g_print ("Got %s message\n", GST_MESSAGE_TYPE_NAME (message));
>>
>>       switch (GST_MESSAGE_TYPE (message)) {
>>         case GST_MESSAGE_ERROR: {
>>           GError *err;
>>           gchar *debug;
>>
>>           gst_message_parse_error (message, &err, &debug);
>>           g_print ("Error: %s\n", err->message);
>>           g_error_free (err);
>>           g_free (debug);
>>
>>           g_main_loop_quit (loop);
>>           break;
>>         }
>>         case GST_MESSAGE_EOS:
>>           /* end-of-stream */
>>           g_main_loop_quit (loop);
>>           break;
>>         default:
>>           /* unhandled message */
>>           break;
>>       }
>>
>>       /* we want to be notified again the next time there is a message
>>        * on the bus, so returning TRUE (FALSE means we want to stop
>> watching
>>        * for messages on the bus and our callback should not be called
>> again)
>>        */
>>       return TRUE;
>>     }
>>
>>
>> But this does not work :
>>
>>     arif at dev:~/GS_samples/cmd_GS$./a.out
>> ../sample_media/M1F1-Alaw-AFsp.wav
>>     Got state-changed message
>>     Got state-changed message
>>     Got stream-status message
>>     Got tag message
>>     Got error message
>>     Error: Internal data flow error.
>> --
>> -Cheers
>> -Arif
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>



-- 
-Cheers
-Arif


More information about the gstreamer-devel mailing list