MPD

- Main Page
- Data Structures
- Files

- File List
- Globals

# src/decoder_plugin.h

Go to the documentation of this file.

    00001 /*
    00002  * Copyright (C) 2003-2010 The Music Player Daemon Project
    00003  * http://www.musicpd.org
    00004  *
    00005  * This program is free software; you can redistribute it and/or modify
    00006  * it under the terms of the GNU General Public License as published by
    00007  * the Free Software Foundation; either version 2 of the License, or
    00008  * (at your option) any later version.
    00009  *
    00010  * This program is distributed in the hope that it will be useful,
    00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00013  * GNU General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU General Public License along
    00016  * with this program; if not, write to the Free Software Foundation, Inc.,
    00017  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    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
    00034 struct decoder;
    00035
    00036 struct decoder_plugin {
    00037         const char *name;
    00038
    00047         bool (*init)(const struct config_param *param);
    00048
    00053         void (*finish)(void);
    00054
    00062         void (*stream_decode)(struct decoder *decoder,
    00063                               struct input_stream *is);
    00064
    00070         void (*file_decode)(struct decoder *decoder, const char *path_fs);
    00071
    00077         struct tag *(*tag_dup)(const char *path_fs);
    00078
    00084         struct tag *(*stream_tag)(struct input_stream *is);
    00085
    00096         char* (*container_scan)(const char *path_fs, const unsigned int tnum);
    00097
    00098         /* last element in these arrays must always be a NULL: */
    00099         const char *const*suffixes;
    00100         const char *const*mime_types;
    00101 };
    00102
    00111 static inline bool
    00112 decoder_plugin_init(const struct decoder_plugin *plugin,
    00113                     const struct config_param *param)
    00114 {
    00115         return plugin->init != NULL
    00116                 ? plugin->init(param)
    00117                 : true;
    00118 }
    00119
    00123 static inline void
    00124 decoder_plugin_finish(const struct decoder_plugin *plugin)
    00125 {
    00126         if (plugin->finish != NULL)
    00127                 plugin->finish();
    00128 }
    00129
    00133 static inline void
    00134 decoder_plugin_stream_decode(const struct decoder_plugin *plugin,
    00135                              struct decoder *decoder, struct input_stream *is)
    00136 {
    00137         plugin->stream_decode(decoder, is);
    00138 }
    00139
    00143 static inline void
    00144 decoder_plugin_file_decode(const struct decoder_plugin *plugin,
    00145                            struct decoder *decoder, const char *path_fs)
    00146 {
    00147         plugin->file_decode(decoder, path_fs);
    00148 }
    00149
    00153 static inline struct tag *
    00154 decoder_plugin_tag_dup(const struct decoder_plugin *plugin,
    00155                        const char *path_fs)
    00156 {
    00157         return plugin->tag_dup != NULL
    00158                 ? plugin->tag_dup(path_fs)
    00159                 : NULL;
    00160 }
    00161
    00165 static inline struct tag *
    00166 decoder_plugin_stream_tag(const struct decoder_plugin *plugin,
    00167                           struct input_stream *is)
    00168 {
    00169         return plugin->stream_tag != NULL
    00170                 ? plugin->stream_tag(is)
    00171                 : NULL;
    00172 }
    00173
    00177 static inline char *
    00178 decoder_plugin_container_scan(  const struct decoder_plugin *plugin,
    00179                                 const char* pathname,
    00180                                 const unsigned int tnum)
    00181 {
    00182         return plugin->container_scan(pathname, tnum);
    00183 }
    00184
    00188 bool
    00189 decoder_plugin_supports_suffix(const struct decoder_plugin *plugin,
    00190                                const char *suffix);
    00191
    00195 bool
    00196 decoder_plugin_supports_mime_type(const struct decoder_plugin *plugin,
    00197                                   const char *mime_type);
    00198
    00199 #endif