2502
|
1 #pragma once
|
|
2 #include "OSWindow.h"
|
2541
|
3
|
|
4 #include "Engine/Engine.h"
|
|
5
|
2502
|
6 #include "Engine/Graphics/Texture.h"
|
|
7
|
|
8 #pragma pack(push, 1)
|
|
9
|
|
10 #pragma pack(pop)
|
|
11
|
|
12 #pragma pack(push, 1)
|
|
13 #pragma pack(pop)
|
|
14
|
|
15
|
|
16
|
|
17 extern "C"
|
|
18 {
|
|
19 #include "lib/libavcodec/avcodec.h"
|
|
20 #include "lib/libavformat/avformat.h"
|
|
21 #include "lib/libavutil/avutil.h"
|
|
22 #include "lib/libavutil/imgutils.h"
|
|
23 #include "lib/libswscale/swscale.h"
|
|
24 #include "lib/libswresample/swresample.h"
|
|
25 #include "lib/libavutil/opt.h"
|
|
26 }
|
|
27 #pragma comment(lib, "avcodec.lib")
|
|
28 #pragma comment(lib, "avformat.lib")
|
|
29 #pragma comment(lib, "avutil.lib")
|
|
30 #pragma comment(lib, "swscale.lib")
|
|
31 #pragma comment(lib, "swresample.lib")
|
|
32
|
|
33 #include "lib/OpenAL/al.h"
|
|
34 #include "lib/OpenAL/alc.h"
|
|
35 #pragma comment(lib, "OpenAL32.lib")
|
|
36
|
|
37 #pragma pack(push, 1)
|
|
38
|
|
39 struct MovieHeader
|
|
40 {
|
|
41 char pVideoName[40];
|
|
42 unsigned int uFileOffset;
|
|
43 };
|
|
44 struct SoundHeader
|
|
45 {
|
|
46 char pSoundName[40];
|
|
47 unsigned int uFileOffset;
|
|
48 unsigned int uCompressedSize;
|
|
49 unsigned int uDecompressedSize;
|
|
50 };
|
|
51
|
|
52 enum MovieType
|
|
53 {
|
|
54 MOVIE_Invalid = 0x0,
|
|
55 MOVIE_3DOLogo = 0x1,
|
|
56 MOVIE_NWCLogo = 0x2,
|
|
57 MOVIE_JVC = 0x3,
|
|
58 MOVIE_Emerald = 0x4,
|
|
59 MOVIE_Intro = 0x5,
|
|
60 MOVIE_Death = 0x6,
|
|
61 MOVIE_Outro = 0x7,
|
|
62 };
|
|
63
|
|
64 namespace Media
|
|
65 {
|
|
66 class ITrack
|
|
67 {
|
|
68 public:
|
|
69 virtual ~ITrack() {}
|
|
70
|
|
71 virtual void Play(bool loop = false) = 0;
|
|
72 virtual void Release() = 0;
|
|
73 };
|
|
74
|
|
75 class IMovie
|
|
76 {
|
|
77 public:
|
|
78 virtual ~IMovie() {}
|
|
79
|
|
80 virtual void Play() = 0;
|
|
81 virtual void GetNextFrame(double dt, void *target_surface) = 0;
|
|
82 virtual void Release() = 0;
|
|
83
|
|
84 };
|
|
85
|
|
86 class MPlayer
|
|
87 {
|
|
88 public:
|
|
89 MPlayer();
|
|
90 virtual ~MPlayer();
|
|
91
|
|
92 //for video/////////////////////////////////////////////////
|
|
93 RGBTexture pVideoFrame;
|
|
94 int field_44;//final video
|
|
95 unsigned int bFirstFrame;
|
|
96 unsigned int bLoopPlaying;
|
|
97 unsigned int bStopBeforeSchedule;
|
|
98 OSWindow *window;
|
|
99 int uMovieType;//0 - null, 1 - bik, 2 - smk
|
|
100 char pCurrentMovieName[64];
|
|
101 char pVideoFrameTextureFilename[32];
|
|
102 MovieHeader *pMightVideoHeaders;
|
|
103 MovieHeader *pMagicVideoHeaders;
|
|
104 HANDLE hMightVid;
|
|
105 HANDLE hMagicVid;
|
|
106 unsigned int uNumMightVideoHeaders;
|
|
107 unsigned int uNumMagicVideoHeaders;
|
|
108 bool bPlaying_Movie;
|
|
109 bool loop_current_file;
|
|
110 DWORD time_video_begin;
|
|
111 int current_movie_width;
|
|
112 int current_movie_height;
|
|
113 HANDLE hVidFile;
|
|
114 int uSize;
|
|
115 int uOffset;
|
|
116
|
|
117 void Initialize(OSWindow *window);
|
|
118
|
|
119 void OpenFullscreenMovie(const char *pFilename, unsigned int bLoop);
|
|
120 void OpenHouseMovie(const char *pMovieName, unsigned int a3_1);
|
|
121
|
|
122 void LoadMovie(const char *);
|
|
123 void SelectMovieType();
|
|
124
|
|
125 inline void PlayFullscreenMovie(MovieType movie_type, bool bShowMouseAfterPlayback)
|
|
126 {
|
|
127 extern unsigned int bNoVideo;
|
|
128 if (bNoVideo) return;
|
|
129
|
|
130 switch (movie_type)
|
|
131 {
|
|
132 case MOVIE_3DOLogo: FullscreenMovieLoop("3dologo", 0); break;
|
|
133 case MOVIE_NWCLogo: FullscreenMovieLoop("new world logo", 0); break;
|
|
134 case MOVIE_JVC: FullscreenMovieLoop("jvc", 0); break;
|
|
135 case MOVIE_Intro: FullscreenMovieLoop("Intro", 0); break;
|
|
136 case MOVIE_Emerald: FullscreenMovieLoop("Intro Post", 0); break;
|
|
137 case MOVIE_Death: FullscreenMovieLoop("losegame", 2); break;
|
|
138 case MOVIE_Outro: FullscreenMovieLoop("end_seq1", 20); break;
|
|
139
|
|
140 default:
|
|
141 Error("Invalid movie requested: %u", movie_type);
|
|
142 break;
|
|
143 }
|
|
144 }
|
|
145 void FullscreenMovieLoop(const char *pMovieName, int a2);
|
|
146 void HouseMovieLoop();
|
|
147
|
|
148 void ShowMM7IntroVideo_and_LoadingScreen();
|
|
149 void Unload();
|
|
150 ///////////////////////////////////////////////
|
|
151
|
|
152 IMovie *LoadMovie(const wchar_t *name, int width, int height, int cache_ms);
|
|
153 IMovie *LoadMovieFromLOD(HANDLE h, int readFunction(void*, uint8_t*, int), int64_t seekFunction(void*, int64_t, int), int width, int height);
|
|
154
|
|
155 //for audio////////////////////////////////////
|
|
156 HANDLE hAudioSnd;
|
|
157 unsigned int uNumSoundHeaders;
|
|
158 struct SoundHeader *pSoundHeaders;
|
|
159
|
|
160 void LoadAudioSnd();
|
|
161 ///////////////////////////////////////////////
|
|
162
|
|
163
|
|
164 ITrack *LoadTrack(const wchar_t *name);
|
|
165
|
|
166 protected:
|
|
167 static int readFunction(void *, uint8_t *, int);
|
|
168 static int64_t seekFunction(void *, int64_t, int);
|
|
169 };
|
|
170 };
|
|
171 #pragma pack(pop)
|
|
172 extern Media::MPlayer *pMediaPlayer;
|
|
173 extern Media::IMovie *pMovie_Track;
|
|
174 extern Media::ITrack *pAudio_Track;
|
|
175 extern class Movie *movie;
|
|
176
|
|
177 extern int mSourceID;
|
|
178
|
|
179 extern void PlayMovie(const wchar_t * pFilename);
|
|
180 extern void PlayAudio(const wchar_t * pFilename);
|
|
181 extern void MovieRelease();
|