<p>Hi<br>I try to use ffmpeg plugin to play wma music file and it works. See my code.</p>
<p>But at the end of stream, it gives a error message: internal data stream error.</p>
<p>I don't know why. Can you help me? Thank you!</p>
<p><br>gcc -Wall `pkg-config --cflags --libs gstreamer-0.10` player.c -o player</p>
<p>#include <gst/gst.h> </p>
<p>GstElement *pipeline, *source, *parser, *decoder, *conv, *sink;</p>
<p>static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)<br>{<br> GMainLoop *loop = data;</p>
<p> switch (GST_MESSAGE_TYPE (msg)) <br> {<br> case GST_MESSAGE_EOS:<br> g_print ("End-of-stream\n");<br> g_main_loop_quit (loop);<br> break;<br> case GST_MESSAGE_ERROR: <br> {<br> gchar *debug;
<br> GError *err;</p>
<p> gst_message_parse_error (msg, &err, &debug);<br> g_free (debug);</p>
<p> g_print ("Error: %s\n", err->message);<br> g_error_free (err);</p>
<p> g_main_loop_quit (loop);<br> break;<br> }<br> default:<br> break;<br> }</p>
<p> return TRUE;<br>}</p>
<p>static void new_pad (GstElement *element, GstPad *pad, gpointer data)<br>{<br> GstPad *sinkpad;<br> g_print ("Dynamic pad created, linking parser/decoder\n");</p>
<p> sinkpad = gst_element_get_pad (decoder, "sink");<br> gst_pad_link (pad, sinkpad);</p>
<p> gst_object_unref (sinkpad);<br>}</p>
<p>int main (int argc, char *argv[])<br>{<br> GMainLoop *loop;<br> GstBus *bus;</p>
<p> /* initialize GStreamer */<br> gst_init (&argc, &argv);<br> loop = g_main_loop_new (NULL, FALSE);</p>
<p> /* check input arguments */<br> if (argc != 2) {<br> g_print ("Usage: %s <wma filename>\n", argv[0]);<br> return -1;<br> }</p>
<p> /* create elements */<br> pipeline = gst_pipeline_new ("audio-player");<br> source = gst_element_factory_make ("filesrc", "file-source");<br> parser = gst_element_factory_make ("ffdemux_asf", "asf-parser");
<br> decoder = gst_element_factory_make ("ffdec_wmav2", "wmav2-decoder");<br> conv = gst_element_factory_make ("audioconvert", "converter");<br> sink = gst_element_factory_make ("alsasink", "alsa-output");
<br> if (!pipeline || !source || !parser || !decoder || !conv || !sink) {<br> g_print ("One element could not be created\n");<br> return -1;<br> }</p>
<p> g_object_set (G_OBJECT (source), "location", argv[1], NULL);</p>
<p> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br> gst_bus_add_watch (bus, bus_call, loop);<br> gst_object_unref (bus);</p>
<p> gst_bin_add_many (GST_BIN (pipeline),<br> source, parser, decoder, conv, sink, NULL);</p>
<p> gst_element_link (source, parser);<br> gst_element_link_many (decoder, conv, sink, NULL);<br> g_signal_connect (parser, "pad-added", G_CALLBACK (new_pad), NULL);</p>
<p> g_print ("Setting to PLAYING\n");<br> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br> g_print ("Running\n");<br> g_main_loop_run (loop);</p>
<p> g_print ("Returned, stopping playback\n");<br> gst_element_set_state (pipeline, GST_STATE_NULL);<br> g_print ("Deleting pipeline\n");<br> gst_object_unref (GST_OBJECT (pipeline));</p>
<p> return 0;<br>}<br></p>