ScummVM API documentation
video.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 ACCESS_VIDEO_H
23 #define ACCESS_VIDEO_H
24 
25 #include "common/scummsys.h"
26 #include "common/memstream.h"
27 #include "audio/audiostream.h"
28 #include "audio/mixer.h"
29 
30 #include "access/data.h"
31 #include "access/asurface.h"
32 #include "access/files.h"
33 
34 namespace Access {
35 
36 enum VideoFlags { VIDEOFLAG_NONE = 0, VIDEOFLAG_BG = 1 };
37 
38 class VideoPlayer : public Manager {
39 public:
41  virtual ~VideoPlayer();
42 
46  void setVideo(BaseSurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate);
47  void setVideo(BaseSurface *vidSurface, const Common::Point &pt, const Common::Path &filename, int rate);
48 
52  virtual void playVideo() = 0;
53 
54  virtual void copyVideo() = 0;
58  virtual void closeVideo();
59 
63  void playToEnd();
64 
65  virtual int getWidth() = 0;
66 
67  virtual int getHeight() = 0;
68 
69 protected:
70  virtual void setVideo(const Common::Point &pt) = 0;
71 
72  virtual void setRate(int rate) = 0;
73 
74  virtual void delayToNextFrame() = 0;
75 
76  Resource *_videoData;
77  BaseSurface *_vidSurface;
78 
79 public:
80  int _videoFrame;
81  bool _soundFlag;
82  int _soundFrame;
83  bool _videoEnd;
84 };
85 
86 
87 class VideoPlayer_v1 : public VideoPlayer {
88  struct VideoHeader {
89  int _frameCount;
90  int _width, _height;
91  VideoFlags _flags;
92  };
93 private:
94  VideoHeader _header;
95  byte *_startCoord;
96  int _frameCount;
97  int _xCount;
98  int _scanCount;
99  int _frameSize;
100  Common::Rect _videoBounds;
101  int _rate;
102 
103  void getFrame();
104 protected:
105  void setVideo(const Common::Point &pt) override;
106 
107  void setRate(int rate) override;
108 
109  void delayToNextFrame() override;
110 
111 public:
113 
114  ~VideoPlayer_v1();
115 
116  void playVideo() override;
117 
118  void copyVideo() override;
119 
120  int getWidth() override { return _header._width; }
121 
122  int getHeight() override { return _header._height; }
123 
124 };
125 
126 class VideoPlayer_v2 : public VideoPlayer {
127  struct VideoHeader {
128  uint32 _id;
129  byte _version;
130  int _frameCount;
131  int _width, _height;
132  int _frameIncr;
133  uint16 _unk;
134  VideoFlags _flags;
135  };
136 private:
137  VideoHeader _header;
138  BaseSurface *_frame;
139  uint32 _nextFrameTime;
140  bool _setPal;
141  bool _drawBorder;
142  uint32 _startMs;
143  uint32 _delayTotal;
144 
145  Audio::QueuingAudioStream *_audioStream;
146  Audio::SoundHandle _audioStreamHandle;
147  Graphics::Palette _pal;
148 
149  void handleStraitChunk();
150  void handlePaletteChunk();
151  void handleFrameChunk(bool delta, bool skipLines);
152  void handleSoundChunk(bool init);
153 
154  void calcNextFrameTime(int delay);
155 
156 protected:
157  void setVideo(const Common::Point &pt) override;
158 
159  void setRate(int rate) override { };
160 
161  void delayToNextFrame() override;
162 public:
163  VideoPlayer_v2(AccessEngine *vm, bool setPal = false);
164 
165  ~VideoPlayer_v2();
166 
167  void playVideo() override;
168 
169  void copyVideo() override {};
170 
171  void closeVideo() override;
172 
173  int getWidth() override { return _header._width; }
174 
175  int getHeight() override { return _header._height; }
176 
177  void setVideoPalNow();
178 
179  void setDrawBorder(bool drawBorder) { _drawBorder = drawBorder; }
180 };
181 
182 
183 } // End of namespace Access
184 
185 #endif /* ACCESS_VIDEO_H */
Definition: video.h:38
Definition: video.h:126
Definition: files.h:36
void setVideo(BaseSurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate)
Definition: data.h:37
Definition: access.h:141
virtual void closeVideo()
virtual void playVideo()=0
Definition: video.h:87
Definition: rect.h:524
Definition: path.h:52
Definition: asurface.h:42
Definition: files.h:55
Definition: mixer.h:49
Definition: rect.h:144
Definition: audiostream.h:370
Simple class for handling a palette data.
Definition: palette.h:61
Definition: access.h:62