[gst-devel] play wma file error

xiaofeng xu kilyxu at gmail.com
Tue Sep 11 07:14:14 CEST 2007

I try to use ffmpeg plugin to play wma music file and it works. See my code.

But at the end of stream, it gives a error message: internal data stream

I don't know why. Can you help me? Thank you!

gcc -Wall `pkg-config --cflags --libs gstreamer-0.10` player.c -o player

#include <gst/gst.h>

GstElement *pipeline, *source, *parser, *decoder, *conv, *sink;

static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
  GMainLoop *loop = data;

  switch (GST_MESSAGE_TYPE (msg))
      g_print ("End-of-stream\n");
      g_main_loop_quit (loop);
      gchar *debug;
      GError *err;

      gst_message_parse_error (msg, &err, &debug);
      g_free (debug);

      g_print ("Error: %s\n", err->message);
      g_error_free (err);

      g_main_loop_quit (loop);

  return TRUE;

static void new_pad (GstElement *element, GstPad *pad, gpointer data)
  GstPad *sinkpad;
  g_print ("Dynamic pad created, linking parser/decoder\n");

  sinkpad = gst_element_get_pad (decoder, "sink");
  gst_pad_link (pad, sinkpad);

  gst_object_unref (sinkpad);

int main (int   argc, char *argv[])
  GMainLoop *loop;
  GstBus *bus;

  /* initialize GStreamer */
  gst_init (&argc, &argv);
  loop = g_main_loop_new (NULL, FALSE);

  /* check input arguments */
  if (argc != 2) {
    g_print ("Usage: %s <wma filename>\n", argv[0]);
    return -1;

  /* create elements */
  pipeline = gst_pipeline_new ("audio-player");
  source = gst_element_factory_make ("filesrc", "file-source");
  parser = gst_element_factory_make ("ffdemux_asf", "asf-parser");
  decoder = gst_element_factory_make ("ffdec_wmav2", "wmav2-decoder");
  conv = gst_element_factory_make ("audioconvert", "converter");
  sink = gst_element_factory_make ("alsasink", "alsa-output");
  if (!pipeline || !source || !parser || !decoder || !conv || !sink) {
    g_print ("One element could not be created\n");
    return -1;

  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  gst_bin_add_many (GST_BIN (pipeline),
      source, parser, decoder, conv, sink, NULL);

  gst_element_link (source, parser);
  gst_element_link_many (decoder, conv, sink, NULL);
  g_signal_connect (parser, "pad-added", G_CALLBACK (new_pad), NULL);

  g_print ("Setting to PLAYING\n");
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_print ("Running\n");
  g_main_loop_run (loop);

  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);
  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));

  return 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20070911/c5e6187b/attachment.htm>

More information about the gstreamer-devel mailing list