MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

DecoderPlugin.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_DECODER_PLUGIN_HXX
21 #define MPD_DECODER_PLUGIN_HXX
22
23 #include "Compiler.h"
24
25 #include <forward_list>
26
27 struct ConfigBlock;
28 class InputStream;
29 struct TagHandler;
30 class Path;
31 class DecoderClient;
32 class DetachedSong;
33
34 struct DecoderPlugin {
35 const char *name;
36
45 bool (*init)(const ConfigBlock &block);
46
51 void (*finish)();
52
60 void (*stream_decode)(DecoderClient &client, InputStream &is);
61
67 void (*file_decode)(DecoderClient &client, Path path_fs);
68
74 bool (*scan_file)(Path path_fs,
75 const TagHandler &handler,
76 void *handler_ctx);
77
83 bool (*scan_stream)(InputStream &is,
84 const TagHandler &handler,
85 void *handler_ctx);
86
96 std::forward_list<DetachedSong> (*container_scan)(Path path_fs);
97
98 /* last element in these arrays must always be a nullptr: */
99 const char *const*suffixes;
100 const char *const*mime_types;
101
109 bool Init(const ConfigBlock &block) const {
110 return init != nullptr
111 ? init(block)
112 : true;
113 }
114
118 void Finish() const {
119 if (finish != nullptr)
120 finish();
121 }
122
126 void StreamDecode(DecoderClient &client, InputStream &is) const {
127 stream_decode(client, is);
128 }
129
133 template<typename P>
134 void FileDecode(DecoderClient &client, P path_fs) const {
135 file_decode(client, path_fs);
136 }
137
141 template<typename P>
142 bool ScanFile(P path_fs,
143 const TagHandler &handler, void *handler_ctx) const {
144 return scan_file != nullptr
145 ? scan_file(path_fs, handler, handler_ctx)
146 : false;
147 }
148
152 bool ScanStream(InputStream &is,
153 const TagHandler &handler, void *handler_ctx) const {
154 return scan_stream != nullptr
155 ? scan_stream(is, handler, handler_ctx)
156 : false;
157 }
158
162 template<typename P>
163 char *ContainerScan(P path, const unsigned int tnum) const {
164 return container_scan(path, tnum);
165 }
166
170 gcc_pure gcc_nonnull_all
171 bool SupportsSuffix(const char *suffix) const;
172
176 gcc_pure gcc_nonnull_all
177 bool SupportsMimeType(const char *mime_type) const;
178 };
179
180 #endif
DecoderPlugin::Finish
void Finish() const
Deinitialize a decoder plugin which was initialized successfully.
Definition: DecoderPlugin.hxx:118
DecoderClient
An interface between the decoder plugin and the MPD core.
Definition: Client.hxx:39
DecoderPlugin::ScanStream
bool ScanStream(InputStream &is, const TagHandler &handler, void *handler_ctx) const
Read the tag of a stream.
Definition: DecoderPlugin.hxx:152
gcc_nonnull_all
#define gcc_nonnull_all
Definition: Compiler.h:122
DecoderPlugin::stream_decode
void(* stream_decode)(DecoderClient &client, InputStream &is)
Decode a stream (data read from an InputStream object).
Definition: DecoderPlugin.hxx:60
DecoderPlugin::SupportsSuffix
gcc_pure gcc_nonnull_all bool SupportsSuffix(const char *suffix) const
Does the plugin announce the specified file name suffix?
DecoderPlugin::container_scan
std::forward_list< DetachedSong >(* container_scan)(Path path_fs)
Return a "virtual" filename for subtracks in container formats like flac.
Definition: DecoderPlugin.hxx:96
TagHandler
A callback table for receiving metadata of a song.
Definition: TagHandler.hxx:32
DecoderPlugin::FileDecode
void FileDecode(DecoderClient &client, P path_fs) const
Decode a file.
Definition: DecoderPlugin.hxx:134
InputStream
Definition: InputStream.hxx:36
DecoderPlugin::mime_types
const char *const * mime_types
Definition: DecoderPlugin.hxx:100
DecoderPlugin::Init
bool Init(const ConfigBlock &block) const
Initialize a decoder plugin.
Definition: DecoderPlugin.hxx:109
DecoderPlugin::StreamDecode
void StreamDecode(DecoderClient &client, InputStream &is) const
Decode a stream.
Definition: DecoderPlugin.hxx:126
ConfigBlock
Definition: Block.hxx:57
Path
A path name in the native file system character set.
Definition: Path.hxx:39
Compiler.h
DecoderPlugin::SupportsMimeType
gcc_pure gcc_nonnull_all bool SupportsMimeType(const char *mime_type) const
Does the plugin announce the specified MIME type?
DecoderPlugin::scan_stream
bool(* scan_stream)(InputStream &is, const TagHandler &handler, void *handler_ctx)
Scan metadata of a file.
Definition: DecoderPlugin.hxx:83
DecoderPlugin::scan_file
bool(* scan_file)(Path path_fs, const TagHandler &handler, void *handler_ctx)
Scan metadata of a file.
Definition: DecoderPlugin.hxx:74
DecoderPlugin::finish
void(* finish)()
Deinitialize a decoder plugin which was initialized successfully.
Definition: DecoderPlugin.hxx:51
DecoderPlugin::ScanFile
bool ScanFile(P path_fs, const TagHandler &handler, void *handler_ctx) const
Read the tag of a file.
Definition: DecoderPlugin.hxx:142
DecoderPlugin::file_decode
void(* file_decode)(DecoderClient &client, Path path_fs)
Decode a local file.
Definition: DecoderPlugin.hxx:67
DecoderPlugin::init
bool(* init)(const ConfigBlock &block)
Initialize the decoder plugin.
Definition: DecoderPlugin.hxx:45
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
DetachedSong
Definition: DetachedSong.hxx:37
DecoderPlugin
Definition: DecoderPlugin.hxx:34
DecoderPlugin::suffixes
const char *const * suffixes
Definition: DecoderPlugin.hxx:99
DecoderPlugin::ContainerScan
char * ContainerScan(P path, const unsigned int tnum) const
return "virtual" tracks in a container
Definition: DecoderPlugin.hxx:163
DecoderPlugin::name
const char * name
Definition: DecoderPlugin.hxx:35