2 * consumer_westley.c -- a libxml2 serialiser of mlt service networks
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Dan Dennedy <dan@dennedy.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "consumer_westley.h"
22 #include <framework/mlt.h>
27 #include <libxml/tree.h>
29 /** Forward references to static functions.
32 static int consumer_start( mlt_consumer parent
);
34 /** This is what will be called by the factory - anything can be passed in
35 via the argument, but keep it simple.
38 mlt_consumer
consumer_westley_init( char *arg
)
40 // Create the consumer object
41 mlt_consumer
this = calloc( sizeof( struct mlt_consumer_s
), 1 );
43 // If no malloc'd and consumer init ok
44 if ( this != NULL
&& mlt_consumer_init( this, NULL
) == 0 )
46 // We have stuff to clean up, so override the close method
47 //parent->close = consumer_close;
49 // Allow thread to be started/stopped
50 this->start
= consumer_start
;
52 // Return the consumer produced
56 // malloc or consumer init failed
63 void serialise_service( mlt_service service
)
65 // Iterate over consumer/producer connections
66 while ( service
!= NULL
)
68 char *mlt_type
= mlt_properties_get( mlt_service_properties(service
), "mlt_type" );
70 // Tell about the producer
71 if ( strcmp( mlt_type
, "producer" ) == 0 )
73 fprintf( stderr
, "mlt_type '%s' mlt_service '%s' resource '%s'\n", mlt_type
,
74 mlt_properties_get( mlt_service_properties( service
), "mlt_service" ),
75 mlt_properties_get( mlt_service_properties( service
), "resource" ) );
78 // Tell about the framework container producers
79 else if ( strcmp( mlt_type
, "mlt_producer" ) == 0 )
81 fprintf( stderr
, "mlt_type '%s' resource '%s'\n", mlt_type
,
82 mlt_properties_get( mlt_service_properties( service
), "resource" ) );
84 // Recurse on multitrack's tracks
85 if ( strcmp( mlt_properties_get( mlt_service_properties( service
), "resource" ), "<multitrack>" ) == 0 )
89 fprintf( stderr
, "contains...\n" );
90 for ( i
= 0; i
< mlt_multitrack_count( MLT_MULTITRACK( service
) ); i
++ )
91 serialise_service( MLT_SERVICE( mlt_multitrack_track( MLT_MULTITRACK( service
), i
) ) );
92 fprintf( stderr
, "...done.\n" );
95 // Recurse on playlist's clips
96 else if ( strcmp( mlt_properties_get( mlt_service_properties( service
), "resource" ), "<playlist>" ) == 0 )
99 mlt_playlist_clip_info info
;
101 fprintf( stderr
, "contains...\n" );
102 for ( i
= 0; i
< mlt_playlist_count( MLT_PLAYLIST( service
) ); i
++ )
104 if ( ! mlt_playlist_get_clip_info( MLT_PLAYLIST( service
), &info
, i
) )
105 serialise_service( MLT_SERVICE( info
.producer
) );
107 fprintf( stderr
, "...done.\n" );
111 // Tell about a filter
112 else if ( strcmp( mlt_type
, "filter" ) == 0 )
114 fprintf( stderr
, "mlt_type '%s' mlt_service '%s'\n", mlt_type
,
115 mlt_properties_get( mlt_service_properties( service
), "mlt_service" ) );
117 fprintf( stderr
, "is applied to\n" );
119 // Recurse on connected producer
120 serialise_service( MLT_SERVICE( MLT_FILTER( service
)->producer
) );
123 // Tell about a transition
124 else if ( strcmp( mlt_type
, "transition" ) == 0 )
126 fprintf( stderr
, "mlt_type '%s' mlt_service '%s'\n", mlt_type
,
127 mlt_properties_get( mlt_service_properties( service
), "mlt_service" ) );
129 fprintf( stderr
, "is applied to\n" );
131 // Recurse on connected producer
132 serialise_service( MLT_SERVICE( MLT_TRANSITION( service
)->producer
) );
135 // Get the next connected service
136 service
= mlt_service_get_producer( service
);
137 if ( service
!= NULL
)
138 fprintf( stderr
, "is connected to\n" );
142 static int consumer_start( mlt_consumer
this )
144 // get a handle on properties
145 mlt_properties properties
= mlt_consumer_properties( this );
147 mlt_service inigo
= NULL
;
149 fprintf( stderr
, "mlt_type '%s' mlt_service '%s'\n",
150 mlt_properties_get( properties
, "mlt_type" ),
151 mlt_properties_get( properties
, "mlt_service" ) );
153 // Get the producer service
154 mlt_service service
= mlt_service_get_producer( mlt_consumer_service( this ) );
155 if ( service
!= NULL
)
157 fprintf( stderr
, "is connected to\n" );
160 if ( mlt_properties_get( mlt_service_properties( service
), "mlt_service" ) != NULL
&&
161 strcmp( mlt_properties_get( mlt_service_properties( service
), "mlt_service" ), "inigo" ) == 0 )
164 serialise_service( service
);
167 mlt_consumer_stop( this );
169 // Tell inigo, enough already!
171 mlt_properties_set_int( mlt_service_properties( inigo
), "done", 1 );