From: Dan Dennedy Date: Thu, 23 May 2013 04:27:23 +0000 (-0700) Subject: Add exit_on_disconnect property to avformat producer. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f9eb18d60216a49b0cdf8f2b0f075f7864a5fb41;p=mlt Add exit_on_disconnect property to avformat producer. --- diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index dbe36a8d..d7a34e83 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -1426,6 +1426,11 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form pthread_mutex_unlock( &self->packets_mutex ); goto exit_get_image; } + if ( !self->seekable && mlt_properties_get_int( properties, "exit_on_disconnect" ) ) + { + mlt_log_fatal( MLT_PRODUCER_SERVICE(producer), "Exiting with error due to disconnected source.\n" ); + exit( EXIT_FAILURE ); + } } } pthread_mutex_unlock( &self->packets_mutex ); @@ -2284,8 +2289,10 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format } else if ( ret < 0 ) { - mlt_log_verbose( MLT_PRODUCER_SERVICE(self->parent), "av_read_frame returned error %d inside get_audio\n", ret ); - if ( !self->seekable && mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( self->parent ), "reconnect" ) ) + mlt_producer producer = self->parent; + mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer ); + mlt_log_verbose( MLT_PRODUCER_SERVICE(producer), "av_read_frame returned error %d inside get_audio\n", ret ); + if ( !self->seekable && mlt_properties_get_int( properties, "reconnect" ) ) { // Try to reconnect to live sources by closing context and codecs, // and letting next call to get_frame() reopen. @@ -2293,6 +2300,11 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format pthread_mutex_unlock( &self->packets_mutex ); goto exit_get_audio; } + if ( !self->seekable && mlt_properties_get_int( properties, "exit_on_disconnect" ) ) + { + mlt_log_fatal( MLT_PRODUCER_SERVICE(producer), "Exiting with error due to disconnected source.\n" ); + exit( EXIT_FAILURE ); + } } } pthread_mutex_unlock( &self->packets_mutex ); diff --git a/src/modules/avformat/producer_avformat.yml b/src/modules/avformat/producer_avformat.yml index d29efd34..c7911b66 100644 --- a/src/modules/avformat/producer_avformat.yml +++ b/src/modules/avformat/producer_avformat.yml @@ -185,3 +185,13 @@ parameters: minimum: 0 maximum: 1 widget: checkbox + + - identifier: exit_on_disconnect + title: Exit upon disconnection? + description: > + When this is set, the program will terminate with an error if a live source + becomes disconnected. + type: integer + minimum: 0 + maximum: 1 + widget: checkbox