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  int32 _frame;
42  bool _updateNeeded;
43  bool _showSubtitles;
44  float _movieTime;
45  int _channels;
46  int _freq;
47  bool _videoFinished;
48  bool _videoPause;
49  bool _videoLooping;
50  bool _timerStarted;
51  int _x, _y;
52 
53 public:
54  MoviePlayer();
55  virtual ~MoviePlayer();
56 
69  virtual bool play(const Common::String &filename, bool looping, int x, int y, bool start = true, bool showSubtitles = false);
70  virtual void stop();
71  virtual void pause(bool p);
72  virtual bool isPlaying() { return !_videoFinished; }
73  virtual bool isUpdateNeeded() { return _updateNeeded; }
74  virtual Graphics::Surface *getDstSurface();
75  virtual int getX() { return _x; }
76  virtual int getY() { return _y; }
77  virtual int getFrame() { return _frame; }
78  virtual void clearUpdateNeeded() { _updateNeeded = false; }
79  virtual int32 getMovieTime() { return (int32)_movieTime; }
80 
81  /* Draw the subtitles, guarded by _drawMutex */
82  void drawMovieSubtitle();
83 
88  void saveState(SaveGame *state);
89  void restoreState(SaveGame *state);
90 
91 protected:
92  static void timerCallback(void *ptr);
100  virtual bool prepareFrame();
101 
112  virtual void handleFrame() {};
113 
124  virtual void postHandleFrame() {};
125 
134  virtual void init();
135 
142  virtual void deinit();
143 
152  virtual bool loadFile(const Common::String &filename);
153 
161  virtual void save(SaveGame *state) {}
162 
170  virtual void restore(SaveGame *state) {}
171 };
172 
173 // Factory-like functions:
174 
175 MoviePlayer *CreateMpegPlayer();
176 MoviePlayer *CreateSmushPlayer(bool demo);
177 MoviePlayer *CreateBinkPlayer(bool demo);
178 MoviePlayer *CreateQuickTimePlayer();
179 extern MoviePlayer *g_movie;
180 
181 } // end of namespace Grim
182 
183 #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:124
virtual bool prepareFrame()
virtual void handleFrame()
Definition: movie.h:112
virtual void save(SaveGame *state)
Definition: movie.h:161
Definition: video_decoder.h:52
Definition: mutex.h:67
void saveState(SaveGame *state)
virtual void restore(SaveGame *state)
Definition: movie.h:170
virtual bool play(const Common::String &filename, bool looping, int x, int y, bool start=true, bool showSubtitles=false)