]> git.sesse.net Git - mlt/commitdiff
Add mlt_frame_unique_properties().
authorDan Dennedy <dan@dennedy.org>
Thu, 3 Mar 2011 07:19:43 +0000 (23:19 -0800)
committerDan Dennedy <dan@dennedy.org>
Thu, 3 Mar 2011 07:19:43 +0000 (23:19 -0800)
src/framework/mlt_frame.c
src/framework/mlt_frame.h

index fd28fac9a5750c2411188b9285b91897526fcdc3..8eac33cbb6a66e8da3ae760f625facc3a4cb825a 100644 (file)
@@ -855,3 +855,35 @@ void mlt_frame_write_ppm( mlt_frame frame )
                fclose( file );
        }
 }
+
+/** Get or create a properties object unique to this service instance.
+ *
+ * Use this function to hold a service's processing parameters for this
+ * particular frame. Set the parameters in the service's process function.
+ * Then, get the parameters in the function it pushes to the frame's audio
+ * or image stack. This makes the service more parallel by reducing race
+ * conditions and less sensitive to multiple instances (by not setting a
+ * non-unique property on the frame). Creation and destruction of the
+ * properties object is handled automatically.
+ *
+ * \public \memberof mlt_frame_s
+ * \param self a frame
+ * \param service a service
+ * \return a properties object
+ */
+
+mlt_properties mlt_frame_unique_properties( mlt_frame self, mlt_service service )
+{
+       mlt_properties frame_props = MLT_FRAME_PROPERTIES( self );
+       mlt_properties service_props = MLT_SERVICE_PROPERTIES( service );
+       char *unique = mlt_properties_get( service_props, "_unique_id" );
+       mlt_properties instance_props = mlt_properties_get_data( frame_props, unique, NULL );
+       
+       if ( !instance_props )
+       {
+               instance_props = mlt_properties_new();
+               mlt_properties_set_data( frame_props, unique, instance_props, 0, (mlt_destructor) mlt_properties_close, NULL );
+       }
+
+       return instance_props;
+}
index 1495c1d7be2d944dafb39155c5e44d912a414026..c87432789f3a9b8a3c5975cda3d3edb324b0ee47 100644 (file)
@@ -127,6 +127,7 @@ extern void *mlt_frame_pop_audio( mlt_frame self );
 extern mlt_deque mlt_frame_service_stack( mlt_frame self );
 extern mlt_producer mlt_frame_get_original_producer( mlt_frame self );
 extern void mlt_frame_close( mlt_frame self );
+extern mlt_properties mlt_frame_unique_properties( mlt_frame self, mlt_service service );
 
 /* convenience functions */
 extern int mlt_sample_calculator( float fps, int frequency, int64_t position );