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( ) )
42 Properties::Properties( mlt_properties properties ) :
43 instance( properties )
48 Properties::Properties( const char *file ) :
51 instance = mlt_properties_load( file );
54 Properties::~Properties( )
56 mlt_properties_close( instance );
59 mlt_properties Properties::get_properties( )
64 int Properties::inc_ref( )
66 return mlt_properties_inc_ref( get_properties( ) );
69 int Properties::dec_ref( )
71 return mlt_properties_dec_ref( get_properties( ) );
74 int Properties::ref_count( )
76 return mlt_properties_ref_count( get_properties( ) );
79 void Properties::block( void *object )
81 mlt_events_block( get_properties( ), object != NULL ? object : get_properties( ) );
84 void Properties::unblock( void *object )
86 mlt_events_unblock( get_properties( ), object != NULL ? object : get_properties( ) );
89 void Properties::fire_event( const char *event )
91 mlt_events_fire( get_properties( ), event, NULL );
94 bool Properties::is_valid( )
96 return get_properties( ) != NULL;
99 int Properties::count( )
101 return mlt_properties_count( get_properties( ) );
104 char *Properties::get( const char *name )
106 return mlt_properties_get( get_properties( ), name );
109 int Properties::get_int( const char *name )
111 return mlt_properties_get_int( get_properties( ), name );
114 double Properties::get_double( const char *name )
116 return mlt_properties_get_double( get_properties( ), name );
119 void *Properties::get_data( const char *name, int &size )
121 return mlt_properties_get_data( get_properties( ), name, &size );
124 void *Properties::get_data( const char *name )
126 return mlt_properties_get_data( get_properties( ), name, NULL );
129 int Properties::set( const char *name, const char *value )
131 return mlt_properties_set( get_properties( ), name, value );
134 int Properties::set( const char *name, int value )
136 return mlt_properties_set_int( get_properties( ), name, value );
139 int Properties::set( const char *name, double value )
141 return mlt_properties_set_double( get_properties( ), name, value );
144 int Properties::set( const char *name, void *value, int size, mlt_destructor destructor, mlt_serialiser serialiser )
146 return mlt_properties_set_data( get_properties( ), name, value, size, destructor, serialiser );
149 int Properties::pass_values( Properties &that, const char *prefix )
151 return mlt_properties_pass( get_properties( ), that.get_properties( ), prefix );
154 int Properties::parse( const char *namevalue )
156 return mlt_properties_parse( get_properties( ), namevalue );
159 char *Properties::get_name( int index )
161 return mlt_properties_get_name( get_properties( ), index );
164 char *Properties::get( int index )
166 return mlt_properties_get_value( get_properties( ), index );
169 void *Properties::get_data( int index, int &size )
171 return mlt_properties_get_data_at( get_properties( ), index, &size );
174 void Properties::mirror( Properties &that )
176 mlt_properties_mirror( get_properties( ), that.get_properties( ) );
179 int Properties::inherit( Properties &that )
181 return mlt_properties_inherit( get_properties( ), that.get_properties( ) );
184 int Properties::rename( const char *source, const char *dest )
186 return mlt_properties_rename( get_properties( ), source, dest );
189 void Properties::dump( FILE *output )
191 mlt_properties_dump( get_properties( ), output );
194 void Properties::debug( const char *title, FILE *output )
196 mlt_properties_debug( get_properties( ), title, output );
199 void Properties::load( const char *file )
201 mlt_properties properties = mlt_properties_load( file );
202 if ( properties != NULL )
203 mlt_properties_pass( get_properties( ), properties, "" );
204 mlt_properties_close( properties );
207 int Properties::save( const char *file )
210 return mlt_properties_save( get_properties( ), file );
213 FILE *f = fopen( file, "w" );
227 #if defined( __DARWIN__ ) && GCC_VERSION < 40000
229 Event *Properties::listen( char *id, void *object, void (*listener)( ... ) )
231 mlt_event event = mlt_events_listen( get_properties( ), object, id, ( mlt_listener )listener );
232 return new Event( event );
237 Event *Properties::listen( char *id, void *object, mlt_listener listener )
239 mlt_event event = mlt_events_listen( get_properties( ), object, id, listener );
240 return new Event( event );
245 Event *Properties::setup_wait_for( const char *id )
247 return new Event( mlt_events_setup_wait_for( get_properties( ), id ) );
250 void Properties::delete_event( Event *event )
255 void Properties::wait_for( Event *event, bool destroy )
257 mlt_events_wait_for( get_properties( ), event->get_event( ) );
259 mlt_events_close_wait_for( get_properties( ), event->get_event( ) );