]> git.sesse.net Git - mlt/blobdiff - src/modules/avformat/producer_avformat.c
make mlt_position type double
[mlt] / src / modules / avformat / producer_avformat.c
index da4dcb2d21f793f0b050fa115a62f288efe06862..89d59b7ea39434b72f30eed0301d461a13db2034 100644 (file)
@@ -959,7 +959,7 @@ static int seek_video( producer_avformat self, mlt_position position,
                                timestamp -= 2 / av_q2d( self->video_time_base );
                        if ( timestamp < 0 )
                                timestamp = 0;
-                       mlt_log_debug( MLT_PRODUCER_SERVICE(producer), "seeking timestamp %"PRId64" position %d expected %d last_pos %"PRId64"\n",
+                       mlt_log_debug( MLT_PRODUCER_SERVICE(producer), "seeking timestamp %"PRId64" position " MLT_POSITION_FMT " expected "MLT_POSITION_FMT" last_pos %"PRId64"\n",
                                timestamp, position, self->video_expected, self->last_position );
 
                        // Seek to the timestamp
@@ -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 );
@@ -1811,8 +1816,7 @@ static int video_codec_init( producer_avformat self, int index, mlt_properties p
                if ( mlt_properties_get( properties, "force_fps" ) )
                {
                        AVRational force_fps = av_d2q( mlt_properties_get_double( properties, "force_fps" ), 1024 );
-                       self->video_time_base.num *= frame_rate.num * force_fps.den;
-                       self->video_time_base.den *= frame_rate.den * force_fps.num;
+                       self->video_time_base = av_mul_q( stream->time_base, av_div_q( frame_rate, force_fps ) );
                        frame_rate = force_fps;
                }
                mlt_properties_set_int( properties, "meta.media.frame_rate_num", frame_rate.num );
@@ -2285,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.
@@ -2294,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 );