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