2 * MltProperties.cpp - MLT Wrapper
3 * Copyright (C) 2004-2005 Charles Yates
4 * Author: Charles Yates <charles.yates@pandora.be>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, 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( void *properties ) :
49 instance( mlt_properties( properties ) )
54 Properties::Properties( const char *file ) :
57 instance = mlt_properties_load( file );
60 Properties::~Properties( )
62 mlt_properties_close( instance );
65 mlt_properties Properties::get_properties( )
70 int Properties::inc_ref( )
72 return mlt_properties_inc_ref( get_properties( ) );
75 int Properties::dec_ref( )
77 return mlt_properties_dec_ref( get_properties( ) );
80 int Properties::ref_count( )
82 return mlt_properties_ref_count( get_properties( ) );
85 void Properties::block( void *object )
87 mlt_events_block( get_properties( ), object != NULL ? object : get_properties( ) );
90 void Properties::unblock( void *object )
92 mlt_events_unblock( get_properties( ), object != NULL ? object : get_properties( ) );
95 void Properties::fire_event( const char *event )
97 mlt_events_fire( get_properties( ), event, NULL );
100 bool Properties::is_valid( )
102 return get_properties( ) != NULL;
105 int Properties::count( )
107 return mlt_properties_count( get_properties( ) );
110 char *Properties::get( const char *name )
112 return mlt_properties_get( get_properties( ), name );
115 int Properties::get_int( const char *name )
117 return mlt_properties_get_int( get_properties( ), name );
120 int64_t Properties::get_int64( const char *name )
122 return mlt_properties_get_int64( get_properties( ), name );
125 double Properties::get_double( const char *name )
127 return mlt_properties_get_double( get_properties( ), name );
130 void *Properties::get_data( const char *name, int &size )
132 return mlt_properties_get_data( get_properties( ), name, &size );
135 void *Properties::get_data( const char *name )
137 return mlt_properties_get_data( get_properties( ), name, NULL );
140 int Properties::set( const char *name, const char *value )
142 return mlt_properties_set( get_properties( ), name, value );
145 int Properties::set( const char *name, int value )
147 return mlt_properties_set_int( get_properties( ), name, value );
150 int Properties::set( const char *name, int64_t value )
152 return mlt_properties_set_int64( get_properties( ), name, value );
155 int Properties::set( const char *name, double value )
157 return mlt_properties_set_double( get_properties( ), name, value );
160 int Properties::set( const char *name, void *value, int size, mlt_destructor destructor, mlt_serialiser serialiser )
162 return mlt_properties_set_data( get_properties( ), name, value, size, destructor, serialiser );
165 void Properties::pass_property( Properties &that, const char *name )
167 return mlt_properties_pass_property( get_properties( ), that.get_properties( ), name );
170 int Properties::pass_values( Properties &that, const char *prefix )
172 return mlt_properties_pass( get_properties( ), that.get_properties( ), prefix );
175 int Properties::pass_list( Properties &that, const char *list )
177 return mlt_properties_pass_list( get_properties( ), that.get_properties( ), list );
180 int Properties::parse( const char *namevalue )
182 return mlt_properties_parse( get_properties( ), namevalue );
185 char *Properties::get_name( int index )
187 return mlt_properties_get_name( get_properties( ), index );
190 char *Properties::get( int index )
192 return mlt_properties_get_value( get_properties( ), index );
195 void *Properties::get_data( int index, int &size )
197 return mlt_properties_get_data_at( get_properties( ), index, &size );
200 void Properties::mirror( Properties &that )
202 mlt_properties_mirror( get_properties( ), that.get_properties( ) );
205 int Properties::inherit( Properties &that )
207 return mlt_properties_inherit( get_properties( ), that.get_properties( ) );
210 int Properties::rename( const char *source, const char *dest )
212 return mlt_properties_rename( get_properties( ), source, dest );
215 void Properties::dump( FILE *output )
217 mlt_properties_dump( get_properties( ), output );
220 void Properties::debug( const char *title, FILE *output )
222 mlt_properties_debug( get_properties( ), title, output );
225 void Properties::load( const char *file )
227 mlt_properties properties = mlt_properties_load( file );
228 if ( properties != NULL )
229 mlt_properties_pass( get_properties( ), properties, "" );
230 mlt_properties_close( properties );
233 int Properties::save( const char *file )
236 return mlt_properties_save( get_properties( ), file );
239 FILE *f = fopen( file, "w" );
253 #if defined( __DARWIN__ ) && GCC_VERSION < 40000
255 Event *Properties::listen( const char *id, void *object, void (*listener)( ... ) )
257 mlt_event event = mlt_events_listen( get_properties( ), object, id, ( mlt_listener )listener );
258 return new Event( event );
263 Event *Properties::listen( const char *id, void *object, mlt_listener listener )
265 mlt_event event = mlt_events_listen( get_properties( ), object, id, listener );
266 return new Event( event );
271 Event *Properties::setup_wait_for( const char *id )
273 return new Event( mlt_events_setup_wait_for( get_properties( ), id ) );
276 void Properties::delete_event( Event *event )
281 void Properties::wait_for( Event *event, bool destroy )
283 mlt_events_wait_for( get_properties( ), event->get_event( ) );
285 mlt_events_close_wait_for( get_properties( ), event->get_event( ) );
288 bool Properties::is_sequence( )
290 return mlt_properties_is_sequence( get_properties( ) );
293 Properties *Properties::parse_yaml( const char *file )
295 return new Properties( mlt_properties_parse_yaml( file ) );
298 char *Properties::serialise_yaml( )
300 return mlt_properties_serialise_yaml( get_properties( ) );