2 * MltProperties.cpp - MLT Wrapper
3 * Copyright (C) 2004-2005 Charles Yates
4 * Author: Charles Yates <charles.yates@pandora.be>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by 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 "MltProperties.h"
25 Properties::Properties( ) :
28 instance = mlt_properties_new( );
31 Properties::Properties( bool dummy ) :
36 Properties::Properties( Properties &properties ) :
37 instance( properties.get_properties( ) )
39 fprintf( stderr, "Incrementing ref count on properties #1\n" );
43 Properties::Properties( mlt_properties properties ) :
44 instance( properties )
46 fprintf( stderr, "Incrementing ref count on properties #2\n" );
50 Properties::Properties( char *file ) :
53 instance = mlt_properties_load( file );
56 Properties::~Properties( )
58 mlt_properties_close( instance );
61 mlt_properties Properties::get_properties( )
66 int Properties::inc_ref( )
68 return mlt_properties_inc_ref( get_properties( ) );
71 int Properties::dec_ref( )
73 return mlt_properties_dec_ref( get_properties( ) );
76 bool Properties::is_valid( )
78 return get_properties( ) != NULL;
81 int Properties::count( )
83 return mlt_properties_count( get_properties( ) );
86 char *Properties::get( char *name )
88 return mlt_properties_get( get_properties( ), name );
91 int Properties::get_int( char *name )
93 return mlt_properties_get_int( get_properties( ), name );
96 double Properties::get_double( char *name )
98 return mlt_properties_get_double( get_properties( ), name );
101 void *Properties::get_data( char *name, int &size )
103 return mlt_properties_get_data( get_properties( ), name, &size );
106 int Properties::set( char *name, char *value )
108 return mlt_properties_set( get_properties( ), name, value );
111 int Properties::set( char *name, int value )
113 return mlt_properties_set_int( get_properties( ), name, value );
116 int Properties::set( char *name, double value )
118 return mlt_properties_set_double( get_properties( ), name, value );
121 int Properties::set( char *name, void *value, int size, mlt_destructor destructor, mlt_serialiser serialiser )
123 return mlt_properties_set_data( get_properties( ), name, value, size, destructor, serialiser );
126 int Properties::pass_values( Properties &that, char *prefix )
128 return mlt_properties_pass( get_properties( ), that.get_properties( ), prefix );
131 int Properties::parse( char *namevalue )
133 return mlt_properties_parse( get_properties( ), namevalue );
136 char *Properties::get_name( int index )
138 return mlt_properties_get_name( get_properties( ), index );
141 char *Properties::get( int index )
143 return mlt_properties_get_value( get_properties( ), index );
146 void *Properties::get_data( int index, int &size )
148 return mlt_properties_get_data_at( get_properties( ), index, &size );
151 void Properties::mirror( Properties &that )
153 mlt_properties_mirror( get_properties( ), that.get_properties( ) );
156 int Properties::inherit( Properties &that )
158 return mlt_properties_inherit( get_properties( ), that.get_properties( ) );
161 int Properties::rename( char *source, char *dest )
163 return mlt_properties_rename( get_properties( ), source, dest );
166 void Properties::dump( FILE *output )
168 mlt_properties_dump( get_properties( ), output );
171 void Properties::debug( char *title, FILE *output )
173 mlt_properties_debug( get_properties( ), title, output );
176 int Properties::save( char *file )
179 FILE *f = fopen( file, "w" );
192 void Properties::listen( char *id, void *object, mlt_listener listener )
195 mlt_event event = mlt_events_listen( get_properties( ), object, id, listener );
198 sprintf( key, "_%p", event );
199 mlt_properties_set_data( get_properties( ), key, event, 0, ( mlt_destructor )mlt_event_close, NULL );
203 Event *Properties::setup_wait_for( char *id )
205 return new Event( mlt_events_setup_wait_for( get_properties( ), id ) );
208 void Properties::wait_for( Event *event, bool destroy )
210 mlt_events_wait_for( get_properties( ), event->get_event( ) );
212 mlt_events_close_wait_for( get_properties( ), event->get_event( ) );