]> git.sesse.net Git - mlt/commitdiff
Add mlt_properties_frames_to_time() and mlt_properties_time_to_frames().
authorDan Dennedy <dan@dennedy.org>
Tue, 3 Dec 2013 04:14:02 +0000 (20:14 -0800)
committerDan Dennedy <dan@dennedy.org>
Thu, 19 Dec 2013 05:19:04 +0000 (21:19 -0800)
Handy conversion functions for apps.

src/framework/mlt.vers
src/framework/mlt_properties.c
src/framework/mlt_properties.h
src/mlt++/MltProperties.cpp
src/mlt++/MltProperties.h
src/mlt++/mlt++.vers

index 45b0b3ff0d1bb71f8b694c08edb53998f5b10f8c..a0069e41f80e53d8485c4451d14d3d73c5ce0087 100644 (file)
@@ -447,3 +447,8 @@ MLT_0.9.0 {
     mlt_service_filter_count;
     mlt_service_move_filter;
 } MLT_0.8.8;
+
+MLT_0.9.2 {
+    mlt_properties_frames_to_time;
+    mlt_properties_time_to_frames;
+} MLT_0.9.0;
index 415313d6c561077a7de5216dca4217d70021ee12..c28af8fc514c2043f574b993b9945683cee39b84 100644 (file)
@@ -2092,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
index 7c4900d35f179bcac8258b1716d51cfcfdb0edc4..f4a44c0e6ca99233de3f80a0d2794e524bd8d873 100644 (file)
@@ -88,7 +88,11 @@ extern mlt_properties mlt_properties_parse_yaml( const char *file );
 extern char *mlt_properties_serialise_yaml( mlt_properties self );
 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 char *mlt_properties_frames_to_time( mlt_properties, mlt_position, mlt_time_format );
+extern mlt_position mlt_properties_time_to_frames( mlt_properties, const char* time );
+
 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 );
 
index 9648e0329c7c2d30eaf09cbfeb2112f203885373..3da531a99757c147de77884b869fac6b57a28316 100644 (file)
@@ -337,6 +337,16 @@ char *Properties::get_time( const char *name, mlt_time_format format )
        return mlt_properties_get_time( get_properties(), name, format );
 }
 
+char *Properties::frames_to_time( int frames, mlt_time_format format )
+{
+       return mlt_properties_frames_to_time( get_properties(), frames, format );
+}
+
+int Properties::time_to_frames( const char *time )
+{
+       return mlt_properties_time_to_frames( get_properties(), time );
+}
+
 mlt_color Properties::get_color( const char *name )
 {
        return mlt_properties_get_color( get_properties(), name );
index d2f8e8a3634d915c0168873c0341074b2807e815..6c5b8e87ab89d403b15c71fdf5a524e3c386f5b8 100644 (file)
@@ -97,6 +97,9 @@ namespace Mlt
                        int set_lcnumeric( const char *locale );
                        const char *get_lcnumeric( );
                        char *get_time( const char *name, mlt_time_format = mlt_time_smpte );
+                       char *frames_to_time( int, mlt_time_format = mlt_time_smpte );
+                       int time_to_frames( const char* time );
+
                        mlt_color get_color( const char *name );
                        int set( const char *name , mlt_color value );
 
index 6dfb3629209f88adef6110108e8c4df90261bcda..17ec647df2e1a79c96993559baa6c5907d6ac311 100644 (file)
@@ -457,3 +457,11 @@ MLTPP_0.9.0 {
       "Mlt::Service::move_filter(int, int)";
     };
 } MLTPP_0.8.8;
+
+MLTPP_0.9.2 {
+  global:
+    extern "C++" {
+      "Mlt::Properties::frames_to_time(int, mlt_time_format)";
+      "Mlt::Properties::time_to_frames(char const*)";
+    };
+} MLTPP_0.9.0;