X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fwestley%2Fproducer_westley.c;h=75fd54184b6a24ca9203c24c61cd15ef6266d461;hb=bf3264b9e340ba5c11cbf59835a8af3db94e0cc2;hp=0869e101c922d20bf2fdfae0e5d5779fa312b583;hpb=1f6faabf5ef11e6321d186772d88fb6958cdd057;p=melted diff --git a/src/modules/westley/producer_westley.c b/src/modules/westley/producer_westley.c index 0869e10..75fd541 100644 --- a/src/modules/westley/producer_westley.c +++ b/src/modules/westley/producer_westley.c @@ -3,19 +3,19 @@ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited * Author: Dan Dennedy * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // TODO: destroy unreferenced producers (they are currently destroyed @@ -433,6 +433,44 @@ static void on_start_producer( deserialise_context context, const xmlChar *name, mlt_properties_set( properties, (char*) atts[0], atts[1] == NULL ? "" : (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; @@ -445,7 +483,6 @@ static void on_end_producer( deserialise_context context, const xmlChar *name ) qualify_property( context, properties, "resource" ); char *resource = mlt_properties_get( properties, "resource" ); - int fx_cut = mlt_properties_get_int( properties, "meta.fx_cut" ); // Let Kino-SMIL src be a synonym for resource if ( resource == NULL ) @@ -455,7 +492,7 @@ static void on_end_producer( deserialise_context context, const xmlChar *name ) } // Instantiate the producer - if ( !fx_cut && mlt_properties_get( properties, "mlt_service" ) != NULL ) + if ( mlt_properties_get( properties, "mlt_service" ) != NULL ) { char temp[ 1024 ]; strncpy( temp, mlt_properties_get( properties, "mlt_service" ), 1024 ); @@ -466,10 +503,6 @@ static void on_end_producer( deserialise_context context, const xmlChar *name ) } producer = MLT_SERVICE( mlt_factory_producer( "fezzik", temp ) ); } - else - { - producer = MLT_SERVICE( mlt_factory_producer( mlt_properties_get( properties, "mlt_service" ), resource ) ); - } // Just in case the plugin requested doesn't exist... if ( producer == NULL && resource != NULL ) @@ -478,6 +511,9 @@ static void on_end_producer( deserialise_context context, const xmlChar *name ) if ( producer == NULL ) producer = MLT_SERVICE( mlt_factory_producer( "fezzik", "+INVALID.txt" ) ); + if ( producer == NULL ) + producer = MLT_SERVICE( mlt_factory_producer( "fezzik", "colour:red" ) ); + // Track this producer track_service( context->destructors, producer, (mlt_destructor) mlt_producer_close ); @@ -497,14 +533,29 @@ static void on_end_producer( deserialise_context context, const xmlChar *name ) in = mlt_properties_get_position( properties, "in" ); // Let Kino-SMIL clipBegin be a synonym for in if ( mlt_properties_get( properties, "clipBegin" ) != NULL ) - in = mlt_properties_get_position( properties, "clipBegin" ); + { + if ( strchr( mlt_properties_get( properties, "clipBegin" ), ':' ) ) + // Parse clock value + in = parse_clock_value( mlt_properties_get( properties, "clipBegin" ), + mlt_properties_get_double( mlt_producer_properties( MLT_PRODUCER( producer ) ), "fps" ) ); + else + // Parse frames value + in = mlt_properties_get_position( properties, "clipBegin" ); + } // Get out if ( mlt_properties_get( properties, "out" ) != NULL ) out = mlt_properties_get_position( properties, "out" ); // Let Kino-SMIL clipEnd be a synonym for out if ( mlt_properties_get( properties, "clipEnd" ) != NULL ) - out = mlt_properties_get_position( properties, "clipEnd" ); - + { + if ( strchr( mlt_properties_get( properties, "clipEnd" ), ':' ) ) + // Parse clock value + out = parse_clock_value( mlt_properties_get( properties, "clipEnd" ), + mlt_properties_get_double( mlt_producer_properties( MLT_PRODUCER( producer ) ), "fps" ) ); + else + // Parse frames value + out = mlt_properties_get_position( properties, "clipEnd" ); + } // Remove in and out mlt_properties_set( properties, "in", NULL ); mlt_properties_set( properties, "out", NULL );