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
5465647c
Commit
5465647c
authored
Dec 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/smbclient: new input plugin
parent
a2baeed3
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
274 additions
and
0 deletions
+274
-0
Makefile.am
Makefile.am
+7
-0
NEWS
NEWS
+1
-0
configure.ac
configure.ac
+14
-0
user.xml
doc/user.xml
+14
-0
InputRegistry.cxx
src/InputRegistry.cxx
+7
-0
SmbclientInputPlugin.cxx
src/input/SmbclientInputPlugin.cxx
+203
-0
SmbclientInputPlugin.hxx
src/input/SmbclientInputPlugin.hxx
+25
-0
ls.cxx
src/ls.cxx
+3
-0
No files found.
Makefile.am
View file @
5465647c
...
@@ -791,6 +791,7 @@ libinput_a_SOURCES = \
...
@@ -791,6 +791,7 @@ libinput_a_SOURCES = \
libinput_a_CPPFLAGS
=
$(AM_CPPFLAGS)
\
libinput_a_CPPFLAGS
=
$(AM_CPPFLAGS)
\
$(CURL_CFLAGS)
\
$(CURL_CFLAGS)
\
$(SMBCLIENT_CFLAGS)
\
$(CDIO_PARANOIA_CFLAGS)
\
$(CDIO_PARANOIA_CFLAGS)
\
$(FFMPEG_CFLAGS)
\
$(FFMPEG_CFLAGS)
\
$(DESPOTIFY_CFLAGS)
\
$(DESPOTIFY_CFLAGS)
\
...
@@ -799,6 +800,7 @@ libinput_a_CPPFLAGS = $(AM_CPPFLAGS) \
...
@@ -799,6 +800,7 @@ libinput_a_CPPFLAGS = $(AM_CPPFLAGS) \
INPUT_LIBS
=
\
INPUT_LIBS
=
\
libinput.a
\
libinput.a
\
$(CURL_LIBS)
\
$(CURL_LIBS)
\
$(SMBCLIENT_LIBS)
\
$(CDIO_PARANOIA_LIBS)
\
$(CDIO_PARANOIA_LIBS)
\
$(FFMPEG_LIBS)
\
$(FFMPEG_LIBS)
\
$(DESPOTIFY_LIBS)
\
$(DESPOTIFY_LIBS)
\
...
@@ -818,6 +820,11 @@ libinput_a_SOURCES += \
...
@@ -818,6 +820,11 @@ libinput_a_SOURCES += \
src/IcyMetaDataParser.cxx src/IcyMetaDataParser.hxx
src/IcyMetaDataParser.cxx src/IcyMetaDataParser.hxx
endif
endif
if
ENABLE_SMBCLIENT
libinput_a_SOURCES
+=
\
src/input/SmbclientInputPlugin.cxx src/input/SmbclientInputPlugin.hxx
endif
if
ENABLE_CDIO_PARANOIA
if
ENABLE_CDIO_PARANOIA
libinput_a_SOURCES
+=
\
libinput_a_SOURCES
+=
\
src/input/CdioParanoiaInputPlugin.cxx
\
src/input/CdioParanoiaInputPlugin.cxx
\
...
...
NEWS
View file @
5465647c
...
@@ -3,6 +3,7 @@ ver 0.19 (not yet released)
...
@@ -3,6 +3,7 @@ ver 0.19 (not yet released)
- new commands "addtagid", "cleartagid"
- new commands "addtagid", "cleartagid"
* input
* input
- alsa: new input plugin
- alsa: new input plugin
- smbclient: new input plugin
* filter
* filter
- volume: improved software volume dithering
- volume: improved software volume dithering
* new resampler option using libsoxr
* new resampler option using libsoxr
...
...
configure.ac
View file @
5465647c
...
@@ -300,6 +300,11 @@ AC_ARG_ENABLE(curl,
...
@@ -300,6 +300,11 @@ AC_ARG_ENABLE(curl,
[enable support for libcurl HTTP streaming (default: auto)]),,
[enable support for libcurl HTTP streaming (default: auto)]),,
[enable_curl=auto])
[enable_curl=auto])
AC_ARG_ENABLE(smbclient,
AS_HELP_STRING([--enable-smbclient],
[enable support for libsmbclient (default: auto)]),,
[enable_smbclient=auto])
AC_ARG_ENABLE(debug,
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
AS_HELP_STRING([--enable-debug],
[enable debugging (default: disabled)]),,
[enable debugging (default: disabled)]),,
...
@@ -827,6 +832,14 @@ if test x$enable_curl = xyes; then
...
@@ -827,6 +832,14 @@ if test x$enable_curl = xyes; then
fi
fi
AM_CONDITIONAL(ENABLE_CURL, test x$enable_curl = xyes)
AM_CONDITIONAL(ENABLE_CURL, test x$enable_curl = xyes)
dnl ----------------------------------- smbclient -----------------------------
MPD_AUTO_PKG(smbclient, SMBCLIENT, [smbclient >= 0.2],
[smbclient input plugin], [libsmbclient not found])
if test x$enable_smbclient = xyes; then
AC_DEFINE(ENABLE_SMBCLIENT, 1, [Define when libsmbclient is used])
fi
AM_CONDITIONAL(ENABLE_SMBCLIENT, test x$enable_smbclient = xyes)
dnl --------------------------------- Despotify ---------------------------------
dnl --------------------------------- Despotify ---------------------------------
MPD_AUTO_PKG(despotify, DESPOTIFY, [despotify],
MPD_AUTO_PKG(despotify, DESPOTIFY, [despotify],
[Despotify support], [despotify not found])
[Despotify support], [despotify not found])
...
@@ -1708,6 +1721,7 @@ fi
...
@@ -1708,6 +1721,7 @@ fi
printf '\nStreaming support:\n\t'
printf '\nStreaming support:\n\t'
results(cdio_paranoia, [CDIO_PARANOIA])
results(cdio_paranoia, [CDIO_PARANOIA])
results(curl,[CURL])
results(curl,[CURL])
results(smbclient,[SMBCLIENT])
results(despotify,[Despotify])
results(despotify,[Despotify])
results(soundcloud,[Soundcloud])
results(soundcloud,[Soundcloud])
printf '\n\t'
printf '\n\t'
...
...
doc/user.xml
View file @
5465647c
...
@@ -1059,6 +1059,20 @@ systemctl start mpd.socket</programlisting>
...
@@ -1059,6 +1059,20 @@ systemctl start mpd.socket</programlisting>
</tgroup>
</tgroup>
</informaltable>
</informaltable>
</section>
</section>
<section>
<title><varname>
smbclient
</varname></title>
<para>
Allows MPD to access files on SMB/CIFS servers (e.g. Samba
or Microsoft Windows). All URIs with the
<filename>
smb://
</filename>
scheme are used. Example:
</para>
<para>
<filename>
mpc add smb://servername/sharename/filename.ogg
</filename>
</para>
</section>
</section>
</section>
<section>
<section>
...
...
src/InputRegistry.cxx
View file @
5465647c
...
@@ -38,6 +38,10 @@
...
@@ -38,6 +38,10 @@
#include "input/FfmpegInputPlugin.hxx"
#include "input/FfmpegInputPlugin.hxx"
#endif
#endif
#ifdef ENABLE_SMBCLIENT
#include "input/SmbclientInputPlugin.hxx"
#endif
#ifdef ENABLE_MMS
#ifdef ENABLE_MMS
#include "input/MmsInputPlugin.hxx"
#include "input/MmsInputPlugin.hxx"
#endif
#endif
...
@@ -64,6 +68,9 @@ const InputPlugin *const input_plugins[] = {
...
@@ -64,6 +68,9 @@ const InputPlugin *const input_plugins[] = {
#ifdef HAVE_FFMPEG
#ifdef HAVE_FFMPEG
&
input_plugin_ffmpeg
,
&
input_plugin_ffmpeg
,
#endif
#endif
#ifdef ENABLE_SMBCLIENT
&
input_plugin_smbclient
,
#endif
#ifdef ENABLE_MMS
#ifdef ENABLE_MMS
&
input_plugin_mms
,
&
input_plugin_mms
,
#endif
#endif
...
...
src/input/SmbclientInputPlugin.cxx
0 → 100644
View file @
5465647c
/*
* Copyright (C) 2003-2013 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 "config.h"
#include "SmbclientInputPlugin.hxx"
#include "InputStream.hxx"
#include "InputPlugin.hxx"
#include "util/StringUtil.hxx"
#include "util/Error.hxx"
#include <libsmbclient.h>
#include <string.h>
class
SmbclientInputStream
{
InputStream
base
;
SMBCCTX
*
ctx
;
int
fd
;
public
:
SmbclientInputStream
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
SMBCCTX
*
_ctx
,
int
_fd
,
const
struct
stat
&
st
)
:
base
(
input_plugin_smbclient
,
uri
,
mutex
,
cond
),
ctx
(
_ctx
),
fd
(
_fd
)
{
base
.
ready
=
true
;
base
.
seekable
=
true
;
base
.
size
=
st
.
st_size
;
}
~
SmbclientInputStream
()
{
smbc_close
(
fd
);
smbc_free_context
(
ctx
,
1
);
}
InputStream
*
GetBase
()
{
return
&
base
;
}
bool
IsEOF
()
const
{
return
base
.
offset
>=
base
.
size
;
}
size_t
Read
(
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
ssize_t
nbytes
=
smbc_read
(
fd
,
ptr
,
size
);
if
(
nbytes
<
0
)
{
error
.
SetErrno
(
"smbc_read() failed"
);
nbytes
=
0
;
}
return
nbytes
;
}
bool
Seek
(
InputStream
::
offset_type
offset
,
int
whence
,
Error
&
error
)
{
off_t
result
=
smbc_lseek
(
fd
,
offset
,
whence
);
if
(
result
<
0
)
{
error
.
SetErrno
(
"smbc_lseek() failed"
);
return
false
;
}
base
.
offset
=
result
;
return
true
;
}
};
static
void
mpd_smbc_get_auth_data
(
gcc_unused
const
char
*
srv
,
gcc_unused
const
char
*
shr
,
char
*
wg
,
gcc_unused
int
wglen
,
char
*
un
,
gcc_unused
int
unlen
,
char
*
pw
,
gcc_unused
int
pwlen
)
{
// TODO: implement
strcpy
(
wg
,
"WORKGROUP"
);
strcpy
(
un
,
"foo"
);
strcpy
(
pw
,
"bar"
);
}
/*
* InputPlugin methods
*
*/
static
bool
input_smbclient_init
(
gcc_unused
const
config_param
&
param
,
Error
&
error
)
{
constexpr
int
debug
=
0
;
if
(
smbc_init
(
mpd_smbc_get_auth_data
,
debug
)
<
0
)
{
error
.
SetErrno
(
"smbc_init() failed"
);
return
false
;
}
// TODO: create one global SMBCCTX here?
// TODO: evaluate config_param, call smbc_setOption*()
return
true
;
}
static
InputStream
*
input_smbclient_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
{
if
(
!
StringStartsWith
(
uri
,
"smb://"
))
return
nullptr
;
SMBCCTX
*
ctx
=
smbc_new_context
();
if
(
ctx
==
nullptr
)
{
error
.
SetErrno
(
"smbc_new_context() failed"
);
return
nullptr
;
}
SMBCCTX
*
ctx2
=
smbc_init_context
(
ctx
);
if
(
ctx2
==
nullptr
)
{
error
.
SetErrno
(
"smbc_init_context() failed"
);
smbc_free_context
(
ctx
,
1
);
return
nullptr
;
}
ctx
=
ctx2
;
int
fd
=
smbc_open
(
uri
,
O_RDONLY
,
0
);
if
(
fd
<
0
)
{
error
.
SetErrno
(
"smbc_open() failed"
);
smbc_free_context
(
ctx
,
1
);
return
nullptr
;
}
struct
stat
st
;
if
(
smbc_fstat
(
fd
,
&
st
)
<
0
)
{
error
.
SetErrno
(
"smbc_fstat() failed"
);
smbc_close
(
fd
);
smbc_free_context
(
ctx
,
1
);
return
nullptr
;
}
auto
s
=
new
SmbclientInputStream
(
uri
,
mutex
,
cond
,
ctx
,
fd
,
st
);
return
s
->
GetBase
();
}
static
size_t
input_smbclient_read
(
InputStream
*
is
,
void
*
ptr
,
size_t
size
,
Error
&
error
)
{
SmbclientInputStream
&
s
=
*
(
SmbclientInputStream
*
)
is
;
return
s
.
Read
(
ptr
,
size
,
error
);
}
static
void
input_smbclient_close
(
InputStream
*
is
)
{
SmbclientInputStream
*
s
=
(
SmbclientInputStream
*
)
is
;
delete
s
;
}
static
bool
input_smbclient_eof
(
InputStream
*
is
)
{
SmbclientInputStream
&
s
=
*
(
SmbclientInputStream
*
)
is
;
return
s
.
IsEOF
();
}
static
bool
input_smbclient_seek
(
InputStream
*
is
,
InputPlugin
::
offset_type
offset
,
int
whence
,
Error
&
error
)
{
SmbclientInputStream
&
s
=
*
(
SmbclientInputStream
*
)
is
;
return
s
.
Seek
(
offset
,
whence
,
error
);
}
const
InputPlugin
input_plugin_smbclient
=
{
"smbclient"
,
input_smbclient_init
,
nullptr
,
input_smbclient_open
,
input_smbclient_close
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
input_smbclient_read
,
input_smbclient_eof
,
input_smbclient_seek
,
};
src/input/SmbclientInputPlugin.hxx
0 → 100644
View file @
5465647c
/*
* Copyright (C) 2003-2013 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.
*/
#ifndef MPD_INPUT_SMBCLIENT_H
#define MPD_INPUT_SMBCLIENT_H
extern
const
struct
InputPlugin
input_plugin_smbclient
;
#endif
src/ls.cxx
View file @
5465647c
...
@@ -49,6 +49,9 @@ static const char *remoteUrlPrefixes[] = {
...
@@ -49,6 +49,9 @@ static const char *remoteUrlPrefixes[] = {
"rtmpt://"
,
"rtmpt://"
,
"rtmps://"
,
"rtmps://"
,
#endif
#endif
#ifdef ENABLE_SMBCLIENT
"smb://"
,
#endif
#ifdef ENABLE_CDIO_PARANOIA
#ifdef ENABLE_CDIO_PARANOIA
"cdda://"
,
"cdda://"
,
#endif
#endif
...
...
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