ScummVM API documentation
video_theora_player.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 /*
23  * This file is based on WME Lite.
24  * http://dead-code.org/redir.php?target=wmelite
25  * Copyright (c) 2011 Jan Nedoma
26  */
27 
28 #ifndef WINTERMUTE_VIDTHEORAPLAYER_H
29 #define WINTERMUTE_VIDTHEORAPLAYER_H
30 
31 #include "engines/wintermute/base/base.h"
32 #include "engines/wintermute/persistent.h"
33 #include "engines/wintermute/video/video_subtitler.h"
34 #include "video/video_decoder.h"
35 #include "common/stream.h"
36 #include "graphics/surface.h"
37 
38 namespace Wintermute {
39 class BaseSurface;
40 class BaseImage;
41 class VideoTheoraPlayer : public BaseClass {
42 private:
43  enum {
44  THEORA_STATE_NONE = 0,
45  THEORA_STATE_PLAYING = 1,
46  THEORA_STATE_PAUSED = 2,
47  THEORA_STATE_FINISHED = 3
48  };
49  Video::VideoDecoder *_theoraDecoder;
50 public:
51  DECLARE_PERSISTENT(VideoTheoraPlayer, BaseClass)
52 
53  VideoTheoraPlayer(BaseGame *inGame);
54  ~VideoTheoraPlayer() override;
55 
56  // external objects
57  Common::String _filename;
58 
59  BaseSurface *_texture;
60  VideoSubtitler *_subtitler;
61 
62  // control methods
63  bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String());
64  bool initializeSimple();
65  bool update();
66  bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1);
67  bool stop();
68  bool display(uint32 alpha = 0xFFFFFFFF);
69 
70  bool pause();
71  bool resume();
72 
73  bool isPlaying() const {
74  return _state == THEORA_STATE_PLAYING;
75  };
76  bool isFinished() const {
77  return _state == THEORA_STATE_FINISHED;
78  };
79  bool isPaused() const {
80  return _state == THEORA_STATE_PAUSED;
81  };
82 
83  uint32 getMovieTime() const;
84 
85  BaseSurface *getTexture() const;
86 
87  // alpha related
88  Common::String _alphaFilename;
89  bool setAlphaImage(const Common::String &filename);
90 
91  bool seekToTime(uint32 Time);
92 
93  void cleanup();
94  bool resetStream();
95 
96  // video properties
97  int32 _posX;
98  int32 _posY;
99 
100  bool _dontDropFrames;
101 private:
102  int32 _state;
103  uint32 _startTime;
104 
105  int32 _savedState;
106  uint32 _savedPos;
107 
108  // video properties
109  TVideoPlayback _playbackType;
110  bool _looping;
111  float _playZoom;
112  int32 _volume;
113 
114  bool _freezeGame;
115  uint32 _currentTime;
116 
117  // seeking support
118  bool _seekingKeyframe;
119  float _timeOffset;
120 
121  bool _frameRendered;
122 
123  bool getIsFrameReady() const {
124  return _videoFrameReady;
125  }
126 
127  bool _audioFrameReady;
128  bool _videoFrameReady;
129  float _videobufTime;
130 
131  bool writeVideo(const Graphics::Surface *decodedFrame);
132 
133  bool _playbackStarted;
134 
135  bool _foundSubtitles;
136 
137  // helpers
138  void setDefaults();
139 };
140 
141 } // End of namespace Wintermute
142 
143 #endif
Definition: base_game.h:75
Definition: str.h:59
Definition: surface.h:67
Definition: video_subtitler.h:36
Definition: video_theora_player.h:41
Definition: video_decoder.h:53
Definition: base_surface.h:37
Definition: base.h:43
Definition: achievements_tables.h:27