]> git.sesse.net Git - mlt/blobdiff - src/modules/avformat/producer_avformat.c
Add exit_on_disconnect property to avformat producer.
[mlt] / src / modules / avformat / producer_avformat.c
index dbe36a8de074efe1450d0a7b20a823090f5906dc..d7a34e83eebbbb18bd646ca588cba83f6e6fdac0 100644 (file)
@@ -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 );