X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fframework%2Fmlt_producer.c;h=d5c049b59b25a834a7a6ba45999357d45824bd19;hb=689ffbad7da48a5c795df6b5995f8b6b3c9a4299;hp=bffdc905b31ef0c32fed7bc2dbc930b99342fbbe;hpb=a2289e7420e67c98dd2c2b940cb8f6dde62c2871;p=mlt diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index bffdc905..d5c049b5 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -156,6 +156,11 @@ mlt_producer mlt_producer_new( mlt_profile profile ) mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( self ), "_profile", profile, 0, NULL, NULL ); mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( self ), "aspect_ratio", mlt_profile_sar( profile ) ); } + else + { + free( self ); + return NULL; + } } return self; } @@ -287,6 +292,7 @@ mlt_properties mlt_producer_properties( mlt_producer self ) * \param position set the "play head" position of the producer * \return false * \todo Document how the properties affect behavior. + * \see mlt_producer_seek_time */ int mlt_producer_seek( mlt_producer self, mlt_position position ) @@ -311,7 +317,7 @@ int mlt_producer_seek( mlt_producer self, mlt_position position ) mlt_producer_set_speed( self, 0 ); position = mlt_producer_get_playtime( self ) - 1; } - else if ( use_points && !strcmp( eof, "loop" ) && position >= mlt_producer_get_playtime( self ) ) + else if ( use_points && eof && !strcmp( eof, "loop" ) && position >= mlt_producer_get_playtime( self ) ) { position = (int)position % (int)mlt_producer_get_playtime( self ); } @@ -325,6 +331,22 @@ int mlt_producer_seek( mlt_producer self, mlt_position position ) return 0; } +/** Seek to a specified time string. + * + * \public \memberof mlt_producer_s + * \param self a producer + * \param time set the "play head" position of the producer to the time string + * \return false + * \see mlt_producer_seek + */ + +int mlt_producer_seek_time( mlt_producer self, const char* time ) +{ + mlt_properties_set( MLT_PRODUCER_PROPERTIES(self), "_seek_time", time ); + mlt_position position = mlt_properties_get_position( MLT_PRODUCER_PROPERTIES(self), "_seek_time" ); + return mlt_producer_seek( self, position ); +} + /** Get the current position (relative to in point). * * \public \memberof mlt_producer_s @@ -349,6 +371,19 @@ mlt_position mlt_producer_frame( mlt_producer self ) return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "_frame" ); } +/** Get the current position (relative to start of producer) as a time string. + * + * \public \memberof mlt_producer_s + * \param self a producer + * \param format the time value format + * \return the position of the "play head" regardless of the in point + */ + +char* mlt_producer_frame_time( mlt_producer self, mlt_time_format format ) +{ + return mlt_properties_get_time( MLT_PRODUCER_PROPERTIES( self ), "_frame", format ); +} + /** Set the playing speed. * * \public \memberof mlt_producer_s @@ -509,6 +544,21 @@ mlt_position mlt_producer_get_length( mlt_producer self ) return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "length" ); } +/** Get the total, unedited length of the producer as a time string. + * + * The value returned by a live streaming producer is unknown. + * + * \public \memberof mlt_producer_s + * \param self a producer + * \param format the time value format + * \return the duration of the producer regardless of in and out points + */ + +char* mlt_producer_get_length_time( mlt_producer self, mlt_time_format format ) +{ + return mlt_properties_get_time( MLT_PRODUCER_PROPERTIES( self ), "length", format ); +} + /** Prepare for next frame. * * Advance the play out position. If the speed is less than zero, it will @@ -563,7 +613,7 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind clone = clone == NULL ? self : clone; // A properly instatiated producer will have a get_frame method... - if ( self->get_frame == NULL || ( !strcmp( eof, "continue" ) && mlt_producer_position( self ) > mlt_producer_get_out( self ) ) ) + if ( self->get_frame == NULL || ( eof && !strcmp( eof, "continue" ) && mlt_producer_position( self ) > mlt_producer_get_out( self ) ) ) { // Generate a test frame *frame = mlt_frame_init( service );