#include <stdlib.h>
#include <sys/time.h>
+static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args );
+
/** Public final methods
*/
// Hmm - default all consumers to yuv422 :-/
this->format = mlt_image_yuv422;
+
+ mlt_events_register( properties, "consumer-frame-show", ( mlt_transmitter )mlt_consumer_frame_show );
+ mlt_events_register( properties, "consumer-stopped", NULL );
}
return error;
}
+static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args )
+{
+ if ( listener != NULL )
+ listener( owner, this, ( mlt_frame )args[ 0 ] );
+}
+
/** Create a new consumer.
*/
// Aspect ratio and other jiggery pokery
mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) );
- mlt_properties_set_int( frame_properties, "consumer_progressive", mlt_properties_get_int( properties, "progressive" ) );
- mlt_properties_set_int( frame_properties, "consumer_deinterlace", mlt_properties_get_int( properties, "deinterlace" ) );
+ if ( mlt_properties_get_int( properties, "progressive" ) || mlt_properties_get_int( properties, "deinterlace" ) )
+ mlt_properties_set_int( frame_properties, "consumer_deinterlace", 1 );
}
// Return the frame
return frame;
}
+/** Callback for the implementation to indicate a stopped condition.
+*/
+
+void mlt_consumer_stopped( mlt_consumer this )
+{
+ mlt_properties_set_int( mlt_consumer_properties( this ), "running", 0 );
+ mlt_events_fire( mlt_consumer_properties( this ), "consumer-stopped", NULL );
+}
+
/** Stop the consumer.
*/
void mlt_consumer_close( mlt_consumer this )
{
- // Get the childs close function
- void ( *consumer_close )( ) = this->close;
+ if ( this != NULL && mlt_properties_dec_ref( mlt_consumer_properties( this ) ) <= 0 )
+ {
+ // Get the childs close function
+ void ( *consumer_close )( ) = this->close;
- // Make sure it only gets called once
- this->close = NULL;
+ // Make sure it only gets called once
+ this->close = NULL;
+ this->parent.close = NULL;
- // Call the childs close if available
- if ( consumer_close != NULL )
- consumer_close( this );
- else
- mlt_service_close( &this->parent );
+ // Call the childs close if available
+ if ( consumer_close != NULL )
+ consumer_close( this );
+ else
+ mlt_service_close( &this->parent );
+ }
}