MPD
decoder_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2010 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_H
21 #define MPD_DECODER_PLUGIN_H
22 
23 #include <stdbool.h>
24 #include <stddef.h>
25 
26 struct config_param;
27 struct input_stream;
28 struct tag;
29 
34 struct decoder;
35 
37  const char *name;
38 
47  bool (*init)(const struct config_param *param);
48 
53  void (*finish)(void);
54 
62  void (*stream_decode)(struct decoder *decoder,
63  struct input_stream *is);
64 
70  void (*file_decode)(struct decoder *decoder, const char *path_fs);
71 
77  struct tag *(*tag_dup)(const char *path_fs);
78 
84  struct tag *(*stream_tag)(struct input_stream *is);
85 
96  char* (*container_scan)(const char *path_fs, const unsigned int tnum);
97 
98  /* last element in these arrays must always be a NULL: */
99  const char *const*suffixes;
100  const char *const*mime_types;
101 };
102 
111 static inline bool
113  const struct config_param *param)
114 {
115  return plugin->init != NULL
116  ? plugin->init(param)
117  : true;
118 }
119 
123 static inline void
125 {
126  if (plugin->finish != NULL)
127  plugin->finish();
128 }
129 
133 static inline void
135  struct decoder *decoder, struct input_stream *is)
136 {
137  plugin->stream_decode(decoder, is);
138 }
139 
143 static inline void
145  struct decoder *decoder, const char *path_fs)
146 {
147  plugin->file_decode(decoder, path_fs);
148 }
149 
153 static inline struct tag *
155  const char *path_fs)
156 {
157  return plugin->tag_dup != NULL
158  ? plugin->tag_dup(path_fs)
159  : NULL;
160 }
161 
165 static inline struct tag *
167  struct input_stream *is)
168 {
169  return plugin->stream_tag != NULL
170  ? plugin->stream_tag(is)
171  : NULL;
172 }
173 
177 static inline char *
179  const char* pathname,
180  const unsigned int tnum)
181 {
182  return plugin->container_scan(pathname, tnum);
183 }
184 
188 bool
190  const char *suffix);
191 
195 bool
197  const char *mime_type);
198 
199 #endif