00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MPD_DECODER_PLUGIN_H
00021 #define MPD_DECODER_PLUGIN_H
00022
00023 #include <stdbool.h>
00024 #include <stddef.h>
00025
00026 struct config_param;
00027 struct input_stream;
00028 struct tag;
00029 struct tag_handler;
00030
00035 struct decoder;
00036
00037 struct decoder_plugin {
00038 const char *name;
00039
00048 bool (*init)(const struct config_param *param);
00049
00054 void (*finish)(void);
00055
00063 void (*stream_decode)(struct decoder *decoder,
00064 struct input_stream *is);
00065
00071 void (*file_decode)(struct decoder *decoder, const char *path_fs);
00072
00078 bool (*scan_file)(const char *path_fs,
00079 const struct tag_handler *handler,
00080 void *handler_ctx);
00081
00087 bool (*scan_stream)(struct input_stream *is,
00088 const struct tag_handler *handler,
00089 void *handler_ctx);
00090
00101 char* (*container_scan)(const char *path_fs, const unsigned int tnum);
00102
00103
00104 const char *const*suffixes;
00105 const char *const*mime_types;
00106 };
00107
00116 static inline bool
00117 decoder_plugin_init(const struct decoder_plugin *plugin,
00118 const struct config_param *param)
00119 {
00120 return plugin->init != NULL
00121 ? plugin->init(param)
00122 : true;
00123 }
00124
00128 static inline void
00129 decoder_plugin_finish(const struct decoder_plugin *plugin)
00130 {
00131 if (plugin->finish != NULL)
00132 plugin->finish();
00133 }
00134
00138 static inline void
00139 decoder_plugin_stream_decode(const struct decoder_plugin *plugin,
00140 struct decoder *decoder, struct input_stream *is)
00141 {
00142 plugin->stream_decode(decoder, is);
00143 }
00144
00148 static inline void
00149 decoder_plugin_file_decode(const struct decoder_plugin *plugin,
00150 struct decoder *decoder, const char *path_fs)
00151 {
00152 plugin->file_decode(decoder, path_fs);
00153 }
00154
00158 static inline bool
00159 decoder_plugin_scan_file(const struct decoder_plugin *plugin,
00160 const char *path_fs,
00161 const struct tag_handler *handler, void *handler_ctx)
00162 {
00163 return plugin->scan_file != NULL
00164 ? plugin->scan_file(path_fs, handler, handler_ctx)
00165 : false;
00166 }
00167
00171 static inline bool
00172 decoder_plugin_scan_stream(const struct decoder_plugin *plugin,
00173 struct input_stream *is,
00174 const struct tag_handler *handler,
00175 void *handler_ctx)
00176 {
00177 return plugin->scan_stream != NULL
00178 ? plugin->scan_stream(is, handler, handler_ctx)
00179 : false;
00180 }
00181
00185 static inline char *
00186 decoder_plugin_container_scan( const struct decoder_plugin *plugin,
00187 const char* pathname,
00188 const unsigned int tnum)
00189 {
00190 return plugin->container_scan(pathname, tnum);
00191 }
00192
00196 bool
00197 decoder_plugin_supports_suffix(const struct decoder_plugin *plugin,
00198 const char *suffix);
00199
00203 bool
00204 decoder_plugin_supports_mime_type(const struct decoder_plugin *plugin,
00205 const char *mime_type);
00206
00207 #endif