annotate Media/MediaPlayer.h @ 2569:d433439699be

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