Exemplo n.º 1
0
int mlt_tractor_connect( mlt_tractor self, mlt_service producer )
{
	int ret = mlt_service_connect_producer( MLT_TRACTOR_SERVICE( self ), producer, 0 );

	// This is the producer we're going to connect to
	if ( ret == 0 )
		self->producer = producer;

	return ret;
}
Exemplo n.º 2
0
int mlt_transition_connect( mlt_transition self, mlt_service producer, int a_track, int b_track )
{
	int ret = mlt_service_connect_producer( &self->parent, producer, a_track );
	if ( ret == 0 )
	{
		mlt_properties properties = MLT_TRANSITION_PROPERTIES( self );
		self->producer = producer;
		mlt_properties_set_int( properties, "a_track", a_track );
		mlt_properties_set_int( properties, "b_track", b_track );
	}
	return ret;
}
Exemplo n.º 3
0
int mlt_multitrack_connect( mlt_multitrack self, mlt_producer producer, int track )
{
	// Connect to the producer to ourselves at the specified track
	int result = mlt_service_connect_producer( MLT_MULTITRACK_SERVICE( self ), MLT_PRODUCER_SERVICE( producer ), track );

	if ( result == 0 )
	{
		mlt_track current_track = ( track < self->count )? self->list[ track ] : NULL;
		// Resize the producer list if need be
		if ( track >= self->size )
		{
			int i;
			self->list = realloc( self->list, ( track + 10 ) * sizeof( mlt_track ) );
			for ( i = self->size; i < track + 10; i ++ )
				self->list[ i ] = NULL;
			self->size = track + 10;
		}

		if ( current_track )
		{
			mlt_event_close( current_track->event );
			mlt_producer_close( current_track->producer );
		}
		else
		{
			self->list[ track ] = malloc( sizeof( struct mlt_track_s ) );
		}

		// Assign the track in our list here
		self->list[ track ]->producer = producer;
		self->list[ track ]->event = mlt_events_listen( MLT_PRODUCER_PROPERTIES( producer ), self,
									 "producer-changed", ( mlt_listener )mlt_multitrack_listener );
		mlt_properties_inc_ref( MLT_PRODUCER_PROPERTIES( producer ) );
		mlt_event_inc_ref( self->list[ track ]->event );

		// Increment the track count if need be
		if ( track >= self->count )
		{
			self->count = track + 1;

			// TODO: Move this into producer_avformat.c when mlt_events broadcasting is available.
			if ( self->count > mlt_service_cache_get_size( MLT_MULTITRACK_SERVICE( self ), "producer_avformat" ) )
				mlt_service_cache_set_size( MLT_MULTITRACK_SERVICE( self ), "producer_avformat", self->count + 1 );
		}

		// Refresh our stats
		mlt_multitrack_refresh( self );
	}

	return result;
}
Exemplo n.º 4
0
void mlt_field_disconnect_service( mlt_field self, mlt_service service )
{
	mlt_service p = mlt_service_producer( service );
	mlt_service c = mlt_service_consumer( service);
	int i;
	switch ( mlt_service_identify(c) )
	{
		case filter_type:
			i = mlt_filter_get_track( MLT_FILTER(c) );
			mlt_service_connect_producer( c, p, i );
			break;
		case transition_type:
			i = mlt_transition_get_a_track ( MLT_TRANSITION(c) );
			mlt_service_connect_producer( c, p, i );
			MLT_TRANSITION(c)->producer = p;
			break;
		case tractor_type:
			self->producer = p;
			mlt_tractor_connect( MLT_TRACTOR(c), p );
		default:
			break;
	}
	mlt_events_fire( mlt_field_properties( self ), "service-changed", NULL );
}
Exemplo n.º 5
0
int mlt_filter_connect( mlt_filter self, mlt_service producer, int index )
{
	int ret = mlt_service_connect_producer( &self->parent, producer, index );

	// If the connection was successful, grab the producer, track and reset in/out
	if ( ret == 0 )
	{
		mlt_properties properties = MLT_SERVICE_PROPERTIES( &self->parent );
		mlt_properties_set_position( properties, "in", 0 );
		mlt_properties_set_position( properties, "out", 0 );
		mlt_properties_set_int( properties, "track", index );
	}

	return ret;
}
Exemplo n.º 6
0
int mlt_consumer_connect( mlt_consumer self, mlt_service producer )
{
	return mlt_service_connect_producer( &self->parent, producer, 0 );
}
Exemplo n.º 7
0
int mlt_service_insert_producer( mlt_service self, mlt_service producer, int index )
{
	// Get the service base
	mlt_service_base *base = self->local;

	if ( index >= base->count )
		return mlt_service_connect_producer( self, producer, index );

	int i = 0;

	// Special case 'track' index - only works for last filter(s) in a particular chain
	// but allows a filter to apply to the output frame regardless of which track it comes from
	if ( index == -1 )
		index = 0;

	// Check if the producer is already registered with this service.
	for ( i = 0; i < base->count; i ++ )
		if ( base->in[ i ] == producer )
			return 3;

	// Allocate space if needed.
	if ( base->count + 1 > base->size )
	{
		int new_size = base->size + 10;
		base->in = realloc( base->in, new_size * sizeof( mlt_service ) );
		if ( base->in != NULL )
		{
			memset( &base->in[ base->size ], 0, new_size - base->size );
			base->size = new_size;
		}
	}

	// If we have space, assign the input
	if ( base->in && index >= 0 && index < base->size )
	{
		// Increment the reference count on this producer.
		if ( producer != NULL )
			mlt_properties_inc_ref( MLT_SERVICE_PROPERTIES( producer ) );

		// Disconnect the producer from its consumer.
		mlt_service_disconnect( producer );

		// Make room in the list for the producer.
		memmove( &base->in[ index + 1 ], &base->in[ index ],
				( base->count - index ) * sizeof( mlt_service ) );

		// Add the service to index specified.
		base->in[ index ] = producer;

		// Increase the number of active tracks.
		base->count ++;

		// Connect the producer to its connected consumer.
		mlt_service_connect( producer, self );

		// Inform caller that all went well
		return 0;
	}
	else
	{
		return -1;
	}
}