From: Dan Dennedy Date: Thu, 30 May 2013 16:15:15 +0000 (-0700) Subject: Add mlt_properties_set_color(). X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=391df9ad99111e28f0542206a0e44cf3c512d828;p=mlt Add mlt_properties_set_color(). --- diff --git a/src/framework/mlt_properties.c b/src/framework/mlt_properties.c index e66c5d6d..c6491376 100644 --- a/src/framework/mlt_properties.c +++ b/src/framework/mlt_properties.c @@ -2114,6 +2114,36 @@ mlt_color mlt_properties_get_color( mlt_properties self, const char* name ) return result; } +/** Set a property to an integer value by color. + * + * \public \memberof mlt_properties_s + * \param self a properties list + * \param name the property to set + * \param value the color + * \return true if error + */ + +int mlt_properties_set_color( mlt_properties self, const char *name, mlt_color color ) +{ + int error = 1; + + if ( !self || !name ) return error; + + // Fetch the property to work with + mlt_property property = mlt_properties_fetch( self, name ); + + // Set it if not NULL + if ( property != NULL ) + { + uint32_t value = ( color.r << 24 ) | ( color.g << 16 ) | ( color.b << 8 ) | color.a; + error = mlt_property_set_int( property, value ); + mlt_properties_do_mirror( self, name ); + } + + mlt_events_fire( self, "property-changed", name, NULL ); + + return error; +} /** Get a string value by name. * diff --git a/src/framework/mlt_properties.h b/src/framework/mlt_properties.h index acd1dd4a..f4b1b2ac 100644 --- a/src/framework/mlt_properties.h +++ b/src/framework/mlt_properties.h @@ -90,6 +90,7 @@ extern void mlt_properties_lock( mlt_properties self ); extern void mlt_properties_unlock( mlt_properties self ); extern char *mlt_properties_get_time( mlt_properties, const char* name, mlt_time_format ); extern mlt_color mlt_properties_get_color( mlt_properties, const char* name ); +extern int mlt_properties_set_color( mlt_properties, const char* name, mlt_color value ); extern char* mlt_properties_anim_get( mlt_properties self, const char *name, int position, int length ); extern int mlt_properties_anim_set( mlt_properties self, const char *name, const char *value, int position, int length ); diff --git a/src/mlt++/MltProperties.cpp b/src/mlt++/MltProperties.cpp index 657b92c0..9648e032 100644 --- a/src/mlt++/MltProperties.cpp +++ b/src/mlt++/MltProperties.cpp @@ -342,6 +342,11 @@ mlt_color Properties::get_color( const char *name ) return mlt_properties_get_color( get_properties(), name ); } +int Properties::set( const char *name, mlt_color value ) +{ + return mlt_properties_set_color( get_properties(), name, value ); +} + char *Properties::anim_get( const char *name, int position, int length ) { return mlt_properties_anim_get( get_properties(), name, position, length ); diff --git a/src/mlt++/MltProperties.h b/src/mlt++/MltProperties.h index a2a68fa8..d2f8e8a3 100644 --- a/src/mlt++/MltProperties.h +++ b/src/mlt++/MltProperties.h @@ -98,6 +98,7 @@ namespace Mlt const char *get_lcnumeric( ); char *get_time( const char *name, mlt_time_format = mlt_time_smpte ); mlt_color get_color( const char *name ); + int set( const char *name , mlt_color value ); char* anim_get( const char *name, int position, int length = 0 ); int anim_set( const char *name, const char *value, int position, int length = 0 ); diff --git a/src/mlt++/mlt++.vers b/src/mlt++/mlt++.vers index a40ae82d..ee03f4e3 100644 --- a/src/mlt++/mlt++.vers +++ b/src/mlt++/mlt++.vers @@ -440,18 +440,19 @@ MLTPP_0.9.0 { global: extern "C++" { "Mlt::Deque::peek(int)"; - "Mlt::Properties::get_color(char const*)"; "Mlt::Properties::anim_get(char const*, int, int)"; - "Mlt::Properties::anim_set(char const*, char const*, int, int)"; - "Mlt::Properties::anim_get_int(char const*, int, int)"; - "Mlt::Properties::anim_set(char const*, int, int, int, mlt_keyframe_type)"; "Mlt::Properties::anim_get_double(char const*, int, int)"; + "Mlt::Properties::anim_get_int(char const*, int, int)"; + "Mlt::Properties::anim_get_rect(char const*, int, int)"; + "Mlt::Properties::anim_set(char const*, char const*, int, int)"; "Mlt::Properties::anim_set(char const*, double, int, int, mlt_keyframe_type)"; - "Mlt::Properties::set(char const*, mlt_rect)"; - "Mlt::Properties::set(char const*, double, double, double, double, double)"; - "Mlt::Properties::get_rect(char const*)"; + "Mlt::Properties::anim_set(char const*, int, int, int, mlt_keyframe_type)"; "Mlt::Properties::anim_set(char const*, mlt_rect, int, int, mlt_keyframe_type)"; - "Mlt::Properties::anim_get_rect(char const*, int, int)"; + "Mlt::Properties::get_color(char const*)"; + "Mlt::Properties::get_rect(char const*)"; + "Mlt::Properties::set(char const*, double, double, double, double, double)"; + "Mlt::Properties::set(char const*, mlt_color); + "Mlt::Properties::set(char const*, mlt_rect)"; "Mlt::Service::filter_count()"; "Mlt::Service::move_filter(int, int)"; }; diff --git a/src/tests/test_properties/test_properties.cpp b/src/tests/test_properties/test_properties.cpp index a2f488c5..dee5e56d 100644 --- a/src/tests/test_properties/test_properties.cpp +++ b/src/tests/test_properties/test_properties.cpp @@ -846,8 +846,8 @@ private Q_SLOTS: QCOMPARE(color.g, quint8(0xbb)); QCOMPARE(color.b, quint8(0xcc)); QCOMPARE(color.a, quint8(0xdd)); - p.set("key", *((int*) &color)); - QCOMPARE(p.get_int("key"), int(0xddccbbaa)); + p.set("key", color); + QCOMPARE(p.get_int("key"), int(0xaabbccdd)); } void ColorFromString()