Rewind a pipeline
Stefan Sauer
ensonic at hora-obscura.de
Tue May 28 02:23:29 PDT 2013
On 05/28/2013 08:36 AM, Jorge Fernandez Monteagudo wrote:
> Hi Stefan!
>
> That will be perfect because I'm looking for a playing loop mode. I've been doing some test but I'm not able to
> get the loop mode working... This is what I'm doing:
>
> in main
>
> // Create main loop.
> decoding_data.loop = g_main_loop_new( NULL, FALSE );
>
> // Create pipeline.
> decoding_data.pipeline = get_pipeline( file_video );
> if( decoding_data.pipeline == NULL ) {
> printf( "Error creating pipeline! Exiting...\n" );
> return 1;
> }
go to PAUSED first, then seek and then go to playing.
>
> // Play new pipeline.
> printf( "Going to play...\n" );
> gst_element_seek( decoding_data.pipeline, 1.0, GST_FORMAT_TIME,
> (GstSeekFlags)(GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
> GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_END, 0);
For start=0 you waont need the ACCURATE flag. For end, you can also use
TYPE_NONE and GST_CLOCK_TIME_NONE instead of 0. Not sure if all elements
handle TYPE_END
>
> ret = gst_element_set_state( decoding_data.pipeline, GST_STATE_PLAYING );
> if( ret == GST_STATE_CHANGE_FAILURE ) {
> printf( "Failed to start up pipeline!\n" );
> return 1;
> }
>
> // Endless loop.
> main_loop();
>
>
> and in the bus messages handler
>
> static GstBusSyncReply on_sync_message( GstBus *bus, GstMessage *msg, gpointer data )
> {
> DecodingPrivateData *priv = (DecodingPrivateData *)data;
>
> // Handle other messages on the bus.
> GstBusSyncReply ret = GST_BUS_PASS;
> switch( GST_MESSAGE_TYPE( msg ) ) {
> case GST_MESSAGE_EOS:
> printf( "End-of-stream\n" );
> priv->eos_detected = 1;
> ret = GST_BUS_DROP;
> break;
>
> case GST_MESSAGE_SEGMENT_DONE:
> printf( "Looping on segment done\n" );
> gst_element_seek( priv->pipeline, 1.0, GST_FORMAT_TIME,
> (GstSeekFlags)(GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_ACCURATE),
> GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_END, 0);
> break;
>
> case GST_MESSAGE_ERROR:
> {
> gchar *debug = NULL;
> GError *err = NULL;
>
> gst_message_parse_error( msg, &err, &debug );
> printf( "Error: %s\n", err->message );
> g_error_free( err );
>
> if( debug ) {
> printf( "Debug details: %s\n", debug );
> g_free( debug );
> }
>
> priv->error_detected = 1;
> ret = GST_BUS_DROP;
> break;
> }
> default:
> break;
> }
>
> return ret;
> }
>
> I've tried doing the seek before and after gst_element_set_state( decoding_data.pipeline, GST_STATE_PLAYING )
> with the same result. The video is played once and I only get the GST_MESSAGE_EOS message! What am I missing?
>
>
> Thanks!
>
> ________________________________________
> From: gstreamer-devel-bounces+jorgefm=cirsa.com at lists.freedesktop.org [gstreamer-devel-bounces+jorgefm=cirsa.com at lists.freedesktop.org] On Behalf Of Stefan Sauer [ensonic at hora-obscura.de]
> Sent: Sunday, May 26, 2013 12:16 PM
> To: gstreamer-devel at lists.freedesktop.org
> Subject: Re: Rewind a pipeline
>
> On 05/20/2013 03:41 PM, Jorge Fernandez Monteagudo wrote:
>> Answering myself I've seen using GST_DEBUG that the event is ignored. First I have to set the
>> pipeline in GST_STATE_PLAYING then send the seek event and now it works!
> If you go to playing again, you should not need to seek. If you want to
> play in a loop, you can seek with the SEGMENT flag initially and then
> wait for SEGMENT_DONE on the bus (instead of EOS) and seek again. The
> continuation seek won't need the FLUSH flag. This way you get seamless
> loops.
>
> Stefan
>> Sorry for disturbing the list!
>>
>> ________________________________________
>> From: gstreamer-devel-bounces+jorgefm=cirsa.com at lists.freedesktop.org [gstreamer-devel-bounces+jorgefm=cirsa.com at lists.freedesktop.org] On Behalf Of Jorge Fernandez Monteagudo [jorgefm at cirsa.com]
>> Sent: Monday, May 20, 2013 3:27 PM
>> To: gstreamer-devel at lists.freedesktop.org
>> Subject: Rewind a pipeline
>>
>> Hi all!
>>
>> Is it possible to reuse a pipeline? I would like to avoid creating and destroying a pipeline when I
>> want to have a video playing in a loop. How can I do that? When I try to send a seek event I
>> always get an error. The next code always print "Send seek event failed!"
>>
>> // Set the pipeline ready.
>> ret = gst_element_set_state( pipeline, GST_STATE_READY );
>> if( ret == GST_STATE_CHANGE_FAILURE ) {
>> printf( "Failed to start up pipeline!\n" );
>> done = 1;
>> return;
>> }
>>
>> // Seek the stream init.
>> GstEvent *seek_event = NULL;
>>
>> seek_event = gst_event_new_seek( 1.0, GST_FORMAT_TIME,
>> (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
>> GST_SEEK_TYPE_SET, 0LL,
>> GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE );
>> if( gst_element_send_event( pipeline, seek_event ) == false ) {
>> printf( "Send seek event failed!\n" );
>> done = 1;
>> return;
>> }
>>
>> Este mensaje se dirige exclusivamente a su destinatario y puede contener información privilegiada o CONFIDENCIAL. Si no es vd. el destinatario indicado, queda notificado de que la utilización, divulgación y/o copia sin autorización está prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
>>
>> This message is intended exclusively for its addressee and may contain information that is CONFIDENTIAL and protected by professional privilege.
>> If you are not the intended recipient you are hereby notified that any dissemination, copy or disclosure of this communication is strictly prohibited by law. If this message has been received in error, please immediately notify us via e-mail and delete it.
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list