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::lock( )
87 mlt_properties_lock( get_properties( ) );
90 void Properties::unlock( )
92 mlt_properties_unlock( get_properties( ) );
95 void Properties::block( void *object )
97 mlt_events_block( get_properties( ), object != NULL ? object : get_properties( ) );
100 void Properties::unblock( void *object )
102 mlt_events_unblock( get_properties( ), object != NULL ? object : get_properties( ) );
105 void Properties::fire_event( const char *event )
107 mlt_events_fire( get_properties( ), event, NULL );
110 bool Properties::is_valid( )
112 return get_properties( ) != NULL;
115 int Properties::count( )
117 return mlt_properties_count( get_properties( ) );
120 char *Properties::get( const char *name )
122 return mlt_properties_get( get_properties( ), name );
125 int Properties::get_int( const char *name )
127 return mlt_properties_get_int( get_properties( ), name );
130 int64_t Properties::get_int64( const char *name )
132 return mlt_properties_get_int64( get_properties( ), name );
135 double Properties::get_double( const char *name )
137 return mlt_properties_get_double( get_properties( ), name );
140 void *Properties::get_data( const char *name, int &size )
142 return mlt_properties_get_data( get_properties( ), name, &size );
145 void *Properties::get_data( const char *name )
147 return mlt_properties_get_data( get_properties( ), name, NULL );
150 int Properties::set( const char *name, const char *value )
152 return mlt_properties_set( get_properties( ), name, value );
155 int Properties::set( const char *name, int value )
157 return mlt_properties_set_int( get_properties( ), name, value );
160 int Properties::set( const char *name, int64_t value )
162 return mlt_properties_set_int64( get_properties( ), name, value );
165 int Properties::set( const char *name, double value )
167 return mlt_properties_set_double( get_properties( ), name, value );
170 int Properties::set( const char *name, void *value, int size, mlt_destructor destructor, mlt_serialiser serialiser )
172 return mlt_properties_set_data( get_properties( ), name, value, size, destructor, serialiser );
175 void Properties::pass_property( Properties &that, const char *name )
177 return mlt_properties_pass_property( get_properties( ), that.get_properties( ), name );
180 int Properties::pass_values( Properties &that, const char *prefix )
182 return mlt_properties_pass( get_properties( ), that.get_properties( ), prefix );
185 int Properties::pass_list( Properties &that, const char *list )
187 return mlt_properties_pass_list( get_properties( ), that.get_properties( ), list );
190 int Properties::parse( const char *namevalue )
192 return mlt_properties_parse( get_properties( ), namevalue );
195 char *Properties::get_name( int index )
197 return mlt_properties_get_name( get_properties( ), index );
200 char *Properties::get( int index )
202 return mlt_properties_get_value( get_properties( ), index );
205 void *Properties::get_data( int index, int &size )
207 return mlt_properties_get_data_at( get_properties( ), index, &size );
210 void Properties::mirror( Properties &that )
212 mlt_properties_mirror( get_properties( ), that.get_properties( ) );
215 int Properties::inherit( Properties &that )
217 return mlt_properties_inherit( get_properties( ), that.get_properties( ) );
220 int Properties::rename( const char *source, const char *dest )
222 return mlt_properties_rename( get_properties( ), source, dest );
225 void Properties::dump( FILE *output )
227 mlt_properties_dump( get_properties( ), output );
230 void Properties::debug( const char *title, FILE *output )
232 mlt_properties_debug( get_properties( ), title, output );
235 void Properties::load( const char *file )
237 mlt_properties properties = mlt_properties_load( file );
238 if ( properties != NULL )
239 mlt_properties_pass( get_properties( ), properties, "" );
240 mlt_properties_close( properties );
243 int Properties::save( const char *file )
246 return mlt_properties_save( get_properties( ), file );
249 FILE *f = fopen( file, "w" );
263 #if defined( __DARWIN__ ) && GCC_VERSION < 40000
265 Event *Properties::listen( const char *id, void *object, void (*listener)( ... ) )
267 mlt_event event = mlt_events_listen( get_properties( ), object, id, ( mlt_listener )listener );
268 return new Event( event );
273 Event *Properties::listen( const char *id, void *object, mlt_listener listener )
275 mlt_event event = mlt_events_listen( get_properties( ), object, id, listener );
276 return new Event( event );
281 Event *Properties::setup_wait_for( const char *id )
283 return new Event( mlt_events_setup_wait_for( get_properties( ), id ) );
286 void Properties::delete_event( Event *event )
291 void Properties::wait_for( Event *event, bool destroy )
293 mlt_events_wait_for( get_properties( ), event->get_event( ) );
295 mlt_events_close_wait_for( get_properties( ), event->get_event( ) );
298 void Properties::wait_for( const char *id )
300 Event *event = setup_wait_for( id );
305 bool Properties::is_sequence( )
307 return mlt_properties_is_sequence( get_properties( ) );
310 Properties *Properties::parse_yaml( const char *file )
312 return new Properties( mlt_properties_parse_yaml( file ) );
315 char *Properties::serialise_yaml( )
317 return mlt_properties_serialise_yaml( get_properties( ) );
320 int Properties::preset( const char *name )
322 return mlt_properties_preset( get_properties(), name );
325 int Properties::set_lcnumeric( const char *locale )
327 return mlt_properties_set_lcnumeric( get_properties(), locale );
330 const char *Properties::get_lcnumeric( )
332 return mlt_properties_get_lcnumeric( get_properties() );
335 char *Properties::get_time( const char *name, mlt_time_format format )
337 return mlt_properties_get_time( get_properties(), name, format );
340 mlt_color Properties::get_color( const char *name )
342 return mlt_properties_get_color( get_properties(), name );
345 int Properties::set( const char *name, mlt_color value )
347 return mlt_properties_set_color( get_properties(), name, value );
350 char *Properties::anim_get( const char *name, int position, int length )
352 return mlt_properties_anim_get( get_properties(), name, position, length );
355 int Properties::anim_set( const char *name, const char *value, int position, int length )
357 return mlt_properties_anim_set( get_properties(), name, value, position, length );
360 int Properties::anim_get_int( const char *name, int position, int length )
362 return mlt_properties_anim_get_int( get_properties(), name, position, length );
365 int Properties::anim_set( const char *name, int value, int position, int length, mlt_keyframe_type keyframe_type )
367 return mlt_properties_anim_set_int( get_properties(), name, value, position, length, keyframe_type );
370 double Properties::anim_get_double(const char *name, int position, int length)
372 return mlt_properties_anim_get_double( get_properties(), name, position, length );
375 int Properties::anim_set( const char *name, double value, int position, int length, mlt_keyframe_type keyframe_type )
377 return mlt_properties_anim_set_double( get_properties(), name, value, position, length, keyframe_type );
380 int Properties::set( const char *name, mlt_rect value )
382 return mlt_properties_set_rect( get_properties(), name, value );
385 int Properties::set( const char *name, double x, double y, double w, double h, double opacity )
387 mlt_rect value = { x, y, w, h, opacity };
388 return mlt_properties_set_rect( get_properties(), name, value );
391 mlt_rect Properties::get_rect( const char *name )
393 return mlt_properties_get_rect( get_properties(), name );
396 int Properties::anim_set( const char *name, mlt_rect value, int position, int length, mlt_keyframe_type keyframe_type )
398 return mlt_properties_anim_set_rect( get_properties(), name, value, position, length, keyframe_type );
401 mlt_rect Properties::anim_get_rect(const char *name, int position, int length)
403 return mlt_properties_anim_get_rect( get_properties(), name, position, length );