MPD  0.20.15
OggDecoder.hxx
Go to the documentation of this file.
1 /*
2  * Copyright 2003-2017 The Music Player Daemon Project
3  * http://www.musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef MPD_OGG_DECODER_HXX
21 #define MPD_OGG_DECODER_HXX
22 
23 #include "config.h" /* must be first for large file support */
24 #include "lib/xiph/OggVisitor.hxx"
25 #include "decoder/Reader.hxx"
26 
27 class OggDecoder : public OggVisitor {
28  ogg_int64_t end_granulepos;
29 
30 protected:
33 
34 public:
35  explicit OggDecoder(DecoderReader &reader)
36  :OggVisitor(reader),
37  client(reader.GetClient()),
38  input_stream(reader.GetInputStream()) {}
39 
40  bool Seek(OggSyncState &oy, uint64_t where_frame);
41 
42 private:
47  bool LoadEndPacket(ogg_packet &packet) const;
48  ogg_int64_t LoadEndGranulePos() const;
49 
50 protected:
51  ogg_int64_t UpdateEndGranulePos() {
52  return end_granulepos = LoadEndGranulePos();
53  }
54 
55  bool IsSeekable() const {
56  return end_granulepos > 0;
57  }
58 
59  void SeekGranulePos(ogg_int64_t where_granulepos);
60 };
61 
62 #endif
OggDecoder(DecoderReader &reader)
Definition: OggDecoder.hxx:35
An interface between the decoder plugin and the MPD core.
Definition: Client.hxx:39
ogg_int64_t UpdateEndGranulePos()
Definition: OggDecoder.hxx:51
bool Seek(OggSyncState &oy, uint64_t where_frame)
void SeekGranulePos(ogg_int64_t where_granulepos)
Abstract class which iterates over Ogg packets in a Reader.
Definition: OggVisitor.hxx:37
InputStream & input_stream
Definition: OggDecoder.hxx:32
DecoderClient & client
Definition: OggDecoder.hxx:31
bool IsSeekable() const
Definition: OggDecoder.hxx:55
A wrapper for decoder_read() which implements the Reader interface.
Definition: Reader.hxx:34
Wrapper for an ogg_sync_state.