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 *****************************************************************************/
28 #include <vlc_input.h>
61 /* VLM media instance */
70 int i_rate; // normal is INPUT_RATE_DEFAULT
71 } vlm_media_instance_t;
80 /* VLM control query */
83 /* --- Media control */
85 VLM_GET_MEDIAS, /* arg1=vlm_media_t ***, int *pi_media */
86 /* Delete all medias */
87 VLM_CLEAR_MEDIAS, /* no arg */
90 VLM_ADD_MEDIA, /* arg1=vlm_media_t* arg2=int64_t *p_id res=can fail */
91 /* Delete an existing media */
92 VLM_DEL_MEDIA, /* arg1=int64_t id */
93 /* Change properties of an existing media (all fields but id and b_vod) */
94 VLM_CHANGE_MEDIA, /* arg1=vlm_media_t* res=can fail */
95 /* Get 1 media by it's ID */
96 VLM_GET_MEDIA, /* arg1=int64_t id arg2=vlm_media_t ** */
97 /* Get media ID from its name */
98 VLM_GET_MEDIA_ID, /* arg1=const char *psz_name arg2=int64_t* */
100 /* Media instance control XXX VOD control are for internal use only */
101 /* Get all media instances */
102 VLM_GET_MEDIA_INSTANCES, /* arg1=int64_t id arg2=vlm_media_instance_t *** arg3=int *pi_instance */
103 /* Delete all media instances */
104 VLM_CLEAR_MEDIA_INSTANCES, /* arg1=int64_t id */
105 /* Control broadcast instance */
106 VLM_START_MEDIA_BROADCAST_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index res=can fail */
107 /* Control VOD instance */
108 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 */
109 /* Stop an instance */
110 VLM_STOP_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
111 /* Pause an instance */
112 VLM_PAUSE_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
113 /* Get instance position time (in microsecond) */
114 VLM_GET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t * */
115 /* Set instance position time (in microsecond) */
116 VLM_SET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t */
117 /* Get instance position ([0.0 .. 1.0]) */
118 VLM_GET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double * */
119 /* Set instance position ([0.0 .. 1.0]) */
120 VLM_SET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double */
122 /* Schedule control */
123 VLM_CLEAR_SCHEDULES, /* no arg */
124 /* TODO: missing schedule control */
130 /* VLM specific - structures and functions */
132 /* ok, here is the structure of a vlm_message:
133 The parent node is ( name_of_the_command , NULL ), or
134 ( name_of_the_command , message_error ) on error.
135 If a node has children, it should not have a value (=NULL).*/
142 vlm_message_t **child;
150 #define vlm_New( a ) __vlm_New( VLC_OBJECT(a) )
151 VLC_EXPORT( vlm_t *, __vlm_New, ( vlc_object_t * ) );
152 VLC_EXPORT( void, vlm_Delete, ( vlm_t * ) );
153 VLC_EXPORT( int, vlm_ExecuteCommand, ( vlm_t *, const char *, vlm_message_t ** ) );
154 VLC_EXPORT( int, vlm_Control, ( vlm_t *p_vlm, int i_query, ... ) );
156 VLC_EXPORT( vlm_message_t *, vlm_MessageNew, ( const char *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
157 VLC_EXPORT( vlm_message_t *, vlm_MessageAdd, ( vlm_message_t *, vlm_message_t * ) );
158 VLC_EXPORT( void, vlm_MessageDelete, ( vlm_message_t * ) );
161 static inline void vlm_media_Init( vlm_media_t *p_media )
163 memset( p_media, 0, sizeof(vlm_media_t) );
164 p_media->id = 0; // invalid id
165 p_media->psz_name = NULL;
166 TAB_INIT( p_media->i_input, p_media->ppsz_input );
167 TAB_INIT( p_media->i_option, p_media->ppsz_option );
168 p_media->psz_output = NULL;
169 p_media->b_vod = false;
171 p_media->vod.psz_mux = NULL;
172 p_media->broadcast.b_loop = false;
175 static inline void vlm_media_Copy( vlm_media_t *p_dst, vlm_media_t *p_src )
179 memset( p_dst, 0, sizeof(vlm_media_t) );
180 p_dst->id = p_src->id;
181 p_dst->b_enabled = p_src->b_enabled;
182 if( p_src->psz_name )
183 p_dst->psz_name = strdup( p_src->psz_name );
185 for( i = 0; i < p_src->i_input; i++ )
186 TAB_APPEND_CPP( char, p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
187 for( i = 0; i < p_src->i_option; i++ )
188 TAB_APPEND_CPP( char, p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
190 if( p_src->psz_output )
191 p_dst->psz_output = strdup( p_src->psz_output );
193 p_dst->b_vod = p_src->b_vod;
196 if( p_src->vod.psz_mux )
197 p_dst->vod.psz_mux = strdup( p_src->vod.psz_mux );
201 p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
204 static inline void vlm_media_Clean( vlm_media_t *p_media )
207 free( p_media->psz_name );
209 for( i = 0; i < p_media->i_input; i++ )
210 free( p_media->ppsz_input[i]) ;
211 TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
213 for( i = 0; i < p_media->i_option; i++ )
214 free( p_media->ppsz_option[i]) ;
215 TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
217 free( p_media->psz_output );
219 free( p_media->vod.psz_mux );
221 static inline vlm_media_t *vlm_media_New(void)
223 vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
225 vlm_media_Init( p_media );
228 static inline void vlm_media_Delete( vlm_media_t *p_media )
230 vlm_media_Clean( p_media );
233 static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
235 vlm_media_t *p_dst = vlm_media_New();
237 vlm_media_Copy( p_dst, p_src );
241 /* media instance helpers */
242 static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
244 memset( p_instance, 0, sizeof(vlm_media_instance_t) );
245 p_instance->psz_name = NULL;
246 p_instance->i_time = 0;
247 p_instance->i_length = 0;
248 p_instance->d_position = 0.0;
249 p_instance->b_paused = false;
250 p_instance->i_rate = INPUT_RATE_DEFAULT;
252 static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
254 free( p_instance->psz_name );
256 static inline vlm_media_instance_t *vlm_media_instance_New(void)
258 vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
260 vlm_media_instance_Init( p_instance );
263 static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
265 vlm_media_instance_Clean( p_instance );