]> git.sesse.net Git - mlt/commitdiff
Add mlt_properties_set_color().
authorDan Dennedy <dan@dennedy.org>
Thu, 30 May 2013 16:15:15 +0000 (09:15 -0700)
committerDan Dennedy <dan@dennedy.org>
Fri, 31 May 2013 23:58:13 +0000 (16:58 -0700)
src/framework/mlt_properties.c
src/framework/mlt_properties.h
src/mlt++/MltProperties.cpp
src/mlt++/MltProperties.h
src/mlt++/mlt++.vers
src/tests/test_properties/test_properties.cpp

index e66c5d6d1e10f44bd1380b0fdb6a77ee5f81726f..c649137616a5e8305de0d83a373a531550c2ca84 100644 (file)
@@ -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.
  *
index acd1dd4a618fb92c74513eb354d5716584ab9410..f4b1b2acfb446170be1301af553922be91b669ce 100644 (file)
@@ -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 );
index 657b92c0097eaac53548fbb420356baa324b82eb..9648e0329c7c2d30eaf09cbfeb2112f203885373 100644 (file)
@@ -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 );
index a2a68fa8bc22bec54967728c3b8becefceaacf9d..d2f8e8a3634d915c0168873c0341074b2807e815 100644 (file)
@@ -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 );
index a40ae82d5d22c53915b29083c0c3b0292b8a6fbc..ee03f4e31e0f5622b2785c2a075b309eff14e6e0 100644 (file)
@@ -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)";
     };
index a2f488c55f7b20d1a83557b4f872a5f7d1caf444..dee5e56d342aed1c6e66b8ec3041db11368b0e81 100644 (file)
@@ -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()