2010-06-25 21:45:04 +02:00
|
|
|
/*
|
2013-01-02 18:38:32 +01:00
|
|
|
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
2010-06-25 21:45:04 +02:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2013-01-02 18:38:32 +01:00
|
|
|
#include "PlaylistAny.hxx"
|
|
|
|
#include "PlaylistMapper.hxx"
|
2013-01-26 01:04:02 +01:00
|
|
|
#include "PlaylistRegistry.hxx"
|
2013-04-08 23:30:21 +02:00
|
|
|
#include "util/UriUtil.hxx"
|
2013-08-10 18:02:44 +02:00
|
|
|
#include "util/Error.hxx"
|
2013-09-05 00:06:31 +02:00
|
|
|
#include "InputStream.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
#include "Log.hxx"
|
2013-01-02 18:38:32 +01:00
|
|
|
|
2010-06-25 21:45:04 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
2013-09-05 09:37:54 +02:00
|
|
|
static SongEnumerator *
|
2013-01-27 17:20:50 +01:00
|
|
|
playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond,
|
2013-10-23 22:08:59 +02:00
|
|
|
InputStream **is_r)
|
2010-06-25 21:45:04 +02:00
|
|
|
{
|
|
|
|
assert(uri_has_scheme(uri));
|
|
|
|
|
2013-09-05 09:37:54 +02:00
|
|
|
SongEnumerator *playlist = playlist_list_open_uri(uri, mutex, cond);
|
2013-10-02 08:13:28 +02:00
|
|
|
if (playlist != nullptr) {
|
|
|
|
*is_r = nullptr;
|
2010-06-25 21:45:04 +02:00
|
|
|
return playlist;
|
|
|
|
}
|
|
|
|
|
2013-08-10 18:02:44 +02:00
|
|
|
Error error;
|
2013-12-29 18:08:49 +01:00
|
|
|
InputStream *is = InputStream::OpenReady(uri, mutex, cond, error);
|
2013-10-02 08:13:28 +02:00
|
|
|
if (is == nullptr) {
|
2013-08-10 18:02:44 +02:00
|
|
|
if (error.IsDefined())
|
2013-09-27 22:31:24 +02:00
|
|
|
FormatError(error, "Failed to open %s", uri);
|
2010-06-25 21:45:04 +02:00
|
|
|
|
2013-10-02 08:13:28 +02:00
|
|
|
return nullptr;
|
2010-06-25 21:45:04 +02:00
|
|
|
}
|
|
|
|
|
2013-10-23 22:08:59 +02:00
|
|
|
playlist = playlist_list_open_stream(*is, uri);
|
2013-10-02 08:13:28 +02:00
|
|
|
if (playlist == nullptr) {
|
2013-09-05 00:06:31 +02:00
|
|
|
is->Close();
|
2013-10-02 08:13:28 +02:00
|
|
|
return nullptr;
|
2010-06-25 21:45:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*is_r = is;
|
|
|
|
return playlist;
|
|
|
|
}
|
|
|
|
|
2013-09-05 09:37:54 +02:00
|
|
|
SongEnumerator *
|
2013-01-27 17:20:50 +01:00
|
|
|
playlist_open_any(const char *uri, Mutex &mutex, Cond &cond,
|
2013-10-23 22:08:59 +02:00
|
|
|
InputStream **is_r)
|
2010-06-25 21:45:04 +02:00
|
|
|
{
|
|
|
|
return uri_has_scheme(uri)
|
2011-09-14 21:46:41 +02:00
|
|
|
? playlist_open_remote(uri, mutex, cond, is_r)
|
|
|
|
: playlist_mapper_open(uri, mutex, cond, is_r);
|
2010-06-25 21:45:04 +02:00
|
|
|
}
|