X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fframework%2Fmlt_service.c;h=f15ec46af90ff7d087d0ceb775b8d589dd2c7b09;hb=944559b0832cfc93a52e2b9483042bfefd36c985;hp=bfcc91349870699a4cc030ac88e25862f60c8c44;hpb=2d328408132825439fc69462865e78659170efdc;p=mlt diff --git a/src/framework/mlt_service.c b/src/framework/mlt_service.c index bfcc9134..f15ec46a 100644 --- a/src/framework/mlt_service.c +++ b/src/framework/mlt_service.c @@ -87,7 +87,7 @@ int mlt_service_init( mlt_service self, void *child ) self->child = child; // Generate local space - self->local = calloc( sizeof( mlt_service_base ), 1 ); + self->local = calloc( 1, sizeof( mlt_service_base ) ); // Associate the methods self->get_frame = service_get_frame; @@ -618,7 +618,66 @@ int mlt_service_detach( mlt_service self, mlt_filter filter ) return error; } -/** Retrieve a filter. +/** Get the number of filters attached. + * + * \public \memberof mlt_service_s + * \param self a service + * \return the number of attached filters or -1 if there was an error + */ + +int mlt_service_filter_count( mlt_service self ) +{ + int result = -1; + if ( self ) + { + mlt_service_base *base = self->local; + result = base->filter_count; + } + return result; +} + +/** Reorder the attached filters. + * + * \public \memberof mlt_service_s + * \param self a service + * \param from the current index value of the filter to move + * \param to the new index value for the filter specified in \p from + * \return true if there was an error + */ + +int mlt_service_move_filter( mlt_service self, int from, int to ) +{ + int error = -1; + if ( self ) + { + mlt_service_base *base = self->local; + if ( from < 0 ) from = 0; + if ( from >= base->filter_count ) from = base->filter_count - 1; + if ( to < 0 ) to = 0; + if ( to >= base->filter_count ) to = base->filter_count - 1; + if ( from != to && base->filter_count > 1 ) + { + mlt_filter filter = base->filters[from]; + int i; + if ( from > to ) + { + for ( i = from; i > to; i-- ) + base->filters[i] = base->filters[i - 1]; + } + else + { + for ( i = from; i < to; i++ ) + base->filters[i] = base->filters[i + 1]; + } + base->filters[to] = filter; + mlt_events_fire( MLT_SERVICE_PROPERTIES(self), "service-changed", NULL ); + error = 0; + } + } + return error; +} + +/** Retrieve an attached filter. * * \public \memberof mlt_service_s * \param self a service @@ -650,6 +709,18 @@ mlt_profile mlt_service_profile( mlt_service self ) return self? mlt_properties_get_data( MLT_SERVICE_PROPERTIES( self ), "_profile", NULL ) : NULL; } +/** Set the profile for a service. + * + * \public \memberof mlt_service_s + * \param self a service + * \param profile the profile to set onto the service + */ + +void mlt_service_set_profile( mlt_service self, mlt_profile profile ) +{ + mlt_properties_set_data( MLT_SERVICE_PROPERTIES( self ), "_profile", profile, 0, NULL, NULL ); +} + /** Destroy a service. * * \public \memberof mlt_service_s