ScummVM API documentation
mjpgPlayer.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 MJPG_PLAYER_H
23 #define MJPG_PLAYER_H
24 
25 #include "common/array.h"
26 #include "common/scummsys.h"
27 #include "common/str.h"
28 #include "common/stream.h"
29 #include "graphics/surface.h"
30 #include "image/jpeg.h"
31 
32 namespace AGDS {
33 
34 class AGDSEngine;
35 class MJPGPlayer {
37  StreamPtr _stream;
38  int32 _firstFramePos;
39  Image::JPEGDecoder _decoder;
40  uint _framesPlayed;
41 
42  struct Text {
43  using Lines = Common::Array<Common::String>;
44 
45  uint begin;
46  uint end;
47  Lines lines;
48  };
49 
50  Common::Array<Text> _subtitles;
51  uint _nextSubtitleIndex;
52 
53 public:
54  MJPGPlayer(Common::SeekableReadStream *stream, const Common::String &subtitles);
55  ~MJPGPlayer();
56 
57  bool eos() {
58  return _stream->eos();
59  }
60 
61  void rewind();
62  const Graphics::Surface *decodeFrame();
63  void paint(AGDSEngine &engine, Graphics::Surface &backbuffer);
64 
65  uint32 getNextFrameTimestamp() const {
66  return _framesPlayed * 1000 / 24;
67  }
68 };
69 
70 } // End of namespace AGDS
71 
72 #endif /* AGDS_MJPG_PLAYER_H */
Definition: str.h:59
Definition: surface.h:67
virtual bool eos() const =0
Definition: stream.h:745
Definition: mjpgPlayer.h:35
Definition: agds.h:58
Definition: jpeg.h:50
Definition: agds.h:81