]> git.sesse.net Git - vlc/blob - bindings/cil/src/libvlc.cs
89bad696aed31d422afa1e6dfe740cefb8bba97b
[vlc] / bindings / cil / src / libvlc.cs
1 /**
2  * @file libvlc.cs
3  * @brief Unmanaged LibVLC APIs
4  * @ingroup Internals
5  *
6  * @defgroup Internals LibVLC internals
7  * This covers internal marshalling functions to use the native LibVLC.
8  * Only VLC developpers should need to read this section.
9  */
10
11 /**********************************************************************
12  *  Copyright (C) 2007-2009 RĂ©mi Denis-Courmont.                      *
13  *  This program is free software; you can redistribute and/or modify *
14  *  it under the terms of the GNU General Public License as published *
15  *  by the Free Software Foundation; version 2 of the license, or (at *
16  *  your option) any later version.                                   *
17  *                                                                    *
18  *  This program is distributed in the hope that it will be useful,   *
19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
21  *  See the GNU General Public License for more details.              *
22  *                                                                    *
23  *  You should have received a copy of the GNU General Public License *
24  *  along with this program; if not, you can get it from:             *
25  *  http://www.gnu.org/copyleft/gpl.html                              *
26  **********************************************************************/
27
28 using System;
29 using System.Runtime.InteropServices;
30
31 namespace VideoLAN.LibVLC
32 {
33     /**
34      * @brief Native: unmanaged LibVLC APIs
35      * @ingroup Internals
36      */
37     internal enum MediaOptionFlag
38     {
39         OptionTrusted = 0x2,
40         OptionUnique = 0x100,
41     };
42
43     internal static class LibVLC
44     {
45         /* Where is the run-time?
46          * On ELF platforms, "libvlc.so.2" should be used instead. */
47         const string lib = "libvlc.dll";
48
49         /* exception.c */
50         [DllImport (lib, EntryPoint="libvlc_exception_init")]
51         public static extern void ExceptionInit (NativeException e);
52
53         [DllImport (lib, EntryPoint="libvlc_exception_clear")]
54         public static extern void ExceptionClear (NativeException e);
55
56         /* core.c */
57         [DllImport (lib, EntryPoint="libvlc_get_version")]
58         public static extern IntPtr GetVersion ();
59
60         [DllImport (lib, EntryPoint="libvlc_get_compiler")]
61         public static extern IntPtr GetCompiler ();
62
63         [DllImport (lib, EntryPoint="libvlc_get_changeset")]
64         public static extern IntPtr GetChangeset ();
65
66         [DllImport (LibVLC.lib, EntryPoint="libvlc_free")]
67         public static extern void Free (IntPtr ptr);
68
69         [DllImport (lib, EntryPoint="libvlc_new")]
70         public static extern
71         InstanceHandle Create (int argc, U8String[] argv, NativeException ex);
72
73         /*[DllImport (lib, EntryPoint="libvlc_retain")]
74         public static extern
75         void Retain (InstanceHandle h, NativeException ex);*/
76
77         [DllImport (lib, EntryPoint="libvlc_release")]
78         public static extern
79         void Release (IntPtr h, NativeException ex);
80
81         [DllImport (lib, EntryPoint="libvlc_add_intf")]
82         public static extern
83         void AddIntf (InstanceHandle h, U8String name, NativeException ex);
84
85         [DllImport (lib, EntryPoint="libvlc_wait")]
86         public static extern
87         void Wait (InstanceHandle h);
88
89         [DllImport (lib, EntryPoint="libvlc_get_vlc_instance")]
90         public static extern
91         IntPtr GetVLCInstance (InstanceHandle h);
92
93         /* media.c */
94         [DllImport (lib, EntryPoint="libvlc_media_new")]
95         public static extern
96         MediaHandle MediaCreate (InstanceHandle inst, U8String mrl,
97                                  NativeException ex);
98
99         [DllImport (lib, EntryPoint="libvlc_media_new_as_node")]
100         public static extern
101         MediaHandle MediaCreateAsNode (InstanceHandle inst, U8String name,
102                                        NativeException ex);
103
104         [DllImport (lib, EntryPoint="libvlc_media_add_option")]
105         public static extern
106         void MediaAddOption (MediaHandle media, U8String options,
107                              NativeException ex);
108
109         [DllImport (lib,
110                     EntryPoint="libvlc_media_add_option_flag")]
111         public static extern
112         void MediaAddOptionWithFlag (MediaHandle media, U8String options,
113                                       MediaOptionFlag flag,
114                                       NativeException ex);
115
116         [DllImport (lib, EntryPoint="libvlc_media_release")]
117         public static extern
118         void MediaRelease (IntPtr ptr);
119
120         [DllImport (lib, EntryPoint="libvlc_media_get_mrl")]
121         public static extern
122         StringHandle MediaGetMRL (MediaHandle media, NativeException ex);
123
124         [DllImport (lib, EntryPoint="libvlc_media_duplicate")]
125         public static extern
126         MediaHandle MediaDuplicate (MediaHandle media);
127
128         [DllImport (lib, EntryPoint="libvlc_media_get_meta")]
129         public static extern
130         StringHandle MediaGetMeta (MediaHandle media, MetaType type,
131                                    NativeException ex);
132
133         [DllImport (lib, EntryPoint="libvlc_media_get_state")]
134         public static extern
135         State MediaGetState (MediaHandle media, NativeException ex);
136
137         /*[DllImport (lib, EntryPoint="libvlc_media_subitems")]
138         public static extern
139         MediaListHandle MediaSubItems (MediaHandle media, NativeException ex);*/
140
141         [DllImport (lib, EntryPoint="libvlc_media_event_manager")]
142         public static extern
143         EventManagerHandle MediaEventManager (MediaHandle media,
144                                               NativeException ex);
145
146         [DllImport (lib, EntryPoint="libvlc_media_get_duration")]
147         public static extern
148         long MediaGetDuration (MediaHandle media, NativeException ex);
149
150         [DllImport (lib, EntryPoint="libvlc_media_is_preparsed")]
151         public static extern
152         int MediaIsPreparsed (MediaHandle media, NativeException ex);
153
154         /*[DllImport (lib, EntryPoint="libvlc_media_set_user_data")]
155         public static extern
156         void MediaIsPreparsed (MediaHandle media, IntPtr data,
157                                NativeException ex);*/
158
159         /*[DllImport (lib, EntryPoint="libvlc_media_get_user_data")]
160         public static extern
161         IntPtr MediaIsPreparsed (MediaHandle media, NativeException ex);*/
162
163         /* media_player.c */
164         [DllImport (lib, EntryPoint="libvlc_media_player_new")]
165         public static extern
166         PlayerHandle PlayerCreate (InstanceHandle inst, NativeException ex);
167
168         [DllImport (lib,
169                     EntryPoint="libvlc_media_player_new_from_media")]
170         public static extern
171         PlayerHandle PlayerCreateFromMedia (MediaHandle media,
172                                             NativeException ex);
173
174         [DllImport (lib, EntryPoint="libvlc_media_player_release")]
175         public static extern
176         void PlayerRelease (IntPtr ptr);
177
178         /* PlayerRetain */
179
180         [DllImport (lib,
181                     EntryPoint="libvlc_media_player_set_media")]
182         public static extern
183         void PlayerSetMedia (PlayerHandle player, MediaHandle media,
184                              NativeException ex);
185
186         /*[DllImport (lib,
187                     EntryPoint="libvlc_media_player_get_media")]
188         public static extern
189         MediaHandle PlayerGetMedia (PlayerHandle player,
190                                     NativeException ex);*/
191
192         [DllImport (lib,
193                       EntryPoint="libvlc_media_player_event_manager")]
194         public static extern
195         EventManagerHandle PlayerEventManager (PlayerHandle media,
196                                                NativeException ex);
197
198         [DllImport (lib,
199                     EntryPoint="libvlc_media_player_is_playing")]
200         public static extern
201         int PlayerIsPlaying (PlayerHandle player, NativeException ex);
202
203         [DllImport (lib,
204                     EntryPoint="libvlc_media_player_play")]
205         public static extern
206         void PlayerPlay (PlayerHandle player, NativeException ex);
207
208         [DllImport (lib,
209                     EntryPoint="libvlc_media_player_pause")]
210         public static extern
211         void PlayerPause (PlayerHandle player, NativeException ex);
212
213         [DllImport (lib,
214                     EntryPoint="libvlc_media_player_stop")]
215         public static extern
216         void PlayerStop (PlayerHandle player, NativeException ex);
217
218         [DllImport (lib,
219                     EntryPoint="libvlc_media_player_set_xwindow")]
220         public static extern
221         void PlayerSetXWindow (PlayerHandle player, int xid,
222                                NativeException ex);
223
224         [DllImport (lib,
225                     EntryPoint="libvlc_media_player_get_xwindow")]
226         public static extern
227         int PlayerGetXWindow (PlayerHandle player);
228
229         [DllImport (lib,
230                     EntryPoint="libvlc_media_player_set_hwnd")]
231         public static extern
232         void PlayerSetHWND (PlayerHandle player, SafeHandle hwnd,
233                             NativeException ex);
234
235         [DllImport (lib,
236                     EntryPoint="libvlc_media_player_get_hwnd")]
237         public static extern
238         SafeHandle PlayerGetHWND (PlayerHandle player);
239
240         [DllImport (lib,
241                     EntryPoint="libvlc_media_player_get_length")]
242         public static extern
243         long PlayerGetLength (PlayerHandle player, NativeException ex);
244
245         [DllImport (lib, EntryPoint="libvlc_media_player_get_time")]
246         public static extern
247         long PlayerGetTime (PlayerHandle player, NativeException ex);
248
249         [DllImport (lib, EntryPoint="libvlc_media_player_set_time")]
250         public static extern
251         void PlayerSetTime (PlayerHandle player, long time,
252                             NativeException ex);
253
254         [DllImport (lib,
255                     EntryPoint="libvlc_media_player_get_position")]
256         public static extern
257         float PlayerGetPosition (PlayerHandle player, NativeException ex);
258
259         [DllImport (lib,
260                     EntryPoint="libvlc_media_player_set_position")]
261         public static extern
262         void PlayerSetPosition (PlayerHandle player, float position,
263                                 NativeException ex);
264
265         [DllImport (lib,
266                     EntryPoint="libvlc_media_player_get_chapter")]
267         public static extern
268         int PlayerGetChapter (PlayerHandle player, NativeException ex);
269
270         [DllImport (lib,
271                     EntryPoint="libvlc_media_player_set_chapter")]
272         public static extern
273         void PlayerSetChapter (PlayerHandle player, int chapter,
274                                NativeException ex);
275
276         [DllImport (lib,
277                     EntryPoint="libvlc_media_player_get_chapter_count")]
278         public static extern
279         int PlayerGetChapterCount (PlayerHandle player, NativeException ex);
280
281         /* PlayerWillPlay */
282
283         [DllImport (lib,
284                 EntryPoint="libvlc_media_player_get_chapter_count_for_title")]
285         public static extern
286         int PlayerGetChapterCountForTitle (PlayerHandle player, int title,
287                                            NativeException ex);
288
289         [DllImport (lib,
290                     EntryPoint="libvlc_media_player_get_title")]
291         public static extern
292         int PlayerGetTitle (PlayerHandle player, NativeException ex);
293
294         [DllImport (lib,
295                     EntryPoint="libvlc_media_player_set_title")]
296         public static extern
297         void PlayerSetTitle (PlayerHandle player, int chapter,
298                              NativeException ex);
299
300         [DllImport (lib,
301                     EntryPoint="libvlc_media_player_get_title_count")]
302         public static extern
303         int PlayerGetTitleCount (PlayerHandle player, NativeException ex);
304
305         [DllImport (lib,
306                     EntryPoint="libvlc_media_player_next_chapter")]
307         public static extern
308         void PlayerNextChapter (PlayerHandle player, NativeException ex);
309
310         [DllImport (lib,
311                     EntryPoint="libvlc_media_player_previous_chapter")]
312         public static extern
313         void PlayerPreviousChapter (PlayerHandle player, NativeException ex);
314
315         [DllImport (lib,
316                     EntryPoint="libvlc_media_player_get_rate")]
317         public static extern
318         float PlayerGetRate (PlayerHandle player, NativeException ex);
319
320         [DllImport (lib,
321                     EntryPoint="libvlc_media_player_set_rate")]
322         public static extern
323         void PlayerSetRate (PlayerHandle player, float rate,
324                             NativeException ex);
325
326         [DllImport (lib,
327                     EntryPoint="libvlc_media_player_get_state")]
328         public static extern
329         State PlayerGetState (PlayerHandle player, NativeException ex);
330
331         [DllImport (lib,
332                     EntryPoint="libvlc_media_player_get_fps")]
333         public static extern
334         float PlayerGetFPS (PlayerHandle player, NativeException ex);
335
336         [DllImport (lib,
337                     EntryPoint="libvlc_media_player_has_vout")]
338         public static extern
339         int PlayerHasVout (PlayerHandle player, NativeException ex);
340
341         [DllImport (lib,
342                     EntryPoint="libvlc_media_player_is_seekable")]
343         public static extern
344         int PlayerIsSeekable (PlayerHandle player, NativeException ex);
345
346         [DllImport (lib,
347                     EntryPoint="libvlc_media_player_can_pause")]
348         public static extern
349         int PlayerCanPause (PlayerHandle player, NativeException ex);
350
351
352         /* TODO: video, audio */
353
354         /* event.c */
355         [DllImport (lib, EntryPoint="libvlc_event_attach")]
356         public static extern
357         void EventAttach (EventManagerHandle manager, EventType type,
358                           IntPtr callback, IntPtr user_data,
359                           NativeException ex);
360
361         [DllImport (lib, EntryPoint="libvlc_event_detach")]
362         public static extern
363         void EventDetach (EventManagerHandle manager, EventType type,
364                           IntPtr callback, IntPtr user_data,
365                           NativeException ex);
366
367         /* libvlc_event_type_name */
368     };
369 };