X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_field.c;h=1a93cd9595669cbc7eef31c6d048549474c5b722;hb=c95736fd9ee742f5e6db06bbe579f23895f55eba;hp=eede159b871292add65de218fd80a819633d19b6;hpb=ec7f7d58e000242e918c2ae2cebd172bffe6e9d4;p=melted diff --git a/src/framework/mlt_field.c b/src/framework/mlt_field.c index eede159..1a93cd9 100644 --- a/src/framework/mlt_field.c +++ b/src/framework/mlt_field.c @@ -63,7 +63,32 @@ mlt_field mlt_field_init( ) this->tractor = mlt_tractor_init( ); // The first plant will be connected to the mulitrack - this->producer = mlt_multitrack_service( this->multitrack ); + this->producer = MLT_MULTITRACK_SERVICE( this->multitrack ); + + // Connect the tractor to the multitrack + mlt_tractor_connect( this->tractor, this->producer ); + } + + // Return this + return this; +} + +mlt_field mlt_field_new( mlt_multitrack multitrack, mlt_tractor tractor ) +{ + // Initialise the field + mlt_field this = calloc( sizeof( struct mlt_field_s ), 1 ); + + // Initialise it + if ( this != NULL ) + { + // Construct a multitrack + this->multitrack = multitrack; + + // Construct a tractor + this->tractor = tractor; + + // The first plant will be connected to the mulitrack + this->producer = MLT_MULTITRACK_SERVICE( this->multitrack ); // Connect the tractor to the multitrack mlt_tractor_connect( this->tractor, this->producer ); @@ -78,7 +103,7 @@ mlt_field mlt_field_init( ) mlt_service mlt_field_service( mlt_field this ) { - return mlt_tractor_service( this->tractor ); + return MLT_TRACTOR_SERVICE( this->tractor ); } /** Get the multi track. @@ -86,7 +111,7 @@ mlt_service mlt_field_service( mlt_field this ) mlt_multitrack mlt_field_multitrack( mlt_field this ) { - return this->multitrack; + return this != NULL ? this->multitrack : NULL; } /** Get the tractor. @@ -94,7 +119,7 @@ mlt_multitrack mlt_field_multitrack( mlt_field this ) mlt_tractor mlt_field_tractor( mlt_field this ) { - return this->tractor; + return this != NULL ? this->tractor : NULL; } /** Get the properties associated to this field. @@ -102,7 +127,7 @@ mlt_tractor mlt_field_tractor( mlt_field this ) mlt_properties mlt_field_properties( mlt_field this ) { - return mlt_service_properties( mlt_field_service( this ) ); + return MLT_SERVICE_PROPERTIES( mlt_field_service( this ) ); } /** Plant a filter. @@ -117,10 +142,13 @@ int mlt_field_plant_filter( mlt_field this, mlt_filter that, int track ) if ( result == 0 ) { // This is now the new producer - this->producer = mlt_filter_service( that ); + this->producer = MLT_FILTER_SERVICE( that ); // Reconnect tractor to new producer mlt_tractor_connect( this->tractor, this->producer ); + + // Fire an event + mlt_events_fire( mlt_field_properties( this ), "service-changed", NULL ); } return result; @@ -138,10 +166,13 @@ int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track if ( result == 0 ) { // This is now the new producer - this->producer = mlt_transition_service( that ); + this->producer = MLT_TRANSITION_SERVICE( that ); // Reconnect tractor to new producer mlt_tractor_connect( this->tractor, this->producer ); + + // Fire an event + mlt_events_fire( mlt_field_properties( this ), "service-changed", NULL ); } return 0; @@ -152,6 +183,11 @@ int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track void mlt_field_close( mlt_field this ) { - free( this ); + if ( this != NULL && mlt_properties_dec_ref( mlt_field_properties( this ) ) <= 0 ) + { + //mlt_tractor_close( this->tractor ); + //mlt_multitrack_close( this->multitrack ); + free( this ); + } }