mlt_frame mlt_frame_init( mlt_service service ) { // Allocate a frame mlt_frame this = calloc( sizeof( struct mlt_frame_s ), 1 ); if ( this != NULL ) { mlt_profile profile = mlt_service_profile( service ); // Initialise the properties mlt_properties properties = &this->parent; mlt_properties_init( properties, this ); // Set default properties on the frame mlt_properties_set_position( properties, "_position", 0.0 ); mlt_properties_set_data( properties, "image", NULL, 0, NULL, NULL ); mlt_properties_set_int( properties, "width", profile? profile->width : 720 ); mlt_properties_set_int( properties, "height", profile? profile->height : 576 ); mlt_properties_set_int( properties, "normalised_width", profile? profile->width : 720 ); mlt_properties_set_int( properties, "normalised_height", profile? profile->height : 576 ); mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( NULL ) ); mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL ); mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL ); // Construct stacks for frames and methods this->stack_image = mlt_deque_init( ); this->stack_audio = mlt_deque_init( ); this->stack_service = mlt_deque_init( ); } return this; }
int mlt_service_init( mlt_service self, void *child ) { int error = 0; // Initialise everything to NULL memset( self, 0, sizeof( struct mlt_service_s ) ); // Assign the child self->child = child; // Generate local space self->local = calloc( 1, sizeof( mlt_service_base ) ); // Associate the methods self->get_frame = service_get_frame; // Initialise the properties error = mlt_properties_init( &self->parent, self ); if ( error == 0 ) { self->parent.close = ( mlt_destructor )mlt_service_close; self->parent.close_object = self; mlt_events_init( &self->parent ); mlt_events_register( &self->parent, "service-changed", NULL ); mlt_events_register( &self->parent, "property-changed", ( mlt_transmitter )mlt_service_property_changed ); pthread_mutex_init( &( ( mlt_service_base * )self->local )->mutex, NULL ); } return error; }
mlt_repository mlt_repository_init( const char *directory ) { // Safety check if ( directory == NULL || strcmp( directory, "" ) == 0 ) return NULL; // Construct the repository mlt_repository self = calloc( 1, sizeof( struct mlt_repository_s )); mlt_properties_init( &self->parent, self ); self->consumers = mlt_properties_new(); self->filters = mlt_properties_new(); self->producers = mlt_properties_new(); self->transitions = mlt_properties_new(); // Get the directory list mlt_properties dir = mlt_properties_new(); int count = mlt_properties_dir_list( dir, directory, NULL, 0 ); int i; // Iterate over files for ( i = 0; i < count; i++ ) { int flags = RTLD_NOW; const char *object_name = mlt_properties_get_value( dir, i); // Very temporary hack to allow the quicktime plugins to work // TODO: extend repository to allow this to be used on a case by case basis if ( strstr( object_name, "libmltkino" ) ) flags |= RTLD_GLOBAL; // Open the shared object void *object = dlopen( object_name, flags ); if ( object != NULL ) { // Get the registration function mlt_repository_callback symbol_ptr = dlsym( object, "mlt_register" ); // Call the registration function if ( symbol_ptr != NULL ) { symbol_ptr( self ); // Register the object file for closure mlt_properties_set_data( &self->parent, object_name, object, 0, ( mlt_destructor )dlclose, NULL ); } else { dlclose( object ); } } else if ( strstr( object_name, "libmlt" ) ) { mlt_log( NULL, MLT_LOG_WARNING, "%s: failed to dlopen %s\n (%s)\n", __FUNCTION__, object_name, dlerror() ); } } mlt_properties_close( dir ); return self; }
mlt_parser mlt_parser_new( ) { mlt_parser self = calloc( 1, sizeof( struct mlt_parser_s ) ); if ( self != NULL && mlt_properties_init( &self->parent, self ) == 0 ) { self->on_invalid = on_invalid; self->on_unknown = on_unknown; self->on_start_producer = on_start_producer; self->on_end_producer = on_end_producer; self->on_start_playlist = on_start_playlist; self->on_end_playlist = on_end_playlist; self->on_start_tractor = on_start_tractor; self->on_end_tractor = on_end_tractor; self->on_start_multitrack = on_start_multitrack; self->on_end_multitrack = on_end_multitrack; self->on_start_track = on_start_track; self->on_end_track = on_end_track; self->on_start_filter = on_start_filter; self->on_end_filter = on_end_filter; self->on_start_transition = on_start_transition; self->on_end_transition = on_end_transition; } return self; }