Mercurial > mm7
comparison Media/MediaPlayer.h @ 2502:a77c34acdbc9
Media folder
author | Ritor1 |
---|---|
date | Fri, 19 Sep 2014 05:13:32 +0600 |
parents | |
children | a902abdfc7f2 |
comparison
equal
deleted
inserted
replaced
2501:0ff6a9e9bf7f | 2502:a77c34acdbc9 |
---|---|
1 #pragma once | |
2 #include "OSWindow.h" | |
3 #include "Engine/Graphics/Texture.h" | |
4 #include "Engine/ErrorHandling.h" | |
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 }; | |
42 struct SoundHeader | |
43 { | |
44 char pSoundName[40]; | |
45 unsigned int uFileOffset; | |
46 unsigned int uCompressedSize; | |
47 unsigned int uDecompressedSize; | |
48 }; | |
49 | |
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 | |
62 namespace Media | |
63 { | |
64 class ITrack | |
65 { | |
66 public: | |
67 virtual ~ITrack() {} | |
68 | |
69 virtual void Play(bool loop = false) = 0; | |
70 virtual void Release() = 0; | |
71 }; | |
72 | |
73 class IMovie | |
74 { | |
75 public: | |
76 virtual ~IMovie() {} | |
77 | |
78 virtual void Play() = 0; | |
79 virtual void GetNextFrame(double dt, void *target_surface) = 0; | |
80 virtual void Release() = 0; | |
81 | |
82 }; | |
83 | |
84 class MPlayer | |
85 { | |
86 public: | |
87 MPlayer(); | |
88 virtual ~MPlayer(); | |
89 | |
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; | |
111 HANDLE hVidFile; | |
112 int uSize; | |
113 int uOffset; | |
114 | |
115 void Initialize(OSWindow *window); | |
116 | |
117 void OpenFullscreenMovie(const char *pFilename, unsigned int bLoop); | |
118 void OpenHouseMovie(const char *pMovieName, unsigned int a3_1); | |
119 | |
120 void LoadMovie(const char *); | |
121 void SelectMovieType(); | |
122 | |
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 { | |
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; | |
137 | |
138 default: | |
139 Error("Invalid movie requested: %u", movie_type); | |
140 break; | |
141 } | |
142 } | |
143 void FullscreenMovieLoop(const char *pMovieName, int a2); | |
144 void HouseMovieLoop(); | |
145 | |
146 void ShowMM7IntroVideo_and_LoadingScreen(); | |
147 void Unload(); | |
148 /////////////////////////////////////////////// | |
149 | |
150 IMovie *LoadMovie(const wchar_t *name, int width, int height, int cache_ms); | |
151 IMovie *LoadMovieFromLOD(HANDLE h, int readFunction(void*, uint8_t*, int), int64_t seekFunction(void*, int64_t, int), int width, int height); | |
152 | |
153 //for audio//////////////////////////////////// | |
154 HANDLE hAudioSnd; | |
155 unsigned int uNumSoundHeaders; | |
156 struct SoundHeader *pSoundHeaders; | |
157 | |
158 void LoadAudioSnd(); | |
159 /////////////////////////////////////////////// | |
160 | |
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); | |
167 }; | |
168 }; | |
169 #pragma pack(pop) | |
170 extern Media::MPlayer *pMediaPlayer; | |
171 extern Media::IMovie *pMovie_Track; | |
172 extern Media::ITrack *pAudio_Track; | |
173 extern class Movie *movie; | |
174 | |
175 extern int mSourceID; | |
176 | |
177 extern void PlayMovie(const wchar_t * pFilename); | |
178 extern void PlayAudio(const wchar_t * pFilename); | |
179 extern void MovieRelease(); |