1 /**
2  * MltProperties.h - MLT Wrapper
3  * Copyright (C) 2004-2021 Meltytech, LLC
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef MLTPP_PROPERTIES_H
21 #define MLTPP_PROPERTIES_H
22 
23 #include "MltConfig.h"
24 
25 #include <stdio.h>
26 #include <framework/mlt.h>
27 
28 namespace Mlt
29 {
30 	class Event;
31 	class Animation;
32 
33 	/** Abstract Properties class.
34 	 */
35 
36 	class MLTPP_DECLSPEC Properties
37 	{
38 		private:
39 			mlt_properties instance;
40 		public:
41 			Properties( );
42 			Properties( bool dummy );
43 			Properties( Properties &properties );
44 			Properties( const Properties &properties );
45 			Properties( mlt_properties properties );
46 			Properties( void *properties );
47 			Properties( const char *file );
48 			virtual ~Properties( );
49 			Properties& operator=( const Properties &properties );
50 			virtual mlt_properties get_properties( );
51 			int inc_ref( );
52 			int dec_ref( );
53 			int ref_count( );
54 			void lock( );
55 			void unlock( );
56 			void block( void *object = NULL );
57 			void unblock( void *object = NULL );
58 			int fire_event( const char *event );
59 			bool is_valid( );
60 			int count( );
61 			char *get( const char *name );
62 			int get_int( const char *name );
63 			int64_t get_int64( const char *name );
64 			double get_double( const char *name );
65 			void *get_data( const char *name, int &size );
66 			void *get_data( const char *name );
67 			int set( const char *name, const char *value );
68 			int set_string( const char *name, const char *value );
69 			int set( const char *name, int value );
70 			int set( const char *name, int64_t value );
71 			int set( const char *name, double value );
72 			int set( const char *name, void *value, int size, mlt_destructor destroy = NULL, mlt_serialiser serial = NULL );
73 			void pass_property( Properties &that, const char *name );
74 			int pass_values( Properties &that, const char *prefix );
75 			int pass_list( Properties &that, const char *list );
76 			int parse( const char *namevalue );
77 			char *get_name( int index );
78 			char *get( int index );
79 			char *get( int index, mlt_time_format );
80 			void *get_data( int index, int &size );
81 			void mirror( Properties &that );
82 			int inherit( Properties &that );
83 			int rename( const char *source, const char *dest );
84 			void dump( FILE *output = stderr );
85 			void debug( const char *title = "Object", FILE *output = stderr );
86 			void load( const char *file );
87 			int save( const char *file );
88 			Event *listen( const char *id, void *object, mlt_listener );
89 			static void delete_event( Event * );
90 			Event *setup_wait_for( const char *id );
91 			void wait_for( Event *, bool destroy = true );
92 			void wait_for( const char *id );
93 			bool is_sequence( );
94 			static Properties *parse_yaml( const char *file );
95 			char *serialise_yaml( );
96 			int preset( const char *name );
97 			int set_lcnumeric( const char *locale );
98 			const char *get_lcnumeric( );
99 			void clear( const char *name );
100 			bool property_exists( const char *name );
101 
102 			char *get_time( const char *name, mlt_time_format = mlt_time_smpte_df );
103 			char *frames_to_time( int, mlt_time_format = mlt_time_smpte_df );
104 			int time_to_frames( const char* time );
105 
106 			mlt_color get_color( const char *name );
107 			int set( const char *name , mlt_color value );
108 
109 			char* anim_get( const char *name, int position, int length = 0 );
110 			int anim_set( const char *name, const char *value, int position, int length = 0 );
111 			int anim_get_int( const char *name, int position, int length = 0 );
112 			int anim_set( const char *name, int value, int position, int length = 0,
113 				mlt_keyframe_type keyframe_type = mlt_keyframe_linear );
114 			double anim_get_double( const char *name, int position, int length = 0 );
115 			int anim_set( const char *name, double value, int position, int length = 0,
116 				mlt_keyframe_type keyframe_type = mlt_keyframe_linear );
117 
118 			int set( const char *name, mlt_rect value );
119 			int set( const char *name, double x, double y, double w, double h, double opacity = 1.0 );
120 			mlt_rect get_rect( const char* name );
121 			int anim_set( const char *name, mlt_rect value, int position, int length = 0,
122 				mlt_keyframe_type keyframe_type = mlt_keyframe_linear );
123 			mlt_rect anim_get_rect( const char *name, int position, int length = 0 );
124 			mlt_animation get_animation( const char *name );
125 			Animation* get_anim( const char *name );
126 	};
127 }
128 
129 #endif
130