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 
31 namespace Titanic {
32 
33 class CSoundManager;
34 class CVideoSurface;
35 
36 enum 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 
49 class y222 : virtual public Common::SeekableReadStream {
50 private:
51  File *_innerStream;
52 public:
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 
75 class AVIDecoder : public Video::AVIDecoder {
76 public:
77  AVIDecoder() {}
78  AVIDecoder(const Common::Rational &frameRateOverride) :
79  Video::AVIDecoder(frameRateOverride) {}
80 
84  uint videoTrackCount() const { return _videoTracks.size(); }
85 
89  Video::AVIDecoder::AVIVideoTrack &getVideoTrack(uint idx);
90 
95  return static_cast<AVIVideoTrack *>(_transparencyTrack.track);
96  }
97 };
98 
99 class AVISurface {
100 private:
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;
111 private:
115  bool renderFrame();
116 
120  void setupDecompressor();
121 
130  void copyMovieFrame(const Graphics::Surface &src, Graphics::ManagedSurface &dest);
131 protected:
135  bool startAtFrame(int frameNumber);
136 
140  virtual void seekToFrame(uint frameNumber);
141 public:
142  CSoundManager *_soundManager;
143  bool _hasAudio;
144 public:
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 
200  void setVideoSurface(CVideoSurface *surface);
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 
235  Graphics::ManagedSurface *getSecondarySurface();
236 
241  return &_movieRangeInfo;
242  }
243 
247  Graphics::ManagedSurface *duplicateTransparency() const;
248 
252  bool isNextFrame();
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 */
Definition: managed_surface.h:51
Definition: resource_key.h:30
virtual char * readLine(char *s, size_t bufSize, bool handleCR=true)
Definition: str.h:59
Definition: surface.h:67
bool eos() const override
Definition: avi_surface.h:57
char * readLine(char *s, size_t bufSize, bool handleCR=true) override
Definition: avi_surface.h:66
AVIVideoTrack * getTransparencyTrack()
Definition: avi_surface.h:94
Definition: avi_decoder.h:64
uint videoTrackCount() const
Definition: avi_surface.h:84
Definition: avi_surface.h:75
Definition: stream.h:745
Definition: movie_range_info.h:76
Definition: rational.h:40
Definition: avi_surface.h:49
uint32 read(void *dataPtr, uint32 dataSize) override
int64 pos() const override
Definition: avi_surface.h:58
Definition: game_object.h:79
int getFrame() const
Definition: avi_surface.h:220
virtual void setPlaying(bool playingFlag)
Definition: avi_surface.h:188
Definition: avi_decoder.h:203
int64 size() const override
Definition: rect.h:35
Definition: sound_manager.h:42
void pauseVideo(bool pause)
Definition: arm.h:30
virtual bool isPlaying() const
Definition: avi_surface.h:181
Definition: avi_surface.h:99
const CMovieRangeInfoList * getMovieRangeInfo() const
Definition: avi_surface.h:240
Definition: simple_file.h:41
bool eos() const override
bool isReversed() const
Definition: avi_surface.h:268
bool seek(int64 offset, int whence=SEEK_SET) override
Definition: avi_surface.h:60
bool isPlaying() const
bool skip(uint32 offset) override
Definition: avi_surface.h:63
Definition: video_surface.h:43
int64 pos() const override
bool seek(int64 offs, int whence=SEEK_SET) override
Common::String readLine(bool handleCR=true) override
Definition: avi_surface.h:69
Definition: movie_event.h:56
virtual bool skip(uint32 offset)
Definition: stream.h:793
int64 size() const override
Definition: avi_surface.h:59