2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "input/mms_input_plugin.h"
22 #include "input_plugin.h"
25 #include <libmms/mmsx.h>
31 #define G_LOG_DOMAIN "input_mms"
34 struct input_stream base
;
44 return g_quark_from_static_string("mms");
47 static struct input_stream
*
48 input_mms_open(const char *url
, GError
**error_r
)
52 if (!g_str_has_prefix(url
, "mms://") &&
53 !g_str_has_prefix(url
, "mmsh://") &&
54 !g_str_has_prefix(url
, "mmst://") &&
55 !g_str_has_prefix(url
, "mmsu://"))
58 m
= g_new(struct input_mms
, 1);
59 input_stream_init(&m
->base
, &input_plugin_mms
, url
);
61 m
->mms
= mmsx_connect(NULL
, NULL
, url
, 128 * 1024);
63 g_set_error(error_r
, mms_quark(), 0, "mmsx_connect() failed");
67 /* XX is this correct? at least this selects the ffmpeg
68 decoder, which seems to work fine*/
69 m
->base
.mime
= g_strdup("audio/x-ms-wma");
77 input_mms_read(struct input_stream
*is
, void *ptr
, size_t size
,
80 struct input_mms
*m
= (struct input_mms
*)is
;
83 ret
= mmsx_read(NULL
, m
->mms
, ptr
, size
);
86 g_set_error(error_r
, mms_quark(), errno
,
87 "mmsx_read() failed: %s",
101 input_mms_close(struct input_stream
*is
)
103 struct input_mms
*m
= (struct input_mms
*)is
;
106 input_stream_deinit(&m
->base
);
111 input_mms_eof(struct input_stream
*is
)
113 struct input_mms
*m
= (struct input_mms
*)is
;
119 input_mms_buffer(G_GNUC_UNUSED
struct input_stream
*is
,
120 G_GNUC_UNUSED GError
**error_r
)
126 input_mms_seek(G_GNUC_UNUSED
struct input_stream
*is
,
127 G_GNUC_UNUSED goffset offset
, G_GNUC_UNUSED
int whence
,
128 G_GNUC_UNUSED GError
**error_r
)
133 const struct input_plugin input_plugin_mms
= {
135 .open
= input_mms_open
,
136 .close
= input_mms_close
,
137 .buffer
= input_mms_buffer
,
138 .read
= input_mms_read
,
139 .eof
= input_mms_eof
,
140 .seek
= input_mms_seek
,