2
* Copyright (C) 2003-2013 The Music Player Daemon Project
3
* http://www.musicpd.org
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.
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.
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.
21
* \brief The MPD Decoder API
23
* This is the public API which is used by decoder plugins to
24
* communicate with the mpd core.
27
#ifndef MPD_DECODER_API_HXX
28
#define MPD_DECODER_API_HXX
31
#include "DecoderCommand.hxx"
32
#include "DecoderPlugin.hxx"
33
#include "ReplayGainInfo.hxx"
34
#include "tag/Tag.hxx"
35
#include "AudioFormat.hxx"
36
#include "MixRampInfo.hxx"
37
#include "ConfigData.hxx"
40
* Notify the player thread that it has finished initialization and
41
* that it has read the song's meta data.
43
* @param decoder the decoder object
44
* @param audio_format the audio format which is going to be sent to
46
* @param seekable true if the song is seekable
47
* @param total_time the total number of seconds in this song; -1 if unknown
50
decoder_initialized(Decoder &decoder,
51
AudioFormat audio_format,
52
bool seekable, float total_time);
55
* Determines the pending decoder command.
57
* @param decoder the decoder object
58
* @return the current command, or DecoderCommand::NONE if there is no
63
decoder_get_command(Decoder &decoder);
66
* Called by the decoder when it has performed the requested command
67
* (dc->command). This function resets dc->command and wakes up the
70
* @param decoder the decoder object
73
decoder_command_finished(Decoder &decoder);
76
* Call this when you have received the DecoderCommand::SEEK command.
78
* @param decoder the decoder object
79
* @return the destination position for the week
83
decoder_seek_where(Decoder &decoder);
86
* Call this instead of decoder_command_finished() when seeking has
89
* @param decoder the decoder object
92
decoder_seek_error(Decoder &decoder);
95
* Blocking read from the input stream.
97
* @param decoder the decoder object
98
* @param is the input stream to read from
99
* @param buffer the destination buffer
100
* @param length the maximum number of bytes to read
101
* @return the number of bytes read, or 0 if one of the following
102
* occurs: end of file; error; command (like SEEK or STOP).
105
decoder_read(Decoder *decoder, InputStream &is,
106
void *buffer, size_t length);
109
decoder_read(Decoder &decoder, InputStream &is,
110
void *buffer, size_t length)
112
return decoder_read(&decoder, is, buffer, length);
116
* Sets the time stamp for the next data chunk [seconds]. The MPD
117
* core automatically counts it up, and a decoder plugin only needs to
118
* use this function if it thinks that adding to the time stamp based
119
* on the buffer size won't work.
122
decoder_timestamp(Decoder &decoder, double t);
125
* This function is called by the decoder plugin when it has
126
* successfully decoded block of input data.
128
* @param decoder the decoder object
129
* @param is an input stream which is buffering while we are waiting
131
* @param data the source buffer
132
* @param length the number of bytes in the buffer
133
* @return the current command, or DecoderCommand::NONE if there is no
137
decoder_data(Decoder &decoder, InputStream *is,
138
const void *data, size_t length,
141
static inline DecoderCommand
142
decoder_data(Decoder &decoder, InputStream &is,
143
const void *data, size_t length,
146
return decoder_data(decoder, &is, data, length, kbit_rate);
150
* This function is called by the decoder plugin when it has
151
* successfully decoded a tag.
153
* @param decoder the decoder object
154
* @param is an input stream which is buffering while we are waiting
156
* @param tag the tag to send
157
* @return the current command, or DecoderCommand::NONE if there is no
161
decoder_tag(Decoder &decoder, InputStream *is, Tag &&tag);
163
static inline DecoderCommand
164
decoder_tag(Decoder &decoder, InputStream &is, Tag &&tag)
166
return decoder_tag(decoder, &is, std::move(tag));
170
* Set replay gain values for the following chunks.
172
* @param decoder the decoder object
173
* @param rgi the replay_gain_info object; may be nullptr to invalidate
174
* the previous replay gain values
177
decoder_replay_gain(Decoder &decoder,
178
const ReplayGainInfo *replay_gain_info);
181
* Store MixRamp tags.
183
* @param decoder the decoder object
184
* @param mixramp_start the mixramp_start tag; may be nullptr to invalidate
185
* @param mixramp_end the mixramp_end tag; may be nullptr to invalidate
188
decoder_mixramp(Decoder &decoder, MixRampInfo &&mix_ramp);