05.09.14 19:28, Dan Dennedy написав(ла):
On Fri, Sep 5, 2014 at 3:51 AM, Maksym Veremeyenko<ve...@m1stereo.tv>  wrote:
Hi,

this patch provides ability to pass properties to encapsulated producer and
consumer.

Thank you for the contribution, Maksym. We have a convention to use a
prefix on the property name to make it pass to encapsulated services.
See for example, watermark and affine filters. In this case, you would
use simply mlt_properties_pass() with "prefix." or "consumer.". How do
you feel to change your patch to work like that? Or, is there are
reason you prefer it as you have submitted?


i reworked a patch to use prefixes "producer." and "consumer.".
please review


--
________________________________________
Maksym Veremeyenko

>From 33cd2bbf7cb0ef5ecedca97e3619272b91575282 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1.tv>
Date: Mon, 8 Sep 2014 12:28:02 +0300
Subject: [PATCH] pass prefixed properties to encapsulated producer and
 consumer

---
 src/modules/core/producer_consumer.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/src/modules/core/producer_consumer.c b/src/modules/core/producer_consumer.c
index dc436cc..e09865f 100644
--- a/src/modules/core/producer_consumer.c
+++ b/src/modules/core/producer_consumer.c
@@ -20,6 +20,9 @@
 
 #include <framework/mlt.h>
 
+#define CONSUMER_PROPERTIES_PREFIX "consumer."
+#define PRODUCER_PROPERTIES_PREFIX "producer."
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -101,6 +104,23 @@ static int get_audio( mlt_frame frame, void **buffer, mlt_audio_format *format,
 	return result;
 }
 
+static void property_changed( mlt_properties owner, mlt_consumer self, char *name )
+{
+	mlt_properties properties = MLT_PRODUCER_PROPERTIES(self);
+	context cx = mlt_properties_get_data( properties, "context", NULL );
+
+	if ( !cx )
+		return;
+
+	if ( name == strstr( name, CONSUMER_PROPERTIES_PREFIX ) )
+		mlt_properties_set(MLT_CONSUMER_PROPERTIES( cx->consumer ), name + strlen( CONSUMER_PROPERTIES_PREFIX ),
+			mlt_properties_get( properties, name ));
+
+	if ( name == strstr( name, PRODUCER_PROPERTIES_PREFIX ) )
+		mlt_properties_set(MLT_PRODUCER_PROPERTIES( cx->producer ), name + strlen( PRODUCER_PROPERTIES_PREFIX ),
+			mlt_properties_get( properties, name ));
+}
+
 static int get_frame( mlt_producer self, mlt_frame_ptr frame, int index )
 {
 	mlt_properties properties = MLT_PRODUCER_PROPERTIES(self);
@@ -152,7 +172,11 @@ static int get_frame( mlt_producer self, mlt_frame_ptr frame, int index )
 			mlt_properties_get_int( properties, "real_time" ) );
 		mlt_properties_pass_list( MLT_CONSUMER_PROPERTIES( cx->consumer ), properties,
 			"buffer, prefill, deinterlace_method, rescale" );
-	
+
+		mlt_properties_pass( MLT_CONSUMER_PROPERTIES( cx->consumer ), properties, CONSUMER_PROPERTIES_PREFIX );
+		mlt_properties_pass( MLT_PRODUCER_PROPERTIES( cx->producer ), properties, PRODUCER_PROPERTIES_PREFIX );
+		mlt_events_listen( properties, self, "property-changed", ( mlt_listener )property_changed );
+
 		// Connect it all together
 		mlt_consumer_connect( cx->consumer, MLT_PRODUCER_SERVICE( cx->producer ) );
 		mlt_consumer_start( cx->consumer );
-- 
1.7.7.6

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to