MPD

- Main Page
- Data Structures
- Files

- File List
- Globals

# src/playlist_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_PLAYLIST_PLUGIN_H
    00021 #define MPD_PLAYLIST_PLUGIN_H
    00022
    00023 #include <stdbool.h>
    00024 #include <stddef.h>
    00025
    00026 struct config_param;
    00027 struct input_stream;
    00028 struct tag;
    00029
    00033 struct playlist_provider {
    00034         const struct playlist_plugin *plugin;
    00035 };
    00036
    00037 static inline void
    00038 playlist_provider_init(struct playlist_provider *playlist,
    00039                        const struct playlist_plugin *plugin)
    00040 {
    00041         playlist->plugin = plugin;
    00042 }
    00043
    00044 struct playlist_plugin {
    00045         const char *name;
    00046
    00055         bool (*init)(const struct config_param *param);
    00056
    00061         void (*finish)(void);
    00062
    00067         struct playlist_provider *(*open_uri)(const char *uri);
    00068
    00074         struct playlist_provider *(*open_stream)(struct input_stream *is);
    00075
    00076         void (*close)(struct playlist_provider *playlist);
    00077
    00078         struct song *(*read)(struct playlist_provider *playlist);
    00079
    00080         const char *const*schemes;
    00081         const char *const*suffixes;
    00082         const char *const*mime_types;
    00083 };
    00084
    00093 static inline bool
    00094 playlist_plugin_init(const struct playlist_plugin *plugin,
    00095                      const struct config_param *param)
    00096 {
    00097         return plugin->init != NULL
    00098                 ? plugin->init(param)
    00099                 : true;
    00100 }
    00101
    00105 static inline void
    00106 playlist_plugin_finish(const struct playlist_plugin *plugin)
    00107 {
    00108         if (plugin->finish != NULL)
    00109                 plugin->finish();
    00110 }
    00111
    00112 static inline struct playlist_provider *
    00113 playlist_plugin_open_uri(const struct playlist_plugin *plugin, const char *uri)
    00114 {
    00115         return plugin->open_uri(uri);
    00116 }
    00117
    00118 static inline struct playlist_provider *
    00119 playlist_plugin_open_stream(const struct playlist_plugin *plugin,
    00120                             struct input_stream *is)
    00121 {
    00122         return plugin->open_stream(is);
    00123 }
    00124
    00125 static inline void
    00126 playlist_plugin_close(struct playlist_provider *playlist)
    00127 {
    00128         playlist->plugin->close(playlist);
    00129 }
    00130
    00131 static inline struct song *
    00132 playlist_plugin_read(struct playlist_provider *playlist)
    00133 {
    00134         return playlist->plugin->read(playlist);
    00135 }
    00136
    00137 #endif