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  Graphics::Surface _surface;
51 public:
52  DECLARE_PERSISTENT(VideoTheoraPlayer, BaseClass)
53 
54  VideoTheoraPlayer(BaseGame *inGame);
55  ~VideoTheoraPlayer() override;
56 
57  // external objects
59  Common::String _filename;
60 
61  BaseSurface *_texture;
62  VideoSubtitler *_subtitler;
63 
64  // control methods
65  bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String());
66  bool initializeSimple();
67  bool update();
68  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);
69  bool stop();
70  bool display(uint32 alpha = 0xFFFFFFFF);
71 
72  bool pause();
73  bool resume();
74 
75  bool isPlaying() const {
76  return _state == THEORA_STATE_PLAYING;
77  };
78  bool isFinished() const {
79  return _state == THEORA_STATE_FINISHED;
80  };
81  bool isPaused() const {
82  return _state == THEORA_STATE_PAUSED;
83  };
84 
85  uint32 getMovieTime() const;
86 
87  BaseSurface *getTexture() const;
88 
89  // alpha related
90  BaseImage *_alphaImage;
91  Common::String _alphaFilename;
92  bool setAlphaImage(const Common::String &filename);
93  byte getAlphaAt(int x, int y) const;
94  void writeAlpha();
95 
96  bool seekToTime(uint32 Time);
97 
98  void cleanup();
99  bool resetStream();
100 
101  // video properties
102  int32 _posX;
103  int32 _posY;
104 
105  bool _dontDropFrames;
106 private:
107  int32 _state;
108  uint32 _startTime;
109 
110  int32 _savedState;
111  uint32 _savedPos;
112 
113  // video properties
114  TVideoPlayback _playbackType;
115  bool _looping;
116  float _playZoom;
117  int32 _volume;
118 
119  bool _freezeGame;
120  uint32 _currentTime;
121 
122  // seeking support
123  bool _seekingKeyframe;
124  float _timeOffset;
125 
126  bool _frameRendered;
127 
128  bool getIsFrameReady() const {
129  return _videoFrameReady;
130  }
131 
132  bool _audioFrameReady;
133  bool _videoFrameReady;
134  float _videobufTime;
135 
136  bool writeVideo();
137 
138  bool _playbackStarted;
139 
140  bool _foundSubtitles;
141 
142  // helpers
143  void SetDefaults();
144 };
145 
146 } // End of namespace Wintermute
147 
148 #endif
Definition: base_game.h:76
Definition: str.h:59
Definition: surface.h:67
Definition: base_image.h:45
Definition: video_subtitler.h:36
Definition: stream.h:745
Definition: video_theora_player.h:41
Definition: video_decoder.h:53
Definition: base_surface.h:38
Definition: base.h:43
Definition: achievements_tables.h:27