PlaylistRegistry.hxx 2.57 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2020 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * http://www.musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

20 21
#ifndef MPD_PLAYLIST_REGISTRY_HXX
#define MPD_PLAYLIST_REGISTRY_HXX
22

23
#include "input/Ptr.hxx"
24
#include "thread/Mutex.hxx"
25
#include "util/Compiler.h"
26

27
struct ConfigData;
28
struct PlaylistPlugin;
29
class SongEnumerator;
30

31
extern const PlaylistPlugin *const playlist_plugins[];
32 33

#define playlist_plugins_for_each(plugin) \
34
	for (const PlaylistPlugin *plugin, \
35
		*const*playlist_plugin_iterator = &playlist_plugins[0]; \
36
		(plugin = *playlist_plugin_iterator) != nullptr; \
37 38
		++playlist_plugin_iterator)

39 40 41 42
/**
 * Initializes all playlist plugins.
 */
void
43
playlist_list_global_init(const ConfigData &config);
44 45 46 47 48

/**
 * Deinitializes all playlist plugins.
 */
void
49
playlist_list_global_finish() noexcept;
50

51 52 53 54 55 56 57 58 59 60 61
class ScopePlaylistPluginsInit {
public:
	explicit ScopePlaylistPluginsInit(const ConfigData &config) {
		playlist_list_global_init(config);
	}

	~ScopePlaylistPluginsInit() noexcept {
		playlist_list_global_finish();
	}
};

62 63 64
/**
 * Opens a playlist by its URI.
 */
65
std::unique_ptr<SongEnumerator>
66
playlist_list_open_uri(const char *uri, Mutex &mutex);
67

68
std::unique_ptr<SongEnumerator>
69
playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix);
70

71 72 73
/**
 * Opens a playlist from an input stream.
 *
74
 * @param is an #InputStream object which is open and ready
75 76 77
 * @param uri optional URI which was used to open the stream; may be
 * used to select the appropriate playlist plugin
 */
78
std::unique_ptr<SongEnumerator>
79
playlist_list_open_stream(InputStreamPtr &&is, const char *uri);
80

81 82 83 84
gcc_pure
const PlaylistPlugin *
FindPlaylistPluginBySuffix(const char *suffix) noexcept;

85 86 87 88
/**
 * Determines if there is a playlist plugin which can handle the
 * specified file name suffix.
 */
89
gcc_pure
90 91 92 93 94
inline bool
playlist_suffix_supported(const char *suffix) noexcept
{
	return FindPlaylistPluginBySuffix(suffix) != nullptr;
}
95

96
#endif