track_service( context->destructors, service, (mlt_destructor) mlt_tractor_close );
for ( ; atts != NULL && *atts != NULL; atts += 2 )
- mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), (char*) atts[0], (char*) atts[1] );
+ mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), (char*) atts[0], atts[1] == NULL ? "" : (char*) atts[1] );
+
+ mlt_properties_set_int( MLT_TRACTOR_PROPERTIES( tractor ), "global_feed", 1 );
if ( mlt_properties_get( properties, "id" ) != NULL )
mlt_properties_set_data( context->producer_map, mlt_properties_get( properties, "id" ), service, 0, NULL, NULL );
mlt_service service = MLT_SERVICE( mlt_tractor_multitrack( MLT_TRACTOR( parent ) ) );
mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
for ( ; atts != NULL && *atts != NULL; atts += 2 )
- mlt_properties_set( properties, (char*) atts[0], (char*) atts[1] );
+ mlt_properties_set( properties, (char*) atts[0], atts[1] == NULL ? "" : (char*) atts[1] );
if ( mlt_properties_get( properties, "id" ) != NULL )
mlt_properties_set_data( context->producer_map, mlt_properties_get( properties,"id" ), service, 0, NULL, NULL );
for ( ; atts != NULL && *atts != NULL; atts += 2 )
{
- mlt_properties_set( properties, ( char* )atts[0], ( char* )atts[1] );
+ mlt_properties_set( properties, (char*) atts[0], atts[1] == NULL ? "" : (char*) atts[1] );
// Out will be overwritten later as we append, so we need to save it
if ( strcmp( atts[ 0 ], "out" ) == 0 )
context_push_service( context, service, mlt_dummy_producer_type );
for ( ; atts != NULL && *atts != NULL; atts += 2 )
- mlt_properties_set( properties, (char*) atts[0], (char*) atts[1] );
+ mlt_properties_set( properties, (char*) atts[0], atts[1] == NULL ? "" : (char*) atts[1] );
}
static void on_end_producer( deserialise_context context, const xmlChar *name )
for ( ; atts != NULL && *atts != NULL; atts += 2 )
{
- mlt_properties_set( temp, (char*) atts[0], (char*) atts[1] );
+ mlt_properties_set( temp, (char*) atts[0], atts[1] == NULL ? "" : (char*) atts[1] );
// Look for the producer attribute
if ( strcmp( atts[ 0 ], "producer" ) == 0 )
for ( ; atts != NULL && *atts != NULL; atts += 2 )
{
- mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), (char*) atts[0], (char*) atts[1] );
+ mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), (char*) atts[0], atts[1] == NULL ? "" : (char*) atts[1] );
// Look for the producer attribute
if ( strcmp( atts[ 0 ], "producer" ) == 0 )
value = (char*) atts[ 1 ];
}
- if ( context->property != NULL && value != NULL )
- mlt_properties_set( properties, context->property, value );
-
+ if ( context->property != NULL )
+ mlt_properties_set( properties, context->property, value == NULL ? "" : value );
+
// Tell parser to collect any further nodes for serialisation
context->is_value = 1;
xmlFreeDoc( context->value_doc );
context->value_doc = NULL;
}
-
+
// Close this property handling
free( context->property );
context->property = NULL;
params_to_entities( context );
}
+// TODO: Check this with Dan... I think this is for westley parameterisation
+// but it's breaking standard escaped entities (like < etc).
static void on_entity_declaration( void *ctx, const xmlChar* name, int type,
const xmlChar* publicId, const xmlChar* systemId, xmlChar* content)
{
xmlAddDocEntity( context->entity_doc, name, type, publicId, systemId, content );
}
-xmlEntityPtr on_get_entity( void *ctx, const xmlChar* name )
+// TODO: Check this functionality (see on_entity_declaration)
+static xmlEntityPtr on_get_entity( void *ctx, const xmlChar* name )
{
struct _xmlParserCtxt *xmlcontext = ( struct _xmlParserCtxt* )ctx;
deserialise_context context = ( deserialise_context )( xmlcontext->_private );
// Add our parameters if not already
params_to_entities( context );
- e = xmlGetDocEntity( context->entity_doc, name );
+ e = xmlGetPredefinedEntity( name );
// Send signal to on_characters that an entity substitutin is pending
- if ( e != NULL )
- context->entity_is_replace = 1;
+ if ( e == NULL )
+ {
+ e = xmlGetDocEntity( context->entity_doc, name );
+ if ( e != NULL )
+ context->entity_is_replace = 1;
+ }
return e;
}
mlt_properties_set( properties, name, value );
}
+// Quick workaround to avoid unecessary libxml2 warnings
+static int file_exists( char *file )
+{
+ char *name = strdup( file );
+ int exists = 0;
+ if ( name != NULL && strchr( name, '?' ) )
+ *( strchr( name, '?' ) ) = '\0';
+ if ( name != NULL )
+ {
+ FILE *f = fopen( name, "r" );
+ exists = f != NULL;
+ if ( exists ) fclose( f );
+ }
+ free( name );
+ return exists;
+}
+
mlt_producer producer_westley_init( int info, char *data )
{
- if ( data == NULL )
- return NULL;
xmlSAXHandler *sax = calloc( 1, sizeof( xmlSAXHandler ) );
struct deserialise_context_s *context = calloc( 1, sizeof( struct deserialise_context_s ) );
mlt_properties properties = NULL;
int well_formed = 0;
char *filename = NULL;
+ if ( data == NULL || !strcmp( data, "" ) || ( info == 0 && !file_exists( data ) ) )
+ return NULL;
+
+ context = calloc( 1, sizeof( struct deserialise_context_s ) );
+ if ( context == NULL )
+ return NULL;
+
context->producer_map = mlt_properties_new();
context->destructors = mlt_properties_new();
context->params = mlt_properties_new();