ScummVM API documentation
avi_surface.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef TITANIC_AVI_SURFACE_H
23#define TITANIC_AVI_SURFACE_H
24
25#include "common/stream.h"
26#include "video/avi_decoder.h"
27#include "graphics/managed_surface.h"
28#include "titanic/core/resource_key.h"
29#include "titanic/support/movie_range_info.h"
30
31namespace Titanic {
32
33class CSoundManager;
34class CVideoSurface;
35
36enum MovieFlag {
37 MOVIE_REPEAT = 1, // Repeat movie
38 MOVIE_STOP_PREVIOUS = 2, // Stop any prior movie playing on the object
39 MOVIE_NOTIFY_OBJECT = 4, // Notify the object when the movie finishes
40 MOVIE_REVERSE = 8, // Play the movie in reverse
41 MOVIE_WAIT_FOR_FINISH = 0x10 // Let finish before playing next movie for object
42};
43
49class y222 : virtual public Common::SeekableReadStream {
50private:
51 File *_innerStream;
52public:
53 y222();
54 ~y222() override;
55
56 uint32 read(void *dataPtr, uint32 dataSize) override;
57 bool eos() const override { return _innerStream->eos(); }
58 int64 pos() const override { return _innerStream->pos(); }
59 int64 size() const override { return _innerStream->size(); }
60 bool seek(int64 offset, int whence = SEEK_SET) override {
61 return _innerStream->seek(offset, whence);
62 }
63 bool skip(uint32 offset) override {
64 return _innerStream->skip(offset);
65 }
66 char *readLine(char *s, size_t bufSize, bool handleCR = true) override {
67 return _innerStream->readLine(s, bufSize, handleCR);
68 }
69 Common::String readLine(bool handleCR = true) override {
70 return _innerStream->readLine(handleCR);
71 }
72};
73
74
76public:
77 AVIDecoder() {}
78 AVIDecoder(const Common::Rational &frameRateOverride) :
79 Video::AVIDecoder(frameRateOverride) {}
80
84 uint videoTrackCount() const { return _videoTracks.size(); }
85
90
95 return static_cast<AVIVideoTrack *>(_transparencyTrack.track);
96 }
97};
98
100private:
101 AVIDecoder *_decoder;
102 CVideoSurface *_videoSurface;
103 CMovieRangeInfoList _movieRangeInfo;
104 int _streamCount;
105 Graphics::ManagedSurface *_movieFrameSurface[2];
106 bool _framePixels;
107 double _frameRate;
108 int _currentFrame, _priorFrame;
109 uint32 _priorFrameTime;
110 Common::String _movieName;
111private:
115 bool renderFrame();
116
120 void setupDecompressor();
121
130 void copyMovieFrame(const Graphics::Surface &src, Graphics::ManagedSurface &dest);
131protected:
135 bool startAtFrame(int frameNumber);
136
140 virtual void seekToFrame(uint frameNumber);
141public:
142 CSoundManager *_soundManager;
143 bool _hasAudio;
144public:
145 AVISurface(const CResourceKey &key);
146 virtual ~AVISurface();
147
151 virtual bool play(uint flags, CGameObject *obj);
152
156 virtual bool play(int startFrame, int endFrame, uint flags, CGameObject *obj);
157
161 virtual bool play(int startFrame, int endFrame, int initialFrame, uint flags, CGameObject *obj);
162
166 virtual void stop();
167
171 virtual void pause();
172
176 virtual void resume();
177
181 virtual bool isPlaying() const {
182 return _decoder->isPlaying();
183 }
184
188 virtual void setPlaying(bool playingFlag) {
189 _decoder->pauseVideo(!playingFlag);
190 }
191
195 virtual bool handleEvents(CMovieEventList &events);
196
201
205 uint getWidth() const;
206
210 uint getHeight() const;
211
215 void setFrame(int frameNumber);
216
220 int getFrame() const { return _priorFrame; }
221
225 bool addEvent(int *frameNumber, CGameObject *obj);
226
230 void setFrameRate(double rate);
231
236
241 return &_movieRangeInfo;
242 }
243
248
253
258 bool playCutscene(const Rect &r, uint startFrame, uint endFrame);
259
263 uint getBitDepth() const;
264
268 bool isReversed() const { return _frameRate < 0.0; }
269};
270
271} // End of namespace Titanic
272
273#endif /* TITANIC_AVI_SURFACE_H */
int64 pos() const override
int64 size() const override
bool seek(int64 offs, int whence=SEEK_SET) override
bool eos() const override
Definition: rational.h:40
Definition: stream.h:745
virtual char * readLine(char *s, size_t bufSize, bool handleCR=true)
virtual bool skip(uint32 offset)
Definition: stream.h:793
Definition: str.h:59
Definition: managed_surface.h:51
Definition: avi_surface.h:75
AVIVideoTrack * getTransparencyTrack()
Definition: avi_surface.h:94
Video::AVIDecoder::AVIVideoTrack & getVideoTrack(uint idx)
uint videoTrackCount() const
Definition: avi_surface.h:84
Definition: avi_surface.h:99
virtual void setPlaying(bool playingFlag)
Definition: avi_surface.h:188
Graphics::ManagedSurface * duplicateTransparency() const
Graphics::ManagedSurface * getSecondarySurface()
virtual bool play(int startFrame, int endFrame, uint flags, CGameObject *obj)
bool addEvent(int *frameNumber, CGameObject *obj)
virtual void seekToFrame(uint frameNumber)
void setVideoSurface(CVideoSurface *surface)
void setFrame(int frameNumber)
const CMovieRangeInfoList * getMovieRangeInfo() const
Definition: avi_surface.h:240
virtual bool handleEvents(CMovieEventList &events)
uint getHeight() const
bool isReversed() const
Definition: avi_surface.h:268
virtual bool isPlaying() const
Definition: avi_surface.h:181
virtual bool play(uint flags, CGameObject *obj)
virtual void stop()
bool playCutscene(const Rect &r, uint startFrame, uint endFrame)
void setFrameRate(double rate)
uint getWidth() const
int getFrame() const
Definition: avi_surface.h:220
uint getBitDepth() const
virtual void resume()
virtual bool play(int startFrame, int endFrame, int initialFrame, uint flags, CGameObject *obj)
virtual void pause()
bool startAtFrame(int frameNumber)
Definition: game_object.h:79
Definition: movie_event.h:56
Definition: movie_range_info.h:76
Definition: resource_key.h:30
Definition: sound_manager.h:42
Definition: video_surface.h:43
Definition: simple_file.h:41
Definition: rect.h:35
Definition: avi_surface.h:49
bool seek(int64 offset, int whence=SEEK_SET) override
Definition: avi_surface.h:60
Common::String readLine(bool handleCR=true) override
Definition: avi_surface.h:69
uint32 read(void *dataPtr, uint32 dataSize) override
char * readLine(char *s, size_t bufSize, bool handleCR=true) override
Definition: avi_surface.h:66
int64 pos() const override
Definition: avi_surface.h:58
bool skip(uint32 offset) override
Definition: avi_surface.h:63
bool eos() const override
Definition: avi_surface.h:57
int64 size() const override
Definition: avi_surface.h:59
Definition: avi_decoder.h:204
Definition: avi_decoder.h:65
void pauseVideo(bool pause)
bool isPlaying() const
Definition: surface.h:67