QVisu
Qt-based visualization for smart homes
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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  * $Id: 11111da6edb9fbecaa750af4c2851a5f0c338f0b $
6  *
7  * Authors: Simon Latapie <garf@videolan.org>
8  * Laurent Aimar <fenrir@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
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 Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24 
25 #ifndef VLC_VLM_H
26 #define VLC_VLM_H 1
27 
33 #include <vlc_input.h>
34 
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  bool b_vod; /*< vlm_media_t is of type VOD */
60  struct
61  {
62  bool b_loop; /*< this vlc_media_t broadcast item should loop */
63  } broadcast; /*< Broadcast specific information */
64  struct
65  {
66  char *psz_mux; /*< name of muxer to use */
67  } vod; /*< VOD specific information */
68 
69 } vlm_media_t;
70 
72 typedef struct
73 {
74  char *psz_name; /*< vlm media instance descriptive name */
75 
76  int64_t i_time; /*< vlm media instance vlm media current time */
77  int64_t i_length; /*< vlm media instance vlm media item length */
78  double d_position; /*< vlm media instance position in stream */
79  bool b_paused; /*< vlm media instance is paused */
80  int i_rate; // normal is INPUT_RATE_DEFAULT
82 
83 #if 0
84 typedef struct
85 {
86 
87 } vlm_schedule_t
88 #endif
89 
96 {
97  /* */
98  VLM_EVENT_MEDIA_ADDED = 0x100,
99  VLM_EVENT_MEDIA_REMOVED,
100  VLM_EVENT_MEDIA_CHANGED,
101 
102  /* */
103  VLM_EVENT_MEDIA_INSTANCE_STARTED = 0x200,
104  VLM_EVENT_MEDIA_INSTANCE_STOPPED,
105  VLM_EVENT_MEDIA_INSTANCE_STATE,
106 };
107 
108 typedef struct
109 {
110  int i_type; /* a vlm_event_type_e value */
111  int64_t id; /* Media ID */
112  const char *psz_name; /* Media name */
113  const char *psz_instance_name; /* Instance name or NULL */
114  input_state_e input_state; /* Input instance event type */
115 } vlm_event_t;
116 
119 {
120  /* --- Media control */
121  /* Get all medias */
122  VLM_GET_MEDIAS, /* arg1=vlm_media_t ***, int *pi_media */
123  /* Delete all medias */
124  VLM_CLEAR_MEDIAS, /* no arg */
125 
126  /* Add a new media */
127  VLM_ADD_MEDIA, /* arg1=vlm_media_t* arg2=int64_t *p_id res=can fail */
128  /* Delete an existing media */
129  VLM_DEL_MEDIA, /* arg1=int64_t id */
130  /* Change properties of an existing media (all fields but id and b_vod) */
131  VLM_CHANGE_MEDIA, /* arg1=vlm_media_t* res=can fail */
132  /* Get 1 media by it's ID */
133  VLM_GET_MEDIA, /* arg1=int64_t id arg2=vlm_media_t ** */
134  /* Get media ID from its name */
135  VLM_GET_MEDIA_ID, /* arg1=const char *psz_name arg2=int64_t* */
136 
137  /* Media instance control XXX VOD control are for internal use only */
138  /* Get all media instances */
139  VLM_GET_MEDIA_INSTANCES, /* arg1=int64_t id arg2=vlm_media_instance_t *** arg3=int *pi_instance */
140  /* Delete all media instances */
141  VLM_CLEAR_MEDIA_INSTANCES, /* arg1=int64_t id */
142  /* Control broadcast instance */
143  VLM_START_MEDIA_BROADCAST_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index res=can fail */
144  /* Control VOD instance */
145  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 */
146  /* Stop an instance */
147  VLM_STOP_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
148  /* Pause an instance */
149  VLM_PAUSE_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
150  /* Get instance position time (in microsecond) */
151  VLM_GET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t * */
152  /* Set instance position time (in microsecond) */
153  VLM_SET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t */
154  /* Get instance position ([0.0 .. 1.0]) */
155  VLM_GET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double * */
156  /* Set instance position ([0.0 .. 1.0]) */
157  VLM_SET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double */
158 
159  /* Schedule control */
160  VLM_CLEAR_SCHEDULES, /* no arg */
161  /* TODO: missing schedule control */
162 
163  /* */
164 };
165 
166 
167 /* VLM specific - structures and functions */
168 
169 /* ok, here is the structure of a vlm_message:
170  The parent node is ( name_of_the_command , NULL ), or
171  ( name_of_the_command , message_error ) on error.
172  If a node has children, it should not have a value (=NULL).*/
174 {
175  char *psz_name; /*< message name */
176  char *psz_value; /*< message value */
177 
178  int i_child; /*< number of child messages */
179  vlm_message_t **child; /*< array of vlm_message_t */
180 };
181 
182 
183 #ifdef __cplusplus
184 extern "C" {
185 #endif
186 
187 VLC_API vlm_t * vlm_New( vlc_object_t * );
188 #define vlm_New( a ) vlm_New( VLC_OBJECT(a) )
189 VLC_API void vlm_Delete( vlm_t * );
190 VLC_API int vlm_ExecuteCommand( vlm_t *, const char *, vlm_message_t ** );
191 VLC_API int vlm_Control( vlm_t *p_vlm, int i_query, ... );
192 
193 VLC_API vlm_message_t * vlm_MessageSimpleNew( const char * );
194 VLC_API vlm_message_t * vlm_MessageNew( const char *, const char *, ... ) VLC_FORMAT( 2, 3 );
195 VLC_API vlm_message_t * vlm_MessageAdd( vlm_message_t *, vlm_message_t * );
196 VLC_API void vlm_MessageDelete( vlm_message_t * );
197 
198 /* media helpers */
199 
204 static inline void vlm_media_Init( vlm_media_t *p_media )
205 {
206  memset( p_media, 0, sizeof(vlm_media_t) );
207  p_media->id = 0; // invalid id
208  p_media->psz_name = NULL;
209  TAB_INIT( p_media->i_input, p_media->ppsz_input );
210  TAB_INIT( p_media->i_option, p_media->ppsz_option );
211  p_media->psz_output = NULL;
212  p_media->b_vod = false;
213 
214  p_media->vod.psz_mux = NULL;
215  p_media->broadcast.b_loop = false;
216 }
217 
223 static inline void
224 #ifndef __cplusplus
225 vlm_media_Copy( vlm_media_t *restrict p_dst, const vlm_media_t *restrict p_src )
226 #else
227 vlm_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->b_vod = p_src->b_vod;
247  if( p_src->b_vod )
248  {
249  if( p_src->vod.psz_mux )
250  p_dst->vod.psz_mux = strdup( p_src->vod.psz_mux );
251  }
252  else
253  {
254  p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
255  }
256 }
257 
263 static inline void vlm_media_Clean( vlm_media_t *p_media )
264 {
265  int i;
266  free( p_media->psz_name );
267 
268  for( i = 0; i < p_media->i_input; i++ )
269  free( p_media->ppsz_input[i]);
270  TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
271 
272  for( i = 0; i < p_media->i_option; i++ )
273  free( p_media->ppsz_option[i]);
274  TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
275 
276  free( p_media->psz_output );
277  if( p_media->b_vod )
278  free( p_media->vod.psz_mux );
279 }
280 
285 static inline vlm_media_t *vlm_media_New(void)
286 {
287  vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
288  if( p_media )
289  vlm_media_Init( p_media );
290  return p_media;
291 }
292 
297 static inline void vlm_media_Delete( vlm_media_t *p_media )
298 {
299  vlm_media_Clean( p_media );
300  free( p_media );
301 }
302 
308 static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
309 {
310  vlm_media_t *p_dst = vlm_media_New();
311  if( p_dst )
312  vlm_media_Copy( p_dst, p_src );
313  return p_dst;
314 }
315 
316 /* media instance helpers */
321 static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
322 {
323  memset( p_instance, 0, sizeof(vlm_media_instance_t) );
324  p_instance->psz_name = NULL;
325  p_instance->i_time = 0;
326  p_instance->i_length = 0;
327  p_instance->d_position = 0.0;
328  p_instance->b_paused = false;
329  p_instance->i_rate = INPUT_RATE_DEFAULT;
330 }
331 
336 static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
337 {
338  free( p_instance->psz_name );
339 }
340 
345 static inline vlm_media_instance_t *vlm_media_instance_New(void)
346 {
347  vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
348  if( p_instance )
349  vlm_media_instance_Init( p_instance );
350  return p_instance;
351 }
352 
357 static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
358 {
359  vlm_media_instance_Clean( p_instance );
360  free( p_instance );
361 }
362 
363 #ifdef __cplusplus
364 }
365 #endif
366 
369 #endif
Definition: vlc_vlm.h:173
vlm_event_type_e
Definition: vlc_vlm.h:95
input_state_e
Definition: vlc_input.h:296
Definition: vlc_vlm.h:108
Definition: vlc_vlm.h:72
vlm_query_e
Definition: vlc_vlm.h:118
Definition: vlc_vlm.h:44
Definition: vlc_objects.h:42
#define INPUT_RATE_DEFAULT
Definition: vlc_input.h:322