* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-// Local header files
-#include "producer_avformat.h"
-
// MLT Header files
+#include <framework/mlt_producer.h>
#include <framework/mlt_frame.h>
// ffmpeg Header files
void avformat_unlock( );
// Forward references.
-static int producer_open( mlt_producer this, char *file );
+static int producer_open( mlt_producer this, mlt_profile profile, char *file );
static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index );
/** Constructor for libavformat.
*/
-mlt_producer producer_avformat_init( char *file )
+mlt_producer producer_avformat_init( mlt_profile profile, char *file )
{
mlt_producer this = NULL;
this->get_frame = producer_get_frame;
// Open the file
- if ( producer_open( this, file ) != 0 )
+ if ( producer_open( this, profile, file ) != 0 )
{
// Clean up
mlt_producer_close( this );
/** Open the file.
*/
-static int producer_open( mlt_producer this, char *file )
+static int producer_open( mlt_producer this, mlt_profile profile, char *file )
{
// Return an error code (0 == no error)
int error = 0;
mlt_properties properties = MLT_PRODUCER_PROPERTIES( this );
// We will treat everything with the producer fps
- double fps = mlt_producer_get_fps( this );
+ double fps = mlt_profile_fps( profile );
// Lock the mutex now
avformat_lock( );
got_picture = 0;
}
}
+ av_free_packet( &pkt );
+ }
+ else if ( ret >= 0 )
+ {
+ av_free_packet( &pkt );
}
// Now handle the picture if we have one
mlt_properties_set_int( properties, "_current_position", int_position );
mlt_properties_set_int( properties, "_got_picture", 1 );
}
-
- // We're finished with this packet regardless
- av_free_packet( &pkt );
}
}
static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index )
{
// Create an empty frame
- *frame = mlt_frame_init( );
+ *frame = mlt_frame_init( MLT_PRODUCER_SERVICE( this ) );
// Update timecode on the frame we're creating
mlt_frame_set_position( *frame, mlt_producer_position( this ) );