1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license ( the "Software" ) to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */
28 module derelict.allegro5.video;
29 
30 private {
31     import derelict.util.loader,
32            derelict.util.system;
33 
34     import derelict.allegro5.internal,
35            derelict.allegro5.audio,
36            derelict.allegro5.types;
37 
38     enum libNames = genLibNames( "Video" );
39 }
40 
41 alias ALLEGRO_VIDEO_EVENT_TYPE = int;
42 enum {
43     ALLEGRO_EVENT_VIDEO_FRAME_SHOW   = 550,
44     ALLEGRO_EVENT_VIDEO_FINISHED     = 551,
45 }
46 
47 alias ALLEGRO_VIDEO_POSITION_TYPE = int;
48 enum {
49     ALLEGRO_VIDEO_POSITION_ACTUAL,
50     ALLEGRO_VIDEO_POSITION_VIDEO_DECODE,
51     ALLEGRO_VIDEO_POSITION_AUDIO_DECODE,
52 }
53 
54 struct ALLEGRO_VIDEO;
55 
56 extern( C ) @nogc nothrow {
57     alias da_al_open_video = ALLEGRO_VIDEO* function(const(char)*);
58     alias da_al_close_video = void function(ALLEGRO_VIDEO*);
59     alias da_al_start_video = void function(ALLEGRO_VIDEO*,ALLEGRO_MIXER*);
60     alias da_al_start_video_with_voice = void function(ALLEGRO_VIDEO*,ALLEGRO_VOICE*);
61     alias da_al_get_video_event_source = ALLEGRO_EVENT_SOURCE* function(ALLEGRO_VIDEO*);
62     alias da_al_set_video_playing = void function(ALLEGRO_VIDEO*,bool);
63     alias da_al_is_video_playing = bool function(ALLEGRO_VIDEO*);
64     alias da_al_get_video_audio_rate = double function(ALLEGRO_VIDEO*);
65     alias da_al_get_video_fps = double function(ALLEGRO_VIDEO*);
66     alias da_al_get_video_scaled_width = float function(ALLEGRO_VIDEO*);
67     alias da_al_get_video_scaled_height = float function(ALLEGRO_VIDEO*);
68     alias da_al_get_video_frame = ALLEGRO_BITMAP* function(ALLEGRO_VIDEO*);
69     alias da_al_get_video_position = double function(ALLEGRO_VIDEO*);
70     alias da_al_seek_video = bool function(ALLEGRO_VIDEO*,double);
71     alias da_al_init_video_addon = bool function();
72     alias da_al_shutdown_video_addon = void function();
73     alias da_al_get_allegro_video_version = uint function();
74 }
75 
76 __gshared {
77     da_al_open_video al_open_video;
78     da_al_close_video al_close_video;
79     da_al_start_video al_start_video;
80     da_al_start_video_with_voice al_start_video_with_voice;
81     da_al_get_video_event_source al_get_video_event_source;
82     da_al_set_video_playing al_set_video_playing;
83     da_al_is_video_playing al_is_video_playing;
84     da_al_get_video_audio_rate al_get_video_audio_rate;
85     da_al_get_video_fps al_get_video_fps;
86     da_al_get_video_scaled_width al_get_video_scaled_width;
87     da_al_get_video_scaled_height al_get_video_scaled_height;
88     da_al_get_video_frame al_get_video_frame;
89     da_al_get_video_position al_get_video_position;
90     da_al_seek_video al_seek_video;
91     da_al_init_video_addon al_init_video_addon;
92     da_al_shutdown_video_addon al_shutdown_video_addon;
93     da_al_get_allegro_video_version al_get_allegro_video_version;
94 }
95 
96 class DerelictAllegro5VideoLoader : SharedLibLoader {
97     public this() {
98         super( libNames );
99     }
100 
101     protected override void loadSymbols() {
102         bindFunc( cast( void** )&al_open_video, "al_open_video" );
103         bindFunc( cast( void** )&al_close_video, "al_close_video" );
104         bindFunc( cast( void** )&al_start_video, "al_start_video" );
105         bindFunc( cast( void** )&al_start_video_with_voice, "al_start_video_with_voice" );
106         bindFunc( cast( void** )&al_get_video_event_source, "al_get_video_event_source" );
107         bindFunc( cast( void** )&al_set_video_playing, "al_set_video_playing" );
108         bindFunc( cast( void** )&al_is_video_playing, "al_is_video_playing" );
109         bindFunc( cast( void** )&al_get_video_audio_rate, "al_get_video_audio_rate" );
110         bindFunc( cast( void** )&al_get_video_fps, "al_get_video_fps" );
111         bindFunc( cast( void** )&al_get_video_scaled_width, "al_get_video_scaled_width" );
112         bindFunc( cast( void** )&al_get_video_scaled_height, "al_get_video_scaled_height" );
113         bindFunc( cast( void** )&al_get_video_frame, "al_get_video_frame" );
114         bindFunc( cast( void** )&al_get_video_position, "al_get_video_position" );
115         bindFunc( cast( void** )&al_seek_video, "al_seek_video" );
116         bindFunc( cast( void** )&al_init_video_addon, "al_init_video_addon" );
117         bindFunc( cast( void** )&al_shutdown_video_addon, "al_shutdown_video_addon" );
118         bindFunc( cast( void** )&al_get_allegro_video_version, "al_get_allegro_video_version" );
119     }
120 }
121 
122 __gshared DerelictAllegro5VideoLoader DerelictAllegro5Video;
123 
124 shared static this() {
125     DerelictAllegro5Video = new DerelictAllegro5VideoLoader;
126 }