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;
/** Disconnect a service from its consumer.
*
- * \public \memberof mlt_service_s
+ * \private \memberof mlt_service_s
* \param self a service
*/
mlt_events_fire( MLT_SERVICE_PROPERTIES( self ), "service-changed", NULL );
}
+/** The property-changed event handler.
+ *
+ * \private \memberof mlt_service_s
+ * \param owner ignored
+ * \param self the service on which the "property-changed" event is fired
+ * \param name the name of the property that changed
+ */
+
+static void mlt_service_filter_property_changed( mlt_service owner, mlt_service self, char *name )
+{
+ mlt_events_fire( MLT_SERVICE_PROPERTIES( self ), "property-changed", name, NULL );
+}
+
/** Attach a filter.
*
* \public \memberof mlt_service_s
mlt_events_fire( properties, "service-changed", NULL );
mlt_events_fire( props, "service-changed", NULL );
mlt_events_listen( props, self, "service-changed", ( mlt_listener )mlt_service_filter_changed );
- mlt_events_listen( props, self, "property-changed", ( mlt_listener )mlt_service_filter_changed );
+ mlt_events_listen( props, self, "property-changed", ( mlt_listener )mlt_service_filter_property_changed );
}
else
{
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
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