]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_properties.c
Propogate service-changed event to cut producer's parent.
[mlt] / src / framework / mlt_properties.c
index c873daf48e09e317311e9fcba792e1f63347dca1..c28af8fc514c2043f574b993b9945683cee39b84 100644 (file)
@@ -777,9 +777,14 @@ int mlt_properties_set_or_default( mlt_properties self, const char *name, const
 
 char *mlt_properties_get( mlt_properties self, const char *name )
 {
+       char *result = NULL;
        mlt_property value = mlt_properties_find( self, name );
-       property_list *list = self->local;
-       return value == NULL ? NULL : mlt_property_get_string_l( value, list->locale );
+       if ( value )
+       {
+               property_list *list = self->local;
+               result = mlt_property_get_string_l( value, list->locale );
+       }
+       return result;
 }
 
 /** Get a property name by index.
@@ -906,11 +911,16 @@ int mlt_properties_parse( mlt_properties self, const char *namevalue )
 
 int mlt_properties_get_int( mlt_properties self, const char *name )
 {
-       mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
-       double fps = mlt_profile_fps( profile );
-       property_list *list = self->local;
+       int result = 0;
        mlt_property value = mlt_properties_find( self, name );
-       return value == NULL ? 0 : mlt_property_get_int( value, fps, list->locale );
+       if ( value )
+       {
+               mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
+               double fps = mlt_profile_fps( profile );
+               property_list *list = self->local;
+               result = mlt_property_get_int( value, fps, list->locale );
+       }
+       return result;
 }
 
 /** Set a property to an integer value.
@@ -997,11 +1007,16 @@ int mlt_properties_set_int64( mlt_properties self, const char *name, int64_t val
 
 double mlt_properties_get_double( mlt_properties self, const char *name )
 {
-       mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
-       double fps = mlt_profile_fps( profile );
+       double result = 0;
        mlt_property value = mlt_properties_find( self, name );
-       property_list *list = self->local;
-       return value == NULL ? 0 : mlt_property_get_double( value, fps, list->locale );
+       if ( value )
+       {
+               mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
+               double fps = mlt_profile_fps( profile );
+               property_list *list = self->local;
+               result = mlt_property_get_double( value, fps, list->locale );
+       }
+       return result;
 }
 
 /** Set a property to a floating point value.
@@ -1044,11 +1059,16 @@ int mlt_properties_set_double( mlt_properties self, const char *name, double val
 
 mlt_position mlt_properties_get_position( mlt_properties self, const char *name )
 {
-       mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
-       double fps = mlt_profile_fps( profile );
-       property_list *list = self->local;
+       mlt_position result = 0;
        mlt_property value = mlt_properties_find( self, name );
-       return value == NULL ? 0 : mlt_property_get_position( value, fps, list->locale );
+       if ( value )
+       {
+               mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
+               double fps = mlt_profile_fps( profile );
+               property_list *list = self->local;
+               result = mlt_property_get_position( value, fps, list->locale );
+       }
+       return result;
 }
 
 /** Set a property to a position value.
@@ -2072,6 +2092,38 @@ char *mlt_properties_get_time( mlt_properties self, const char* name, mlt_time_f
        return NULL;
 }
 
+/** Convert a frame count to a time string.
+ *
+ * Do not free the returned string. It's lifetime is controlled by the property.
+ * \public \memberof mlt_properties_s
+ * \param self a properties list
+ * \param frames the frame count to convert
+ * \param format the time format that you want
+ * \return the time string or NULL if error, e.g. there is no profile
+ */
+
+char *mlt_properties_frames_to_time( mlt_properties self, mlt_position frames, mlt_time_format format )
+{
+       const char *name = "_mlt_properties_time";
+       mlt_properties_set_position( self, name, frames );
+       return mlt_properties_get_time( self, name, format );
+}
+
+/** Convert a time string to a frame count.
+ *
+ * \public \memberof mlt_properties_s
+ * \param self a properties list
+ * \param time the time string to convert
+ * \return a frame count or a negative value if error, e.g. there is no profile
+ */
+
+mlt_position mlt_properties_time_to_frames( mlt_properties self, const char *time )
+{
+       const char *name = "_mlt_properties_time";
+       mlt_properties_set( self, name, time );
+       return mlt_properties_get_position( self, name );
+}
+
 /** Convert a numeric property to a tuple of color components.
  *
  * If the property's string is red, green, blue, white, or black, then it