Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
3e78c9ab
Commit
3e78c9ab
authored
Oct 24, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/Plugin: add attribute `prefixes`
parent
9ec86acb
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
127 additions
and
87 deletions
+127
-87
InputPlugin.cxx
src/input/InputPlugin.cxx
+35
-0
InputPlugin.hxx
src/input/InputPlugin.hxx
+11
-1
Open.cxx
src/input/Open.cxx
+3
-0
ScanTags.cxx
src/input/ScanTags.cxx
+1
-1
meson.build
src/input/meson.build
+1
-0
AlsaInputPlugin.cxx
src/input/plugins/AlsaInputPlugin.cxx
+6
-0
CdioParanoiaInputPlugin.cxx
src/input/plugins/CdioParanoiaInputPlugin.cxx
+6
-0
CurlInputPlugin.cxx
src/input/plugins/CurlInputPlugin.cxx
+7
-0
FfmpegInputPlugin.cxx
src/input/plugins/FfmpegInputPlugin.cxx
+11
-8
MmsInputPlugin.cxx
src/input/plugins/MmsInputPlugin.cxx
+9
-6
NfsInputPlugin.cxx
src/input/plugins/NfsInputPlugin.cxx
+6
-3
QobuzInputPlugin.cxx
src/input/plugins/QobuzInputPlugin.cxx
+6
-0
SmbclientInputPlugin.cxx
src/input/plugins/SmbclientInputPlugin.cxx
+6
-3
TidalInputPlugin.cxx
src/input/plugins/TidalInputPlugin.cxx
+6
-0
ls.cxx
src/ls.cxx
+12
-64
ls.hxx
src/ls.hxx
+1
-1
No files found.
src/input/InputPlugin.cxx
0 → 100644
View file @
3e78c9ab
/*
* Copyright 2003-2018 The Music Player Daemon Project
* 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 "InputPlugin.hxx"
#include "util/StringCompare.hxx"
#include <assert.h>
bool
InputPlugin
::
SupportsUri
(
const
char
*
uri
)
const
noexcept
{
assert
(
prefixes
!=
nullptr
);
for
(
auto
i
=
prefixes
;
*
i
!=
nullptr
;
++
i
)
if
(
StringStartsWithIgnoreCase
(
uri
,
*
i
))
return
true
;
return
false
;
}
src/input/InputPlugin.hxx
View file @
3e78c9ab
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -21,6 +21,7 @@
#define MPD_INPUT_PLUGIN_HXX
#include "Ptr.hxx"
#include "util/Compiler.h"
struct
ConfigBlock
;
class
Mutex
;
...
...
@@ -32,6 +33,12 @@ struct InputPlugin {
const
char
*
name
;
/**
* A nullptr-terminated list of URI prefixes handled by this
* plugin. This is usually a string in the form "scheme://".
*/
const
char
*
const
*
prefixes
;
/**
* Global initialization. This method is called when MPD starts.
*
* Throws #PluginUnavailable if the plugin is not available
...
...
@@ -66,6 +73,9 @@ struct InputPlugin {
*/
std
::
unique_ptr
<
RemoteTagScanner
>
(
*
scan_tags
)(
const
char
*
uri
,
RemoteTagHandler
&
handler
)
=
nullptr
;
gcc_pure
bool
SupportsUri
(
const
char
*
uri
)
const
noexcept
;
};
#endif
src/input/Open.cxx
View file @
3e78c9ab
...
...
@@ -38,6 +38,9 @@ InputStream::Open(const char *url, Mutex &mutex)
}
input_plugins_for_each_enabled
(
plugin
)
{
if
(
!
plugin
->
SupportsUri
(
url
))
continue
;
auto
is
=
plugin
->
open
(
url
,
mutex
);
if
(
is
!=
nullptr
)
return
input_rewind_open
(
std
::
move
(
is
));
...
...
src/input/ScanTags.cxx
View file @
3e78c9ab
...
...
@@ -27,7 +27,7 @@ std::unique_ptr<RemoteTagScanner>
InputScanTags
(
const
char
*
uri
,
RemoteTagHandler
&
handler
)
{
input_plugins_for_each_enabled
(
plugin
)
{
if
(
plugin
->
scan_tags
==
nullptr
)
if
(
plugin
->
scan_tags
==
nullptr
||
!
plugin
->
SupportsUri
(
uri
)
)
continue
;
auto
scanner
=
plugin
->
scan_tags
(
uri
,
handler
);
...
...
src/input/meson.build
View file @
3e78c9ab
input_api = static_library(
'input_api',
'Error.cxx',
'InputPlugin.cxx',
'InputStream.cxx',
'ThreadInputStream.cxx',
'AsyncInputStream.cxx',
...
...
src/input/plugins/AlsaInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -409,8 +409,14 @@ alsa_input_open(const char *uri, Mutex &mutex)
mutex
);
}
static
constexpr
const
char
*
alsa_prefixes
[]
=
{
"alsa://"
,
nullptr
};
const
struct
InputPlugin
input_plugin_alsa
=
{
"alsa"
,
alsa_prefixes
,
alsa_input_init
,
nullptr
,
alsa_input_open
,
...
...
src/input/plugins/CdioParanoiaInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -357,8 +357,14 @@ CdioParanoiaInputStream::IsEOF() noexcept
return
lsn_from
+
lsn_relofs
>
lsn_to
;
}
static
constexpr
const
char
*
cdio_paranoia_prefixes
[]
=
{
"cdda://"
,
nullptr
};
const
InputPlugin
input_plugin_cdio_paranoia
=
{
"cdio_paranoia"
,
cdio_paranoia_prefixes
,
input_cdio_init
,
nullptr
,
input_cdio_open
,
...
...
src/input/plugins/CurlInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -473,8 +473,15 @@ input_curl_open(const char *url, Mutex &mutex)
return
CurlInputStream
::
Open
(
url
,
{},
mutex
);
}
static
constexpr
const
char
*
curl_prefixes
[]
=
{
"http://"
,
"https://"
,
nullptr
};
const
struct
InputPlugin
input_plugin_curl
=
{
"curl"
,
curl_prefixes
,
input_curl_init
,
input_curl_finish
,
input_curl_open
,
...
...
src/input/plugins/FfmpegInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -85,14 +85,6 @@ static InputStreamPtr
input_ffmpeg_open
(
const
char
*
uri
,
Mutex
&
mutex
)
{
if
(
!
StringStartsWithCaseASCII
(
uri
,
"gopher://"
)
&&
!
StringStartsWithCaseASCII
(
uri
,
"rtp://"
)
&&
!
StringStartsWithCaseASCII
(
uri
,
"rtsp://"
)
&&
!
StringStartsWithCaseASCII
(
uri
,
"rtmp://"
)
&&
!
StringStartsWithCaseASCII
(
uri
,
"rtmpt://"
)
&&
!
StringStartsWithCaseASCII
(
uri
,
"rtmps://"
))
return
nullptr
;
AVIOContext
*
h
;
auto
result
=
avio_open
(
&
h
,
uri
,
AVIO_FLAG_READ
);
if
(
result
!=
0
)
...
...
@@ -146,8 +138,19 @@ FfmpegInputStream::Seek(offset_type new_offset)
eof
=
false
;
}
static
constexpr
const
char
*
ffmpeg_prefixes
[]
=
{
"gopher://"
,
"rtp://"
,
"rtsp://"
,
"rtmp://"
,
"rtmpt://"
,
"rtmps://"
,
nullptr
};
const
InputPlugin
input_plugin_ffmpeg
=
{
"ffmpeg"
,
ffmpeg_prefixes
,
input_ffmpeg_init
,
nullptr
,
input_ffmpeg_open
,
...
...
src/input/plugins/MmsInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -72,12 +72,6 @@ static InputStreamPtr
input_mms_open
(
const
char
*
url
,
Mutex
&
mutex
)
{
if
(
!
StringStartsWithCaseASCII
(
url
,
"mms://"
)
&&
!
StringStartsWithCaseASCII
(
url
,
"mmsh://"
)
&&
!
StringStartsWithCaseASCII
(
url
,
"mmst://"
)
&&
!
StringStartsWithCaseASCII
(
url
,
"mmsu://"
))
return
nullptr
;
auto
m
=
std
::
make_unique
<
MmsInputStream
>
(
url
,
mutex
);
m
->
Start
();
return
m
;
...
...
@@ -103,8 +97,17 @@ MmsInputStream::ThreadRead(void *ptr, size_t read_size)
return
(
size_t
)
nbytes
;
}
static
constexpr
const
char
*
mms_prefixes
[]
=
{
"mms://"
,
"mmsh://"
,
"mmst://"
,
"mmsu://"
,
nullptr
};
const
InputPlugin
input_plugin_mms
=
{
"mms"
,
mms_prefixes
,
nullptr
,
nullptr
,
input_mms_open
,
...
...
src/input/plugins/NfsInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -217,16 +217,19 @@ static InputStreamPtr
input_nfs_open
(
const
char
*
uri
,
Mutex
&
mutex
)
{
if
(
!
StringStartsWithCaseASCII
(
uri
,
"nfs://"
))
return
nullptr
;
auto
is
=
std
::
make_unique
<
NfsInputStream
>
(
uri
,
mutex
);
is
->
Open
();
return
is
;
}
static
constexpr
const
char
*
nfs_prefixes
[]
=
{
"nfs://"
,
nullptr
};
const
InputPlugin
input_plugin_nfs
=
{
"nfs"
,
nfs_prefixes
,
input_nfs_init
,
input_nfs_finish
,
input_nfs_open
,
...
...
src/input/plugins/QobuzInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -209,8 +209,14 @@ ScanQobuzTags(const char *uri, RemoteTagHandler &handler)
handler
);
}
static
constexpr
const
char
*
qobuz_prefixes
[]
=
{
"qobuz://"
,
nullptr
};
const
InputPlugin
qobuz_input_plugin
=
{
"qobuz"
,
qobuz_prefixes
,
InitQobuzInput
,
FinishQobuzInput
,
OpenQobuzInput
,
...
...
src/input/plugins/SmbclientInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -87,9 +87,6 @@ static InputStreamPtr
input_smbclient_open
(
const
char
*
uri
,
Mutex
&
mutex
)
{
if
(
!
StringStartsWithCaseASCII
(
uri
,
"smb://"
))
return
nullptr
;
const
std
::
lock_guard
<
Mutex
>
protect
(
smbclient_mutex
);
SMBCCTX
*
ctx
=
smbc_new_context
();
...
...
@@ -158,8 +155,14 @@ SmbclientInputStream::Seek(offset_type new_offset)
offset
=
result
;
}
static
constexpr
const
char
*
smbclient_prefixes
[]
=
{
"smb://"
,
nullptr
};
const
InputPlugin
input_plugin_smbclient
=
{
"smbclient"
,
smbclient_prefixes
,
input_smbclient_init
,
nullptr
,
input_smbclient_open
,
...
...
src/input/plugins/TidalInputPlugin.cxx
View file @
3e78c9ab
...
...
@@ -239,8 +239,14 @@ ScanTidalTags(const char *uri, RemoteTagHandler &handler)
track_id
,
handler
);
}
static
constexpr
const
char
*
tidal_prefixes
[]
=
{
"tidal://"
,
nullptr
};
const
InputPlugin
tidal_input_plugin
=
{
"tidal"
,
tidal_prefixes
,
InitTidalInput
,
FinishTidalInput
,
OpenTidalInput
,
...
...
src/ls.cxx
View file @
3e78c9ab
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -19,94 +19,42 @@
#include "config.h"
#include "ls.hxx"
#include "input/Registry.hxx"
#include "input/InputPlugin.hxx"
#include "client/Response.hxx"
#include "util/ASCII.hxx"
#include "util/UriUtil.hxx"
#include <assert.h>
/**
* file:// is not included in remoteUrlPrefixes, the connection method
* is detected at runtime and displayed as a urlhandler if the client is
* connected by IPC socket.
*/
static
const
char
*
const
remoteUrlPrefixes
[]
=
{
#if defined(ENABLE_CURL)
"http://"
,
"https://"
,
#endif
#ifdef ENABLE_MMS
"mms://"
,
"mmsh://"
,
"mmst://"
,
"mmsu://"
,
#endif
#ifdef ENABLE_FFMPEG
"gopher://"
,
"rtp://"
,
"rtsp://"
,
"rtmp://"
,
"rtmpt://"
,
"rtmps://"
,
#endif
#ifdef ENABLE_SMBCLIENT
"smb://"
,
#endif
#ifdef ENABLE_NFS
"nfs://"
,
#endif
#ifdef ENABLE_CDIO_PARANOIA
"cdda://"
,
#endif
#ifdef ENABLE_ALSA
"alsa://"
,
#endif
#ifdef ENABLE_QOBUZ
"qobuz://"
,
#endif
#ifdef ENABLE_TIDAL
"tidal://"
,
#endif
NULL
};
void
print_supported_uri_schemes_to_fp
(
FILE
*
fp
)
{
const
char
*
const
*
prefixes
=
remoteUrlPrefixes
;
#ifdef HAVE_UN
fprintf
(
fp
,
" file://"
);
#endif
while
(
*
prefixes
)
{
fprintf
(
fp
,
" %s"
,
*
prefixes
);
prefixes
++
;
}
input_plugins_for_each
(
plugin
)
for
(
auto
i
=
plugin
->
prefixes
;
*
i
!=
nullptr
;
++
i
)
fprintf
(
fp
,
" %s"
,
*
i
);
fprintf
(
fp
,
"
\n
"
);
}
void
print_supported_uri_schemes
(
Response
&
r
)
{
const
char
*
const
*
prefixes
=
remoteUrlPrefixes
;
while
(
*
prefixes
)
{
r
.
Format
(
"handler: %s
\n
"
,
*
prefixes
);
prefixes
++
;
}
input_plugins_for_each_enabled
(
plugin
)
for
(
auto
i
=
plugin
->
prefixes
;
*
i
!=
nullptr
;
++
i
)
r
.
Format
(
"handler: %s
\n
"
,
*
i
);
}
bool
uri_supported_scheme
(
const
char
*
uri
)
noexcept
{
const
char
*
const
*
urlPrefixes
=
remoteUrlPrefixes
;
assert
(
uri_has_scheme
(
uri
));
while
(
*
urlPrefixes
)
{
if
(
StringStartsWithCaseASCII
(
uri
,
*
urlPrefixes
))
input_plugins_for_each_enabled
(
plugin
)
for
(
auto
i
=
plugin
->
prefixes
;
*
i
!=
nullptr
;
++
i
)
if
(
StringStartsWithCaseASCII
(
uri
,
*
i
))
return
true
;
urlPrefixes
++
;
}
return
false
;
}
src/ls.hxx
View file @
3e78c9ab
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment