VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_vlm.h
Go to the documentation of this file.
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 */
44typedef struct
46 int64_t id; /*< numeric id for vlm_media_t item */
47 bool b_enabled; /*< vlm_media_t is enabled */
49 char *psz_name; /*< descriptive name of vlm_media_t item */
51 int i_input; /*< number of input options */
52 char **ppsz_input; /*< array of input options */
54 int i_option; /*< number of output options */
55 char **ppsz_option; /*< array of output options */
57 char *psz_output; /*< */
59 struct
60 {
61 bool b_loop; /*< this vlc_media_t broadcast item should loop */
62 } broadcast; /*< Broadcast specific information */
65
66/** VLM media instance */
67typedef struct
69 char *psz_name; /*< vlm media instance descriptive name */
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
77
78#if 0
79typedef 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 */
103typedef enum vlm_state_e
113typedef struct
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 */
121
122/** VLM control query */
123enum vlm_query_e
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 */
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* */
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 */
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).*/
176struct vlm_message_t
178 char *psz_name; /*< message name */
179 char *psz_value; /*< message value */
181 int i_child; /*< number of child messages */
182 vlm_message_t **child; /*< array of vlm_message_t */
184
185
186#ifdef __cplusplus
187extern "C" {
188#endif
189
190VLC_API vlm_t * vlm_New( libvlc_int_t *, const char *path );
191VLC_API void vlm_Delete( vlm_t * );
192VLC_API int vlm_ExecuteCommand( vlm_t *, const char *, vlm_message_t ** );
193VLC_API int vlm_Control( vlm_t *p_vlm, int i_query, ... );
194
196VLC_API vlm_message_t * vlm_MessageNew( const char *, const char *, ... ) VLC_FORMAT( 2, 3 );
199
200/* media helpers */
201
202/**
203 * Initialize a vlm_media_t instance
204 * \param p_media vlm_media_t instance to initialize
205 */
206static inline void vlm_media_Init( vlm_media_t *p_media )
208 memset( p_media, 0, sizeof(vlm_media_t) );
209 p_media->id = 0; // invalid id
210 p_media->psz_name = NULL;
211 TAB_INIT( p_media->i_input, p_media->ppsz_input );
212 TAB_INIT( p_media->i_option, p_media->ppsz_option );
213 p_media->psz_output = NULL;
214
215 p_media->broadcast.b_loop = false;
216}
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 */
223static inline void
224#ifndef __cplusplus
225vlm_media_Copy( vlm_media_t *restrict p_dst, const vlm_media_t *restrict p_src )
226#else
227vlm_media_Copy( vlm_media_t *p_dst, const vlm_media_t *p_src )
228#endif
229{
230 int i;
231
232 memset( p_dst, 0, sizeof(vlm_media_t) );
233 p_dst->id = p_src->id;
234 p_dst->b_enabled = p_src->b_enabled;
235 if( p_src->psz_name )
236 p_dst->psz_name = strdup( p_src->psz_name );
237
238 for( i = 0; i < p_src->i_input; i++ )
239 TAB_APPEND_CAST( (char**), p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
240 for( i = 0; i < p_src->i_option; i++ )
241 TAB_APPEND_CAST( (char**), p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
242
243 if( p_src->psz_output )
244 p_dst->psz_output = strdup( p_src->psz_output );
245
246 p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
247}
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 */
254static inline void vlm_media_Clean( vlm_media_t *p_media )
256 int i;
257 free( p_media->psz_name );
258
259 for( i = 0; i < p_media->i_input; i++ )
260 free( p_media->ppsz_input[i]);
261 TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
262
263 for( i = 0; i < p_media->i_option; i++ )
264 free( p_media->ppsz_option[i]);
265 TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
266
267 free( p_media->psz_output );
268}
269
270/**
271 * Allocate a new vlm_media_t instance
272 * \return vlm_media_t instance
273 */
274static inline vlm_media_t *vlm_media_New(void)
276 vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
277 if( p_media )
278 vlm_media_Init( p_media );
279 return p_media;
280}
281
282/**
283 * Delete a vlm_media_t instance
284 * \param p_media vlm_media_t instance to delete
285 */
286static inline void vlm_media_Delete( vlm_media_t *p_media )
288 vlm_media_Clean( p_media );
289 free( p_media );
290}
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 */
297static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
299 vlm_media_t *p_dst = vlm_media_New();
300 if( p_dst )
301 vlm_media_Copy( p_dst, p_src );
302 return p_dst;
303}
304
305/* media instance helpers */
306/**
307 * Initialize vlm_media_instance_t
308 * \param p_instance vlm_media_instance_t to initialize
309 */
310static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
312 memset( p_instance, 0, sizeof(vlm_media_instance_t) );
313 p_instance->psz_name = NULL;
314 p_instance->i_time = 0;
315 p_instance->i_length = 0;
316 p_instance->d_position = 0.0;
317 p_instance->b_paused = false;
318 p_instance->f_rate = 1.0f;
319}
320
321/**
322 * Cleanup vlm_media_instance_t
323 * \param p_instance vlm_media_instance_t to cleanup
324 */
325static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
327 free( p_instance->psz_name );
328}
329
330/**
331 * Allocate a new vlm_media_instance_t
332 * \return a new vlm_media_instance_t
333 */
336 vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
337 if( p_instance )
338 vlm_media_instance_Init( p_instance );
339 return p_instance;
340}
341
342/**
343 * Delete a vlm_media_instance_t
344 * \param p_instance vlm_media_instance_t to delete
345 */
346static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
348 vlm_media_instance_Clean( p_instance );
349 free( p_instance );
350}
351
352#ifdef __cplusplus
353}
354#endif
355
356/**@}*/
357
358#endif
#define VLC_API
Definition fourcc_gen.c:31
#define VLC_FORMAT(x, y)
String format function annotation.
Definition vlc_common.h:193
vlm_message_t * vlm_MessageSimpleNew(const char *)
Definition missing.c:78
vlm_t * vlm_New(libvlc_int_t *, const char *path)
Definition vlm.c:118
static void vlm_media_instance_Clean(vlm_media_instance_t *p_instance)
Cleanup vlm_media_instance_t.
Definition vlc_vlm.h:326
vlm_state_e
Definition vlc_vlm.h:105
vlm_message_t * vlm_MessageNew(const char *, const char *,...)
Definition missing.c:84
static vlm_media_instance_t * vlm_media_instance_New(void)
Allocate a new vlm_media_instance_t.
Definition vlc_vlm.h:335
static void vlm_media_Delete(vlm_media_t *p_media)
Delete a vlm_media_t instance.
Definition vlc_vlm.h:287
static void vlm_media_Clean(vlm_media_t *p_media)
Cleanup and release memory associated with this vlm_media_t instance.
Definition vlc_vlm.h:255
vlm_message_t * vlm_MessageAdd(vlm_message_t *, vlm_message_t *)
Definition missing.c:65
static vlm_media_t * vlm_media_Duplicate(vlm_media_t *p_src)
Copy a vlm_media_t instance.
Definition vlc_vlm.h:298
static void vlm_media_Copy(vlm_media_t *restrict p_dst, const vlm_media_t *restrict p_src)
Copy a vlm_media_t instance into another vlm_media_t instance.
Definition vlc_vlm.h:226
void vlm_MessageDelete(vlm_message_t *)
Definition missing.c:72
int vlm_Control(vlm_t *p_vlm, int i_query,...)
Definition vlm.c:965
static vlm_media_t * vlm_media_New(void)
Allocate a new vlm_media_t instance.
Definition vlc_vlm.h:275
static void vlm_media_instance_Delete(vlm_media_instance_t *p_instance)
Delete a vlm_media_instance_t.
Definition vlc_vlm.h:347
void vlm_Delete(vlm_t *)
Definition vlm.c:192
vlm_query_e
VLM control query.
Definition vlc_vlm.h:125
static void vlm_media_instance_Init(vlm_media_instance_t *p_instance)
Initialize vlm_media_instance_t.
Definition vlc_vlm.h:311
vlm_event_type_e
VLM events You can catch vlm event by adding a callback on the variable "intf-event" of the VLM objec...
Definition vlc_vlm.h:92
int vlm_ExecuteCommand(vlm_t *, const char *, vlm_message_t **)
Definition vlm.c:233
static void vlm_media_Init(vlm_media_t *p_media)
Initialize a vlm_media_t instance.
Definition vlc_vlm.h:207
@ VLM_END_S
Definition vlc_vlm.h:110
@ VLM_ERROR_S
Definition vlc_vlm.h:111
@ VLM_INIT_S
Definition vlc_vlm.h:106
@ VLM_PAUSE_S
Definition vlc_vlm.h:109
@ VLM_PLAYING_S
Definition vlc_vlm.h:108
@ VLM_OPENING_S
Definition vlc_vlm.h:107
@ VLM_PAUSE_MEDIA_INSTANCE
Definition vlc_vlm.h:153
@ VLM_DEL_MEDIA
Definition vlc_vlm.h:135
@ VLM_GET_MEDIA_INSTANCE_TIME
Definition vlc_vlm.h:155
@ VLM_SET_MEDIA_INSTANCE_POSITION
Definition vlc_vlm.h:161
@ VLM_GET_MEDIAS
Definition vlc_vlm.h:128
@ VLM_ADD_MEDIA
Definition vlc_vlm.h:133
@ VLM_CLEAR_SCHEDULES
Definition vlc_vlm.h:164
@ VLM_GET_MEDIA_INSTANCES
Definition vlc_vlm.h:145
@ VLM_SET_MEDIA_INSTANCE_TIME
Definition vlc_vlm.h:157
@ VLM_CLEAR_MEDIA_INSTANCES
Definition vlc_vlm.h:147
@ VLM_GET_MEDIA
Definition vlc_vlm.h:139
@ VLM_GET_MEDIA_INSTANCE_POSITION
Definition vlc_vlm.h:159
@ VLM_GET_MEDIA_ID
Definition vlc_vlm.h:141
@ VLM_STOP_MEDIA_INSTANCE
Definition vlc_vlm.h:151
@ VLM_CHANGE_MEDIA
Definition vlc_vlm.h:137
@ VLM_CLEAR_MEDIAS
Definition vlc_vlm.h:130
@ VLM_START_MEDIA_BROADCAST_INSTANCE
Definition vlc_vlm.h:149
@ VLM_EVENT_MEDIA_REMOVED
Definition vlc_vlm.h:95
@ VLM_EVENT_MEDIA_INSTANCE_STOPPED
Definition vlc_vlm.h:100
@ VLM_EVENT_MEDIA_CHANGED
Definition vlc_vlm.h:96
@ VLM_EVENT_MEDIA_INSTANCE_STARTED
Definition vlc_vlm.h:99
@ VLM_EVENT_MEDIA_INSTANCE_STATE
Definition vlc_vlm.h:101
@ VLM_EVENT_MEDIA_ADDED
Definition vlc_vlm.h:94
int i_type
Definition httpd.c:1299
Definition vlc_objects.h:103
Definition vlc_vlm.h:115
int i_type
Definition vlc_vlm.h:116
const char * psz_name
Definition vlc_vlm.h:118
int64_t id
Definition vlc_vlm.h:117
const char * psz_instance_name
Definition vlc_vlm.h:119
vlm_state_e input_state
Definition vlc_vlm.h:120
VLM media instance.
Definition vlc_vlm.h:69
int64_t i_length
Definition vlc_vlm.h:73
double d_position
Definition vlc_vlm.h:74
float f_rate
Definition vlc_vlm.h:76
char * psz_name
Definition vlc_vlm.h:70
bool b_paused
Definition vlc_vlm.h:75
int64_t i_time
Definition vlc_vlm.h:72
VLM media.
Definition vlc_vlm.h:46
int i_input
Definition vlc_vlm.h:52
struct vlm_media_t::@295 broadcast
char ** ppsz_option
Definition vlc_vlm.h:56
char * psz_name
Definition vlc_vlm.h:50
int64_t id
Definition vlc_vlm.h:47
bool b_loop
Definition vlc_vlm.h:62
int i_option
Definition vlc_vlm.h:55
char * psz_output
Definition vlc_vlm.h:58
char ** ppsz_input
Definition vlc_vlm.h:53
bool b_enabled
Definition vlc_vlm.h:48
Definition vlc_vlm.h:178
vlm_message_t ** child
Definition vlc_vlm.h:183
int i_child
Definition vlc_vlm.h:182
char * psz_value
Definition vlc_vlm.h:180
char * psz_name
Definition vlc_vlm.h:179
Definition vlm_internal.h:76
const char * psz_name
Definition text_style.c:33
This file defines functions, structures and macros for handling arrays in vlc.
#define TAB_CLEAN(count, tab)
Definition vlc_arrays.h:63
#define TAB_INIT(count, tab)
Definition vlc_arrays.h:57
#define TAB_APPEND_CAST(cast, count, tab, p)
Definition vlc_arrays.h:70
This file is a collection of common definitions and types.
char * strdup(const char *)
Input thread interface.