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