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 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/** VLM events
79 * You can catch vlm event by adding a callback on the variable "intf-event"
80 * of the VLM object.
81 * This variable is an address that will hold a vlm_event_t* value.
82 */
96typedef enum vlm_state_e
106typedef struct
108 int i_type; /* a vlm_event_type_e value */
109 int64_t id; /* Media ID */
110 const char *psz_name; /* Media name */
111 const char *psz_instance_name; /* Instance name or NULL */
112 vlm_state_e input_state; /* Input instance event type */
114
115/** VLM control query */
116enum vlm_query_e
118 /* --- Media control */
119 /* Get all medias */
120 VLM_GET_MEDIAS, /* arg1=vlm_media_t ***, int *pi_media */
121 /* Delete all medias */
122 VLM_CLEAR_MEDIAS, /* no arg */
124 /* Add a new media */
125 VLM_ADD_MEDIA, /* arg1=vlm_media_t* arg2=int64_t *p_id res=can fail */
126 /* Delete an existing media */
127 VLM_DEL_MEDIA, /* arg1=int64_t id */
128 /* Change properties of an existing media (all fields but id) */
129 VLM_CHANGE_MEDIA, /* arg1=vlm_media_t* res=can fail */
130 /* Get 1 media by it's ID */
131 VLM_GET_MEDIA, /* arg1=int64_t id arg2=vlm_media_t ** */
132 /* Get media ID from its name */
133 VLM_GET_MEDIA_ID, /* arg1=const char *psz_name arg2=int64_t* */
135 /* Media instance control */
136 /* Get all media instances */
137 VLM_GET_MEDIA_INSTANCES, /* arg1=int64_t id arg2=vlm_media_instance_t *** arg3=int *pi_instance */
138 /* Delete all media instances */
139 VLM_CLEAR_MEDIA_INSTANCES, /* arg1=int64_t id */
140 /* Control broadcast instance */
141 VLM_START_MEDIA_BROADCAST_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index res=can fail */
142 /* Stop an instance */
143 VLM_STOP_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
144 /* Pause an instance */
145 VLM_PAUSE_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
146 /* Get instance position time (in microsecond) */
147 VLM_GET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t * */
148 /* Set instance position time (in microsecond) */
149 VLM_SET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t */
150 /* Get instance position ([0.0 .. 1.0]) */
151 VLM_GET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double * */
152 /* Set instance position ([0.0 .. 1.0]) */
153 VLM_SET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double */
155 /* */
156};
157
158
159/* VLM specific - structures and functions */
160
161/* ok, here is the structure of a vlm_message:
162 The parent node is ( name_of_the_command , NULL ), or
163 ( name_of_the_command , message_error ) on error.
164 If a node has children, it should not have a value (=NULL).*/
165struct vlm_message_t
167 char *psz_name; /*< message name */
168 char *psz_value; /*< message value */
170 int i_child; /*< number of child messages */
171 vlm_message_t **child; /*< array of vlm_message_t */
173
174
175#ifdef __cplusplus
176extern "C" {
177#endif
178
179VLC_API vlm_t * vlm_New( libvlc_int_t *, const char *path );
180VLC_API void vlm_Delete( vlm_t * );
181VLC_API int vlm_ExecuteCommand( vlm_t *, const char *, vlm_message_t ** );
182VLC_API int vlm_Control( vlm_t *p_vlm, int i_query, ... );
183
185VLC_API vlm_message_t * vlm_MessageNew( const char *, const char *, ... ) VLC_FORMAT( 2, 3 );
188
189/* media helpers */
190
191/**
192 * Initialize a vlm_media_t instance
193 * \param p_media vlm_media_t instance to initialize
194 */
195static inline void vlm_media_Init( vlm_media_t *p_media )
197 memset( p_media, 0, sizeof(vlm_media_t) );
198 p_media->id = 0; // invalid id
199 p_media->psz_name = NULL;
200 TAB_INIT( p_media->i_input, p_media->ppsz_input );
201 TAB_INIT( p_media->i_option, p_media->ppsz_option );
202 p_media->psz_output = NULL;
203
204 p_media->broadcast.b_loop = false;
205}
206
207/**
208 * Copy a vlm_media_t instance into another vlm_media_t instance
209 * \param p_dst vlm_media_t instance to copy to
210 * \param p_src vlm_media_t instance to copy from
211 */
212static inline void
213#ifndef __cplusplus
214vlm_media_Copy( vlm_media_t *restrict p_dst, const vlm_media_t *restrict p_src )
215#else
216vlm_media_Copy( vlm_media_t *p_dst, const vlm_media_t *p_src )
217#endif
218{
219 int i;
220
221 memset( p_dst, 0, sizeof(vlm_media_t) );
222 p_dst->id = p_src->id;
223 p_dst->b_enabled = p_src->b_enabled;
224 if( p_src->psz_name )
225 p_dst->psz_name = strdup( p_src->psz_name );
226
227 for( i = 0; i < p_src->i_input; i++ )
228 TAB_APPEND_CAST( (char**), p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
229 for( i = 0; i < p_src->i_option; i++ )
230 TAB_APPEND_CAST( (char**), p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
231
232 if( p_src->psz_output )
233 p_dst->psz_output = strdup( p_src->psz_output );
234
235 p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
236}
237
238/**
239 * Cleanup and release memory associated with this vlm_media_t instance.
240 * You still need to release p_media itself with vlm_media_Delete().
241 * \param p_media vlm_media_t to cleanup
242 */
243static inline void vlm_media_Clean( vlm_media_t *p_media )
245 int i;
246 free( p_media->psz_name );
247
248 for( i = 0; i < p_media->i_input; i++ )
249 free( p_media->ppsz_input[i]);
250 TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
251
252 for( i = 0; i < p_media->i_option; i++ )
253 free( p_media->ppsz_option[i]);
254 TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
255
256 free( p_media->psz_output );
257}
258
259/**
260 * Allocate a new vlm_media_t instance
261 * \return vlm_media_t instance
262 */
263static inline vlm_media_t *vlm_media_New(void)
265 vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
266 if( p_media )
267 vlm_media_Init( p_media );
268 return p_media;
269}
270
271/**
272 * Delete a vlm_media_t instance
273 * \param p_media vlm_media_t instance to delete
274 */
275static inline void vlm_media_Delete( vlm_media_t *p_media )
277 vlm_media_Clean( p_media );
278 free( p_media );
279}
280
281/**
282 * Copy a vlm_media_t instance
283 * \param p_src vlm_media_t instance to copy
284 * \return vlm_media_t duplicate of p_src
285 */
286static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
288 vlm_media_t *p_dst = vlm_media_New();
289 if( p_dst )
290 vlm_media_Copy( p_dst, p_src );
291 return p_dst;
292}
293
294/* media instance helpers */
295/**
296 * Initialize vlm_media_instance_t
297 * \param p_instance vlm_media_instance_t to initialize
298 */
299static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
301 memset( p_instance, 0, sizeof(vlm_media_instance_t) );
302 p_instance->psz_name = NULL;
303 p_instance->i_time = 0;
304 p_instance->i_length = 0;
305 p_instance->d_position = 0.0;
306 p_instance->b_paused = false;
307 p_instance->f_rate = 1.0f;
308}
309
310/**
311 * Cleanup vlm_media_instance_t
312 * \param p_instance vlm_media_instance_t to cleanup
313 */
314static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
316 free( p_instance->psz_name );
317}
318
319/**
320 * Allocate a new vlm_media_instance_t
321 * \return a new vlm_media_instance_t
322 */
325 vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
326 if( p_instance )
327 vlm_media_instance_Init( p_instance );
328 return p_instance;
329}
330
331/**
332 * Delete a vlm_media_instance_t
333 * \param p_instance vlm_media_instance_t to delete
334 */
335static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
337 vlm_media_instance_Clean( p_instance );
338 free( p_instance );
339}
340
341#ifdef __cplusplus
342}
343#endif
344
345/**@}*/
346
347#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:315
vlm_state_e
Definition vlc_vlm.h:98
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:324
static void vlm_media_Delete(vlm_media_t *p_media)
Delete a vlm_media_t instance.
Definition vlc_vlm.h:276
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:244
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:287
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:215
void vlm_MessageDelete(vlm_message_t *)
Definition missing.c:72
int vlm_Control(vlm_t *p_vlm, int i_query,...)
Definition vlm.c:866
static vlm_media_t * vlm_media_New(void)
Allocate a new vlm_media_t instance.
Definition vlc_vlm.h:264
static void vlm_media_instance_Delete(vlm_media_instance_t *p_instance)
Delete a vlm_media_instance_t.
Definition vlc_vlm.h:336
void vlm_Delete(vlm_t *)
Definition vlm.c:191
vlm_query_e
VLM control query.
Definition vlc_vlm.h:118
static void vlm_media_instance_Init(vlm_media_instance_t *p_instance)
Initialize vlm_media_instance_t.
Definition vlc_vlm.h:300
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:85
int vlm_ExecuteCommand(vlm_t *, const char *, vlm_message_t **)
Definition vlm.c:228
static void vlm_media_Init(vlm_media_t *p_media)
Initialize a vlm_media_t instance.
Definition vlc_vlm.h:196
@ VLM_END_S
Definition vlc_vlm.h:103
@ VLM_ERROR_S
Definition vlc_vlm.h:104
@ VLM_INIT_S
Definition vlc_vlm.h:99
@ VLM_PAUSE_S
Definition vlc_vlm.h:102
@ VLM_PLAYING_S
Definition vlc_vlm.h:101
@ VLM_OPENING_S
Definition vlc_vlm.h:100
@ VLM_PAUSE_MEDIA_INSTANCE
Definition vlc_vlm.h:146
@ VLM_DEL_MEDIA
Definition vlc_vlm.h:128
@ VLM_GET_MEDIA_INSTANCE_TIME
Definition vlc_vlm.h:148
@ VLM_SET_MEDIA_INSTANCE_POSITION
Definition vlc_vlm.h:154
@ VLM_GET_MEDIAS
Definition vlc_vlm.h:121
@ VLM_ADD_MEDIA
Definition vlc_vlm.h:126
@ VLM_GET_MEDIA_INSTANCES
Definition vlc_vlm.h:138
@ VLM_SET_MEDIA_INSTANCE_TIME
Definition vlc_vlm.h:150
@ VLM_CLEAR_MEDIA_INSTANCES
Definition vlc_vlm.h:140
@ VLM_GET_MEDIA
Definition vlc_vlm.h:132
@ VLM_GET_MEDIA_INSTANCE_POSITION
Definition vlc_vlm.h:152
@ VLM_GET_MEDIA_ID
Definition vlc_vlm.h:134
@ VLM_STOP_MEDIA_INSTANCE
Definition vlc_vlm.h:144
@ VLM_CHANGE_MEDIA
Definition vlc_vlm.h:130
@ VLM_CLEAR_MEDIAS
Definition vlc_vlm.h:123
@ VLM_START_MEDIA_BROADCAST_INSTANCE
Definition vlc_vlm.h:142
@ VLM_EVENT_MEDIA_REMOVED
Definition vlc_vlm.h:88
@ VLM_EVENT_MEDIA_INSTANCE_STOPPED
Definition vlc_vlm.h:93
@ VLM_EVENT_MEDIA_CHANGED
Definition vlc_vlm.h:89
@ VLM_EVENT_MEDIA_INSTANCE_STARTED
Definition vlc_vlm.h:92
@ VLM_EVENT_MEDIA_INSTANCE_STATE
Definition vlc_vlm.h:94
@ VLM_EVENT_MEDIA_ADDED
Definition vlc_vlm.h:87
int i_type
Definition httpd.c:1299
Definition vlc_objects.h:103
Definition vlc_vlm.h:108
int i_type
Definition vlc_vlm.h:109
const char * psz_name
Definition vlc_vlm.h:111
int64_t id
Definition vlc_vlm.h:110
const char * psz_instance_name
Definition vlc_vlm.h:112
vlm_state_e input_state
Definition vlc_vlm.h:113
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
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
struct vlm_media_t::@297 broadcast
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:167
vlm_message_t ** child
Definition vlc_vlm.h:172
int i_child
Definition vlc_vlm.h:171
char * psz_value
Definition vlc_vlm.h:169
char * psz_name
Definition vlc_vlm.h:168
Definition vlm_internal.h:56
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.