// Determine the value
if ( isdigit( id[ 0 ] ) )
- current = atof( id );
+ {
+#if defined(__GLIBC__) || defined(__DARWIN__)
+ property_list *list = self->local;
+ if ( list->locale )
+ current = strtod_l( id, NULL, list->locale );
+#endif
+ else
+ current = strtod( id, NULL );
+ }
else
+ {
current = mlt_properties_get_double( self, id );
+ }
// Apply the operation
switch( op )
return NULL;
}
+/** Get a string value by name.
+ *
+ * Do not free the returned string. It's lifetime is controlled by the property
+ * and this properties object.
+ * \public \memberof mlt_properties_s
+ * \param self a properties list
+ * \param name the property to get
+ * \return the property's string value or NULL if it does not exist
+ */
+
+char* mlt_properties_anim_get( mlt_properties self, const char *name, int position, int length )
+{
+ mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
+ double fps = mlt_profile_fps( profile );
+ mlt_property value = mlt_properties_find( self, name );
+ property_list *list = self->local;
+ return value == NULL ? NULL : mlt_property_anim_get_string( value, fps, list->locale, position, length );
+}
+
+/** Set a property to a string.
+ *
+ * The event "property-changed" is fired after the property has been set.
+ *
+ * This makes a copy of the string value you supply.
+ * \public \memberof mlt_properties_s
+ * \param self a properties list
+ * \param name the property to set
+ * \param value the property's new value
+ * \return true if error
+ */
+
+int mlt_properties_anim_set( mlt_properties self, const char *name, const char *value, int position, int length )
+{
+ 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 )
+ {
+ mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
+ double fps = mlt_profile_fps( profile );
+ property_list *list = self->local;
+ error = mlt_property_anim_set_string( property, value,
+ fps, list->locale, position, length );
+ mlt_properties_do_mirror( self, name );
+ }
+
+ mlt_events_fire( self, "property-changed", name, NULL );
+
+ return error;
+}
+
/** Get an integer associated to the name at a frame position.
*
* \public \memberof mlt_properties_s
extern void mlt_properties_unlock( mlt_properties self );
extern char *mlt_properties_get_time( mlt_properties, const char* name, mlt_time_format );
+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 );
extern int mlt_properties_anim_get_int( mlt_properties self, const char *name, int position, int length );
extern int mlt_properties_anim_set_int( mlt_properties self, const char *name, int value, mlt_keyframe_type keyframe_type, int position, int length );
extern double mlt_properties_anim_get_double( mlt_properties self, const char *name, int position, int length );
return result;
}
+char* mlt_property_anim_get_string( mlt_property self, double fps, locale_t locale, int position, int length )
+{
+ char *result;
+ if ( self->animation || ( ( self->types & mlt_prop_string ) && self->prop_string ) )
+ {
+ struct mlt_animation_item_s item;
+ item.property = mlt_property_init();
+
+ if ( !self->animation )
+ refresh_animation( self, fps, locale, length );
+ mlt_animation_get_item( self->animation, &item, position );
+
+ pthread_mutex_lock( &self->mutex );
+ if ( self->prop_string )
+ free( self->prop_string );
+ self->prop_string = mlt_property_get_string_l( item.property, locale );
+ if ( self->prop_string )
+ self->prop_string = strdup( self->prop_string );
+ self->types |= mlt_prop_string;
+ pthread_mutex_unlock( &self->mutex );
+
+ result = self->prop_string;
+ mlt_property_close( item.property );
+ }
+ else
+ {
+ result = mlt_property_get_string_l( self, locale );
+ }
+ return result;
+}
+
/** Set a property animation keyframe to a real number.
*
* \public \memberof mlt_property_s
return result;
}
+int mlt_property_anim_set_string( mlt_property self, const char *value, double fps, locale_t locale, int position, int length )
+{
+ int result;
+ struct mlt_animation_item_s item;
+
+ item.property = mlt_property_init();
+ item.frame = position;
+ item.keyframe_type = mlt_keyframe_discrete;
+ mlt_property_set_string( item.property, value );
+
+ refresh_animation( self, fps, locale, length );
+ result = mlt_animation_insert( self->animation, &item );
+ mlt_animation_interpolate( self->animation );
+ mlt_property_close( item.property );
+
+ return result;
+}
+
static char* serialise_mlt_rect( mlt_rect *rect, int length )
{
char* result = calloc( 1, 100 );
double progress, double fps, locale_t locale, mlt_keyframe_type interp );
extern double mlt_property_anim_get_double( mlt_property self, double fps, locale_t locale, int position, int length );
extern int mlt_property_anim_get_int( mlt_property self, double fps, locale_t locale, int position, int length );
+extern char* mlt_property_anim_get_string( mlt_property self, double fps, locale_t locale, int position, int length );
extern int mlt_property_anim_set_double( mlt_property self, double value, double fps, locale_t locale,
- mlt_keyframe_type keyframe_type, int position, int length );
+ mlt_keyframe_type keyframe_type, int position, int length );
extern int mlt_property_anim_set_int( mlt_property self, int value, double fps, locale_t locale,
- mlt_keyframe_type keyframe_type, int position, int length );
+ mlt_keyframe_type keyframe_type, int position, int length );
+extern int mlt_property_anim_set_string( mlt_property self, const char *value, double fps, locale_t locale,
+ int position, int length );
extern int mlt_property_set_rect( mlt_property self, mlt_rect value );
extern mlt_rect mlt_property_get_rect( mlt_property self, locale_t locale );
extern int mlt_property_anim_set_rect( mlt_property self, mlt_rect value, double fps, locale_t locale,
return mlt_properties_get_time( get_properties(), name, format );
}
+char *Properties::anim_get( const char *name, int position, int length )
+{
+ return mlt_properties_anim_get( get_properties(), name, position, length );
+}
+
+int Properties::anim_set( const char *name, const char *value, int position, int length )
+{
+ return mlt_properties_anim_set( get_properties(), name, value, position, length );
+}
+
int Properties::anim_get_int( const char *name, int position, int length )
{
return mlt_properties_anim_get_int( get_properties(), name, position, length );
const char *get_lcnumeric( );
char *get_time( const char *name, mlt_time_format = mlt_time_smpte );
+ char* anim_get( const char *name, int position, int length );
+ int anim_set( const char *name, const char *value, int position, int length );
int anim_get_int( const char *name, int position, int length );
int anim_set( const char *name, int value, int position, int length,
mlt_keyframe_type keyframe_type = mlt_keyframe_linear );
QCOMPARE(p.anim_get_double("foo", 50, len), 200.0);
}
+ void PropertiesStringAnimation()
+ {
+ Properties p;
+ int len = 50;
+ p.anim_set("key", "foo", 10, len);
+ p.anim_set("key", "bar", 30, len);
+ QCOMPARE(p.get("key"), "10|=foo;30|=bar");
+ p.set("key", "0=; 10=foo bar; 30=hello world");
+ QCOMPARE(p.anim_get("key", 1, len), "");
+ QCOMPARE(p.anim_get("key", 15, len), "foo bar");
+ QCOMPARE(p.anim_get("key", 45, len), "hello world");
+ }
+
void test_mlt_rect()
{
mlt_property p = mlt_property_init();