annotate VideoPlayer.h @ 2137:d24ee391fd1f

libavcodec playing movies and houses, loops not working yet
author zipi
date Wed, 01 Jan 2014 13:43:09 +0000
parents 992d2e6f907d
children ca548138d6aa
rev   line source
0
Ritor1
parents:
diff changeset
1 #pragma once
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
2 #include "OSWindow.h"
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
3 #include "Texture.h"
0
Ritor1
parents:
diff changeset
4
Ritor1
parents:
diff changeset
5
Ritor1
parents:
diff changeset
6
Ritor1
parents:
diff changeset
7
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
8
0
Ritor1
parents:
diff changeset
9 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
10
Ritor1
parents:
diff changeset
11
Ritor1
parents:
diff changeset
12
Ritor1
parents:
diff changeset
13 struct _BINK
Ritor1
parents:
diff changeset
14 {
Ritor1
parents:
diff changeset
15 int uWidth;
Ritor1
parents:
diff changeset
16 int uHeight;
Ritor1
parents:
diff changeset
17 };
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19 struct _BINK_1_5_21_0: public _BINK
Ritor1
parents:
diff changeset
20 {
Ritor1
parents:
diff changeset
21 int uNumFrames;
Ritor1
parents:
diff changeset
22 int uCurrentFrame;
Ritor1
parents:
diff changeset
23 int Data1;
Ritor1
parents:
diff changeset
24 int uFrameRate;
Ritor1
parents:
diff changeset
25 int field_18[3];
Ritor1
parents:
diff changeset
26 int uFlags;
Ritor1
parents:
diff changeset
27 };
Ritor1
parents:
diff changeset
28
Ritor1
parents:
diff changeset
29 struct _BINK_3_0_0_0: public _BINK
Ritor1
parents:
diff changeset
30 {
Ritor1
parents:
diff changeset
31 int unk_0;
Ritor1
parents:
diff changeset
32 int unk_1;
Ritor1
parents:
diff changeset
33 int uNumFrames;
Ritor1
parents:
diff changeset
34 int uCurrentFrame;
Ritor1
parents:
diff changeset
35 int _unk2;
Ritor1
parents:
diff changeset
36 int _unk_[10];
Ritor1
parents:
diff changeset
37 };
Ritor1
parents:
diff changeset
38
Ritor1
parents:
diff changeset
39
Ritor1
parents:
diff changeset
40 struct _BINKBUF
Ritor1
parents:
diff changeset
41 {
Ritor1
parents:
diff changeset
42 int uWidth;
Ritor1
parents:
diff changeset
43 int uHeight;
Ritor1
parents:
diff changeset
44 int field_8;
Ritor1
parents:
diff changeset
45 int field_C;
Ritor1
parents:
diff changeset
46 int uBinkDDSurfaceType;
Ritor1
parents:
diff changeset
47 void *pDDrawSurfaceData;
Ritor1
parents:
diff changeset
48 int uDDrawSurfacePitch;
Ritor1
parents:
diff changeset
49 int field_1C;
Ritor1
parents:
diff changeset
50 int field_20;
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
51 int target_width;
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
52 int target_height;
0
Ritor1
parents:
diff changeset
53 int field_2C;
Ritor1
parents:
diff changeset
54 int field_30;
Ritor1
parents:
diff changeset
55 int field_34;
Ritor1
parents:
diff changeset
56 int field_38;
Ritor1
parents:
diff changeset
57 int field_3C;
Ritor1
parents:
diff changeset
58 int field_40;
Ritor1
parents:
diff changeset
59 int field_44;
Ritor1
parents:
diff changeset
60 struct IDirectDrawSurface *pTargetDDrawSurface;
Ritor1
parents:
diff changeset
61 int field_4C;
Ritor1
parents:
diff changeset
62 int uRectX;
Ritor1
parents:
diff changeset
63 int uRectY;
Ritor1
parents:
diff changeset
64 HWND hWnd;
Ritor1
parents:
diff changeset
65 int field_5C;
Ritor1
parents:
diff changeset
66 float field_60;
Ritor1
parents:
diff changeset
67 float field_64;
Ritor1
parents:
diff changeset
68 int field_68;
Ritor1
parents:
diff changeset
69 int field_6C;
Ritor1
parents:
diff changeset
70 void *pDDrawSurfaceData_;
Ritor1
parents:
diff changeset
71 int field_74;
Ritor1
parents:
diff changeset
72 int field_78;
Ritor1
parents:
diff changeset
73 };
Ritor1
parents:
diff changeset
74 struct _BINKBUF_1_5_21_0: public _BINKBUF
Ritor1
parents:
diff changeset
75 {
Ritor1
parents:
diff changeset
76 int field_7C;
Ritor1
parents:
diff changeset
77 int field_80;
Ritor1
parents:
diff changeset
78 int field_84;
Ritor1
parents:
diff changeset
79 int field_88;
Ritor1
parents:
diff changeset
80 int field_8C;
Ritor1
parents:
diff changeset
81 int field_90;
Ritor1
parents:
diff changeset
82 int field_94;
Ritor1
parents:
diff changeset
83 int field_98;
Ritor1
parents:
diff changeset
84 int field_9C;
Ritor1
parents:
diff changeset
85 int field_A0;
Ritor1
parents:
diff changeset
86 };
Ritor1
parents:
diff changeset
87
Ritor1
parents:
diff changeset
88 struct _BINKBUF_3_0_0_0: public _BINKBUF
Ritor1
parents:
diff changeset
89 {
Ritor1
parents:
diff changeset
90 };
Ritor1
parents:
diff changeset
91 #pragma pack(pop)
Ritor1
parents:
diff changeset
92
Ritor1
parents:
diff changeset
93
Ritor1
parents:
diff changeset
94
Ritor1
parents:
diff changeset
95
Ritor1
parents:
diff changeset
96 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
97 struct MovieHeader
Ritor1
parents:
diff changeset
98 {
Ritor1
parents:
diff changeset
99 char pVideoName[40];
Ritor1
parents:
diff changeset
100 unsigned int uFileOffset;
Ritor1
parents:
diff changeset
101 };
Ritor1
parents:
diff changeset
102 #pragma pack(pop)
Ritor1
parents:
diff changeset
103
Ritor1
parents:
diff changeset
104
Ritor1
parents:
diff changeset
105
Ritor1
parents:
diff changeset
106
Ritor1
parents:
diff changeset
107
1458
934074e7fcc1 ModalWindow
Nomad
parents: 1262
diff changeset
108 void ShowIntroVideo_and_LoadingScreen();
0
Ritor1
parents:
diff changeset
109
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
110 extern "C"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
111 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
112 #include "lib/libavcodec/avcodec.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
113 #include "lib/libavformat/avformat.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
114 #include "lib/libavutil/avutil.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
115 #include "lib/libavutil/imgutils.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
116 #include "lib/libswscale/swscale.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
117 #include "lib/libswresample/swresample.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
118 #include "lib/libavutil/opt.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
119 //#include "libavutil/samplefmt.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
120 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
121 #pragma comment(lib, "avcodec.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
122 #pragma comment(lib, "avformat.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
123 #pragma comment(lib, "avutil.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
124 #pragma comment(lib, "swscale.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
125 #pragma comment(lib, "swresample.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
126
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
127 #include "lib/OpenAL/al.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
128 #include "lib/OpenAL/alc.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
129 #pragma comment(lib, "OpenAL32.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
130
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
131
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
132
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
133 template<int MAX_SAMPLES_BUFFERS>
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
134 class OpenALSoundProviderGeneric
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
135 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
136 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
137 inline OpenALSoundProviderGeneric()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
138 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
139 this->device = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
140 this->context = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
141 this->samples_current_buffer = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
142
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
143 this->samples_source_id = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
144 for (int i = 0; i < MAX_SAMPLES_BUFFERS; ++i)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
145 samples_buffer_id[i] = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
146 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
147
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
148 inline bool Initialize()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
149 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
150 auto device_names = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
151 if (!device_names)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
152 device_names = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
153 if (device_names)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
154 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
155 for (auto device_name = device_names; device_name[0]; device_name += strlen(device_name))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
156 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
157 continue;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
158 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
159 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
160
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
161 device = alcOpenDevice(nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
162 if (!device || CheckError())
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
163 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
164
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
165 context = alcCreateContext(device, nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
166 if (!context || CheckError())
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
167 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
168
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
169 alcMakeContextCurrent(context);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
170
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
171 bool eax2 = alIsExtensionPresent("EAX2.0");
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
172 bool eax3 = alIsExtensionPresent("EAX3.0");
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
173 bool eax4 = alIsExtensionPresent("EAX4.0");
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
174 bool eax5 = alIsExtensionPresent("EAX5.0");
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
175
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
176 auto vendor = alGetString(AL_VERSION);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
177 auto version = alGetString(AL_VERSION);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
178 auto extensions = alcGetString(device, ALC_EXTENSIONS);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
179
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
180 alGenBuffers(MAX_SAMPLES_BUFFERS, samples_buffer_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
181 if (CheckError())
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
182 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
183
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
184 alGenSources(1, &samples_source_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
185 if (CheckError())
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
186 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
187
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
188 float sound_pos[] = { 0.0f, 0.0f, 0.0f };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
189 alSourcefv(samples_source_id, AL_POSITION, sound_pos);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
190 alSourcei(samples_source_id, AL_LOOPING, AL_FALSE);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
191
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
192 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
193 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
194
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
195 void Release()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
196 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
197 if (samples_source_id != -1)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
198 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
199 alDeleteSources(1, &samples_source_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
200 samples_source_id = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
201 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
202
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
203 for (int i = 0; i < MAX_SAMPLES_BUFFERS; ++i)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
204 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
205 if (samples_buffer_id[i] != -1)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
206 alDeleteBuffers(1, &samples_buffer_id[i]);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
207 samples_buffer_id[i] = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
208 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
209
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
210 alcMakeContextCurrent(nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
211 if (context)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
212 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
213 alcDestroyContext(context);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
214 context = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
215 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
216 if (device)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
217 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
218 alcCloseDevice(device);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
219 device = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
220 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
221 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
222
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
223
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
224
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
225
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
226
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
227
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
228
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
229
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
230 void PlaySample(int num_channels, int sample_rate, int num_samples, void *samples)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
231 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
232 //char msg[256];sprintf(msg, "chan %u rate %5u num %5u ptr %p\n", num_channels, sample_rate, num_samples, samples);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
233 //log(msg);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
234 ALenum sound_format;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
235 switch (num_channels)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
236 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
237 case 1: sound_format = AL_FORMAT_MONO16; break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
238 case 2: sound_format = AL_FORMAT_STEREO16; break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
239 default:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
240 if (bool multichannel = alIsExtensionPresent("AL_EXT_MCFORMATS"))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
241 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
242 switch (num_channels)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
243 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
244 case 4: sound_format = alGetEnumValue("AL_FORMAT_QUAD16"); break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
245 case 6: sound_format = alGetEnumValue("AL_FORMAT_51CHN16"); break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
246 case 7: sound_format = alGetEnumValue("AL_FORMAT_61CHN16"); break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
247 case 8: sound_format = alGetEnumValue("AL_FORMAT_71CHN16"); break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
248 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
249 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
250 __debugbreak();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
251 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
252
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
253 float listener_pos[] = { 0.0f, 0.0f, 0.0f };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
254 float listener_vel[] = { 0.0f, 0.0f, 0.0f };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
255 float listener_orientation[] = { 0.0f, 0.0f, -1.0f, // direction
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
256 0.0f, 1.0f, 0.0f }; // up vector
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
257 alListenerfv(AL_POSITION, listener_pos);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
258 alListenerfv(AL_VELOCITY, listener_vel);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
259 alListenerfv(AL_ORIENTATION, listener_orientation);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
260
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
261 unsigned int *next_buffer = samples_buffer_id + samples_current_buffer;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
262
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
263 alBufferData(*next_buffer, sound_format, samples, num_samples * sizeof(__int16), sample_rate);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
264 CheckError();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
265
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
266
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
267 int num_processed_buffers;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
268 alGetSourcei(samples_source_id, AL_BUFFERS_PROCESSED, &num_processed_buffers);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
269 while (num_processed_buffers)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
270 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
271 unsigned int processed_buffers_id[4];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
272 alSourceUnqueueBuffers(samples_source_id, min(4, num_processed_buffers), processed_buffers_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
273 CheckError();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
274 alGetSourcei(samples_source_id, AL_BUFFERS_PROCESSED, &num_processed_buffers);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
275 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
276
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
277 int num_queued_buffers;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
278 alGetSourcei(samples_source_id, AL_BUFFERS_QUEUED, &num_queued_buffers);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
279 if (num_queued_buffers >= MAX_SAMPLES_BUFFERS)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
280 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
281 __debugbreak();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
282 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
283
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
284 alSourceQueueBuffers(samples_source_id, 1, next_buffer);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
285 CheckError();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
286
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
287 int status;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
288 alGetSourcei(samples_source_id, AL_SOURCE_STATE, &status);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
289 if (status != AL_PLAYING)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
290 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
291 alSourcePlay(samples_source_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
292 CheckError();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
293 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
294
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
295 if (++samples_current_buffer >= MAX_SAMPLES_BUFFERS)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
296 samples_current_buffer = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
297 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
298
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
299
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
300
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
301 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
302 ALCdevice *device;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
303 ALCcontext *context;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
304 unsigned int samples_buffer_id[MAX_SAMPLES_BUFFERS];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
305 unsigned int samples_source_id;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
306 int samples_current_buffer;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
307
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
308
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
309 bool CheckError()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
310 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
311 ALenum code = alcGetError(device);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
312 if (code != ALC_NO_ERROR)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
313 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
314 DWORD w;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
315 const char *message = alcGetString(device, code);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
316 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), message, lstrlenA(message), &w, nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
317 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
318 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
319 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
320 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
321 };
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
322 typedef OpenALSoundProviderGeneric<64> OpenALSoundProvider;
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
323
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
324
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
325
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
326 void av_logger(void *, int, const char *format, va_list args);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
327
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
328
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
329
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
330 #include <memory>
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
331 using std::tr1::shared_ptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
332 using std::tr1::make_shared;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
333
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
334 class MultimediaFrame
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
335 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
336 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
337 typedef shared_ptr<MultimediaFrame> Ptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
338 inline MultimediaFrame(AVMediaType type, AVPacket *packet, AVCodecContext *dec_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
339 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
340 this->type = type;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
341 this->f = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
342 this->p = packet;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
343 this->dec_ctx = dec_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
344 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
345 virtual ~MultimediaFrame() { return; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
346
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
347
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
348 AVMediaType Type() const { return type; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
349 AVFrame *GetAVFrame() { return f; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
350
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
351 virtual int Decode() = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
352 virtual void *GetData() = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
353 virtual int GetDataPitch() = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
354
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
355
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
356 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
357 AVMediaType type;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
358 AVFrame *f;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
359 AVPacket *p;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
360 AVCodecContext *dec_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
361 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
362
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
363
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
364
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
365 class MultimediaVideoFrame : public MultimediaFrame
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
366 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
367 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
368 inline MultimediaVideoFrame(AVMediaType type, AVPacket *packet, AVCodecContext *dec_ctx, int width, int height) :
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
369 MultimediaFrame(type, packet, dec_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
370 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
371 this->width = width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
372 this->height = height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
373 this->rescaled_data[0] = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
374 this->rescaled_linesize[0] = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
375 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
376 virtual ~MultimediaVideoFrame()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
377 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
378 av_freep(&rescaled_data);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
379 av_frame_free(&f);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
380 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
381
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
382 int Decode() override
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
383 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
384 f = avcodec_alloc_frame();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
385 avcodec_get_frame_defaults(f);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
386
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
387 volatile int done = false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
388 do
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
389 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
390 int ret;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
391 if ((ret = avcodec_decode_video2(dec_ctx, f, (int *)&done, p)) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
392 return ret;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
393 } while (!done);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
394 if (Rescale(f, width, height, AV_PIX_FMT_RGB32, rescaled_data, rescaled_linesize))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
395 return 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
396 else return -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
397 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
398
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
399 virtual void *GetData() { return rescaled_data[0]; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
400 virtual int GetDataPitch() { return rescaled_linesize[0]; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
401
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
402 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
403 int width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
404 int height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
405 uint8_t *rescaled_data[8];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
406 int rescaled_linesize[8];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
407
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
408 bool Rescale(AVFrame *frame, int dst_width, int dst_height, AVPixelFormat format, uint8_t **out_data, int *out_linesize)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
409 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
410 if (av_image_alloc(out_data, out_linesize, dst_width, dst_height, format, 1) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
411 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
412
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
413 SwsContext *converter = sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
414 dst_width, dst_height, format,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
415 SWS_BICUBIC, nullptr, nullptr, nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
416 sws_scale(converter, frame->data, frame->linesize, 0, frame->height, out_data, out_linesize);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
417 sws_freeContext(converter);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
418
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
419 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
420 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
421 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
422
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
423
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
424
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
425 class MultimediaAudioFrame : public MultimediaFrame
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
426 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
427 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
428 inline MultimediaAudioFrame(AVMediaType type, AVPacket *packet, AVCodecContext *dec_ctx) :
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
429 MultimediaFrame(type, packet, dec_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
430 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
431 this->resampled_data = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
432 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
433 virtual ~MultimediaAudioFrame()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
434 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
435 av_free(resampled_data);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
436 av_frame_free(&f);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
437 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
438
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
439 int Decode() override
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
440 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
441 f = avcodec_alloc_frame();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
442 avcodec_get_frame_defaults(f);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
443
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
444 volatile int done = false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
445 do
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
446 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
447 int ret;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
448 if ((ret = avcodec_decode_audio4(dec_ctx, f, (int *)&done, p)) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
449 return ret;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
450 } while (!done);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
451 if (Resample(f, f->channel_layout, f->sample_rate,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
452 f->channel_layout, f->sample_rate, AV_SAMPLE_FMT_S16, &resampled_data))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
453 return 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
454 else return -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
455 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
456
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
457 virtual void *GetData() { return resampled_data; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
458 virtual int GetDataPitch() { return 2 * f->nb_samples; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
459
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
460 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
461 uint8_t *resampled_data;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
462
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
463 bool Resample(AVFrame *frame,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
464 int64_t src_channel_layout, int src_sample_rate,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
465 int64_t dst_channel_layout, int dst_sample_rate, AVSampleFormat dst_format, uint8_t **out_data)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
466 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
467 SwrContext *converter = swr_alloc();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
468
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
469 av_opt_set_int(converter, "in_channel_layout", src_channel_layout, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
470 av_opt_set_int(converter, "in_sample_rate", src_sample_rate, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
471 av_opt_set_sample_fmt(converter, "in_sample_fmt", (AVSampleFormat)frame->format, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
472
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
473 av_opt_set_int(converter, "out_channel_layout", dst_channel_layout, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
474 av_opt_set_int(converter, "out_sample_rate", dst_sample_rate, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
475 av_opt_set_sample_fmt(converter, "out_sample_fmt", dst_format, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
476
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
477 if (swr_init(converter) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
478 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
479
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
480 int dst_nb_samples;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
481 int max_dst_nb_samples = dst_nb_samples = av_rescale_rnd(frame->nb_samples, dst_sample_rate, src_channel_layout, AV_ROUND_UP);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
482
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
483 uint8_t **dst_data;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
484 int dst_linesize;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
485 int dst_nb_channels = av_get_channel_layout_nb_channels(dst_channel_layout);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
486 if (av_samples_alloc_array_and_samples(&dst_data, &dst_linesize, dst_nb_channels, dst_nb_samples, dst_format, 0) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
487 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
488 swr_free(&converter);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
489 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
490 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
491
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
492 dst_nb_samples = av_rescale_rnd(swr_get_delay(converter, src_sample_rate) + frame->nb_samples, dst_sample_rate, src_sample_rate, AV_ROUND_UP);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
493 if (dst_nb_samples > max_dst_nb_samples)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
494 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
495 av_free(dst_data[0]);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
496 if (av_samples_alloc(dst_data, &dst_linesize, dst_nb_channels, dst_nb_samples, dst_format, 1) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
497 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
498 swr_free(&converter);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
499 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
500 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
501 max_dst_nb_samples = dst_nb_samples;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
502 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
503
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
504
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
505 if (swr_convert(converter, dst_data, dst_nb_samples, (const uint8_t **)frame->data, frame->nb_samples) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
506 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
507 av_free(dst_data[0]);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
508 swr_free(&converter);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
509 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
510 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
511
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
512 *out_data = dst_data[0];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
513 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
514 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
515 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
516
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
517 int readFunction(void* opaque, uint8_t* buf, int buf_size);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
518
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
519 int64_t seekFunction(void* opaque, int64_t offset, int whence);
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
520
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
521 template<int NUM_PRECACHED_FRAMES>
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
522 class MovieCached
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
523 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
524 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
525 bool Stopped() const { return stopped; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
526
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
527 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
528 friend class MultimediaPlayer;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
529 inline MovieCached(OpenALSoundProvider *sound_provider)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
530 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
531 this->format_ctx = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
532 this->sound_provider = sound_provider;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
533 this->stopped = false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
534
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
535 this->video_stream_idx = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
536 this->video_stream = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
537 this->video_stream_dec = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
538 this->video_stream_dec_ctx = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
539
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
540 this->audio_stream_idx = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
541 this->audio_stream = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
542 this->audio_stream_dec = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
543 this->audio_stream_dec_ctx = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
544 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
545
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
546 bool Load(const char *video_filename, int width, int height)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
547 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
548 this->width = width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
549 this->height = height;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
550
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
551 /* for (uint i = 0; i < pVideoPlayer->uNumMagicVideoHeaders; ++i)
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
552 if (!_stricmp(video_filename, pVideoPlayer->pMagicVideoHeaders[i].pVideoName))
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
553 {
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
554 SetFilePointer(pVideoPlayer->hMagicVid, pVideoPlayer->pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
555 break;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
556 }
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
557 */ packet = nullptr;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
558 int ioBufferSize = 32768;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
559 void *src;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
560
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
561 unsigned char * ioBuffer = (unsigned char *)av_malloc(ioBufferSize + FF_INPUT_BUFFER_PADDING_SIZE); // can get av_free()ed by libav
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
562 if (pVideoPlayer->uVidFile)
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
563 {
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
564 src = (void*)pVideoPlayer->hMagicVid;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
565 }
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
566 else
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
567 {
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
568 src = (void*)pVideoPlayer->hMightVid;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
569 }
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
570
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
571 avioContext = avio_alloc_context(ioBuffer, ioBufferSize, 0, src, &readFunction, NULL, &seekFunction);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
572 //offset = SetFilePointer(pVideoPlayer->hMagicVid,0,0,FILE_CURRENT);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
573 LARGE_INTEGER li, li2;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
574 PLARGE_INTEGER pli = &li2;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
575 li.QuadPart = 0;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
576 SetFilePointerEx(pVideoPlayer->hMagicVid, li, pli, FILE_CURRENT);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
577 offset = pli->QuadPart;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
578
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
579 format_ctx = avformat_alloc_context();
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
580 format_ctx->pb = avioContext;
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
581 if (avformat_open_input(&format_ctx, video_filename, nullptr, nullptr) >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
582 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
583 if (avformat_find_stream_info(format_ctx, nullptr) >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
584 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
585 av_dump_format(format_ctx, 0, video_filename, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
586
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
587 video_stream_idx = OpenStream(AVMEDIA_TYPE_VIDEO, &video_stream, &video_stream_dec, &video_stream_dec_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
588 if (video_stream_idx < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
589 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
590
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
591 audio_stream_idx = OpenStream(AVMEDIA_TYPE_AUDIO, &audio_stream, &audio_stream_dec, &audio_stream_dec_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
592 if (audio_stream_idx < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
593 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
594
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
595 strcpy(movie_name, video_filename);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
596 packet = new AVPacket;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
597 av_init_packet(packet);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
598 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
599 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
600 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
601 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
602 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
603
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
604 bool Release()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
605 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
606 if (format_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
607 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
608 avformat_free_context(format_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
609 format_ctx = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
610 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
611 if (packet)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
612 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
613 av_free_packet(packet);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
614 delete packet;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
615 packet = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
616 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
617
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
618 if (video_stream_idx >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
619 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
620 video_stream_idx = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
621 video_stream = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
622 video_stream_dec = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
623 avcodec_close(video_stream_dec_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
624 video_stream_dec_ctx = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
625 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
626
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
627 if (audio_stream_idx >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
628 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
629 audio_stream_idx = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
630 audio_stream = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
631 audio_stream_dec = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
632 avcodec_close(audio_stream_dec_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
633 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
634 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
635 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
636
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
637
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
638 int OpenStream(AVMediaType type, AVStream **out_stream, AVCodec **out_dec, AVCodecContext **out_dec_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
639 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
640 int stream_idx = av_find_best_stream(format_ctx, type, -1, -1, nullptr, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
641 if (stream_idx < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
642 return stream_idx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
643
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
644 auto stream = format_ctx->streams[stream_idx];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
645 auto dec_ctx = stream->codec;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
646 auto dec = avcodec_find_decoder(dec_ctx->codec_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
647 if (dec)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
648 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
649 if (avcodec_open2(dec_ctx, dec, nullptr) >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
650 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
651 *out_stream = stream;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
652 *out_dec = dec;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
653 *out_dec_ctx = dec_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
654 return stream_idx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
655 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
656 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
657 return -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
658 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
659
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
660 void Rewind()
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
661 {
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
662 //auto i=avio_seek(avioContext, pVideoPlayer->uOffset, 0);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
663 //auto i = av_seek_frame(format_ctx, -1, 0, AVSEEK_FLAG_BYTE);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
664 //i = av_seek_frame(format_ctx, audio_stream_idx, 0, AVSEEK_FLAG_BYTE);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
665
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
666 int64_t timestamp = 9;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
667 int ret, i;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
668 if (format_ctx->start_time != AV_NOPTS_VALUE)
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
669 timestamp += format_ctx->start_time;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
670 ret = av_seek_frame(format_ctx, -1, format_ctx->start_time, AVSEEK_FLAG_BYTE);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
671 if (ret < 0) {
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
672 // av_log(ctx, AV_LOG_ERROR, "Unable to loop: %s\n", av_err2str(ret));
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
673 //loop_count = 1; /* do not try again */
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
674 return;// ret;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
675 }
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
676
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
677
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
678 stopped = false;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
679 }
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
680
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
681 MultimediaFrame::Ptr GetNextFrame()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
682 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
683 packet->data = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
684 packet->size = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
685
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
686 volatile int got_frame = false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
687 do
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
688 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
689 if (av_read_frame(format_ctx, packet) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
690 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
691 stopped = true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
692 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
693 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
694 } while (packet->stream_index != video_stream_idx &&
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
695 packet->stream_index != audio_stream_idx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
696
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
697 if (packet->stream_index == video_stream_idx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
698 return MultimediaFrame::Ptr(new MultimediaVideoFrame(AVMEDIA_TYPE_VIDEO, packet, video_stream_dec_ctx, width, height));
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
699 else if (packet->stream_index == audio_stream_idx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
700 return MultimediaFrame::Ptr(new MultimediaAudioFrame(AVMEDIA_TYPE_AUDIO, packet, audio_stream_dec_ctx));
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
701 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
702 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
703
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
704
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
705
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
706 char movie_name[256];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
707 int width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
708 int height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
709 bool stopped;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
710 AVFormatContext *format_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
711 //AVFrame *frame;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
712 AVPacket *packet;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
713 //MultimediaFrame *frames[NUM_PRECACHED_FRAMES];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
714 OpenALSoundProvider *sound_provider;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
715
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
716 int video_stream_idx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
717 AVStream *video_stream;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
718 AVCodec *video_stream_dec;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
719 AVCodecContext *video_stream_dec_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
720
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
721 int audio_stream_idx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
722 AVStream *audio_stream;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
723 AVCodec *audio_stream_dec;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
724 AVCodecContext *audio_stream_dec_ctx;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
725 AVIOContext * avioContext;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
726 int64_t offset;
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
727 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
728 typedef MovieCached<10> Movie;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
729
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
730
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
731
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
732
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
733 class MultimediaPlayer
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
734 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
735 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
736 inline MultimediaPlayer()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
737 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
738 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
739
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
740 bool Initialize()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
741 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
742 if (!libavcodec_initialized)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
743 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
744 av_log_set_callback(Logger);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
745 avcodec_register_all();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
746 av_register_all();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
747
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
748 libavcodec_initialized = true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
749 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
750
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
751 sound_provider = new OpenALSoundProvider;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
752 sound_provider->Initialize();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
753
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
754 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
755 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
756
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
757
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
758 Movie *LoadMovie(const char *filename, int width, int height)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
759 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
760 auto movie = new Movie(sound_provider);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
761 if (movie)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
762 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
763 if (movie->Load(filename, width, height))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
764 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
765 current_movie_width = width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
766 current_movie_height = height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
767 return current_movie = movie;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
768 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
769 delete movie;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
770 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
771 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
772 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
773
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
774 inline void Rewind()
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
775 {
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
776 current_movie->Rewind();
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
777 }
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
778
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
779 inline char *DoFrame()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
780 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
781 if (!current_movie)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
782 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
783
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
784 while (true)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
785 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
786 auto frame = current_movie->GetNextFrame();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
787 if (!frame)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
788 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
789
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
790 if (frame->Type() == AVMEDIA_TYPE_AUDIO)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
791 {
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
792 //continue;
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
793 uint8_t *data;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
794 if (frame->Decode() >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
795 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
796 auto f = frame->GetAVFrame();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
797 sound_provider->PlaySample(f->channels, f->sample_rate, f->nb_samples, frame->GetData());
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
798 Sleep(20);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
799 continue;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
800 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
801 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
802 else if (frame->Type() == AVMEDIA_TYPE_VIDEO)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
803 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
804 uint8_t *dst_data[4] = { 0 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
805 int dst_linesize[4] = { 0 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
806 if (frame->Decode() >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
807 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
808 auto image = new char[current_movie_width * current_movie_height * 4];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
809 memcpy(image, frame->GetData(), current_movie_height * frame->GetDataPitch());
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
810
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
811 return image;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
812 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
813 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
814 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
815 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
816 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
817
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
818
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
819
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
820 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
821 static void Logger(void *, int, const char *format, va_list args);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
822
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
823 OpenALSoundProvider *sound_provider;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
824 Movie *current_movie;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
825 int current_movie_width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
826 int current_movie_height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
827
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
828 static bool libavcodec_initialized;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
829 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
830
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
831
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
832
0
Ritor1
parents:
diff changeset
833
Ritor1
parents:
diff changeset
834
Ritor1
parents:
diff changeset
835
Ritor1
parents:
diff changeset
836 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
837 struct VideoPlayer
Ritor1
parents:
diff changeset
838 {
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
839 VideoPlayer();
0
Ritor1
parents:
diff changeset
840 //----- (004BECBD) --------------------------------------------------------
Ritor1
parents:
diff changeset
841 virtual ~VideoPlayer()
Ritor1
parents:
diff changeset
842 {
Ritor1
parents:
diff changeset
843 bStopBeforeSchedule = false;
165
Ritor1
parents: 0
diff changeset
844 pResetflag = 0;
0
Ritor1
parents:
diff changeset
845 pVideoFrame.Release();
Ritor1
parents:
diff changeset
846 }
Ritor1
parents:
diff changeset
847
Ritor1
parents:
diff changeset
848 void PlayDeathMovie();
Ritor1
parents:
diff changeset
849 unsigned int SmackCheckSurfaceFromat();
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
850 void Initialize(OSWindow *window);
0
Ritor1
parents:
diff changeset
851 void Prepare();
Ritor1
parents:
diff changeset
852 void Unload();
Ritor1
parents:
diff changeset
853 void FastForwardToFrame(unsigned int uFrameNum);
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
854 void BinkDrawFrame(int a3, int a4);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
855 void BinkUpdatePalette() {}
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
856 void SmackDrawFrame(int a3, int a4);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
857 void SmackUpdatePalette();
0
Ritor1
parents:
diff changeset
858 _BINK *OpenBink(const char *pName);
Ritor1
parents:
diff changeset
859 struct _SMACK *OpenSmack(const char *pFilename);
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 323
diff changeset
860 void OpenHouseMovie(const char *pMovieName, unsigned int a3_1);//0x4BF28F
0
Ritor1
parents:
diff changeset
861 bool AnyMovieLoaded();
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 323
diff changeset
862 void OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4);
0
Ritor1
parents:
diff changeset
863 void _4BF5B2();
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 323
diff changeset
864 void SelectMovieType();//0x4BF73A
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
865 _BINKBUF *CreateBinkBuffer(unsigned int uWidth, unsigned int uHeight, char a4);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
866 void _inlined_in_463149();
0
Ritor1
parents:
diff changeset
867
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
868 static void MovieLoop(const char *pMovieName, int a2, int a3, int a4);
0
Ritor1
parents:
diff changeset
869
Ritor1
parents:
diff changeset
870
Ritor1
parents:
diff changeset
871 RGBTexture pVideoFrame;
Ritor1
parents:
diff changeset
872 struct _SMACK *pSmackerMovie;
Ritor1
parents:
diff changeset
873 struct _SMACKBUF *pSmackerBuffer;
Ritor1
parents:
diff changeset
874 char *pSomeSmackerBuffer;
Ritor1
parents:
diff changeset
875 int field_34;
Ritor1
parents:
diff changeset
876 MovieHeader *pMightVideoHeaders;
Ritor1
parents:
diff changeset
877 MovieHeader *pMagicVideoHeaders;
165
Ritor1
parents: 0
diff changeset
878 int pResetflag;
0
Ritor1
parents:
diff changeset
879 int field_44;
Ritor1
parents:
diff changeset
880 unsigned int uNumMightVideoHeaders;
Ritor1
parents:
diff changeset
881 unsigned int uNumMagicVideoHeaders;
Ritor1
parents:
diff changeset
882 int uBinkDirectDrawSurfaceType;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
883 int bBufferLoaded;
0
Ritor1
parents:
diff changeset
884 unsigned int bPlayingMovie;
Ritor1
parents:
diff changeset
885 unsigned int bFirstFrame;
Ritor1
parents:
diff changeset
886 unsigned int bUsingSmackerMMX;
Ritor1
parents:
diff changeset
887 unsigned int bLoopPlaying;
Ritor1
parents:
diff changeset
888 int field_68;
Ritor1
parents:
diff changeset
889 unsigned int bStopBeforeSchedule;
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
890 //HWND hWindow;
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
891 OSWindow *window;
0
Ritor1
parents:
diff changeset
892 struct _SMACKBLIT *pSmackMovieBlit;
Ritor1
parents:
diff changeset
893 HANDLE hMightVid;
Ritor1
parents:
diff changeset
894 HANDLE hMagicVid;
Ritor1
parents:
diff changeset
895 _BINK *pBinkMovie;
Ritor1
parents:
diff changeset
896 _BINKBUF *pBinkBuffer;
Ritor1
parents:
diff changeset
897 char field_88[20];
Ritor1
parents:
diff changeset
898 unsigned int uMovieFormat;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
899 int uMovieFormatSwapped;
0
Ritor1
parents:
diff changeset
900 char pCurrentMovieName[64];
Ritor1
parents:
diff changeset
901 char pVideoFrameTextureFilename[32];
323
d720a13e2273 Very basic picking & entering houses
Nomad
parents: 165
diff changeset
902 int field_104;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
903 MultimediaPlayer *mPlayer;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
904 Movie *mMovie;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
905 int uVidFile;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
906 int uSize;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
907 int uOffset;
0
Ritor1
parents:
diff changeset
908 };
Ritor1
parents:
diff changeset
909 #pragma pack(pop)
Ritor1
parents:
diff changeset
910
Ritor1
parents:
diff changeset
911
Ritor1
parents:
diff changeset
912
Ritor1
parents:
diff changeset
913
Ritor1
parents:
diff changeset
914
Ritor1
parents:
diff changeset
915 extern VideoPlayer *pVideoPlayer;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
916 extern LRESULT __stdcall wWinProc(HWND hwnd, unsigned int msg, WPARAM wparam, LPARAM lparam);