ScummVM API documentation
videoplayer.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_VIDEOPLAYER_H
29 #define GOB_VIDEOPLAYER_H
30 
31 #include "common/array.h"
32 #include "common/list.h"
33 #include "common/rect.h"
34 #include "common/str.h"
35 
36 #include "graphics/surface.h"
37 
38 #include "gob/util.h"
39 #include "gob/draw.h"
40 
41 namespace Video {
42 class CoktelDecoder;
43 }
44 
45 namespace Gob {
46 
47 class GobEngine;
48 class DataStream;
49 
50 class VideoPlayer {
51 public:
52  enum Flags {
53  kFlagNone = 0x000000,
54  kFlagUseBackSurfaceContent = 0x000040,
55  kFlagFrontSurface = 0x000080,
56  kFlagNoVideo = 0x000100,
57  kFlagOtherSurface = 0x000800,
58  kFlagScreenSurface = 0x400000
59  };
60 
62  enum Type {
63  kVideoTypeTry = -1,
64  kVideoTypeIMD = 0,
65  kVideoTypePreIMD = 1,
66  kVideoTypeVMD = 2,
67  kVideoTypeRMD = 3
68  };
69 
70  struct Properties {
72 
73  int sprite;
74 
75  int32 x;
76  int32 y;
77  int32 width;
78  int32 height;
79 
80  uint32 flags;
81 
83 
84  int32 startFrame;
85  int32 lastFrame;
86  int32 endFrame;
87 
88  bool forceSeek;
89 
90  int16 breakKey;
91 
92  uint16 palCmd;
93  int16 palStart;
94  int16 palEnd;
95  int32 palFrame;
96 
97  bool noBlock;
98 
99  bool loop;
100  bool fade;
101 
103 
104  bool hasSound;
105  bool canceled;
106 
107  int slot;
108  bool reuseSlotWitSameFilename;
109 
110  bool noWaitSound;
111 
112  Properties();
113  };
114 
115  VideoPlayer(GobEngine *vm);
116  ~VideoPlayer();
117 
118  void evaluateFlags(Properties &properties);
119 
120  int openVideo(bool primary, const Common::String &file, Properties &properties);
121  bool closeVideo(int slot = 0);
122 
123  void closeLiveVideos();
124  void closeAll();
125 
126  bool reopenVideo(int slot = 0);
127  bool reopenAll();
128 
129  void pauseVideo(int slot, bool pause);
130  void pauseAll(bool pause);
131 
132  void finishVideoSound(int slot);
133  void waitSoundEnd(int slot);
134 
135  bool play(int slot, Properties &properties);
136  void waitEndFrame(int slot, bool onlySound = false);
137  int32 getExpectedFrameFromCurrentTime(int slot);
138 
139  bool isPlayingLive() const;
140  bool isSoundPlaying() const;
141 
142  void updateVideos(bool force = false, int exceptSlot = -1);
143  void liveVideosLoop();
144 
145  bool slotIsOpen(int slot = 0) const;
146 
147  Common::String getFileName(int slot = 0) const;
148 
149  uint32 getFrameCount (int slot = 0) const;
150  uint32 getCurrentFrame (int slot = 0) const;
151  uint16 getWidth (int slot = 0) const;
152  uint16 getHeight (int slot = 0) const;
153  uint16 getDefaultX (int slot = 0) const;
154  uint16 getDefaultY (int slot = 0) const;
155  uint32 getFlags (int slot = 0) const;
156  uint16 getSoundFlags (int slot = 0) const;
157  uint32 getVideoBufferSize(int slot = 0) const;
158  bool hasVideo (int slot = 0) const;
159 
160 
161  const Common::List<Common::Rect> *getDirtyRects(int slot = 0) const;
162 
163  bool hasEmbeddedFile(const Common::String &fileName, int slot = 0) const;
164  Common::SeekableReadStream *getEmbeddedFile(const Common::String &fileName, int slot = 0);
165 
166  int32 getSubtitleIndex(int slot = 0) const;
167 
168  void writeVideoInfo(const Common::String &file, uint16 varX, uint16 varY,
169  uint16 varFrames, uint16 varWidth, uint16 varHeight);
170 
171  bool copyFrame(int slot, Surface &dest,
172  uint16 left, uint16 top, uint16 width, uint16 height, uint16 x, uint16 y,
173  int32 transp = -1, bool yAxisReflexion = false) const;
174 
175 private:
176  struct Video {
177  ::Video::CoktelDecoder *decoder;
178  Common::String fileName;
179 
180  SurfacePtr surface;
181  Common::SharedPtr<Graphics::Surface> tmpSurfBppConversion;
182  uint32 *highColorMap;
183 
184  Properties properties;
185 
186  bool live;
187 
188  Video();
189 
190  bool isEmpty() const;
191  void close();
192 
193  void reopen();
194  };
195 
196  static const int kVideoSlotCount = 32;
197  static const int kPrimaryVideoSlot = 0;
198  static const int kLiveVideoSlotCount = 6;
199  static const int kVideoSlotWithCurFrameVarCount = 4;
200 
201  static const char *const _extensions[];
202 
203  GobEngine *_vm;
204 
205  // _videoSlots[0] is reserved for the "primary" video
206  Video _videoSlots[kVideoSlotCount];
207 
208  bool _needBlit;
209 
210  bool _noCursorSwitch;
211  bool _woodruffCohCottWorkaround;
212  uint32 _lastLiveVideosLoopCall;
213 
214 
215  const Video *getVideoBySlot(int slot) const;
216  Video *getVideoBySlot(int slot);
217 
218  int getNextFreeSlot();
219 
220  Common::String findFile(const Common::String &file, Properties &properties);
221 
222  ::Video::CoktelDecoder *openVideo(const Common::String &file, Properties &properties);
223 
224  bool reopenVideo(Video &video);
225 
226  bool lastFrameReached(Video &video, Properties &properties);
227  bool playFrame(int slot, Properties &properties);
228 
229  void checkAbort(Video &video, Properties &properties);
230  void evalBgShading(Video &video);
231 
232  void copyPalette(const Video &video, int16 palStart, int16 palEnd);
233 
234  void updateVideo(int slot, bool force = false);
235 };
236 
237 } // End of namespace Gob
238 
239 #endif // GOB_VIDEOPLAYER_H
int32 x
X coordinate of the video.
Definition: videoplayer.h:75
int slot
Explicit slot index (-1 = auto).
Definition: videoplayer.h:107
Definition: gob.h:166
Definition: str.h:59
bool noBlock
Non-blocking "live" video?
Definition: videoplayer.h:97
int32 y
Y coordinate of the video.
Definition: videoplayer.h:76
int32 lastFrame
Frame to stop playback at.
Definition: videoplayer.h:85
int16 breakKey
Keycode of the break/abort key.
Definition: videoplayer.h:90
int32 startFrame
Frame to start playback from.
Definition: videoplayer.h:84
Definition: stream.h:745
Flags
Definition: videoplayer.h:52
Type type
Type of the video to open.
Definition: videoplayer.h:71
Definition: anifile.h:40
bool hasSound
Does the video have sound?
Definition: videoplayer.h:104
int32 width
Width of the video.
Definition: videoplayer.h:77
bool switchColorMode
Switch between paletted / true color modes?
Definition: videoplayer.h:82
bool canceled
Was the video canceled?
Definition: videoplayer.h:105
int16 palEnd
Palette entry to end at.
Definition: videoplayer.h:94
int16 palStart
Palette entry to start with.
Definition: videoplayer.h:93
bool waitEndFrame
Wait for the frame&#39;s time to run out?
Definition: videoplayer.h:102
int32 palFrame
Frame to apply the palette command at.
Definition: videoplayer.h:95
Type
Definition: videoplayer.h:62
Definition: surface.h:106
Definition: videoplayer.h:70
int sprite
The sprite onto which to draw the video.
Definition: videoplayer.h:73
uint16 palCmd
Palette command.
Definition: videoplayer.h:92
bool fade
Fade in?
Definition: videoplayer.h:100
uint32 flags
Video flags.
Definition: videoplayer.h:80
Definition: animation.h:37
bool forceSeek
Force the seeking to the start frame.
Definition: videoplayer.h:88
int32 endFrame
Last frame of this playback cycle.
Definition: videoplayer.h:86
int32 height
Height of the video.
Definition: videoplayer.h:78
bool loop
Loop the video?
Definition: videoplayer.h:99
Definition: videoplayer.h:50