MPD  0.20.15
FlacInput.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_FLAC_INPUT_HXX
21 #define MPD_FLAC_INPUT_HXX
22 
23 #include <FLAC/stream_decoder.h>
24 
25 class DecoderClient;
26 class InputStream;
27 
32 class FlacInput {
33  DecoderClient *const client;
34 
35  InputStream &input_stream;
36 
37 public:
38  FlacInput(InputStream &_input_stream,
39  DecoderClient *_client=nullptr)
40  :client(_client), input_stream(_input_stream) {}
41 
43  return client;
44  }
45 
47  return input_stream;
48  }
49 
50 protected:
51  FLAC__StreamDecoderReadStatus Read(FLAC__byte buffer[], size_t *bytes);
52  FLAC__StreamDecoderSeekStatus Seek(FLAC__uint64 absolute_byte_offset);
53  FLAC__StreamDecoderTellStatus Tell(FLAC__uint64 *absolute_byte_offset);
54  FLAC__StreamDecoderLengthStatus Length(FLAC__uint64 *stream_length);
55  FLAC__bool Eof();
56  void Error(FLAC__StreamDecoderErrorStatus status);
57 
58 public:
59  static FLAC__StreamDecoderReadStatus
60  Read(const FLAC__StreamDecoder *flac_decoder,
61  FLAC__byte buffer[], size_t *bytes, void *client_data);
62 
63  static FLAC__StreamDecoderSeekStatus
64  Seek(const FLAC__StreamDecoder *flac_decoder,
65  FLAC__uint64 absolute_byte_offset, void *client_data);
66 
67  static FLAC__StreamDecoderTellStatus
68  Tell(const FLAC__StreamDecoder *flac_decoder,
69  FLAC__uint64 *absolute_byte_offset, void *client_data);
70 
71  static FLAC__StreamDecoderLengthStatus
72  Length(const FLAC__StreamDecoder *flac_decoder,
73  FLAC__uint64 *stream_length, void *client_data);
74 
75  static FLAC__bool
76  Eof(const FLAC__StreamDecoder *flac_decoder, void *client_data);
77 
78  static void
79  Error(const FLAC__StreamDecoder *decoder,
80  FLAC__StreamDecoderErrorStatus status, void *client_data);
81 };
82 
83 #endif
DecoderClient * GetClient()
Definition: FlacInput.hxx:42
An interface between the decoder plugin and the MPD core.
Definition: Client.hxx:39
FLAC__StreamDecoderLengthStatus Length(FLAC__uint64 *stream_length)
FLAC__bool Eof()
InputStream & GetInputStream()
Definition: FlacInput.hxx:46
FLAC__StreamDecoderSeekStatus Seek(FLAC__uint64 absolute_byte_offset)
FLAC__StreamDecoderReadStatus Read(FLAC__byte buffer[], size_t *bytes)
FLAC__StreamDecoderTellStatus Tell(FLAC__uint64 *absolute_byte_offset)
void Error(FLAC__StreamDecoderErrorStatus status)
This class wraps an InputStream in libFLAC stream decoder callbacks.
Definition: FlacInput.hxx:32
FlacInput(InputStream &_input_stream, DecoderClient *_client=nullptr)
Definition: FlacInput.hxx:38