#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.
*/
static int producer_get_frame( mlt_service this, mlt_frame_ptr frame, int index );
static void mlt_producer_property_changed( mlt_service owner, mlt_producer this, char *name );
+static void mlt_producer_service_changed( mlt_service owner, mlt_producer this );
/** Constructor
*/
// Override service get_frame
parent->get_frame = producer_get_frame;
+ mlt_events_listen( properties, this, "service-changed", ( mlt_listener )mlt_producer_service_changed );
mlt_events_listen( properties, this, "property-changed", ( mlt_listener )mlt_producer_property_changed );
mlt_events_register( properties, "producer-changed", NULL );
}
mlt_events_fire( mlt_producer_properties( this ), "producer-changed", NULL );
}
+/** Listener for service changes.
+*/
+
+static void mlt_producer_service_changed( mlt_service owner, mlt_producer this )
+{
+ mlt_events_fire( mlt_producer_properties( this ), "producer-changed", NULL );
+}
+
/** Create a new producer.
*/
this->parent.close_object = this;
mlt_events_init( &this->parent );
+ mlt_events_register( &this->parent, "service-changed", NULL );
mlt_events_register( &this->parent, "property-changed", ( mlt_transmitter )mlt_service_property_changed );
}
return 0;
}
+static void mlt_service_filter_changed( mlt_service owner, mlt_service this )
+{
+ mlt_events_fire( mlt_service_properties( this ), "service-changed", NULL );
+}
+
/** Attach a filter.
*/
if ( base->filters != NULL )
{
+ mlt_properties props = mlt_filter_properties( filter );
mlt_properties_inc_ref( mlt_filter_properties( filter ) );
base->filters[ base->filter_count ++ ] = filter;
mlt_events_fire( properties, "service-changed", NULL );
+ mlt_events_listen( props, this, "service-changed", ( mlt_listener )mlt_service_filter_changed );
+ mlt_events_listen( props, this, "property-changed", ( mlt_listener )mlt_service_filter_changed );
}
else
{
for ( i ++ ; i < base->filter_count; i ++ )
base->filters[ i - 1 ] = base->filters[ i ];
base->filter_count --;
+ mlt_events_disconnect( mlt_filter_properties( filter ), this );
mlt_filter_close( filter );
mlt_events_fire( properties, "service-changed", NULL );
}
mlt_service_base *base = this->local;
int i = 0;
int count = base->filter_count;
+ mlt_events_block( mlt_service_properties( this ), this );
while( count -- )
mlt_service_detach( this, base->filters[ 0 ] );
free( base->filters );
uint8_t *p;
uint8_t *q;
+ mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
mlt_frame_get_image( frame, &image, &img_fmt, &img_width, &img_height, 0 );
q = image;
if ( frame != NULL )
{
// Close the frame
+ mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
mlt_frame_close( frame );
}
}
uint8_t *image = NULL;
// Get the image
+ mlt_events_fire( this_properties, "consumer-frame-show", frame, NULL );
mlt_frame_get_image( frame, &image, &fmt, &width, &height, 0 );
// Check that we get what we expected
static void consumer_close( mlt_consumer parent );
static void *consumer_thread( void * );
static int consumer_get_dimensions( int *width, int *height );
+static void consumer_sdl_event( mlt_listener listener, mlt_properties owner, mlt_service this, void **args );
/** This is what will be called by the factory - anything can be passed in
via the argument, but keep it simple.
parent->stop = consumer_stop;
parent->is_stopped = consumer_is_stopped;
+ // Register specific events
+ mlt_events_register( this->properties, "consumer-sdl-event", ( mlt_transmitter )consumer_sdl_event );
+
// Return the consumer produced
return parent;
}
return NULL;
}
+static void consumer_sdl_event( mlt_listener listener, mlt_properties owner, mlt_service this, void **args )
+{
+ if ( listener != NULL )
+ listener( owner, this, ( SDL_Event * )args[ 0 ] );
+}
+
int consumer_start( mlt_consumer parent )
{
consumer_sdl this = parent->child;
if ( mlt_properties_get_int( properties, "video_off" ) == 0 )
{
// Get the image, width and height
+ mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
// Handle events
while ( SDL_PollEvent( &event ) )
{
+ mlt_events_fire( this->properties, "consumer-sdl-event", &event, NULL );
+
switch( event.type )
{
case SDL_VIDEORESIZE: