]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_service.c
Stash the backtrace code somewhere.
[mlt] / src / framework / mlt_service.c
index bfcc91349870699a4cc030ac88e25862f60c8c44..9b1eb7037d9b861510270666e0637131fe028834 100644 (file)
@@ -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;
@@ -131,6 +131,8 @@ static void mlt_service_property_changed( mlt_listener listener, mlt_properties
  * \param self the service to lock
  */
 
+#include <execinfo.h>
+
 void mlt_service_lock( mlt_service self )
 {
        if ( self != NULL )
@@ -544,6 +546,19 @@ static void mlt_service_filter_property_changed( mlt_service owner, mlt_service
 
 int mlt_service_attach( mlt_service self, mlt_filter filter )
 {
+#if 0
+       void *buffer[1024];
+       int num, i;
+       char **sym;
+       printf("ATTACHING %p -> %p\n", self, filter);
+       for (i = 0; i < 1024; ++i) buffer[i] = 0;
+       num = backtrace(buffer, 1024);
+       sym = backtrace_symbols(buffer, num);
+       for (i = 0; i < num; ++i) {
+               //printf("%3d: %s\n", sym[i]);
+       }
+       free(sym);
+#endif
        int error = self == NULL || filter == NULL;
        if ( error == 0 )
        {
@@ -571,6 +586,9 @@ int mlt_service_attach( mlt_service self, mlt_filter filter )
                                mlt_properties_set_data( props, "service", self, 0, NULL, NULL );
                                mlt_events_fire( properties, "service-changed", NULL );
                                mlt_events_fire( props, "service-changed", NULL );
+                               mlt_service cp = mlt_properties_get_data( properties, "_cut_parent", NULL );
+                               if ( cp )
+                                       mlt_events_fire( MLT_SERVICE_PROPERTIES(cp), "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_property_changed );
                        }
@@ -618,7 +636,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 +727,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