]> git.sesse.net Git - vlc/blob - bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlc.java
jvlc: LibVlcMediaInstance renamed to LibVlcMediaPlayer
[vlc] / bindings / java / core / src / main / java / org / videolan / jvlc / internal / LibVlc.java
1 /*****************************************************************************
2  * LibVlc.java: VLC Java Bindings JNA Glue
3  *****************************************************************************
4  * Copyright (C) 1998-2008 the VideoLAN team
5  *
6  * Authors: Filippo Carone <filippo@carone.org>
7  *
8  *
9  * $Id $
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 package org.videolan.jvlc.internal;
27
28 import java.util.HashMap;
29 import java.util.Map;
30
31 import com.sun.jna.Callback;
32 import com.sun.jna.Library;
33 import com.sun.jna.Native;
34 import com.sun.jna.NativeLong;
35 import com.sun.jna.Platform;
36 import com.sun.jna.Pointer;
37 import com.sun.jna.PointerType;
38 import com.sun.jna.Structure;
39 import com.sun.jna.Union;
40 import com.sun.jna.win32.W32APIFunctionMapper;
41 import com.sun.jna.win32.W32APITypeMapper;
42
43
44 public interface LibVlc extends Library
45 {
46     Map options = new HashMap() {
47         {
48             put(Library.OPTION_DLOPEN_GLOBAL, Boolean.TRUE);
49         }
50     };
51     
52     LibVlc INSTANCE = (LibVlc) Native.loadLibrary(Platform.isWindows()? "libvlc" : "vlc", LibVlc.class, options);
53
54     LibVlc SYNC_INSTANCE = (LibVlc) Native.synchronizedLibrary(INSTANCE);
55     
56     public static class libvlc_exception_t extends Structure
57     {
58
59         public int raised;
60
61         public int code;
62
63         public String message;
64     }
65
66     public static class libvlc_log_message_t extends Structure
67     {
68
69         public int sizeof_msg; /* sizeof() of message structure, must be filled in by user */
70
71         public int i_severity; /* 0=INFO, 1=ERR, 2=WARN, 3=DBG */
72
73         public String psz_type; /* module type */
74
75         public String psz_name; /* module name */
76
77         public String psz_header; /* optional header */
78
79         public String psz_message; /* message */
80     }
81
82     public static class libvlc_event_t extends Structure
83     {
84
85         public int type;
86
87         public Pointer obj;
88
89         public event_type_specific event_type_specific;
90
91     }
92
93     public class media_meta_changed extends Structure
94     {
95
96         public Pointer meta_type;
97     }
98
99     public class media_subitem_added extends Structure
100     {
101
102         public LibVlcMedia new_child;
103     }
104
105     public class media_duration_changed extends Structure
106     {
107
108         public NativeLong new_duration;
109     }
110
111     public class media_preparsed_changed extends Structure
112     {
113
114         public int new_status;
115     }
116
117     public class media_freed extends Structure
118     {
119
120         public LibVlcMedia md;
121     }
122
123     public class media_state_changed extends Structure
124     {
125
126         // @todo: check this one
127         public int new_state;
128     }
129
130     /* media instance */
131
132     public class media_player_position_changed extends Structure
133     {
134
135         public float new_position;
136     }
137
138     public class media_player_time_changed extends Structure
139     {
140
141         // @todo: check this one
142         public long new_time;
143     }
144
145     /* media list */
146     public class media_list_item_added extends Structure
147     {
148
149         public LibVlcMedia item;
150
151         public int index;
152     }
153
154     public class media_list_will_add_item extends Structure
155     {
156
157         public LibVlcMedia item;
158
159         public int index;
160     }
161
162     public class media_list_item_deleted extends Structure
163     {
164
165         public LibVlcMedia item;
166
167         public int index;
168     }
169
170     public class media_list_will_delete_item extends Structure
171     {
172
173         public LibVlcMedia item;
174
175         public int index;
176     }
177
178     /* media list view */
179     public class media_list_view_item_added extends Structure
180     {
181
182         public LibVlcMedia item;
183
184         public int index;
185     }
186
187     public class media_list_view_will_add_item extends Structure
188     {
189
190         public LibVlcMedia item;
191
192         public int index;
193     }
194
195     public class media_list_view_item_deleted extends Structure
196     {
197
198         public LibVlcMedia item;
199
200         public int index;
201     }
202
203     public class media_list_view_will_delete_item extends Structure
204     {
205
206         public LibVlcMedia item;
207
208         public int index;
209     }
210
211     /* media discoverer */
212     public class media_media_discoverer_started extends Structure
213     {
214
215         public Pointer unused;
216     }
217
218     public class media_media_discoverer_ended extends Structure
219     {
220
221         public Pointer unused;
222     }
223
224     public class event_type_specific extends Union
225     {
226
227         public media_meta_changed media_meta_changed;
228
229         public media_subitem_added media_subitem_added;
230
231         public media_duration_changed media_duration_changed;
232
233         public media_preparsed_changed media_preparsed_changed;
234
235         public media_freed media_freed;
236
237         public media_state_changed media_state_changed;
238
239         public media_player_position_changed media_player_position_changed;
240
241         public media_player_time_changed media_player_time_changed;
242
243         public media_list_item_added media_list_item_added;
244
245         public media_list_will_add_item media_list_will_add_item;
246
247         public media_list_item_deleted media_list_item_deleted;
248
249         public media_list_will_delete_item media_list_will_delete_item;
250
251         public media_list_view_item_added media_list_view_item_added;
252
253         public media_list_view_will_add_item media_list_view_will_add_item;
254
255         public media_list_view_item_deleted media_list_view_item_deleted;
256
257         public media_list_view_will_delete_item media_list_view_will_delete_item;
258     }
259
260     public class LibVlcInstance extends PointerType
261     {
262     }
263
264     public class LibVlcMedia extends PointerType
265     {
266     }
267
268     public class LibVlcMediaPlayer extends PointerType
269     {
270     }
271
272     public class LibVlcMediaList extends PointerType
273     {
274     }
275
276     public class LibVlcMediaListPlayer extends PointerType
277     {
278     }
279
280     public class LibVlcEventManager extends PointerType
281     {
282     }
283
284     public class LibVlcLog extends PointerType
285     {
286     }
287
288     public class LibVlcLogIterator extends PointerType
289     {
290     }
291
292     // exception handling
293     void libvlc_exception_init(libvlc_exception_t exception);
294
295     int libvlc_exception_raised(final libvlc_exception_t exception);
296
297     void libvlc_exception_raise(libvlc_exception_t exception, String format, Object... args);
298
299     void libvlc_exception_clear(libvlc_exception_t exception);
300
301     String libvlc_exception_get_message(libvlc_exception_t exception);
302
303     // core
304     LibVlcInstance libvlc_new(int argc, String[] argv, libvlc_exception_t exception);
305
306     void libvlc_release(LibVlcInstance libvlc_instance_t);
307   
308     void libvlc_add_intf(LibVlcInstance libvlc_instance_t, String name, libvlc_exception_t exception);
309     
310     void libvlc_wait(LibVlcInstance libvlc_instance_t);
311     
312     String libvlc_get_version();
313     
314     String libvlc_get_compiler();
315     
316     String libvlc_get_changeset();
317
318     // video
319
320     void libvlc_video_set_parent(LibVlcInstance libvlc_instance, long drawable, libvlc_exception_t exception);
321
322     void libvlc_toggle_fullscreen(LibVlcMediaPlayer libvlc_instance);
323
324     void libvlc_set_fullscreen(LibVlcMediaPlayer instance, int fullscreen, libvlc_exception_t exception);
325
326     int libvlc_get_fullscreen(LibVlcMediaPlayer instance, libvlc_exception_t exception);
327
328     int libvlc_video_get_height(LibVlcMediaPlayer instance, libvlc_exception_t exception);
329
330     int libvlc_video_get_width(LibVlcMediaPlayer instance, libvlc_exception_t exception);
331
332     String libvlc_video_get_aspect_ration(LibVlcMediaPlayer instance, libvlc_exception_t exception);
333
334     void libvlc_video_set_aspect_ration(LibVlcMediaPlayer instance, String ratio, libvlc_exception_t exception);
335
336     int libvlc_video_get_spu(LibVlcMediaPlayer instance, libvlc_exception_t exception);
337
338     int libvlc_video_set_spu(LibVlcMediaPlayer instance, int spu, libvlc_exception_t exception);
339
340     String libvlc_video_get_crop_geometry(LibVlcMediaPlayer instance, libvlc_exception_t exception);
341
342     void libvlc_video_set_crop_geometry(LibVlcMediaPlayer instance, String geometry, libvlc_exception_t exception);
343
344     void libvlc_video_take_snapshot(LibVlcMediaPlayer instance, String filename, int width, int height,
345         libvlc_exception_t exception);
346
347     void libvlc_video_destroy(LibVlcMediaPlayer instance, libvlc_exception_t exception);
348
349     void libvlc_video_resize(LibVlcMediaPlayer instance, int width, int height, libvlc_exception_t exception);
350
351     void libvlc_video_reparent(LibVlcMediaPlayer instance, long drawable, libvlc_exception_t exception);
352
353     void libvlc_video_set_size(LibVlcInstance instance, int width, int height, libvlc_exception_t exception);
354
355     // audio
356
357     void libvlc_audio_toggle_mute(LibVlcInstance instance, libvlc_exception_t exception);
358
359     void libvlc_audio_set_mute(LibVlcInstance instance, int mute, libvlc_exception_t exception);
360
361     int libvlc_audio_get_mute(LibVlcInstance instance, libvlc_exception_t exception);
362
363     int libvlc_audio_get_volume(LibVlcInstance instance, libvlc_exception_t exception);
364
365     int libvlc_audio_set_volume(LibVlcInstance instance, int volume, libvlc_exception_t exception);
366
367     int libvlc_audio_get_track_count(LibVlcMediaPlayer mediaInstance, libvlc_exception_t exception);
368
369     int libvlc_audio_get_track(LibVlcMediaPlayer mediaInstance, libvlc_exception_t exception);
370
371     void libvlc_audio_set_track(LibVlcMediaPlayer mediaInstance, int channel, libvlc_exception_t exception);
372
373     int libvlc_audio_get_channel(LibVlcInstance instance, libvlc_exception_t exception);
374
375     void libvlc_audio_set_channel(LibVlcInstance instance, int channel, libvlc_exception_t exception);
376
377     // playlist
378
379     void libvlc_playlist_loop(LibVlcInstance instance, int loop, libvlc_exception_t exception);
380
381     void libvlc_playlist_play(LibVlcInstance instance, int itemIndex, int optionsCount, String[] options,
382         libvlc_exception_t exception);
383
384     void libvlc_playlist_pause(LibVlcInstance instance, libvlc_exception_t exception);
385
386     void libvlc_playlist_stop(LibVlcInstance instance, libvlc_exception_t exception);
387
388     int libvlc_playlist_isplaying(LibVlcInstance instance, libvlc_exception_t exception);
389
390     int libvlc_playlist_items_count(LibVlcInstance instance, libvlc_exception_t exception);
391
392     void libvlc_playlist_next(LibVlcInstance instance, libvlc_exception_t exception);
393
394     void libvlc_playlist_prev(LibVlcInstance instance, libvlc_exception_t exception);
395
396     void libvlc_playlist_clear(LibVlcInstance instance, libvlc_exception_t exception);
397
398     int libvlc_playlist_add(LibVlcInstance instance, String uri, String name, libvlc_exception_t exception);
399
400     int libvlc_playlist_delete_item(LibVlcInstance instance, int itemIndex, libvlc_exception_t exception);
401
402     LibVlcMediaPlayer libvlc_playlist_get_media_player(LibVlcInstance instance, libvlc_exception_t exception);
403
404     int libvlc_media_player_is_seekable(LibVlcMediaPlayer instance, libvlc_exception_t exception);
405
406     int libvlc_media_player_can_pause(LibVlcMediaPlayer instance, libvlc_exception_t exception);
407
408     // media descriptor
409
410     LibVlcMedia libvlc_media_new(LibVlcInstance libvlc_instance, String mrl, libvlc_exception_t exception);
411
412     void libvlc_media_add_option(LibVlcMedia media, String option, libvlc_exception_t exception);
413
414     LibVlcMedia libvlc_media_duplicate(LibVlcMedia media);
415     
416     String libvlc_media_get_mrl(LibVlcMedia media);
417
418     void libvlc_media_retain(LibVlcMedia media);
419     
420     void libvlc_media_release(LibVlcMedia media);
421     
422     int libvlc_media_get_state(LibVlcMedia media, libvlc_exception_t exception);
423     
424     LibVlcMediaList libvlc_media_subitems(LibVlcMedia media, libvlc_exception_t exception);
425
426     LibVlcEventManager libvlc_media_event_manager(LibVlcMedia media, libvlc_exception_t exception);
427     
428     long libvlc_get_duration(LibVlcMedia media, libvlc_exception_t exception);
429     
430     int libvlc_media_is_preparsed(LibVlcMedia media, libvlc_exception_t exception);
431
432     // media player
433
434     LibVlcMediaPlayer libvlc_media_player_new(LibVlcInstance instance, libvlc_exception_t exception);
435
436     LibVlcMediaPlayer libvlc_media_player_new_from_media(LibVlcMedia media, libvlc_exception_t exception);
437
438     void libvlc_media_player_play(LibVlcMediaPlayer media_player, libvlc_exception_t exception);
439
440     void libvlc_media_player_pause(LibVlcMediaPlayer media_player, libvlc_exception_t exception);
441
442     void libvlc_media_player_stop(LibVlcMediaPlayer media_player, libvlc_exception_t exception);
443
444     void libvlc_media_player_set_drawable(LibVlcMediaPlayer libvlc_media_player, int drawable,
445         libvlc_exception_t exception);
446
447     long libvlc_media_player_get_length(LibVlcMediaPlayer instance, libvlc_exception_t exception);
448
449     long libvlc_media_player_get_time(LibVlcMediaPlayer instance, libvlc_exception_t exception);
450
451     void libvlc_media_player_set_time(LibVlcMediaPlayer instance, long time, libvlc_exception_t exception);
452
453     float libvlc_media_player_get_position(LibVlcMediaPlayer instance, libvlc_exception_t exception);
454
455     void libvlc_media_player_set_position(LibVlcMediaPlayer instance, float position, libvlc_exception_t exception);
456
457     int libvlc_media_player_will_play(LibVlcMediaPlayer instance, libvlc_exception_t exception);
458
459     void libvlc_media_player_set_rate(LibVlcMediaPlayer instance, float rate, libvlc_exception_t exception);
460
461     float libvlc_media_player_get_rate(LibVlcMediaPlayer instance, libvlc_exception_t exception);
462
463     int libvlc_media_player_has_vout(LibVlcMediaPlayer instance2, libvlc_exception_t exception);
464
465     float libvlc_media_player_get_fps(LibVlcMediaPlayer instance2, libvlc_exception_t exception);
466
467     void libvlc_media_player_release(LibVlcMediaPlayer instance);
468
469     LibVlcEventManager libvlc_media_player_event_manager(LibVlcMediaPlayer media_player, libvlc_exception_t exception);
470
471     // media list
472
473     LibVlcMediaList libvlc_media_list_new(LibVlcInstance libvlc_instance, libvlc_exception_t exception);
474
475     void libvlc_media_list_release(LibVlcMediaList libVlcMediaList);
476
477     void libvlc_media_list_add_file_content(LibVlcMediaList libvlc_media_list, String fileName,
478         libvlc_exception_t exception);
479
480     void libvlc_media_list_set_media(LibVlcMediaList libvlc_media_list, LibVlcMedia libvlc_media,
481         libvlc_exception_t exception);
482
483     LibVlcMedia libvlc_media_list_media(LibVlcMediaList libvlc_media_list, libvlc_exception_t exception);
484
485     void libvlc_media_list_add_media(LibVlcMediaList libvlc_media_list, LibVlcMedia libvlc_media,
486         libvlc_exception_t exception);
487
488     void libvlc_media_list_insert_media(LibVlcMediaList libvlc_media_list, LibVlcMedia libvlc_media,
489         int position, libvlc_exception_t exception);
490
491     void libvlc_media_list_remove_index(LibVlcMediaList libvlc_media_list, int position, libvlc_exception_t exception);
492
493     int libvlc_media_list_count(LibVlcMediaList libvlc_media_list, libvlc_exception_t exception);
494
495     LibVlcMedia libvlc_media_list_item_at_index(LibVlcMediaList libvlc_media_list, int position,
496         libvlc_exception_t exception);
497
498     int libvlc_media_list_index_of_item(LibVlcMediaList libvlc_media_list, LibVlcMedia libvlc_media,
499         libvlc_exception_t exception);
500
501     int libvlc_media_list_is_readonly(LibVlcMediaList libvlc_media_list);
502
503     LibVlcEventManager libvlc_media_list_event_manager(LibVlcMediaList libvlc_media_list, libvlc_exception_t exception);
504
505     // libvlc_media_list_player
506
507     LibVlcMediaListPlayer libvlc_media_list_player_new(LibVlcInstance libvlc_media_player, libvlc_exception_t exception);
508
509     void libvlc_media_list_player_release(LibVlcMediaListPlayer libvlc_media_list_player);
510
511     void libvlc_media_list_player_set_media_player(LibVlcMediaListPlayer libvlc_media_list_player,
512         LibVlcMediaPlayer libvlc_media_player, libvlc_exception_t exception);
513
514     void libvlc_media_list_player_set_media_list(LibVlcMediaListPlayer libvlc_media_list_player,
515         LibVlcMediaList libvlc_media_list, libvlc_exception_t exception);
516
517     void libvlc_media_list_player_play(LibVlcMediaListPlayer libvlc_media_list_player, libvlc_exception_t exception);
518
519     void libvlc_media_list_player_pause(LibVlcMediaListPlayer libvlc_media_list_player, libvlc_exception_t exception);
520
521     int libvlc_media_list_player_is_playing(LibVlcMediaListPlayer libvlc_media_list_player, libvlc_exception_t exception);
522
523     int libvlc_media_list_player_get_state(LibVlcMediaListPlayer libvlc_media_list_player, libvlc_exception_t exception);
524
525     void libvlc_media_list_player_play_item_at_index(LibVlcMediaListPlayer libvlc_media_list_player, int position,
526         libvlc_exception_t exception);
527
528     void libvlc_media_list_player_play_item(LibVlcMediaListPlayer libvlc_media_list_player,
529         LibVlcMedia libvlc_media, libvlc_exception_t exception);
530
531     void libvlc_media_list_player_stop(LibVlcMediaListPlayer libvlc_media_list_player, libvlc_exception_t exception);
532
533     void libvlc_media_list_player_next(LibVlcMediaListPlayer libvlc_media_list_player, libvlc_exception_t exception);
534
535     // VLM
536
537     void libvlc_vlm_add_broadcast(LibVlcInstance p_instance, String psz_name, String psz_input, String psz_output,
538         int i_options, String[] ppsz_options, int b_enabled, int b_loop, libvlc_exception_t p_e);
539
540     void libvlc_vlm_add_vod(LibVlcInstance p_instance, String psz_name, String psz_input, int i_options,
541         String[] ppsz_options, int b_enabled, String psz_mux, libvlc_exception_t p_e);
542
543     void libvlc_vlm_del_media(LibVlcInstance p_instance, String psz_name, libvlc_exception_t p_e);
544
545     void libvlc_vlm_set_enabled(LibVlcInstance p_instance, String psz_name, int b_enabled, libvlc_exception_t p_e);
546
547     void libvlc_vlm_set_output(LibVlcInstance p_instance, String psz_name, String psz_output, libvlc_exception_t p_e);
548
549     void libvlc_vlm_set_input(LibVlcInstance p_instance, String psz_name, String psz_input, libvlc_exception_t p_e);
550
551     void libvlc_vlm_add_input(LibVlcInstance p_instance, String psz_name, String psz_input, libvlc_exception_t p_e);
552
553     void libvlc_vlm_set_loop(LibVlcInstance p_instance, String psz_name, int b_loop, libvlc_exception_t p_e);
554
555     void libvlc_vlm_set_mux(LibVlcInstance p_instance, String psz_name, String psz_mux, libvlc_exception_t p_e);
556
557     void libvlc_vlm_change_media(LibVlcInstance p_instance, String psz_name, String psz_input, String psz_output,
558         int i_options, String[] ppsz_options, int b_enabled, int b_loop, libvlc_exception_t p_e);
559
560     void libvlc_vlm_play_media(LibVlcInstance p_instance, String psz_name, libvlc_exception_t p_e);
561
562     void libvlc_vlm_stop_media(LibVlcInstance p_instance, String psz_name, libvlc_exception_t p_e);
563
564     void libvlc_vlm_pause_media(LibVlcInstance p_instance, String psz_name, libvlc_exception_t p_e);
565
566     void libvlc_vlm_seek_media(LibVlcInstance p_instance, String psz_name, float f_percentage, libvlc_exception_t p_e);
567
568     String libvlc_vlm_show_media(LibVlcInstance p_instance, String psz_name, libvlc_exception_t p_e);
569
570     void libvlc_vlm_release(LibVlcInstance p_instance, libvlc_exception_t p_e);
571
572     // event manager
573
574     public static interface LibVlcCallback extends Callback
575     {
576
577         void callback(libvlc_event_t libvlc_event, Pointer userData);
578     }
579
580     void libvlc_event_attach(LibVlcEventManager event_manager, int event_type, LibVlcCallback callback,
581         Pointer userData, libvlc_exception_t exception);
582
583     void libvlc_event_detach(LibVlcEventManager event_manager, int event_type, LibVlcCallback callback,
584         Pointer userData, libvlc_exception_t excecption);
585
586     void libvlc_toggle_fullscreen(LibVlcMediaPlayer instance, libvlc_exception_t exception);
587
588     // logging
589
590     int libvlc_get_log_verbosity(LibVlcInstance p_instance, libvlc_exception_t p_e);
591
592     void libvlc_set_log_verbosity(LibVlcInstance p_instance, int level, libvlc_exception_t p_e);
593
594     LibVlcLog libvlc_log_open(LibVlcInstance p_instance, libvlc_exception_t p_e);
595
596     void libvlc_log_close(LibVlcLog p_log, libvlc_exception_t p_e);
597
598     int libvlc_log_count(LibVlcLog p_log, libvlc_exception_t p_e);
599
600     void libvlc_log_clear(LibVlcLog p_log, libvlc_exception_t p_e);
601
602     LibVlcLogIterator libvlc_log_get_iterator(LibVlcLog p_log, libvlc_exception_t p_e);
603
604     void libvlc_log_iterator_free(LibVlcLogIterator p_iter, libvlc_exception_t p_e);
605
606     int libvlc_log_iterator_has_next(LibVlcLogIterator p_iter, libvlc_exception_t p_e);
607
608     libvlc_log_message_t libvlc_log_iterator_next(LibVlcLogIterator p_iter, libvlc_log_message_t p_buffer,
609         libvlc_exception_t p_e);
610
611 }