/src/vlc/include/vlc_vlm.h
Line | Count | Source (jump to first uncovered line) |
1 | | /***************************************************************************** |
2 | | * vlc_vlm.h: VLM core structures |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2000, 2001 VLC authors and VideoLAN |
5 | | * |
6 | | * Authors: Simon Latapie <garf@videolan.org> |
7 | | * Laurent Aimar <fenrir@videolan.org> |
8 | | * |
9 | | * This program is free software; you can redistribute it and/or modify it |
10 | | * under the terms of the GNU Lesser General Public License as published by |
11 | | * the Free Software Foundation; either version 2.1 of the License, or |
12 | | * (at your option) any later version. |
13 | | * |
14 | | * This program is distributed in the hope that it will be useful, |
15 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | * GNU Lesser General Public License for more details. |
18 | | * |
19 | | * You should have received a copy of the GNU Lesser General Public License |
20 | | * along with this program; if not, write to the Free Software Foundation, |
21 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
22 | | *****************************************************************************/ |
23 | | |
24 | | #ifndef VLC_VLM_H |
25 | | #define VLC_VLM_H 1 |
26 | | |
27 | | #include <vlc_input.h> |
28 | | #include <vlc_arrays.h> |
29 | | |
30 | | /** |
31 | | * \defgroup server VLM |
32 | | * \ingroup interface |
33 | | * VLC stream manager |
34 | | * |
35 | | * VLM is the server core in vlc that allows streaming of multiple media streams |
36 | | * at the same time. It provides broadcast, schedule and video on demand features |
37 | | * for streaming using several streaming and network protocols. |
38 | | * @{ |
39 | | * \file |
40 | | * VLC stream manager interface |
41 | | */ |
42 | | |
43 | | /** VLM media */ |
44 | | typedef struct |
45 | | { |
46 | | int64_t id; /*< numeric id for vlm_media_t item */ |
47 | | bool b_enabled; /*< vlm_media_t is enabled */ |
48 | | |
49 | | char *psz_name; /*< descriptive name of vlm_media_t item */ |
50 | | |
51 | | int i_input; /*< number of input options */ |
52 | | char **ppsz_input; /*< array of input options */ |
53 | | |
54 | | int i_option; /*< number of output options */ |
55 | | char **ppsz_option; /*< array of output options */ |
56 | | |
57 | | char *psz_output; /*< */ |
58 | | |
59 | | struct |
60 | | { |
61 | | bool b_loop; /*< this vlc_media_t broadcast item should loop */ |
62 | | } broadcast; /*< Broadcast specific information */ |
63 | | |
64 | | } vlm_media_t; |
65 | | |
66 | | /** VLM media instance */ |
67 | | typedef struct |
68 | | { |
69 | | char *psz_name; /*< vlm media instance descriptive name */ |
70 | | |
71 | | int64_t i_time; /*< vlm media instance vlm media current time */ |
72 | | int64_t i_length; /*< vlm media instance vlm media item length */ |
73 | | double d_position; /*< vlm media instance position in stream */ |
74 | | bool b_paused; /*< vlm media instance is paused */ |
75 | | float f_rate; // normal is 1.0f |
76 | | } vlm_media_instance_t; |
77 | | |
78 | | #if 0 |
79 | | typedef struct |
80 | | { |
81 | | |
82 | | } vlm_schedule_t |
83 | | #endif |
84 | | |
85 | | /** VLM events |
86 | | * You can catch vlm event by adding a callback on the variable "intf-event" |
87 | | * of the VLM object. |
88 | | * This variable is an address that will hold a vlm_event_t* value. |
89 | | */ |
90 | | enum vlm_event_type_e |
91 | | { |
92 | | /* */ |
93 | | VLM_EVENT_MEDIA_ADDED = 0x100, |
94 | | VLM_EVENT_MEDIA_REMOVED, |
95 | | VLM_EVENT_MEDIA_CHANGED, |
96 | | |
97 | | /* */ |
98 | | VLM_EVENT_MEDIA_INSTANCE_STARTED = 0x200, |
99 | | VLM_EVENT_MEDIA_INSTANCE_STOPPED, |
100 | | VLM_EVENT_MEDIA_INSTANCE_STATE, |
101 | | }; |
102 | | |
103 | | typedef enum vlm_state_e |
104 | | { |
105 | | VLM_INIT_S = 0, |
106 | | VLM_OPENING_S, |
107 | | VLM_PLAYING_S, |
108 | | VLM_PAUSE_S, |
109 | | VLM_END_S, |
110 | | VLM_ERROR_S, |
111 | | } vlm_state_e; |
112 | | |
113 | | typedef struct |
114 | | { |
115 | | int i_type; /* a vlm_event_type_e value */ |
116 | | int64_t id; /* Media ID */ |
117 | | const char *psz_name; /* Media name */ |
118 | | const char *psz_instance_name; /* Instance name or NULL */ |
119 | | vlm_state_e input_state; /* Input instance event type */ |
120 | | } vlm_event_t; |
121 | | |
122 | | /** VLM control query */ |
123 | | enum vlm_query_e |
124 | | { |
125 | | /* --- Media control */ |
126 | | /* Get all medias */ |
127 | | VLM_GET_MEDIAS, /* arg1=vlm_media_t ***, int *pi_media */ |
128 | | /* Delete all medias */ |
129 | | VLM_CLEAR_MEDIAS, /* no arg */ |
130 | | |
131 | | /* Add a new media */ |
132 | | VLM_ADD_MEDIA, /* arg1=vlm_media_t* arg2=int64_t *p_id res=can fail */ |
133 | | /* Delete an existing media */ |
134 | | VLM_DEL_MEDIA, /* arg1=int64_t id */ |
135 | | /* Change properties of an existing media (all fields but id) */ |
136 | | VLM_CHANGE_MEDIA, /* arg1=vlm_media_t* res=can fail */ |
137 | | /* Get 1 media by it's ID */ |
138 | | VLM_GET_MEDIA, /* arg1=int64_t id arg2=vlm_media_t ** */ |
139 | | /* Get media ID from its name */ |
140 | | VLM_GET_MEDIA_ID, /* arg1=const char *psz_name arg2=int64_t* */ |
141 | | |
142 | | /* Media instance control */ |
143 | | /* Get all media instances */ |
144 | | VLM_GET_MEDIA_INSTANCES, /* arg1=int64_t id arg2=vlm_media_instance_t *** arg3=int *pi_instance */ |
145 | | /* Delete all media instances */ |
146 | | VLM_CLEAR_MEDIA_INSTANCES, /* arg1=int64_t id */ |
147 | | /* Control broadcast instance */ |
148 | | VLM_START_MEDIA_BROADCAST_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index res=can fail */ |
149 | | /* Stop an instance */ |
150 | | VLM_STOP_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */ |
151 | | /* Pause an instance */ |
152 | | VLM_PAUSE_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */ |
153 | | /* Get instance position time (in microsecond) */ |
154 | | VLM_GET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t * */ |
155 | | /* Set instance position time (in microsecond) */ |
156 | | VLM_SET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t */ |
157 | | /* Get instance position ([0.0 .. 1.0]) */ |
158 | | VLM_GET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double * */ |
159 | | /* Set instance position ([0.0 .. 1.0]) */ |
160 | | VLM_SET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double */ |
161 | | |
162 | | /* Schedule control */ |
163 | | VLM_CLEAR_SCHEDULES, /* no arg */ |
164 | | /* TODO: missing schedule control */ |
165 | | |
166 | | /* */ |
167 | | }; |
168 | | |
169 | | |
170 | | /* VLM specific - structures and functions */ |
171 | | |
172 | | /* ok, here is the structure of a vlm_message: |
173 | | The parent node is ( name_of_the_command , NULL ), or |
174 | | ( name_of_the_command , message_error ) on error. |
175 | | If a node has children, it should not have a value (=NULL).*/ |
176 | | struct vlm_message_t |
177 | | { |
178 | | char *psz_name; /*< message name */ |
179 | | char *psz_value; /*< message value */ |
180 | | |
181 | | int i_child; /*< number of child messages */ |
182 | | vlm_message_t **child; /*< array of vlm_message_t */ |
183 | | }; |
184 | | |
185 | | |
186 | | #ifdef __cplusplus |
187 | | extern "C" { |
188 | | #endif |
189 | | |
190 | | VLC_API vlm_t * vlm_New( libvlc_int_t *, const char *path ); |
191 | | VLC_API void vlm_Delete( vlm_t * ); |
192 | | VLC_API int vlm_ExecuteCommand( vlm_t *, const char *, vlm_message_t ** ); |
193 | | VLC_API int vlm_Control( vlm_t *p_vlm, int i_query, ... ); |
194 | | |
195 | | VLC_API vlm_message_t * vlm_MessageSimpleNew( const char * ); |
196 | | VLC_API vlm_message_t * vlm_MessageNew( const char *, const char *, ... ) VLC_FORMAT( 2, 3 ); |
197 | | VLC_API vlm_message_t * vlm_MessageAdd( vlm_message_t *, vlm_message_t * ); |
198 | | VLC_API void vlm_MessageDelete( vlm_message_t * ); |
199 | | |
200 | | /* media helpers */ |
201 | | |
202 | | /** |
203 | | * Initialize a vlm_media_t instance |
204 | | * \param p_media vlm_media_t instance to initialize |
205 | | */ |
206 | | static inline void vlm_media_Init( vlm_media_t *p_media ) |
207 | 0 | { |
208 | 0 | memset( p_media, 0, sizeof(vlm_media_t) ); |
209 | 0 | p_media->id = 0; // invalid id |
210 | 0 | p_media->psz_name = NULL; |
211 | 0 | TAB_INIT( p_media->i_input, p_media->ppsz_input ); |
212 | 0 | TAB_INIT( p_media->i_option, p_media->ppsz_option ); |
213 | 0 | p_media->psz_output = NULL; |
214 | |
|
215 | 0 | p_media->broadcast.b_loop = false; |
216 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_Init Unexecuted instantiation: vlm.c:vlm_media_Init Unexecuted instantiation: vlm_event.c:vlm_media_Init Unexecuted instantiation: vlmshell.c:vlm_media_Init |
217 | | |
218 | | /** |
219 | | * Copy a vlm_media_t instance into another vlm_media_t instance |
220 | | * \param p_dst vlm_media_t instance to copy to |
221 | | * \param p_src vlm_media_t instance to copy from |
222 | | */ |
223 | | static inline void |
224 | | #ifndef __cplusplus |
225 | | vlm_media_Copy( vlm_media_t *restrict p_dst, const vlm_media_t *restrict p_src ) |
226 | | #else |
227 | | vlm_media_Copy( vlm_media_t *p_dst, const vlm_media_t *p_src ) |
228 | | #endif |
229 | 0 | { |
230 | 0 | int i; |
231 | |
|
232 | 0 | memset( p_dst, 0, sizeof(vlm_media_t) ); |
233 | 0 | p_dst->id = p_src->id; |
234 | 0 | p_dst->b_enabled = p_src->b_enabled; |
235 | 0 | if( p_src->psz_name ) |
236 | 0 | p_dst->psz_name = strdup( p_src->psz_name ); |
237 | |
|
238 | 0 | for( i = 0; i < p_src->i_input; i++ ) |
239 | 0 | TAB_APPEND_CAST( (char**), p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) ); |
240 | 0 | for( i = 0; i < p_src->i_option; i++ ) |
241 | 0 | TAB_APPEND_CAST( (char**), p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) ); |
242 | | |
243 | 0 | if( p_src->psz_output ) |
244 | 0 | p_dst->psz_output = strdup( p_src->psz_output ); |
245 | |
|
246 | 0 | p_dst->broadcast.b_loop = p_src->broadcast.b_loop; |
247 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_Copy Unexecuted instantiation: vlm.c:vlm_media_Copy Unexecuted instantiation: vlm_event.c:vlm_media_Copy Unexecuted instantiation: vlmshell.c:vlm_media_Copy |
248 | | |
249 | | /** |
250 | | * Cleanup and release memory associated with this vlm_media_t instance. |
251 | | * You still need to release p_media itself with vlm_media_Delete(). |
252 | | * \param p_media vlm_media_t to cleanup |
253 | | */ |
254 | | static inline void vlm_media_Clean( vlm_media_t *p_media ) |
255 | 0 | { |
256 | 0 | int i; |
257 | 0 | free( p_media->psz_name ); |
258 | |
|
259 | 0 | for( i = 0; i < p_media->i_input; i++ ) |
260 | 0 | free( p_media->ppsz_input[i]); |
261 | 0 | TAB_CLEAN(p_media->i_input, p_media->ppsz_input ); |
262 | |
|
263 | 0 | for( i = 0; i < p_media->i_option; i++ ) |
264 | 0 | free( p_media->ppsz_option[i]); |
265 | 0 | TAB_CLEAN(p_media->i_option, p_media->ppsz_option ); |
266 | |
|
267 | 0 | free( p_media->psz_output ); |
268 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_Clean Unexecuted instantiation: vlm.c:vlm_media_Clean Unexecuted instantiation: vlm_event.c:vlm_media_Clean Unexecuted instantiation: vlmshell.c:vlm_media_Clean |
269 | | |
270 | | /** |
271 | | * Allocate a new vlm_media_t instance |
272 | | * \return vlm_media_t instance |
273 | | */ |
274 | | static inline vlm_media_t *vlm_media_New(void) |
275 | 0 | { |
276 | 0 | vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) ); |
277 | 0 | if( p_media ) |
278 | 0 | vlm_media_Init( p_media ); |
279 | 0 | return p_media; |
280 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_New Unexecuted instantiation: vlm.c:vlm_media_New Unexecuted instantiation: vlm_event.c:vlm_media_New Unexecuted instantiation: vlmshell.c:vlm_media_New |
281 | | |
282 | | /** |
283 | | * Delete a vlm_media_t instance |
284 | | * \param p_media vlm_media_t instance to delete |
285 | | */ |
286 | | static inline void vlm_media_Delete( vlm_media_t *p_media ) |
287 | 0 | { |
288 | 0 | vlm_media_Clean( p_media ); |
289 | 0 | free( p_media ); |
290 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_Delete Unexecuted instantiation: vlm.c:vlm_media_Delete Unexecuted instantiation: vlm_event.c:vlm_media_Delete Unexecuted instantiation: vlmshell.c:vlm_media_Delete |
291 | | |
292 | | /** |
293 | | * Copy a vlm_media_t instance |
294 | | * \param p_src vlm_media_t instance to copy |
295 | | * \return vlm_media_t duplicate of p_src |
296 | | */ |
297 | | static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src ) |
298 | 0 | { |
299 | 0 | vlm_media_t *p_dst = vlm_media_New(); |
300 | 0 | if( p_dst ) |
301 | 0 | vlm_media_Copy( p_dst, p_src ); |
302 | 0 | return p_dst; |
303 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_Duplicate Unexecuted instantiation: vlm.c:vlm_media_Duplicate Unexecuted instantiation: vlm_event.c:vlm_media_Duplicate Unexecuted instantiation: vlmshell.c:vlm_media_Duplicate |
304 | | |
305 | | /* media instance helpers */ |
306 | | /** |
307 | | * Initialize vlm_media_instance_t |
308 | | * \param p_instance vlm_media_instance_t to initialize |
309 | | */ |
310 | | static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance ) |
311 | 0 | { |
312 | 0 | memset( p_instance, 0, sizeof(vlm_media_instance_t) ); |
313 | 0 | p_instance->psz_name = NULL; |
314 | 0 | p_instance->i_time = 0; |
315 | 0 | p_instance->i_length = 0; |
316 | 0 | p_instance->d_position = 0.0; |
317 | 0 | p_instance->b_paused = false; |
318 | 0 | p_instance->f_rate = 1.0f; |
319 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_instance_Init Unexecuted instantiation: vlm.c:vlm_media_instance_Init Unexecuted instantiation: vlm_event.c:vlm_media_instance_Init Unexecuted instantiation: vlmshell.c:vlm_media_instance_Init |
320 | | |
321 | | /** |
322 | | * Cleanup vlm_media_instance_t |
323 | | * \param p_instance vlm_media_instance_t to cleanup |
324 | | */ |
325 | | static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance ) |
326 | 0 | { |
327 | 0 | free( p_instance->psz_name ); |
328 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_instance_Clean Unexecuted instantiation: vlm.c:vlm_media_instance_Clean Unexecuted instantiation: vlm_event.c:vlm_media_instance_Clean Unexecuted instantiation: vlmshell.c:vlm_media_instance_Clean |
329 | | |
330 | | /** |
331 | | * Allocate a new vlm_media_instance_t |
332 | | * \return a new vlm_media_instance_t |
333 | | */ |
334 | | static inline vlm_media_instance_t *vlm_media_instance_New(void) |
335 | 0 | { |
336 | 0 | vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) ); |
337 | 0 | if( p_instance ) |
338 | 0 | vlm_media_instance_Init( p_instance ); |
339 | 0 | return p_instance; |
340 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_instance_New Unexecuted instantiation: vlm.c:vlm_media_instance_New Unexecuted instantiation: vlm_event.c:vlm_media_instance_New Unexecuted instantiation: vlmshell.c:vlm_media_instance_New |
341 | | |
342 | | /** |
343 | | * Delete a vlm_media_instance_t |
344 | | * \param p_instance vlm_media_instance_t to delete |
345 | | */ |
346 | | static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance ) |
347 | 0 | { |
348 | 0 | vlm_media_instance_Clean( p_instance ); |
349 | 0 | free( p_instance ); |
350 | 0 | } Unexecuted instantiation: libvlc.c:vlm_media_instance_Delete Unexecuted instantiation: vlm.c:vlm_media_instance_Delete Unexecuted instantiation: vlm_event.c:vlm_media_instance_Delete Unexecuted instantiation: vlmshell.c:vlm_media_instance_Delete |
351 | | |
352 | | #ifdef __cplusplus |
353 | | } |
354 | | #endif |
355 | | |
356 | | /**@}*/ |
357 | | |
358 | | #endif |