ScummVM API documentation
movie.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 GRIM_MOVIE_PLAYER_H
23 #define GRIM_MOVIE_PLAYER_H
24 
25 #include "common/mutex.h"
26 #include "common/system.h"
27 
28 #include "video/video_decoder.h"
29 
30 namespace Grim {
31 
32 class SaveGame;
33 
34 class MoviePlayer {
35 protected:
36  Common::String _fname;
37  Common::Mutex _frameMutex;
38  Video::VideoDecoder *_videoDecoder; //< Initialize this to your needed subclass of VideoDecoder in the constructor
39  const Graphics::Surface *_internalSurface;
40  Graphics::Surface *_externalSurface;
41  const byte *_internalPalette;
42  byte *_externalPalette;
43  int32 _frame;
44  bool _updateNeeded;
45  bool _showSubtitles;
46  float _movieTime;
47  int _channels;
48  int _freq;
49  bool _videoFinished;
50  bool _videoPause;
51  bool _videoLooping;
52  bool _timerStarted;
53  int _x, _y;
54 
55 public:
56  MoviePlayer();
57  virtual ~MoviePlayer();
58 
71  virtual bool play(const Common::String &filename, bool looping, int x, int y, bool start = true, bool showSubtitles = false);
72  virtual void stop();
73  virtual void pause(bool p);
74  virtual bool isPlaying() { return !_videoFinished; }
75  virtual bool isUpdateNeeded() { return _updateNeeded; }
76  virtual Graphics::Surface *getDstSurface();
77  virtual const byte *getDstPalette();
78  virtual int getX() { return _x; }
79  virtual int getY() { return _y; }
80  virtual int getFrame() { return _frame; }
81  virtual void clearUpdateNeeded() { _updateNeeded = false; }
82  virtual int32 getMovieTime() { return (int32)_movieTime; }
83 
84  /* Draw the subtitles, guarded by _drawMutex */
85  void drawMovieSubtitle();
86 
91  void saveState(SaveGame *state);
92  void restoreState(SaveGame *state);
93 
94 protected:
95  static void timerCallback(void *ptr);
103  virtual bool prepareFrame();
104 
115  virtual void handleFrame() {};
116 
127  virtual void postHandleFrame() {};
128 
137  virtual void init();
138 
145  virtual void deinit();
146 
155  virtual bool loadFile(const Common::String &filename);
156 
164  virtual void save(SaveGame *state) {}
165 
173  virtual void restore(SaveGame *state) {}
174 };
175 
176 // Factory-like functions:
177 
178 MoviePlayer *CreateMpegPlayer();
179 MoviePlayer *CreateSmushPlayer(bool demo);
180 MoviePlayer *CreateBinkPlayer(bool demo);
181 MoviePlayer *CreateQuickTimePlayer();
182 extern MoviePlayer *g_movie;
183 
184 } // end of namespace Grim
185 
186 #endif
Definition: movie.h:34
Definition: str.h:59
virtual void init()
Definition: surface.h:67
virtual bool loadFile(const Common::String &filename)
virtual void deinit()
Definition: savegame.h:33
Definition: actor.h:33
virtual void postHandleFrame()
Definition: movie.h:127
virtual bool prepareFrame()
virtual void handleFrame()
Definition: movie.h:115
virtual void save(SaveGame *state)
Definition: movie.h:164
Definition: video_decoder.h:53
Definition: mutex.h:67
void saveState(SaveGame *state)
virtual void restore(SaveGame *state)
Definition: movie.h:173
virtual bool play(const Common::String &filename, bool looping, int x, int y, bool start=true, bool showSubtitles=false)