Coverage Report

Created: 2026-01-10 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/include/vlc_vlm.h
Line
Count
Source
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 */
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
/** 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
 */
83
enum vlm_event_type_e
84
{
85
    /* */
86
    VLM_EVENT_MEDIA_ADDED   = 0x100,
87
    VLM_EVENT_MEDIA_REMOVED,
88
    VLM_EVENT_MEDIA_CHANGED,
89
90
    /* */
91
    VLM_EVENT_MEDIA_INSTANCE_STARTED    = 0x200,
92
    VLM_EVENT_MEDIA_INSTANCE_STOPPED,
93
    VLM_EVENT_MEDIA_INSTANCE_STATE,
94
};
95
96
typedef enum vlm_state_e
97
{
98
    VLM_INIT_S = 0,
99
    VLM_OPENING_S,
100
    VLM_PLAYING_S,
101
    VLM_PAUSE_S,
102
    VLM_END_S,
103
    VLM_ERROR_S,
104
} vlm_state_e;
105
106
typedef struct
107
{
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 */
113
} vlm_event_t;
114
115
/** VLM control query */
116
enum vlm_query_e
117
{
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 */
123
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*  */
134
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     */
154
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).*/
165
struct vlm_message_t
166
{
167
    char *psz_name;         /*< message name */
168
    char *psz_value;        /*< message value */
169
170
    int           i_child;  /*< number of child messages */
171
    vlm_message_t **child;  /*< array of vlm_message_t */
172
};
173
174
175
#ifdef __cplusplus
176
extern "C" {
177
#endif
178
179
VLC_API vlm_t * vlm_New( libvlc_int_t *, const char *path );
180
VLC_API void vlm_Delete( vlm_t * );
181
VLC_API int vlm_ExecuteCommand( vlm_t *, const char *, vlm_message_t ** );
182
VLC_API int vlm_Control( vlm_t *p_vlm, int i_query, ... );
183
184
VLC_API vlm_message_t * vlm_MessageSimpleNew( const char * );
185
VLC_API vlm_message_t * vlm_MessageNew( const char *, const char *, ... ) VLC_FORMAT( 2, 3 );
186
VLC_API vlm_message_t * vlm_MessageAdd( vlm_message_t *, vlm_message_t * );
187
VLC_API void vlm_MessageDelete( vlm_message_t * );
188
189
/* media helpers */
190
191
/**
192
 * Initialize a vlm_media_t instance
193
 * \param p_media vlm_media_t instance to initialize
194
 */
195
static inline void vlm_media_Init( vlm_media_t *p_media )
196
0
{
197
0
    memset( p_media, 0, sizeof(vlm_media_t) );
198
0
    p_media->id = 0;    // invalid id
199
0
    p_media->psz_name = NULL;
200
0
    TAB_INIT( p_media->i_input, p_media->ppsz_input );
201
0
    TAB_INIT( p_media->i_option, p_media->ppsz_option );
202
0
    p_media->psz_output = NULL;
203
204
0
    p_media->broadcast.b_loop = false;
205
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
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
 */
212
static inline void
213
#ifndef __cplusplus
214
vlm_media_Copy( vlm_media_t *restrict p_dst, const vlm_media_t *restrict p_src )
215
#else
216
vlm_media_Copy( vlm_media_t *p_dst, const vlm_media_t *p_src )
217
#endif
218
0
{
219
0
    int i;
220
221
0
    memset( p_dst, 0, sizeof(vlm_media_t) );
222
0
    p_dst->id = p_src->id;
223
0
    p_dst->b_enabled = p_src->b_enabled;
224
0
    if( p_src->psz_name )
225
0
        p_dst->psz_name = strdup( p_src->psz_name );
226
227
0
    for( i = 0; i < p_src->i_input; i++ )
228
0
        TAB_APPEND_CAST( (char**), p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
229
0
    for( i = 0; i < p_src->i_option; i++ )
230
0
        TAB_APPEND_CAST( (char**), p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
231
232
0
    if( p_src->psz_output )
233
0
        p_dst->psz_output = strdup( p_src->psz_output );
234
235
0
    p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
236
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
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
 */
243
static inline void vlm_media_Clean( vlm_media_t *p_media )
244
0
{
245
0
    int i;
246
0
    free( p_media->psz_name );
247
248
0
    for( i = 0; i < p_media->i_input; i++ )
249
0
        free( p_media->ppsz_input[i]);
250
0
    TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
251
252
0
    for( i = 0; i < p_media->i_option; i++ )
253
0
        free( p_media->ppsz_option[i]);
254
0
    TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
255
256
0
    free( p_media->psz_output );
257
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
258
259
/**
260
 * Allocate a new vlm_media_t instance
261
 * \return vlm_media_t instance
262
 */
263
static inline vlm_media_t *vlm_media_New(void)
264
0
{
265
0
    vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
266
0
    if( p_media )
267
0
        vlm_media_Init( p_media );
268
0
    return p_media;
269
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
270
271
/**
272
 * Delete a vlm_media_t instance
273
 * \param p_media vlm_media_t instance to delete
274
 */
275
static inline void vlm_media_Delete( vlm_media_t *p_media )
276
0
{
277
0
    vlm_media_Clean( p_media );
278
0
    free( p_media );
279
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
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
 */
286
static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
287
0
{
288
0
    vlm_media_t *p_dst = vlm_media_New();
289
0
    if( p_dst )
290
0
        vlm_media_Copy( p_dst, p_src );
291
0
    return p_dst;
292
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
293
294
/* media instance helpers */
295
/**
296
 * Initialize vlm_media_instance_t
297
 * \param p_instance vlm_media_instance_t to initialize
298
 */
299
static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
300
0
{
301
0
    memset( p_instance, 0, sizeof(vlm_media_instance_t) );
302
0
    p_instance->psz_name = NULL;
303
0
    p_instance->i_time = 0;
304
0
    p_instance->i_length = 0;
305
0
    p_instance->d_position = 0.0;
306
0
    p_instance->b_paused = false;
307
0
    p_instance->f_rate = 1.0f;
308
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
309
310
/**
311
 * Cleanup vlm_media_instance_t
312
 * \param p_instance vlm_media_instance_t to cleanup
313
 */
314
static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
315
0
{
316
0
    free( p_instance->psz_name );
317
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
318
319
/**
320
 * Allocate a new vlm_media_instance_t
321
 * \return a new vlm_media_instance_t
322
 */
323
static inline vlm_media_instance_t *vlm_media_instance_New(void)
324
0
{
325
0
    vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
326
0
    if( p_instance )
327
0
        vlm_media_instance_Init( p_instance );
328
0
    return p_instance;
329
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
330
331
/**
332
 * Delete a vlm_media_instance_t
333
 * \param p_instance vlm_media_instance_t to delete
334
 */
335
static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
336
0
{
337
0
    vlm_media_instance_Clean( p_instance );
338
0
    free( p_instance );
339
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
340
341
#ifdef __cplusplus
342
}
343
#endif
344
345
/**@}*/
346
347
#endif