Odd problem playing wav file

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Odd problem playing wav file

Tiago Katcipis
Im having some trouble making a wav player, when i try to build the pipeline using gst-launch it works fine, but the source code building the same pipeline generates an error. Im sorry if the question is stupid, im new at gstreamer and im not getting what im doing wrong :-(. I followed an example i found on gstreamer documentation.

The gst-launch comand:
gst-launch filesrc location="exemploWav.wav" ! wavparse ! audioconvert ! gconfaudiosink

The source code that builds the same pipe (or at least it should build):
#include <gst/gst.h>
#include <glib.h>

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, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);
      break;
    }
    default:
      g_print("Teste.....[%d]\n", GST_MESSAGE_TYPE (msg));
      break;
  }

  return TRUE;
}

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

  GstElement *pipeline, *source, *sink, *convert, *wavparse;
  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

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

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("wav_player");
  source   = gst_element_factory_make ("filesrc",       "file_source");
  wavparse = gst_element_factory_make ("wavparse",      "wav_parser");
  convert  = gst_element_factory_make ("audioconvert",  "audio_convert");
  sink     = gst_element_factory_make ("gconfaudiosink","gnome_output");

  if (!pipeline || !source || !sink || !convert || !wavparse ) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* Set up the pipeline */
  /* we set the input filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, convert, wavparse, sink, NULL);

  /* we link the elements together */
  gst_element_link (source, wavparse);
  gst_element_link (wavparse, convert);
  gst_element_link (convert, sink);
 
 
  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);


  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  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;
}

The error:
Error: Erro no fluxo interno de dados. (something like "Error on internal data flow").

best regards,
Katcipis

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Odd problem playing wav file

Andrey Boyko
wavparse element has 'sometimes' src pads so you can't just do gst_element_link (wavparse, convert);
See http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/index.html section 8.1.1 how to handle it.

Tiago Katcipis wrote:
Im having some trouble making a wav player, when i try to build the pipeline using gst-launch it works fine, but the source code building the same pipeline generates an error. Im sorry if the question is stupid, im new at gstreamer and im not getting what im doing wrong :-(. I followed an example i found on gstreamer documentation.

The gst-launch comand:
gst-launch filesrc location="exemploWav.wav" ! wavparse ! audioconvert ! gconfaudiosink

The source code that builds the same pipe (or at least it should build):
#include <gst/gst.h>
#include <glib.h>

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, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);
      break;
    }
    default:
      g_print("Teste.....[%d]\n", GST_MESSAGE_TYPE (msg));
      break;
  }

  return TRUE;
}

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

  GstElement *pipeline, *source, *sink, *convert, *wavparse;
  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

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

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("wav_player");
  source   = gst_element_factory_make ("filesrc",       "file_source");
  wavparse = gst_element_factory_make ("wavparse",      "wav_parser");
  convert  = gst_element_factory_make ("audioconvert",  "audio_convert");
  sink     = gst_element_factory_make ("gconfaudiosink","gnome_output");

  if (!pipeline || !source || !sink || !convert || !wavparse ) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* Set up the pipeline */
  /* we set the input filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, convert, wavparse, sink, NULL);

  /* we link the elements together */
  gst_element_link (source, wavparse);
  gst_element_link (wavparse, convert);
  gst_element_link (convert, sink);
 
 
  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);


  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  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;
}

The error:
Error: Erro no fluxo interno de dados. (something like "Error on internal data flow").

best regards,
Katcipis

------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com

_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Odd problem playing wav file

Tiago Katcipis
but why does it work every time with gst-launch?

On Thu, May 7, 2009 at 11:14 AM, Andrey Boyko <[hidden email]> wrote:
wavparse element has 'sometimes' src pads so you can't just do gst_element_link (wavparse, convert);
See http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/index.html section 8.1.1 how to handle it.

Tiago Katcipis wrote:
Im having some trouble making a wav player, when i try to build the pipeline using gst-launch it works fine, but the source code building the same pipeline generates an error. Im sorry if the question is stupid, im new at gstreamer and im not getting what im doing wrong :-(. I followed an example i found on gstreamer documentation.

The gst-launch comand:
gst-launch filesrc location="exemploWav.wav" ! wavparse ! audioconvert ! gconfaudiosink

The source code that builds the same pipe (or at least it should build):
#include <gst/gst.h>
#include <glib.h>

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, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);
      break;
    }
    default:
      g_print("Teste.....[%d]\n", GST_MESSAGE_TYPE (msg));
      break;
  }

  return TRUE;
}

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

  GstElement *pipeline, *source, *sink, *convert, *wavparse;
  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

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

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("wav_player");
  source   = gst_element_factory_make ("filesrc",       "file_source");
  wavparse = gst_element_factory_make ("wavparse",      "wav_parser");
  convert  = gst_element_factory_make ("audioconvert",  "audio_convert");
  sink     = gst_element_factory_make ("gconfaudiosink","gnome_output");

  if (!pipeline || !source || !sink || !convert || !wavparse ) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* Set up the pipeline */
  /* we set the input filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, convert, wavparse, sink, NULL);

  /* we link the elements together */
  gst_element_link (source, wavparse);
  gst_element_link (wavparse, convert);
  gst_element_link (convert, sink);
 
 
  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);


  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  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;
}

The error:
Error: Erro no fluxo interno de dados. (something like "Error on internal data flow").

best regards,
Katcipis

------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com

_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




--
"it might be a profitable thing to learn Java, but it has no intellectual value whatsoever" Alexander Stepanov

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Odd problem playing wav file

Andrey Boyko
Because gst-launch as an application do it for you. I think in function gst_parse_perform_delayed_link in file grammar.tab.c.

Tiago Katcipis wrote:
but why does it work every time with gst-launch?

On Thu, May 7, 2009 at 11:14 AM, Andrey Boyko <[hidden email]> wrote:
wavparse element has 'sometimes' src pads so you can't just do gst_element_link (wavparse, convert);
See http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/index.html section 8.1.1 how to handle it.

Tiago Katcipis wrote:
Im having some trouble making a wav player, when i try to build the pipeline using gst-launch it works fine, but the source code building the same pipeline generates an error. Im sorry if the question is stupid, im new at gstreamer and im not getting what im doing wrong :-(. I followed an example i found on gstreamer documentation.

The gst-launch comand:
gst-launch filesrc location="exemploWav.wav" ! wavparse ! audioconvert ! gconfaudiosink

The source code that builds the same pipe (or at least it should build):
#include <gst/gst.h>
#include <glib.h>

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, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);
      break;
    }
    default:
      g_print("Teste.....[%d]\n", GST_MESSAGE_TYPE (msg));
      break;
  }

  return TRUE;
}

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

  GstElement *pipeline, *source, *sink, *convert, *wavparse;
  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

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

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("wav_player");
  source   = gst_element_factory_make ("filesrc",       "file_source");
  wavparse = gst_element_factory_make ("wavparse",      "wav_parser");
  convert  = gst_element_factory_make ("audioconvert",  "audio_convert");
  sink     = gst_element_factory_make ("gconfaudiosink","gnome_output");

  if (!pipeline || !source || !sink || !convert || !wavparse ) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* Set up the pipeline */
  /* we set the input filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, convert, wavparse, sink, NULL);

  /* we link the elements together */
  gst_element_link (source, wavparse);
  gst_element_link (wavparse, convert);
  gst_element_link (convert, sink);
 
 
  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);


  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  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;
}

The error:
Error: Erro no fluxo interno de dados. (something like "Error on internal data flow").

best regards,
Katcipis

------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com

_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




--
"it might be a profitable thing to learn Java, but it has no intellectual value whatsoever" Alexander Stepanov


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Odd problem playing wav file

Tiago Katcipis
hmm thanks for the help, im going to read more then. I got confused because on gst-launch it worked, i didnt realized that gst-launch was linking diferent.

On Thu, May 7, 2009 at 11:57 AM, Andrey Boyko <[hidden email]> wrote:
Because gst-launch as an application do it for you. I think in function gst_parse_perform_delayed_link in file grammar.tab.c.


Tiago Katcipis wrote:
but why does it work every time with gst-launch?

On Thu, May 7, 2009 at 11:14 AM, Andrey Boyko <[hidden email]> wrote:
wavparse element has 'sometimes' src pads so you can't just do gst_element_link (wavparse, convert);
See http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/index.html section 8.1.1 how to handle it.

Tiago Katcipis wrote:
Im having some trouble making a wav player, when i try to build the pipeline using gst-launch it works fine, but the source code building the same pipeline generates an error. Im sorry if the question is stupid, im new at gstreamer and im not getting what im doing wrong :-(. I followed an example i found on gstreamer documentation.

The gst-launch comand:
gst-launch filesrc location="exemploWav.wav" ! wavparse ! audioconvert ! gconfaudiosink

The source code that builds the same pipe (or at least it should build):
#include <gst/gst.h>
#include <glib.h>

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, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);
      break;
    }
    default:
      g_print("Teste.....[%d]\n", GST_MESSAGE_TYPE (msg));
      break;
  }

  return TRUE;
}

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

  GstElement *pipeline, *source, *sink, *convert, *wavparse;
  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

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

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("wav_player");
  source   = gst_element_factory_make ("filesrc",       "file_source");
  wavparse = gst_element_factory_make ("wavparse",      "wav_parser");
  convert  = gst_element_factory_make ("audioconvert",  "audio_convert");
  sink     = gst_element_factory_make ("gconfaudiosink","gnome_output");

  if (!pipeline || !source || !sink || !convert || !wavparse ) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* Set up the pipeline */
  /* we set the input filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, convert, wavparse, sink, NULL);

  /* we link the elements together */
  gst_element_link (source, wavparse);
  gst_element_link (wavparse, convert);
  gst_element_link (convert, sink);
 
 
  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);


  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  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;
}

The error:
Error: Erro no fluxo interno de dados. (something like "Error on internal data flow").

best regards,
Katcipis

------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com

_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




--
"it might be a profitable thing to learn Java, but it has no intellectual value whatsoever" Alexander Stepanov




--
"it might be a profitable thing to learn Java, but it has no intellectual value whatsoever" Alexander Stepanov

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Odd problem playing wav file

Thiago Sousa Santos-2
In reply to this post by Tiago Katcipis


On Thu, May 7, 2009 at 11:44 AM, Tiago Katcipis <[hidden email]> wrote:
but why does it work every time with gst-launch?

Because gst-launch handle sometimes src pads. Your application doesn't.

gst-launch doesn't just link'em all and play, it handles pads accordingly to their types: request, sometimes and always, as described in the docs. You should read to understand what is happening and why it is that way.
 

On Thu, May 7, 2009 at 11:14 AM, Andrey Boyko <[hidden email]> wrote:
wavparse element has 'sometimes' src pads so you can't just do gst_element_link (wavparse, convert);
See http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/index.html section 8.1.1 how to handle it.

Tiago Katcipis wrote:
Im having some trouble making a wav player, when i try to build the pipeline using gst-launch it works fine, but the source code building the same pipeline generates an error. Im sorry if the question is stupid, im new at gstreamer and im not getting what im doing wrong :-(. I followed an example i found on gstreamer documentation.

The gst-launch comand:
gst-launch filesrc location="exemploWav.wav" ! wavparse ! audioconvert ! gconfaudiosink

The source code that builds the same pipe (or at least it should build):
#include <gst/gst.h>
#include <glib.h>

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, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);
      break;
    }
    default:
      g_print("Teste.....[%d]\n", GST_MESSAGE_TYPE (msg));
      break;
  }

  return TRUE;
}

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

  GstElement *pipeline, *source, *sink, *convert, *wavparse;
  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

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

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("wav_player");
  source   = gst_element_factory_make ("filesrc",       "file_source");
  wavparse = gst_element_factory_make ("wavparse",      "wav_parser");
  convert  = gst_element_factory_make ("audioconvert",  "audio_convert");
  sink     = gst_element_factory_make ("gconfaudiosink","gnome_output");

  if (!pipeline || !source || !sink || !convert || !wavparse ) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* Set up the pipeline */
  /* we set the input filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, convert, wavparse, sink, NULL);

  /* we link the elements together */
  gst_element_link (source, wavparse);
  gst_element_link (wavparse, convert);
  gst_element_link (convert, sink);
 
 
  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);


  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  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;
}

The error:
Error: Erro no fluxo interno de dados. (something like "Error on internal data flow").

best regards,
Katcipis

------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com

_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




--
"it might be a profitable thing to learn Java, but it has no intellectual value whatsoever" Alexander Stepanov

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




--
Thiago Sousa Santos

Embedded Systems and Pervasive Computing Lab (Embedded)
Center of Electrical Engineering and Informatics (CEEI)
Federal University of Campina Grande (UFCG)

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Odd problem playing wav file

Wim Taymans
In reply to this post by Tiago Katcipis
On Thu, 2009-05-07 at 10:23 -0300, Tiago Katcipis wrote:
> Im having some trouble making a wav player, when i try to build the
> pipeline using gst-launch it works fine, but the source code building
> the same pipeline generates an error. Im sorry if the question is
> stupid, im new at gstreamer and im not getting what im doing
> wrong :-(. I followed an example i found on gstreamer documentation.
>
> The gst-launch comand:
> gst-launch filesrc location="exemploWav.wav" ! wavparse !
> audioconvert ! gconfaudiosink

Hi,

Check the result codes from various methods (hint some elements will not
link correctly. Another hint, read some more about dynamic pads)

Wim

>
> The source code that builds the same pipe (or at least it should
> build):
> #include <gst/gst.h>
> #include <glib.h>
>
> 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, &error, &debug);
>       g_free (debug);
>
>       g_printerr ("Error: %s\n", error->message);
>       g_error_free (error);
>
>       g_main_loop_quit (loop);
>       break;
>     }
>     default:
>       g_print("Teste.....[%d]\n", GST_MESSAGE_TYPE (msg));
>       break;
>   }
>
>   return TRUE;
> }
>
> int
> main (int   argc,
>       char *argv[])
> {
>   GMainLoop *loop;
>
>   GstElement *pipeline, *source, *sink, *convert, *wavparse;
>   GstBus *bus;
>
>   /* Initialisation */
>   gst_init (&argc, &argv);
>
>   loop = g_main_loop_new (NULL, FALSE);
>
>   /* Check input arguments */
>   if (argc != 2) {
>     g_printerr ("Usage: %s <Wav filename>\n", argv[0]);
>     return -1;
>   }
>
>   /* Create gstreamer elements */
>   pipeline = gst_pipeline_new ("wav_player");
>   source   = gst_element_factory_make ("filesrc",
> "file_source");
>   wavparse = gst_element_factory_make ("wavparse",      "wav_parser");
>   convert  = gst_element_factory_make ("audioconvert",
> "audio_convert");
>   sink     = gst_element_factory_make
> ("gconfaudiosink","gnome_output");
>
>   if (!pipeline || !source || !sink || !convert || !wavparse ) {
>     g_printerr ("One element could not be created. Exiting.\n");
>     return -1;
>   }
>
>   /* Set up the pipeline */
>   /* we set the input filename to the source element */
>   g_object_set (G_OBJECT (source), "location", argv[1], NULL);
>
>   /* we add a message handler */
>   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
>   gst_bus_add_watch (bus, bus_call, loop);
>   gst_object_unref (bus);
>
>   /* we add all elements into the pipeline */
>   gst_bin_add_many (GST_BIN (pipeline),
>                     source, convert, wavparse, sink, NULL);
>
>   /* we link the elements together */
>   gst_element_link (source, wavparse);
>   gst_element_link (wavparse, convert);
>   gst_element_link (convert, sink);
>  
>  
>   /* Set the pipeline to "playing" state*/
>   g_print ("Now playing: %s\n", argv[1]);
>   gst_element_set_state (pipeline, GST_STATE_PLAYING);
>
>
>   /* Iterate */
>   g_print ("Running...\n");
>   g_main_loop_run (loop);
>
>   /* Out of the main loop, clean up nicely */
>   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;
> }
>
> The error:
> Error: Erro no fluxo interno de dados. (something like "Error on
> internal data flow").
>
> best regards,
> Katcipis
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
> Series Scanner you'll get full speed at 300 dpi even with all image
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Odd problem playing wav file

Tiago Katcipis
thanks fot the hints Wim. Im going to read more before posting now.

On Thu, May 7, 2009 at 12:19 PM, Wim Taymans <[hidden email]> wrote:
On Thu, 2009-05-07 at 10:23 -0300, Tiago Katcipis wrote:
> Im having some trouble making a wav player, when i try to build the
> pipeline using gst-launch it works fine, but the source code building
> the same pipeline generates an error. Im sorry if the question is
> stupid, im new at gstreamer and im not getting what im doing
> wrong :-(. I followed an example i found on gstreamer documentation.
>
> The gst-launch comand:
> gst-launch filesrc location="exemploWav.wav" ! wavparse !
> audioconvert ! gconfaudiosink

Hi,

Check the result codes from various methods (hint some elements will not
link correctly. Another hint, read some more about dynamic pads)

Wim
>
> The source code that builds the same pipe (or at least it should
> build):
> #include <gst/gst.h>
> #include <glib.h>
>
> 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, &error, &debug);
>       g_free (debug);
>
>       g_printerr ("Error: %s\n", error->message);
>       g_error_free (error);
>
>       g_main_loop_quit (loop);
>       break;
>     }
>     default:
>       g_print("Teste.....[%d]\n", GST_MESSAGE_TYPE (msg));
>       break;
>   }
>
>   return TRUE;
> }
>
> int
> main (int   argc,
>       char *argv[])
> {
>   GMainLoop *loop;
>
>   GstElement *pipeline, *source, *sink, *convert, *wavparse;
>   GstBus *bus;
>
>   /* Initialisation */
>   gst_init (&argc, &argv);
>
>   loop = g_main_loop_new (NULL, FALSE);
>
>   /* Check input arguments */
>   if (argc != 2) {
>     g_printerr ("Usage: %s <Wav filename>\n", argv[0]);
>     return -1;
>   }
>
>   /* Create gstreamer elements */
>   pipeline = gst_pipeline_new ("wav_player");
>   source   = gst_element_factory_make ("filesrc",
> "file_source");
>   wavparse = gst_element_factory_make ("wavparse",      "wav_parser");
>   convert  = gst_element_factory_make ("audioconvert",
> "audio_convert");
>   sink     = gst_element_factory_make
> ("gconfaudiosink","gnome_output");
>
>   if (!pipeline || !source || !sink || !convert || !wavparse ) {
>     g_printerr ("One element could not be created. Exiting.\n");
>     return -1;
>   }
>
>   /* Set up the pipeline */
>   /* we set the input filename to the source element */
>   g_object_set (G_OBJECT (source), "location", argv[1], NULL);
>
>   /* we add a message handler */
>   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
>   gst_bus_add_watch (bus, bus_call, loop);
>   gst_object_unref (bus);
>
>   /* we add all elements into the pipeline */
>   gst_bin_add_many (GST_BIN (pipeline),
>                     source, convert, wavparse, sink, NULL);
>
>   /* we link the elements together */
>   gst_element_link (source, wavparse);
>   gst_element_link (wavparse, convert);
>   gst_element_link (convert, sink);
>
>
>   /* Set the pipeline to "playing" state*/
>   g_print ("Now playing: %s\n", argv[1]);
>   gst_element_set_state (pipeline, GST_STATE_PLAYING);
>
>
>   /* Iterate */
>   g_print ("Running...\n");
>   g_main_loop_run (loop);
>
>   /* Out of the main loop, clean up nicely */
>   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;
> }
>
> The error:
> Error: Erro no fluxo interno de dados. (something like "Error on
> internal data flow").
>
> best regards,
> Katcipis
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
> Series Scanner you'll get full speed at 300 dpi even with all image
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
"it might be a profitable thing to learn Java, but it has no intellectual value whatsoever" Alexander Stepanov

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel