X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_field.c;h=2439fe97f39ebfef57468966b64c08221eeeaebd;hb=a450db7b8af164bcc71255fd74d406be98c9eb21;hp=a54d97e19e1cf4672672efc3702461d0b36d3833;hpb=e4c9ccbcef39cadaccbad655bc6e36e825bf3dde;p=melted diff --git a/src/framework/mlt_field.c b/src/framework/mlt_field.c index a54d97e..2439fe9 100644 --- a/src/framework/mlt_field.c +++ b/src/framework/mlt_field.c @@ -73,12 +73,37 @@ mlt_field mlt_field_init( ) 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 ); + } + + // Return this + return this; +} + /** Get the service associated to this field. */ mlt_service mlt_field_service( mlt_field this ) { - return mlt_tractor_service( this->tractor ); + return this != NULL ? mlt_tractor_service( this->tractor ) : NULL; } /** Get the multi track. @@ -86,7 +111,15 @@ 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. +*/ + +mlt_tractor mlt_field_tractor( mlt_field this ) +{ + return this != NULL ? this->tractor : NULL; } /** Get the properties associated to this field. @@ -113,6 +146,9 @@ int mlt_field_plant_filter( mlt_field this, mlt_filter that, int track ) // 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; @@ -134,6 +170,9 @@ int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track // 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; @@ -144,8 +183,11 @@ int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track void mlt_field_close( mlt_field this ) { - mlt_tractor_close( this->tractor ); - mlt_multitrack_close( this->multitrack ); - 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 ); + } }