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 MOHAWK_VIDEO_H
23 #define MOHAWK_VIDEO_H
24 
25 #include "audio/mixer.h"
26 #include "audio/timestamp.h"
27 #include "common/array.h"
28 #include "common/list.h"
29 #include "common/noncopyable.h"
30 #include "common/ptr.h"
31 #include "common/rational.h"
32 #include "graphics/pixelformat.h"
33 #include "video/subtitles.h"
34 
35 namespace Video {
36 class VideoDecoder;
37 }
38 
39 namespace Mohawk {
40 
41 class MohawkEngine;
42 
47  // The private members should be able to be manipulated by VideoManager
48  friend class VideoManager;
49 
50 private:
51  // Hide the destructor/constructor
52  // Only VideoManager should be allowed
53  VideoEntry();
54  VideoEntry(Video::VideoDecoder *video, const Common::Path &fileName);
55  VideoEntry(Video::VideoDecoder *video, int id);
56 
57 public:
58  ~VideoEntry();
59 
63  operator bool() const { return isOpen(); }
64 
68  bool isOpen() const { return _video != 0; }
69 
73  void close();
74 
78  bool endOfVideo() const;
79 
83  uint16 getX() const { return _x; }
84 
88  uint16 getY() const { return _y; }
89 
93  bool isLooping() const { return _loop; }
94 
98  bool isEnabled() const { return _enabled; }
99 
103  const Audio::Timestamp &getStart() const { return _start; }
104 
108  const Common::Path &getFileName() const { return _fileName; }
109 
113  int getID() const { return _id; }
114 
118  int getCurFrame() const;
119 
123  uint32 getFrameCount() const;
124 
128  uint32 getTime() const;
129 
133  Audio::Timestamp getDuration() const;
134 
138  Common::Rational getRate() const;
139 
143  void setX(uint16 x) { _x = x; }
144 
148  void setY(uint16 y) { _y = y; }
149 
153  void moveTo(uint16 x, uint16 y) { setX(x); setY(y); }
154 
158  void center();
159 
163  void setStart(const Audio::Timestamp &time) { _start = time; }
164 
168  void setLooping(bool loop) { _loop = loop; }
169 
173  void setEnabled(bool enabled) { _enabled = enabled; }
174 
180  void setBounds(const Audio::Timestamp &startTime, const Audio::Timestamp &endTime);
181 
185  void seek(const Audio::Timestamp &time);
186 
190  void setRate(const Common::Rational &rate);
191 
195  void pause(bool isPaused);
196 
200  void start();
201 
205  void stop();
206 
210  bool isPlaying() const;
211 
215  int getVolume() const;
216 
220  void setVolume(int volume);
221 
225  void loadSubtitles(const Common::Path &fname) { _subtitles.loadSRTFile(fname); }
226 private:
227  // Non-changing variables
228  Video::VideoDecoder *_video;
229  Common::Path _fileName; // External video files
230  int _id; // Internal Mohawk files
231 
232  // Playback variables
233  uint16 _x;
234  uint16 _y;
235  bool _loop;
236  bool _enabled;
237  Audio::Timestamp _start;
238 
239  Video::Subtitles _subtitles;
240 };
241 
243 
245 public:
246  explicit VideoManager(MohawkEngine *vm);
247  virtual ~VideoManager();
248 
249  // Generic movie functions
250  VideoEntryPtr playMovie(const Common::Path &filename, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
251  VideoEntryPtr playMovie(uint16 id);
252  bool updateMovies();
253  void pauseVideos();
254  void resumeVideos();
255  void stopVideos();
256  bool isVideoPlaying();
257 
258  // Handle functions
259  VideoEntryPtr findVideo(uint16 id);
260  VideoEntryPtr findVideo(const Common::Path &fileName);
261  void drawVideoFrame(const VideoEntryPtr &video, const Audio::Timestamp &time);
262  void removeEntry(const VideoEntryPtr &video);
263 
264 protected:
265  MohawkEngine *_vm;
266 
267  // Keep tabs on any videos playing
269  VideoList _videos;
270 
271  // Utility functions for managing entries
272  VideoEntryPtr open(uint16 id);
273  VideoEntryPtr open(const Common::Path &fileName, Audio::Mixer::SoundType soundType);
274 
275  VideoList::iterator findEntry(VideoEntryPtr ptr);
276 
277  bool drawNextFrame(VideoEntryPtr videoEntry);
278 
279  // Dithering control
280  bool _enableDither;
281  void checkEnableDither(VideoEntryPtr &entry);
282 };
283 
284 } // End of namespace Mohawk
285 
286 #endif
void moveTo(uint16 x, uint16 y)
Definition: video.h:153
bool isOpen() const
Definition: video.h:68
void setStart(const Audio::Timestamp &time)
Definition: video.h:163
int getID() const
Definition: video.h:113
bool isEnabled() const
Definition: video.h:98
Definition: path.h:52
Definition: timestamp.h:83
uint16 getX() const
Definition: video.h:83
Definition: rational.h:40
void setEnabled(bool enabled)
Definition: video.h:173
uint16 getY() const
Definition: video.h:88
Definition: video.h:244
Definition: noncopyable.h:39
Definition: subtitles.h:61
SoundType
Definition: mixer.h:62
Definition: video_decoder.h:53
void setY(uint16 y)
Definition: video.h:148
Definition: mohawk.h:54
bool isLooping() const
Definition: video.h:93
void setLooping(bool loop)
Definition: video.h:168
void loadSubtitles(const Common::Path &fname)
Definition: video.h:225
void setX(uint16 x)
Definition: video.h:143
Definition: list_intern.h:51
Definition: avi_frames.h:36
const Audio::Timestamp & getStart() const
Definition: video.h:103
Definition: video.h:46
const Common::Path & getFileName() const
Definition: video.h:108
Definition: mixer.h:63
Definition: bitmap.h:32