]> git.sesse.net Git - mlt/commitdiff
add support for parsing time(code) values to xml producer
authorDan Dennedy <dan@dennedy.org>
Sat, 31 Mar 2012 23:53:51 +0000 (16:53 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 2 Apr 2012 01:42:19 +0000 (18:42 -0700)
src/modules/xml/producer_xml.c

index f38c96c882ac48887b71fdac46bd0aa0641bfd04..b736be6cfc604bd2b5b6f1ee75742d044cf8885c 100644 (file)
@@ -158,6 +158,9 @@ static mlt_service context_pop_service( deserialise_context context, enum servic
                result = context->stack_service[ -- context->stack_service_size ];
                if ( type != NULL )
                        *type = context->stack_types[ context->stack_service_size ];
+               // Set the service's profile and locale so mlt_property time-to-position conversions can get fps
+               mlt_properties_set_data( MLT_SERVICE_PROPERTIES( result ), "_profile", context->profile, 0, NULL, NULL );
+               mlt_properties_set_lcnumeric( MLT_SERVICE_PROPERTIES( result ), context->lc_numeric );
        }
        return result;
 }
@@ -524,44 +527,6 @@ static void on_start_producer( deserialise_context context, const xmlChar *name,
                mlt_properties_set( properties, (const char*) atts[0], atts[1] == NULL ? "" : (const char*) atts[1] );
 }
 
-// Parse a SMIL clock value (as produced by Kino 0.9.1) and return position in frames
-static mlt_position parse_clock_value( char *value, double fps )
-{
-       // This implementation expects a fully specified clock value - no optional
-       // parts (e.g. 1:05)
-       char *pos, *copy = strdup( value );
-       int hh, mm, ss, ms;
-       mlt_position result = -1;
-
-       value = copy;
-       pos = strchr( value, ':' );
-       if ( !pos )
-               return result;
-       *pos = '\0';
-       hh = atoi( value );
-       value = pos + 1;
-
-       pos = strchr( value, ':' );
-       if ( !pos )
-               return result;
-       *pos = '\0';
-       mm = atoi( value );
-       value = pos + 1;
-       
-       pos = strchr( value, '.' );
-       if ( !pos )
-               return result;
-       *pos = '\0';
-       ss = atoi( value );
-       value = pos + 1;
-       
-       ms = atoi( value );
-       free( copy );
-       result = ( fps * ( ( (hh * 3600) + (mm * 60) + ss ) * 1000  + ms ) / 1000 + 0.5 );
-       
-       return result;
-}
-
 static void on_end_producer( deserialise_context context, const xmlChar *name )
 {
        enum service_type type;
@@ -632,33 +597,17 @@ static void on_end_producer( deserialise_context context, const xmlChar *name )
                mlt_position out = -1;
        
                // Get in
-               if ( mlt_properties_get( properties, "in" ) != NULL )
+               if ( mlt_properties_get( properties, "in" ) )
                        in = mlt_properties_get_position( properties, "in" );
                // Let Kino-SMIL clipBegin be a synonym for in
-               if ( mlt_properties_get( properties, "clipBegin" ) != NULL )
-               {
-                       if ( strchr( mlt_properties_get( properties, "clipBegin" ), ':' ) )
-                               // Parse clock value
-                               in = parse_clock_value( mlt_properties_get( properties, "clipBegin" ),
-                                       mlt_producer_get_fps( MLT_PRODUCER(  producer ) ) );
-                       else
-                               // Parse frames value
-                               in = mlt_properties_get_position( properties, "clipBegin" );
-               }
+               else if ( mlt_properties_get( properties, "clipBegin" ) )
+                       in = mlt_properties_get_position( properties, "clipBegin" );
                // Get out
-               if ( mlt_properties_get( properties, "out" ) != NULL )
+               if ( mlt_properties_get( properties, "out" ) )
                        out = mlt_properties_get_position( properties, "out" );
                // Let Kino-SMIL clipEnd be a synonym for out
-               if ( mlt_properties_get( properties, "clipEnd" ) != NULL )
-               {
-                       if ( strchr( mlt_properties_get( properties, "clipEnd" ), ':' ) )
-                               // Parse clock value
-                               out = parse_clock_value( mlt_properties_get( properties, "clipEnd" ),
-                                       mlt_producer_get_fps( MLT_PRODUCER( producer ) ) );
-                       else
-                               // Parse frames value
-                               out = mlt_properties_get_position( properties, "clipEnd" );
-               }
+               else if ( mlt_properties_get( properties, "clipEnd" ) )
+                       out = mlt_properties_get_position( properties, "clipEnd" );
                // Remove in and out
                mlt_properties_set( properties, "in", NULL );
                mlt_properties_set( properties, "out", NULL );
@@ -754,6 +703,8 @@ static void on_start_entry( deserialise_context context, const xmlChar *name, co
 {
        mlt_producer entry = NULL;
        mlt_properties temp = mlt_properties_new( );
+       mlt_properties_set_data( temp, "_profile", context->profile, 0, NULL, NULL );
+       mlt_properties_set_lcnumeric( temp, context->lc_numeric );
 
        for ( ; atts != NULL && *atts != NULL; atts += 2 )
        {