MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

EncoderInterface.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_ENCODER_INTERFACE_HXX
21 #define MPD_ENCODER_INTERFACE_HXX
22
23 #include "EncoderPlugin.hxx"
24 #include "Compiler.h"
25
26 #include <assert.h>
27 #include <stddef.h>
28
29 struct AudioFormat;
30 struct Tag;
31
32 class Encoder {
33 const bool implements_tag;
34
35 public:
36 explicit Encoder(bool _implements_tag)
37 :implements_tag(_implements_tag) {}
38 virtual ~Encoder() {}
39
40 bool ImplementsTag() const {
41 return implements_tag;
42 }
43
55 virtual void End() {
56 }
57
64 virtual void Flush() {
65 }
66
74 virtual void PreTag() {
75 }
76
87 virtual void SendTag(gcc_unused const Tag &tag) {
88 }
89
98 virtual void Write(const void *data, size_t length) = 0;
99
109 virtual size_t Read(void *dest, size_t length) = 0;
110 };
111
112 class PreparedEncoder {
113 public:
114 virtual ~PreparedEncoder() {}
115
130 virtual Encoder *Open(AudioFormat &audio_format) = 0;
131
137 virtual const char *GetMimeType() const {
138 return nullptr;
139 }
140 };
141
142 #endif
Encoder::Flush
virtual void Flush()
Flushes an encoder object, make everything which might currently be buffered available by Read()...
Definition: EncoderInterface.hxx:64
AudioFormat
This structure describes the format of a raw PCM stream.
Definition: AudioFormat.hxx:37
Encoder::Encoder
Encoder(bool _implements_tag)
Definition: EncoderInterface.hxx:36
Tag
The meta information about a song file.
Definition: Tag.hxx:34
PreparedEncoder::~PreparedEncoder
virtual ~PreparedEncoder()
Definition: EncoderInterface.hxx:114
Encoder
Definition: EncoderInterface.hxx:32
Encoder::ImplementsTag
bool ImplementsTag() const
Definition: EncoderInterface.hxx:40
Encoder::End
virtual void End()
Ends the stream: flushes the encoder object, generate an end-of-stream marker (if applicable)...
Definition: EncoderInterface.hxx:55
Encoder::PreTag
virtual void PreTag()
Prepare for sending a tag to the encoder.
Definition: EncoderInterface.hxx:74
Encoder::SendTag
virtual void SendTag(gcc_unused const Tag &tag)
Sends a tag to the encoder.
Definition: EncoderInterface.hxx:87
Compiler.h
PreparedEncoder::GetMimeType
virtual const char * GetMimeType() const
Get mime type of encoded content.
Definition: EncoderInterface.hxx:137
Encoder::~Encoder
virtual ~Encoder()
Definition: EncoderInterface.hxx:38
Encoder::Write
virtual void Write(const void *data, size_t length)=0
Writes raw PCM data to the encoder.
PreparedEncoder
Definition: EncoderInterface.hxx:112
gcc_unused
#define gcc_unused
Definition: Compiler.h:118
EncoderPlugin.hxx
PreparedEncoder::Open
virtual Encoder * Open(AudioFormat &audio_format)=0
Opens the object.
Encoder::Read
virtual size_t Read(void *dest, size_t length)=0
Reads encoded data from the encoder.