* Copyright (C) 2003-2004 Ushodaya Enterprises Limited
* Author: Dan Dennedy <dan@dennedy.org>
*
- * 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
*/
-#include "consumer_westley.h"
#include <framework/mlt.h>
#include <stdio.h>
#include <stdlib.h>
#define ID_SIZE 128
+#define _x (xmlChar*)
+#define _s (char*)
+
// This maintains counters for adding ids to elements
struct serialise_context_s
{
via the argument, but keep it simple.
*/
-mlt_consumer consumer_westley_init( char *arg )
+mlt_consumer consumer_westley_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
// Create the consumer object
mlt_consumer this = calloc( sizeof( struct mlt_consumer_s ), 1 );
// If no malloc'd and consumer init ok
- if ( this != NULL && mlt_consumer_init( this, NULL ) == 0 )
+ if ( this != NULL && mlt_consumer_init( this, NULL, profile ) == 0 )
{
// Allow thread to be started/stopped
this->start = consumer_start;
strcmp( name, "in" ) != 0 &&
strcmp( name, "out" ) != 0 &&
strcmp( name, "id" ) != 0 &&
+ strcmp( name, "title" ) != 0 &&
strcmp( name, "root" ) != 0 &&
strcmp( name, "width" ) != 0 &&
strcmp( name, "height" ) != 0 )
{
char *value = mlt_properties_get_value( properties, i );
- p = xmlNewChild( node, NULL, "property", NULL );
- xmlNewProp( p, "name", mlt_properties_get_name( properties, i ) );
if ( strcmp( context->root, "" ) && !strncmp( value, context->root, strlen( context->root ) ) )
- xmlNodeSetContent( p, value + strlen( context->root ) + 1 );
- else
- xmlNodeSetContent( p, value );
+ value += strlen( context->root ) + 1;
+ p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
+ xmlNewProp( p, _x("name"), _x(name) );
}
}
}
char *value = mlt_properties_get_value( properties, i );
if ( value != NULL )
{
- p = xmlNewChild( node, NULL, "property", NULL );
- xmlNewProp( p, "name", mlt_properties_get_name( properties, i ) );
- if ( context->root != NULL && strcmp( context->root, "" ) && !strncmp( value, context->root, strlen( context->root ) ) )
- xmlNodeSetContent( p, value + strlen( context->root ) + 1 );
- else
- xmlNodeSetContent( p, value );
+ if ( strcmp( context->root, "" ) && !strncmp( value, context->root, strlen( context->root ) ) )
+ value += strlen( context->root ) + 1;
+ p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
+ xmlNewProp( p, _x("name"), _x(name) );
}
}
}
{
int in = mlt_properties_get_position( properties, "in" );
int out = mlt_properties_get_position( properties, "out" );
- p = xmlNewChild( node, NULL, "filter", NULL );
- xmlNewProp( p, "id", id );
+ p = xmlNewChild( node, NULL, _x("filter"), NULL );
+ xmlNewProp( p, _x("id"), _x(id) );
+ if ( mlt_properties_get( properties, "title" ) )
+ xmlNewProp( p, _x("title"), _x(mlt_properties_get( properties, "title" )) );
if ( in != 0 || out != 0 )
{
char temp[ 20 ];
sprintf( temp, "%d", in );
- xmlNewProp( p, "in", temp );
+ xmlNewProp( p, _x("in"), _x(temp) );
sprintf( temp, "%d", out );
- xmlNewProp( p, "out", temp );
+ xmlNewProp( p, _x("out"), _x(temp) );
}
serialise_properties( context, properties, p );
serialise_service_filters( context, MLT_FILTER_SERVICE( filter ), p );
if ( id == NULL )
return;
- child = xmlNewChild( node, NULL, "producer", NULL );
+ child = xmlNewChild( node, NULL, _x("producer"), NULL );
// Set the id
- xmlNewProp( child, "id", id );
- xmlNewProp( child, "in", mlt_properties_get( properties, "in" ) );
- xmlNewProp( child, "out", mlt_properties_get( properties, "out" ) );
+ xmlNewProp( child, _x("id"), _x(id) );
+ if ( mlt_properties_get( properties, "title" ) )
+ xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
+ xmlNewProp( child, _x("in"), _x(mlt_properties_get( properties, "in" )) );
+ xmlNewProp( child, _x("out"), _x(mlt_properties_get( properties, "out" )) );
serialise_properties( context, properties, child );
serialise_service_filters( context, service, child );
{
char *id = westley_get_id( context, parent, westley_existing );
mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
- xmlNewProp( node, "parent", id );
- xmlNewProp( node, "in", mlt_properties_get( properties, "in" ) );
- xmlNewProp( node, "out", mlt_properties_get( properties, "out" ) );
+ xmlNewProp( node, _x("parent"), _x(id) );
+ xmlNewProp( node, _x("in"), _x(mlt_properties_get( properties, "in" )) );
+ xmlNewProp( node, _x("out"), _x(mlt_properties_get( properties, "out" )) );
}
}
// Serialise the tracks
for ( i = 0; i < mlt_multitrack_count( MLT_MULTITRACK( service ) ); i++ )
{
- xmlNode *track = xmlNewChild( node, NULL, "track", NULL );
+ xmlNode *track = xmlNewChild( node, NULL, _x("track"), NULL );
int hide = 0;
mlt_producer producer = mlt_multitrack_track( MLT_MULTITRACK( service ), i );
mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
mlt_service parent = MLT_SERVICE( mlt_producer_cut_parent( producer ) );
char *id = westley_get_id( context, MLT_SERVICE( parent ), westley_existing );
- xmlNewProp( track, "producer", id );
+ xmlNewProp( track, _x("producer"), _x(id) );
if ( mlt_producer_is_cut( producer ) )
{
- xmlNewProp( track, "in", mlt_properties_get( properties, "in" ) );
- xmlNewProp( track, "out", mlt_properties_get( properties, "out" ) );
+ xmlNewProp( track, _x("in"), _x(mlt_properties_get( properties, "in" )) );
+ xmlNewProp( track, _x("out"), _x(mlt_properties_get( properties, "out" )) );
serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( producer ), track, context->store );
serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( producer ), track, "meta." );
serialise_service_filters( context, MLT_PRODUCER_SERVICE( producer ), track );
hide = mlt_properties_get_int( context->hide_map, id );
if ( hide )
- xmlNewProp( track, "hide", hide == 1 ? "video" : ( hide == 2 ? "audio" : "both" ) );
+ xmlNewProp( track, _x("hide"), _x( hide == 1 ? "video" : ( hide == 2 ? "audio" : "both" ) ) );
}
serialise_service_filters( context, service, node );
}
}
}
- child = xmlNewChild( node, NULL, "playlist", NULL );
+ child = xmlNewChild( node, NULL, _x("playlist"), NULL );
// Set the id
- xmlNewProp( child, "id", id );
+ xmlNewProp( child, _x("id"), _x(id) );
+ if ( mlt_properties_get( properties, "title" ) )
+ xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
// Store application specific properties
serialise_store_properties( context, properties, child, context->store );
{
char length[ 20 ];
length[ 19 ] = '\0';
- xmlNode *entry = xmlNewChild( child, NULL, "blank", NULL );
- snprintf( length, 19, "%d", info.frame_count );
- xmlNewProp( entry, "length", length );
+ xmlNode *entry = xmlNewChild( child, NULL, _x("blank"), NULL );
+ snprintf( length, 19, "%d", (int)info.frame_count );
+ xmlNewProp( entry, _x("length"), _x(length) );
}
else
{
char temp[ 20 ];
- xmlNode *entry = xmlNewChild( child, NULL, "entry", NULL );
+ xmlNode *entry = xmlNewChild( child, NULL, _x("entry"), NULL );
id = westley_get_id( context, MLT_SERVICE( producer ), westley_existing );
- xmlNewProp( entry, "producer", id );
- sprintf( temp, "%d", info.frame_in );
- xmlNewProp( entry, "in", temp );
- sprintf( temp, "%d", info.frame_out );
- xmlNewProp( entry, "out", temp );
+ xmlNewProp( entry, _x("producer"), _x(id) );
+ sprintf( temp, "%d", (int)info.frame_in );
+ xmlNewProp( entry, _x("in"), _x(temp) );
+ sprintf( temp, "%d", (int)info.frame_out );
+ xmlNewProp( entry, _x("out"), _x(temp) );
if ( info.repeat > 1 )
{
sprintf( temp, "%d", info.repeat );
- xmlNewProp( entry, "repeat", temp );
+ xmlNewProp( entry, _x("repeat"), _x(temp) );
}
if ( mlt_producer_is_cut( info.cut ) )
{
serialise_service_filters( context, service, child );
}
- else if ( strcmp( (const char*) node->name, "tractor" ) != 0 )
+ else if ( xmlStrcmp( node->name, _x("tractor") ) != 0 )
{
char *id = westley_get_id( context, service, westley_existing );
- xmlNewProp( node, "producer", id );
+ xmlNewProp( node, _x("producer"), _x(id) );
}
}
if ( id == NULL )
return;
- child = xmlNewChild( node, NULL, "tractor", NULL );
+ child = xmlNewChild( node, NULL, _x("tractor"), NULL );
// Set the id
- xmlNewProp( child, "id", id );
- xmlNewProp( child, "in", mlt_properties_get( properties, "in" ) );
- xmlNewProp( child, "out", mlt_properties_get( properties, "out" ) );
+ xmlNewProp( child, _x("id"), _x(id) );
+ if ( mlt_properties_get( properties, "title" ) )
+ xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
+ if ( mlt_properties_get( properties, "global_feed" ) )
+ xmlNewProp( child, _x("global_feed"), _x(mlt_properties_get( properties, "global_feed" )) );
+ xmlNewProp( child, _x("in"), _x(mlt_properties_get( properties, "in" )) );
+ xmlNewProp( child, _x("out"), _x(mlt_properties_get( properties, "out" )) );
// Store application specific properties
serialise_store_properties( context, MLT_SERVICE_PROPERTIES( service ), child, context->store );
if ( id == NULL )
return;
- child = xmlNewChild( node, NULL, "filter", NULL );
+ child = xmlNewChild( node, NULL, _x("filter"), NULL );
// Set the id
- xmlNewProp( child, "id", id );
- xmlNewProp( child, "in", mlt_properties_get( properties, "in" ) );
- xmlNewProp( child, "out", mlt_properties_get( properties, "out" ) );
+ xmlNewProp( child, _x("id"), _x(id) );
+ if ( mlt_properties_get( properties, "title" ) )
+ xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
+ xmlNewProp( child, _x("in"), _x(mlt_properties_get( properties, "in" )) );
+ xmlNewProp( child, _x("out"), _x(mlt_properties_get( properties, "out" )) );
serialise_properties( context, properties, child );
serialise_service_filters( context, service, child );
if ( id == NULL )
return;
- child = xmlNewChild( node, NULL, "transition", NULL );
+ child = xmlNewChild( node, NULL, _x("transition"), NULL );
// Set the id
- xmlNewProp( child, "id", id );
- xmlNewProp( child, "in", mlt_properties_get( properties, "in" ) );
- xmlNewProp( child, "out", mlt_properties_get( properties, "out" ) );
+ xmlNewProp( child, _x("id"), _x(id) );
+ if ( mlt_properties_get( properties, "title" ) )
+ xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
+ xmlNewProp( child, _x("in"), _x(mlt_properties_get( properties, "in" )) );
+ xmlNewProp( child, _x("out"), _x(mlt_properties_get( properties, "out" )) );
serialise_properties( context, properties, child );
serialise_service_filters( context, service, child );
if ( strcmp( mlt_type, "producer" ) == 0 )
{
char *mlt_service = mlt_properties_get( properties, "mlt_service" );
- if ( mlt_properties_get( properties, "westley" ) == NULL && !strcmp( mlt_service, "tractor" ) )
+ if ( mlt_properties_get( properties, "westley" ) == NULL && ( mlt_service != NULL && !strcmp( mlt_service, "tractor" ) ) )
{
context->pass = 0;
serialise_tractor( context, service, node );
xmlDocPtr westley_make_doc( mlt_consumer consumer, mlt_service service )
{
mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
- xmlDocPtr doc = xmlNewDoc( "1.0" );
- xmlNodePtr root = xmlNewNode( NULL, "westley" );
+ xmlDocPtr doc = xmlNewDoc( _x("1.0") );
+ xmlNodePtr root = xmlNewNode( NULL, _x("westley") );
struct serialise_context_s *context = calloc( 1, sizeof( struct serialise_context_s ) );
xmlDocSetRootElement( doc, root );
// If we have root, then deal with it now
if ( mlt_properties_get( properties, "root" ) != NULL )
{
- xmlNewProp( root, "root", mlt_properties_get( properties, "root" ) );
+ xmlNewProp( root, _x("root"), _x(mlt_properties_get( properties, "root" )) );
context->root = strdup( mlt_properties_get( properties, "root" ) );
}
else
// Assign a title property
if ( mlt_properties_get( properties, "title" ) != NULL )
- xmlNewProp( root, "title", mlt_properties_get( properties, "title" ) );
+ xmlNewProp( root, _x("title"), _x(mlt_properties_get( properties, "title" )) );
+ mlt_properties_set_int( properties, "global_feed", 1 );
// Construct the context maps
context->id_map = mlt_properties_new();
{
xmlChar *buffer = NULL;
int length = 0;
- xmlDocDumpMemory( doc, &buffer, &length );
- mlt_properties_set( properties, resource, buffer );
+ xmlDocDumpMemoryEnc( doc, &buffer, &length, "utf-8" );
+ mlt_properties_set( properties, resource, _s(buffer) );
xmlFree( buffer );
}
else
{
- xmlSaveFormatFile( resource, doc, 1 );
+ xmlSaveFormatFileEnc( resource, doc, "utf-8", 1 );
}
// Close the document