1 /*****************************************************************************
2 * vlc_vlm.h: VLM core structures
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 the VideoLAN team
7 * Authors: Simon Latapie <garf@videolan.org>
8 * Laurent Aimar <fenrir@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
30 * This file defines VLM core functions and structures in vlc
33 #include <vlc_input.h>
36 * \defgroup server VLM
37 * VLM is the server core in vlc that allows streaming of multiple media streams
38 * at the same time. It provides broadcast, schedule and video on demand features
39 * for streaming using several streaming and network protocols.
74 /* VLM media instance */
83 int i_rate; // normal is INPUT_RATE_DEFAULT
84 } vlm_media_instance_t;
93 /* VLM control query */
96 /* --- Media control */
98 VLM_GET_MEDIAS, /* arg1=vlm_media_t ***, int *pi_media */
99 /* Delete all medias */
100 VLM_CLEAR_MEDIAS, /* no arg */
102 /* Add a new media */
103 VLM_ADD_MEDIA, /* arg1=vlm_media_t* arg2=int64_t *p_id res=can fail */
104 /* Delete an existing media */
105 VLM_DEL_MEDIA, /* arg1=int64_t id */
106 /* Change properties of an existing media (all fields but id and b_vod) */
107 VLM_CHANGE_MEDIA, /* arg1=vlm_media_t* res=can fail */
108 /* Get 1 media by it's ID */
109 VLM_GET_MEDIA, /* arg1=int64_t id arg2=vlm_media_t ** */
110 /* Get media ID from its name */
111 VLM_GET_MEDIA_ID, /* arg1=const char *psz_name arg2=int64_t* */
113 /* Media instance control XXX VOD control are for internal use only */
114 /* Get all media instances */
115 VLM_GET_MEDIA_INSTANCES, /* arg1=int64_t id arg2=vlm_media_instance_t *** arg3=int *pi_instance */
116 /* Delete all media instances */
117 VLM_CLEAR_MEDIA_INSTANCES, /* arg1=int64_t id */
118 /* Control broadcast instance */
119 VLM_START_MEDIA_BROADCAST_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index res=can fail */
120 /* Control VOD instance */
121 VLM_START_MEDIA_VOD_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index char *psz_vod_output res=can fail */
122 /* Stop an instance */
123 VLM_STOP_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
124 /* Pause an instance */
125 VLM_PAUSE_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
126 /* Get instance position time (in microsecond) */
127 VLM_GET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t * */
128 /* Set instance position time (in microsecond) */
129 VLM_SET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t */
130 /* Get instance position ([0.0 .. 1.0]) */
131 VLM_GET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double * */
132 /* Set instance position ([0.0 .. 1.0]) */
133 VLM_SET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double */
135 /* Schedule control */
136 VLM_CLEAR_SCHEDULES, /* no arg */
137 /* TODO: missing schedule control */
143 /* VLM specific - structures and functions */
145 /* ok, here is the structure of a vlm_message:
146 The parent node is ( name_of_the_command , NULL ), or
147 ( name_of_the_command , message_error ) on error.
148 If a node has children, it should not have a value (=NULL).*/
155 vlm_message_t **child;
163 #define vlm_New( a ) __vlm_New( VLC_OBJECT(a) )
164 VLC_EXPORT( vlm_t *, __vlm_New, ( vlc_object_t * ) );
165 VLC_EXPORT( void, vlm_Delete, ( vlm_t * ) );
166 VLC_EXPORT( int, vlm_ExecuteCommand, ( vlm_t *, const char *, vlm_message_t ** ) );
167 VLC_EXPORT( int, vlm_Control, ( vlm_t *p_vlm, int i_query, ... ) );
169 VLC_EXPORT( vlm_message_t *, vlm_MessageNew, ( const char *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
170 VLC_EXPORT( vlm_message_t *, vlm_MessageAdd, ( vlm_message_t *, vlm_message_t * ) );
171 VLC_EXPORT( void, vlm_MessageDelete, ( vlm_message_t * ) );
174 static inline void vlm_media_Init( vlm_media_t *p_media )
176 memset( p_media, 0, sizeof(vlm_media_t) );
177 p_media->id = 0; // invalid id
178 p_media->psz_name = NULL;
179 TAB_INIT( p_media->i_input, p_media->ppsz_input );
180 TAB_INIT( p_media->i_option, p_media->ppsz_option );
181 p_media->psz_output = NULL;
182 p_media->b_vod = false;
184 p_media->vod.psz_mux = NULL;
185 p_media->broadcast.b_loop = false;
188 static inline void vlm_media_Copy( vlm_media_t *p_dst, vlm_media_t *p_src )
192 memset( p_dst, 0, sizeof(vlm_media_t) );
193 p_dst->id = p_src->id;
194 p_dst->b_enabled = p_src->b_enabled;
195 if( p_src->psz_name )
196 p_dst->psz_name = strdup( p_src->psz_name );
198 for( i = 0; i < p_src->i_input; i++ )
199 TAB_APPEND_CPP( char, p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
200 for( i = 0; i < p_src->i_option; i++ )
201 TAB_APPEND_CPP( char, p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
203 if( p_src->psz_output )
204 p_dst->psz_output = strdup( p_src->psz_output );
206 p_dst->b_vod = p_src->b_vod;
209 if( p_src->vod.psz_mux )
210 p_dst->vod.psz_mux = strdup( p_src->vod.psz_mux );
214 p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
217 static inline void vlm_media_Clean( vlm_media_t *p_media )
220 free( p_media->psz_name );
222 for( i = 0; i < p_media->i_input; i++ )
223 free( p_media->ppsz_input[i]) ;
224 TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
226 for( i = 0; i < p_media->i_option; i++ )
227 free( p_media->ppsz_option[i]) ;
228 TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
230 free( p_media->psz_output );
232 free( p_media->vod.psz_mux );
234 static inline vlm_media_t *vlm_media_New(void)
236 vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
238 vlm_media_Init( p_media );
241 static inline void vlm_media_Delete( vlm_media_t *p_media )
243 vlm_media_Clean( p_media );
246 static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
248 vlm_media_t *p_dst = vlm_media_New();
250 vlm_media_Copy( p_dst, p_src );
254 /* media instance helpers */
255 static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
257 memset( p_instance, 0, sizeof(vlm_media_instance_t) );
258 p_instance->psz_name = NULL;
259 p_instance->i_time = 0;
260 p_instance->i_length = 0;
261 p_instance->d_position = 0.0;
262 p_instance->b_paused = false;
263 p_instance->i_rate = INPUT_RATE_DEFAULT;
265 static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
267 free( p_instance->psz_name );
269 static inline vlm_media_instance_t *vlm_media_instance_New(void)
271 vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
273 vlm_media_instance_Init( p_instance );
276 static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
278 vlm_media_instance_Clean( p_instance );