[gst-devel] Trouble with giostreamsrc

W. Michael Petullo mike at flyn.org
Mon Jul 6 05:49:26 CEST 2009


I am trying to move an application from giosrc to giostreamsrc.  
However, I have not been able to get my giostreamsrc pipeline to  
work. Everything worked fine when I was using giosrc with a URI.

When I run the application with the GST_DEBUG environment variable  
set, I see the error "No stream given yet." This happens as the  
application tries to change the pipeline's state to playing.

The strange thing is that I added a check right before the state  
change that reads the stream property from the giostreamsrc element  
using g_object_get and confirms that it is a G_IS_INPUT_STREAM. The  
check does not complain. However, something sets the stream back to  
NULL after I call gst_element_set_state (see "FIRST CHECK" and  
"SECOND CHECK" below).

I've run my application through valgrind and did not see any memory  
issues, though I have not yet ruled that out entirely.

I am using gstreamer-plugins-base 0.10.22.

My code follows:

GInputStream* g_gst_mp3_input_stream_new (GInputStream *src_stream)
{
         GstStateChangeReturn sret;
         GstState state;
         GGstMP3InputStream *stream;

         stream = G_GST_MP3_INPUT_STREAM (g_object_new  
(TYPE_G_GST_MP3_INPUT_STREAM,
                                                    NULL));

         stream->priv->pipeline = gst_pipeline_new ("pipeline");

         stream->priv->src     = gst_element_factory_make  
("giostreamsrc", "src");
         stream->priv->decode  = gst_element_factory_make  
("decodebin", "decode");
         stream->priv->convert = gst_element_factory_make  
("audioconvert", "convert");
         stream->priv->encode  = gst_element_factory_make ("lame",  
"encode");
         stream->priv->sink    = gst_element_factory_make ("appsink",  
"sink");

         gst_bin_add_many (GST_BIN (stream->priv->pipeline),
                           stream->priv->src,
                           stream->priv->decode,
                           stream->priv->convert,
                           stream->priv->encode,
                           stream->priv->sink,
                           NULL);

         if (gst_element_link (stream->priv->src, stream->priv- 
 >decode) == FALSE) {
                 g_warning ("Error linking source and decode elements");
         }

         g_assert (G_IS_INPUT_STREAM (src_stream));
         g_object_set (G_OBJECT (stream->priv->src), "stream",  
src_stream, NULL);

         /* quality=9 is important for fast, realtime transcoding: */
         g_object_set (G_OBJECT (stream->priv->encode), "quality", 9,  
NULL);
         g_object_set (G_OBJECT (stream->priv->encode), "bitrate",  
128, NULL);
         g_object_set (G_OBJECT (stream->priv->encode), "vbr", 0, NULL);
         g_signal_connect (stream->priv->decode, "new-decoded-pad",  
G_CALLBACK (new_decoded_pad_cb), stream);

         g_object_set (G_OBJECT (stream->priv->sink), "emit-signals",  
TRUE, "sync", FALSE, NULL);
         gst_app_sink_set_max_buffers (GST_APP_SINK (stream->priv- 
 >sink),
                                       GST_APP_MAX_BUFFERS);
         gst_app_sink_set_drop (GST_APP_SINK (stream->priv->sink),  
FALSE);

         g_signal_connect (stream->priv->sink, "new-buffer",  
G_CALLBACK (g_gst_input_stream_new_buffer_cb), stream);

/* MY FIRST CHECK: NO PROBLEM: */
gpointer foo;
g_warning ("CHECK 1");
g_object_get (G_OBJECT (stream->priv->src), "stream",  &foo, NULL);
g_assert (G_IS_INPUT_STREAM (foo));
g_assert (src_stream == foo);

         sret = gst_element_set_state (stream->priv->pipeline,  
GST_STATE_PLAYING);
         if (GST_STATE_CHANGE_ASYNC == sret) {
                 if (GST_STATE_CHANGE_SUCCESS !=  
gst_element_get_state (GST_ELEMENT (stream->priv->pipeline), &state,  
NULL, 5 * GST_SECOND)) {
                         g_warning ("State change failed for stream.");
                 }
         } else if (sret != GST_STATE_CHANGE_SUCCESS) {
                 g_warning ("Could not read stream.");
         }

/* MY SECOND CHECK: FAILS, FOO == NULL! */
g_warning ("CHECK 2");
g_object_get (G_OBJECT (stream->priv->src), "stream",  &foo, NULL);
g_warning ("NULL == foo %d", NULL == foo);
g_assert (G_IS_INPUT_STREAM (src_stream));
g_assert (G_IS_INPUT_STREAM (foo));
g_assert (src_stream == foo);

         g_assert (G_IS_SEEKABLE (stream));
         return G_INPUT_STREAM (stream);
}

Mike




More information about the gstreamer-devel mailing list