[gst-devel] Odd problem playing wav file
Tiago Katcipis
katcipis at inf.ufsc.br
Thu May 7 16:44:46 CEST 2009
but why does it work every time with gst-launch?
On Thu, May 7, 2009 at 11:14 AM, Andrey Boyko <andreib at module.ru> 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.htmlsection 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 listgstreamer-devel at lists.sourceforge.nethttps://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20090507/75d26cd1/attachment.htm>
More information about the gstreamer-devel
mailing list