9490e6db32c3303ddbd26d527f53ff64f761e359
[melted] / src / mvcp / mvcp.h
1 /*
2 * mvcp.h -- High Level Client API for Melted
3 * Copyright (C) 2002-2009 Ushodaya Enterprises Limited
4 * Author: Charles Yates <charles.yates@pandora.be>
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #ifndef _MVCP_H_
22 #define _MVCP_H_
23
24 /* System header files */
25 #include <limits.h>
26
27 /* MLT Header files. */
28 #include <framework/mlt.h>
29
30 /* Application header files */
31 #include "mvcp_parser.h"
32 #include "mvcp_status.h"
33 #include "mvcp_notifier.h"
34
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39
40 /** Client error conditions
41 */
42
43 typedef enum
44 {
45 mvcp_ok = 0,
46 mvcp_malloc_failed,
47 mvcp_unknown_error,
48 mvcp_no_response,
49 mvcp_invalid_command,
50 mvcp_server_timeout,
51 mvcp_missing_argument,
52 mvcp_server_unavailable,
53 mvcp_unit_creation_failed,
54 mvcp_unit_unavailable,
55 mvcp_invalid_file,
56 mvcp_invalid_position
57 }
58 mvcp_error_code;
59
60 /** Clip index specification.
61 */
62
63 typedef enum
64 {
65 mvcp_absolute = 0,
66 mvcp_relative
67 }
68 mvcp_clip_offset;
69
70 /** Client structure.
71 */
72
73 typedef struct
74 {
75 mvcp_parser parser;
76 mvcp_response last_response;
77 }
78 *mvcp, mvcp_t;
79
80 /** Client API.
81 */
82
83 extern mvcp mvcp_init( mvcp_parser );
84
85 /* Connect to the mvcp parser instance */
86 extern mvcp_error_code mvcp_connect( mvcp );
87
88 /* Global functions */
89 extern mvcp_error_code mvcp_set( mvcp, char *, char * );
90 extern mvcp_error_code mvcp_get( mvcp, char *, char *, int );
91 extern mvcp_error_code mvcp_run( mvcp, char * );
92
93 /* Unit functions */
94 extern mvcp_error_code mvcp_unit_add( mvcp, char *, int * );
95 extern mvcp_error_code mvcp_unit_load( mvcp, int, char * );
96 extern mvcp_error_code mvcp_unit_load_clipped( mvcp, int, char *, int32_t, int32_t );
97 extern mvcp_error_code mvcp_unit_load_back( mvcp, int, char * );
98 extern mvcp_error_code mvcp_unit_load_back_clipped( mvcp, int, char *, int32_t, int32_t );
99 extern mvcp_error_code mvcp_unit_append( mvcp, int, char *, int32_t, int32_t );
100 extern mvcp_error_code mvcp_unit_receive( mvcp, int, char *, char * );
101 extern mvcp_error_code mvcp_unit_push( mvcp, int, char *, mlt_service );
102 extern mvcp_error_code mvcp_unit_clean( mvcp, int );
103 extern mvcp_error_code mvcp_unit_wipe( mvcp, int );
104 extern mvcp_error_code mvcp_unit_clear( mvcp, int );
105 extern mvcp_error_code mvcp_unit_clip_move( mvcp, int, mvcp_clip_offset, int, mvcp_clip_offset, int );
106 extern mvcp_error_code mvcp_unit_clip_remove( mvcp, int, mvcp_clip_offset, int );
107 extern mvcp_error_code mvcp_unit_remove_current_clip( mvcp, int );
108 extern mvcp_error_code mvcp_unit_clip_insert( mvcp, int, mvcp_clip_offset, int, char *, int32_t, int32_t );
109 extern mvcp_error_code mvcp_unit_play( mvcp, int );
110 extern mvcp_error_code mvcp_unit_play_at_speed( mvcp, int, int );
111 extern mvcp_error_code mvcp_unit_stop( mvcp, int );
112 extern mvcp_error_code mvcp_unit_pause( mvcp, int );
113 extern mvcp_error_code mvcp_unit_rewind( mvcp, int );
114 extern mvcp_error_code mvcp_unit_fast_forward( mvcp, int );
115 extern mvcp_error_code mvcp_unit_step( mvcp, int, int32_t );
116 extern mvcp_error_code mvcp_unit_goto( mvcp, int, int32_t );
117 extern mvcp_error_code mvcp_unit_clip_goto( mvcp, int, mvcp_clip_offset, int, int32_t );
118 extern mvcp_error_code mvcp_unit_clip_set_in( mvcp, int, mvcp_clip_offset, int, int32_t );
119 extern mvcp_error_code mvcp_unit_clip_set_out( mvcp, int, mvcp_clip_offset, int, int32_t );
120 extern mvcp_error_code mvcp_unit_set_in( mvcp, int, int32_t );
121 extern mvcp_error_code mvcp_unit_set_out( mvcp, int, int32_t );
122 extern mvcp_error_code mvcp_unit_clear_in( mvcp, int );
123 extern mvcp_error_code mvcp_unit_clear_out( mvcp, int );
124 extern mvcp_error_code mvcp_unit_clear_in_out( mvcp, int );
125 extern mvcp_error_code mvcp_unit_set( mvcp, int, const char *, const char * );
126 extern mvcp_error_code mvcp_unit_get( mvcp, int, char *, char *, int );
127 extern mvcp_error_code mvcp_unit_status( mvcp, int, mvcp_status );
128 extern mvcp_error_code mvcp_unit_transfer( mvcp, int, int );
129
130 /* Notifier functionality. */
131 extern mvcp_notifier mvcp_get_notifier( mvcp );
132
133 /** Structure for the directory.
134 */
135
136 typedef struct
137 {
138 char *directory;
139 mvcp_response response;
140 }
141 *mvcp_dir, mvcp_dir_t;
142
143 /** Directory entry structure.
144 */
145
146 typedef struct
147 {
148 int dir;
149 char name[ NAME_MAX ];
150 char full[ PATH_MAX + NAME_MAX ];
151 unsigned long long size;
152 }
153 *mvcp_dir_entry, mvcp_dir_entry_t;
154
155 /* Directory reading. */
156 extern mvcp_dir mvcp_dir_init( mvcp, const char * );
157 extern mvcp_error_code mvcp_dir_get_error_code( mvcp_dir );
158 extern mvcp_error_code mvcp_dir_get( mvcp_dir, int, mvcp_dir_entry );
159 extern int mvcp_dir_count( mvcp_dir );
160 extern void mvcp_dir_close( mvcp_dir );
161
162 /** Structure for the list.
163 */
164
165 typedef struct
166 {
167 int generation;
168 mvcp_response response;
169 }
170 *mvcp_list, mvcp_list_t;
171
172 /** List entry structure.
173 */
174
175 typedef struct
176 {
177 int clip;
178 char full[ PATH_MAX + NAME_MAX ];
179 int32_t in;
180 int32_t out;
181 int32_t max;
182 int32_t size;
183 float fps;
184 }
185 *mvcp_list_entry, mvcp_list_entry_t;
186
187 /* List reading. */
188 extern mvcp_list mvcp_list_init( mvcp, int );
189 extern mvcp_error_code mvcp_list_get_error_code( mvcp_list );
190 extern mvcp_error_code mvcp_list_get( mvcp_list, int, mvcp_list_entry );
191 extern int mvcp_list_count( mvcp_list );
192 extern void mvcp_list_close( mvcp_list );
193
194 /** Structure for nodes.
195 */
196
197 typedef struct
198 {
199 mvcp_response response;
200 }
201 *mvcp_nodes, mvcp_nodes_t;
202
203 /** Node entry structure.
204 */
205
206 typedef struct
207 {
208 int node;
209 char guid[ 17 ];
210 char name[ 1024 ];
211 }
212 *mvcp_node_entry, mvcp_node_entry_t;
213
214 /* Node reading. */
215 extern mvcp_nodes mvcp_nodes_init( mvcp );
216 extern mvcp_error_code mvcp_nodes_get_error_code( mvcp_nodes );
217 extern mvcp_error_code mvcp_nodes_get( mvcp_nodes, int, mvcp_node_entry );
218 extern int mvcp_nodes_count( mvcp_nodes );
219 extern void mvcp_nodes_close( mvcp_nodes );
220
221 /** Structure for units.
222 */
223
224 typedef struct
225 {
226 mvcp_response response;
227 }
228 *mvcp_units, mvcp_units_t;
229
230 /** Unit entry structure.
231 */
232
233 typedef struct
234 {
235 int unit;
236 int node;
237 char guid[ 512 ];
238 int online;
239 }
240 *mvcp_unit_entry, mvcp_unit_entry_t;
241
242 /* Unit reading. */
243 extern mvcp_units mvcp_units_init( mvcp );
244 extern mvcp_error_code mvcp_units_get_error_code( mvcp_units );
245 extern mvcp_error_code mvcp_units_get( mvcp_units, int, mvcp_unit_entry );
246 extern int mvcp_units_count( mvcp_units );
247 extern void mvcp_units_close( mvcp_units );
248
249 /* Miscellaenous functions */
250 extern mvcp_response mvcp_get_last_response( mvcp );
251 extern const char *mvcp_error_description( mvcp_error_code );
252
253 /* Courtesy functions. */
254 extern mvcp_error_code mvcp_execute( mvcp, size_t, const char *, ... );
255 extern mvcp_error_code mvcp_push( mvcp, mlt_service, size_t, const char *, ... );
256
257 /* Close function. */
258 extern void mvcp_close( mvcp );
259
260 #ifdef __cplusplus
261 }
262 #endif
263
264 #endif