]> git.sesse.net Git - vlc/blob - include/vlc/mediacontrol.h
2d2f0de6c6e0f91ad0ec0c0dc821540822acece1
[vlc] / include / vlc / mediacontrol.h
1 /*****************************************************************************
2  * control.h: global header for mediacontrol
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Olivier Aubert <olivier.aubert@liris.univ-lyon1.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 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 General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /**
25  * \defgroup mediacontrol MediaControl 
26  * This is the MediaControl API, * intended to provide a generic API to movie players.
27  *
28  * @{
29  */
30
31
32 #ifndef _VLC_CONTROL_H
33 #define _VLC_CONTROL_H 1
34
35 # ifdef __cplusplus
36 extern "C" {
37 # endif
38
39 #if defined( WIN32 )
40 #include <windows.h>
41 #define WINDOWHANDLE HWND
42 #else
43 #define WINDOWHANDLE int
44 #endif
45
46 #include <vlc/mediacontrol_structures.h>
47
48 /**
49  * RGBPicture structure
50  * This generic structure holds a picture in an encoding specified by type.
51  */
52 typedef struct {
53     int  width;
54     int  height;
55     long type;
56     vlc_int64_t date;
57     int  size;
58     char *data;
59 } mediacontrol_RGBPicture;
60
61 /**
62  * Playlist sequence
63  * A simple list of strings.
64  */
65 typedef struct {
66     int size;
67     char **data;
68 } mediacontrol_PlaylistSeq;
69
70 typedef struct {
71     int code;
72     char *message;
73 } mediacontrol_Exception;
74
75 /**
76  * Exception codes
77  */
78 #define mediacontrol_PositionKeyNotSupported    1
79 #define mediacontrol_PositionOriginNotSupported 2
80 #define mediacontrol_InvalidPosition            3
81 #define mediacontrol_PlaylistException          4
82 #define mediacontrol_InternalException          5
83
84 /**
85  * mediacontrol_Instance is an opaque structure, defined in
86  * mediacontrol_internal.h. API users do not have to mess with it. 
87  */
88 typedef struct mediacontrol_Instance mediacontrol_Instance;
89
90 /**
91  * Possible player status
92  */
93 enum mediacontrol_PlayerStatusList
94 {
95     mediacontrol_PlayingStatus, mediacontrol_PauseStatus,
96     mediacontrol_ForwardStatus, mediacontrol_BackwardStatus,
97     mediacontrol_InitStatus,    mediacontrol_EndStatus,
98     mediacontrol_UndefinedStatus
99 };
100 typedef enum mediacontrol_PlayerStatusList mediacontrol_PlayerStatus;
101
102 /**
103  * Stream information
104  * This structure allows to quickly get various informations about the stream.
105  */
106 typedef struct {
107     mediacontrol_PlayerStatus streamstatus;
108     char *url;         /* The URL of the current media stream */
109     vlc_int64_t position;     /* actual location in the stream (in ms) */
110     vlc_int64_t length;         /* total length of the stream (in ms) */
111 } mediacontrol_StreamInformation;
112
113 /**************************************************************************
114  *  Helper functions
115  ***************************************************************************/
116
117 /**
118  * Allocate a RGBPicture structure.
119  * \param datasize: the size of the data
120  */
121 mediacontrol_RGBPicture *mediacontrol_RGBPicture__alloc( int datasize );
122
123 /**
124  * Free a RGBPicture structure.
125  * \param pic: the RGBPicture structure
126  */
127 VLC_PUBLIC_API void mediacontrol_RGBPicture__free( mediacontrol_RGBPicture *pic );
128
129 mediacontrol_RGBPicture *_mediacontrol_createRGBPicture( int, int, long, vlc_int64_t l_date,
130                                   char *, int);
131
132 mediacontrol_PlaylistSeq *mediacontrol_PlaylistSeq__alloc( int size );
133
134 VLC_PUBLIC_API void mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq *ps );
135
136 /**
137  * Free a StreamInformation structure.
138  * \param pic: the StreamInformation structure
139  */
140 VLC_PUBLIC_API void
141 mediacontrol_StreamInformation__free( mediacontrol_StreamInformation* p_si );
142
143 /**
144  * Instanciate and initialize an exception structure.
145  * \return the exception
146  */
147 VLC_PUBLIC_API mediacontrol_Exception *
148   mediacontrol_exception_create( void );
149
150 /**
151  * Initialize an existing exception structure.
152  * \param p_exception the exception to initialize.
153  */
154 VLC_PUBLIC_API void
155   mediacontrol_exception_init( mediacontrol_Exception *exception );
156
157 /**
158  * Free an exception structure.
159  * \return the exception
160  */
161 VLC_PUBLIC_API void mediacontrol_exception_free(mediacontrol_Exception *exception);
162
163 /*****************************************************************************
164  * Core functions
165  *****************************************************************************/
166
167 /**
168  * Create a MediaControl instance with parameters
169  * \param argc the number of arguments
170  * \param argv parameters
171  * \param exception an initialized exception pointer
172  * \return a mediacontrol_Instance
173  */
174 VLC_PUBLIC_API mediacontrol_Instance *
175 mediacontrol_new( int argc, char **argv, mediacontrol_Exception *exception );
176
177 /**
178  * Create a MediaControl instance from an existing libvlc instance
179  * \param p_instance the libvlc instance
180  * \param exception an initialized exception pointer
181  * \return a mediacontrol_Instance
182  */
183 VLC_PUBLIC_API mediacontrol_Instance *
184 mediacontrol_new_from_instance( libvlc_instance_t* p_instance,
185                                 mediacontrol_Exception *exception );
186
187 /**
188  * Get the associated libvlc instance
189  * \param self: the mediacontrol instance
190  * \return a libvlc instance
191  */
192 VLC_PUBLIC_API libvlc_instance_t*
193 mediacontrol_get_libvlc_instance( mediacontrol_Instance* self );
194
195 /**
196  * Get the current position
197  * \param self the mediacontrol instance
198  * \param an_origin the position origin
199  * \param a_key the position unit
200  * \param exception an initialized exception pointer
201  * \return a mediacontrol_Position
202  */
203 VLC_PUBLIC_API mediacontrol_Position * mediacontrol_get_media_position(
204                          mediacontrol_Instance *self,
205                          const mediacontrol_PositionOrigin an_origin,
206                          const mediacontrol_PositionKey a_key,
207                          mediacontrol_Exception *exception );
208
209 /**
210  * Set the position
211  * \param self the mediacontrol instance
212  * \param a_position a mediacontrol_Position
213  * \param exception an initialized exception pointer
214  */
215 VLC_PUBLIC_API void mediacontrol_set_media_position( mediacontrol_Instance *self,
216                                       const mediacontrol_Position *a_position,
217                                       mediacontrol_Exception *exception );
218
219 /**
220  * Play the movie at a given position
221  * \param self the mediacontrol instance
222  * \param a_position a mediacontrol_Position
223  * \param exception an initialized exception pointer
224  */
225 VLC_PUBLIC_API void mediacontrol_start( mediacontrol_Instance *self,
226                          const mediacontrol_Position *a_position,
227                          mediacontrol_Exception *exception );
228
229 /**
230  * Pause the movie at a given position
231  * \param self the mediacontrol instance
232  * \param a_position a mediacontrol_Position (ignored for now)
233  * \param exception an initialized exception pointer
234  */
235 VLC_PUBLIC_API void mediacontrol_pause( mediacontrol_Instance *self,
236                          const mediacontrol_Position *a_position,
237                          mediacontrol_Exception *exception );
238
239 /**
240  * Resume the movie at a given position
241  * \param self the mediacontrol instance
242  * \param a_position a mediacontrol_Position (ignored for now)
243  * \param exception an initialized exception pointer
244  */
245 VLC_PUBLIC_API void mediacontrol_resume( mediacontrol_Instance *self,
246                           const mediacontrol_Position *a_position,
247                           mediacontrol_Exception *exception );
248
249 /**
250  * Stop the movie at a given position
251  * \param self the mediacontrol instance
252  * \param a_position a mediacontrol_Position (ignored for now)
253  * \param exception an initialized exception pointer
254  */
255 VLC_PUBLIC_API void mediacontrol_stop( mediacontrol_Instance *self,
256                         const mediacontrol_Position *a_position,
257                         mediacontrol_Exception *exception );
258
259 /**
260  * Exit the player
261  * \param self the mediacontrol instance
262  */
263 VLC_PUBLIC_API void mediacontrol_exit( mediacontrol_Instance *self );
264
265 /**
266  * Add a new MRL to the playlist
267  * \param self the mediacontrol instance
268  * \param psz_file the MRL
269  * \param exception an initialized exception pointer
270  */
271 VLC_PUBLIC_API void mediacontrol_playlist_add_item( mediacontrol_Instance *self,
272                                      const char* psz_file,
273                                      mediacontrol_Exception *exception );
274 /**
275  * Clear the playlist
276  * \param self the mediacontrol instance
277  * \param exception an initialized exception pointer
278  */
279 VLC_PUBLIC_API void mediacontrol_playlist_clear( mediacontrol_Instance *self,
280                                   mediacontrol_Exception *exception );
281 /**
282  * Get a flattened view of the playlist
283  * \param self the mediacontrol instance
284  * \param exception an initialized exception pointer
285  * \return a list of strings
286  */
287 VLC_PUBLIC_API mediacontrol_PlaylistSeq *
288   mediacontrol_playlist_get_list( mediacontrol_Instance *self,
289                                   mediacontrol_Exception *exception );
290
291 /**
292  * Play the next item
293  * \param self the mediacontrol instance
294  * \param exception an initialized exception pointer
295  */
296 VLC_PUBLIC_API void
297 mediacontrol_playlist_next_item( mediacontrol_Instance *self,
298                                  mediacontrol_Exception *exception );
299
300 /*****************************************************************************
301  * A/V functions
302  *****************************************************************************/
303 /**
304  * Get a snapshot
305  * \param self the mediacontrol instance
306  * \param a_position the desired position (ignored for now)
307  * \param exception an initialized exception pointer
308  * \return a RGBpicture
309  */
310 VLC_PUBLIC_API mediacontrol_RGBPicture *
311   mediacontrol_snapshot( mediacontrol_Instance *self,
312                          const mediacontrol_Position *a_position,
313                          mediacontrol_Exception *exception );
314
315 /* Return a NULL terminated list */
316 /**
317  * Get a list of all cached snapshots (unimplemented)
318  * \param self the mediacontrol instance
319  * \param exception an initialized exception pointer
320  * \return a NULL-terminated list of RGBpicture
321  */
322 VLC_PUBLIC_API mediacontrol_RGBPicture **
323   mediacontrol_all_snapshots( mediacontrol_Instance *self,
324                               mediacontrol_Exception *exception );
325
326 /**
327  *  Displays the message string, between "begin" and "end" positions.
328  * \param self the mediacontrol instance
329  * \param message the message to display
330  * \param begin the begin position
331  * \param end the end position
332  * \param exception an initialized exception pointer
333  */
334 VLC_PUBLIC_API void mediacontrol_display_text( mediacontrol_Instance *self,
335                                 const char *message,
336                                 const mediacontrol_Position *begin,
337                                 const mediacontrol_Position *end,
338                                 mediacontrol_Exception *exception );
339
340 /**
341  *  Get information about a stream
342  * \param self the mediacontrol instance
343  * \param a_key the time unit
344  * \param exception an initialized exception pointer
345  * \return a mediacontrol_StreamInformation
346  */
347 VLC_PUBLIC_API mediacontrol_StreamInformation *
348   mediacontrol_get_stream_information( mediacontrol_Instance *self,
349                                        mediacontrol_PositionKey a_key,
350                                        mediacontrol_Exception *exception );
351
352 /**
353  * Get the current audio level, normalized in [0..100]
354  * \param self the mediacontrol instance
355  * \param exception an initialized exception pointer
356  * \return the volume
357  */
358 VLC_PUBLIC_API unsigned short
359   mediacontrol_sound_get_volume( mediacontrol_Instance *self,
360                                  mediacontrol_Exception *exception );
361 /**
362  * Set the audio level
363  * \param self the mediacontrol instance
364  * \param volume the volume (normalized in [0..100])
365  * \param exception an initialized exception pointer
366  */
367 VLC_PUBLIC_API void mediacontrol_sound_set_volume( mediacontrol_Instance *self,
368                                     const unsigned short volume,
369                                     mediacontrol_Exception *exception );
370
371 /**
372  * Set the video output window
373  * \param self the mediacontrol instance
374  * \param visual_id the Xid or HWND, depending on the platform
375  * \param exception an initialized exception pointer
376  */
377 VLC_PUBLIC_API vlc_bool_t mediacontrol_set_visual( mediacontrol_Instance *self,
378                                     WINDOWHANDLE visual_id,
379                                     mediacontrol_Exception *exception );
380
381 /**
382  * Get the current playing rate, in percent
383  * \param self the mediacontrol instance
384  * \param exception an initialized exception pointer
385  * \return the rate
386  */
387 VLC_PUBLIC_API int mediacontrol_get_rate( mediacontrol_Instance *self,
388                            mediacontrol_Exception *exception );
389
390 /**
391  * Set the playing rate, in percent
392  * \param self the mediacontrol instance
393  * \param rate the desired rate
394  * \param exception an initialized exception pointer
395  */
396 VLC_PUBLIC_API void mediacontrol_set_rate( mediacontrol_Instance *self,
397                             const int rate,
398                             mediacontrol_Exception *exception );
399
400 /**
401  * Get current fullscreen status
402  * \param self the mediacontrol instance
403  * \param exception an initialized exception pointer
404  * \return the fullscreen status
405  */
406 VLC_PUBLIC_API int mediacontrol_get_fullscreen( mediacontrol_Instance *self,
407                                  mediacontrol_Exception *exception );
408
409 /**
410  * Set fullscreen status
411  * \param self the mediacontrol instance
412  * \param b_fullscreen the desired status
413  * \param exception an initialized exception pointer
414  */
415 VLC_PUBLIC_API void mediacontrol_set_fullscreen( mediacontrol_Instance *self,
416                                   const int b_fullscreen,
417                                   mediacontrol_Exception *exception );
418
419 # ifdef __cplusplus
420 }
421 # endif
422
423 #endif
424
425 /** @} */