this->child = child;
if ( mlt_service_init( service, this ) == 0 )
{
+ mlt_properties properties = mlt_service_properties( service );
+
+ // Override the get_frame method
service->get_frame = filter_get_frame;
+
+ // Default in, out, track properties
+ mlt_properties_set_timecode( properties, "in", 0 );
+ mlt_properties_set_timecode( properties, "out", 0 );
+ mlt_properties_set_int( properties, "track", 0 );
+
return 0;
}
return 1;
return &this->parent;
}
+mlt_properties mlt_filter_properties( mlt_filter this )
+{
+ return mlt_service_properties( mlt_filter_service( this ) );
+}
+
/** Connect this filter to a producers track. Note that a filter only operates
on a single track, and by default it operates on the entirety of that track.
*/
// If the connection was successful, grab the producer, track and reset in/out
if ( ret == 0 )
{
+ mlt_properties properties = mlt_service_properties( &this->parent );
this->producer = producer;
- this->track = index;
- this->in = 0;
- this->out = 0;
+ mlt_properties_set_timecode( properties, "in", 0 );
+ mlt_properties_set_timecode( properties, "out", 0 );
+ mlt_properties_set_int( properties, "track", index );
}
return ret;
void mlt_filter_set_in_and_out( mlt_filter this, mlt_timecode in, mlt_timecode out )
{
- this->in = in;
- this->out = out;
+ mlt_properties properties = mlt_service_properties( &this->parent );
+ mlt_properties_set_timecode( properties, "in", in );
+ mlt_properties_set_timecode( properties, "out", out );
}
/** Return the track that this filter is operating on.
int mlt_filter_get_track( mlt_filter this )
{
- return this->track;
+ mlt_properties properties = mlt_service_properties( &this->parent );
+ return mlt_properties_get_int( properties, "track" );
}
/** Get the in point.
mlt_timecode mlt_filter_get_in( mlt_filter this )
{
- return this->in;
+ mlt_properties properties = mlt_service_properties( &this->parent );
+ return mlt_properties_get_timecode( properties, "in" );
}
/** Get the out point.
mlt_timecode mlt_filter_get_out( mlt_filter this )
{
- return this->out;
+ mlt_properties properties = mlt_service_properties( &this->parent );
+ return mlt_properties_get_timecode( properties, "out" );
}
/** Process the frame.
static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index )
{
mlt_filter this = service->child;
+
+ // Get coords in/out/track
+ int track = mlt_filter_get_track( this );
+ int in = mlt_filter_get_in( this );
+ int out = mlt_filter_get_out( this );
// If the frame request is for this filters track, we need to process it
- if ( index == this->track )
+ if ( index == track )
{
int ret = mlt_service_get_frame( this->producer, frame, index );
if ( ret == 0 )
if ( !mlt_frame_is_test_card( *frame ) )
{
mlt_timecode timecode = mlt_frame_get_timecode( *frame );
- if ( timecode >= this->in && ( this->out == 0 || timecode < this->out ) )
+ if ( timecode >= in && ( out == 0 || timecode < out ) )
*frame = filter_process( this, *frame );
}
return 0;