2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
4 * Copyright (C) <2012> Ralph Giles <giles@mozilla.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 * SECTION:element-shout2send
25 * shout2send pushes a media stream to an Icecast server
28 * <title>Example launch line</title>
30 * gst-launch-1.0 uridecodebin uri=file:///path/to/audiofile ! audioconvert ! vorbisenc ! oggmux ! shout2send mount=/stream.ogg port=8000 username=source password=somepassword ip=server_IP_address_or_hostname
31 * ]| This pipeline demuxes, decodes, re-encodes and re-muxes an audio
32 * media file into oggvorbis and sends the resulting stream to an Icecast
33 * server. Properties mount, port, username and password are all server-config
42 #include "gstshout2.h"
46 #include "gst/gst-i18n-plugin.h"
48 GST_DEBUG_CATEGORY_STATIC (shout2_debug);
49 #define GST_CAT_DEFAULT shout2_debug
54 SIGNAL_CONNECTION_PROBLEM, /* FIXME 2.0: remove this */
61 ARG_IP, /* the IP address or hostname of the server */
62 ARG_PORT, /* the encoder port number on the server */
63 ARG_PASSWORD, /* the encoder password on the server */
64 ARG_USERNAME, /* the encoder username on the server */
65 ARG_PUBLIC, /* is this stream public? */
66 ARG_STREAMNAME, /* Name of the stream */
67 ARG_DESCRIPTION, /* Description of the stream */
68 ARG_GENRE, /* Genre of the stream */
70 ARG_PROTOCOL, /* Protocol to connect with */
72 ARG_MOUNT, /* mountpoint of stream (icecast only) */
73 ARG_URL /* the stream's homepage URL */
76 #define DEFAULT_IP "127.0.0.1"
77 #define DEFAULT_PORT 8000
78 #define DEFAULT_PASSWORD "hackme"
79 #define DEFAULT_USERNAME "source"
80 #define DEFAULT_PUBLIC FALSE
81 #define DEFAULT_STREAMNAME ""
82 #define DEFAULT_DESCRIPTION ""
83 #define DEFAULT_GENRE ""
84 #define DEFAULT_MOUNT ""
85 #define DEFAULT_URL ""
86 #define DEFAULT_PROTOCOL SHOUT2SEND_PROTOCOL_HTTP
88 #ifdef SHOUT_FORMAT_WEBM
89 #define WEBM_CAPS "; video/webm; audio/webm"
93 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
96 GST_STATIC_CAPS ("application/ogg; audio/ogg; video/ogg; "
97 "audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]" WEBM_CAPS));
99 static void gst_shout2send_finalize (GstShout2send * shout2send);
101 static gboolean gst_shout2send_event (GstBaseSink * sink, GstEvent * event);
102 static gboolean gst_shout2send_unlock (GstBaseSink * basesink);
103 static gboolean gst_shout2send_unlock_stop (GstBaseSink * basesink);
104 static GstFlowReturn gst_shout2send_render (GstBaseSink * sink,
106 static gboolean gst_shout2send_start (GstBaseSink * basesink);
107 static gboolean gst_shout2send_stop (GstBaseSink * basesink);
109 static void gst_shout2send_set_property (GObject * object, guint prop_id,
110 const GValue * value, GParamSpec * pspec);
111 static void gst_shout2send_get_property (GObject * object, guint prop_id,
112 GValue * value, GParamSpec * pspec);
114 static gboolean gst_shout2send_setcaps (GstBaseSink * basesink, GstCaps * caps);
116 static guint gst_shout2send_signals[LAST_SIGNAL] = { 0 };
118 #define GST_TYPE_SHOUT_PROTOCOL (gst_shout2send_protocol_get_type())
120 gst_shout2send_protocol_get_type (void)
122 static GType shout2send_protocol_type = 0;
123 static const GEnumValue shout2send_protocol[] = {
124 {SHOUT2SEND_PROTOCOL_XAUDIOCAST,
125 "Xaudiocast Protocol (icecast 1.3.x)", "xaudiocast"},
126 {SHOUT2SEND_PROTOCOL_ICY, "Icy Protocol (ShoutCast)", "icy"},
127 {SHOUT2SEND_PROTOCOL_HTTP, "Http Protocol (icecast 2.x)", "http"},
131 if (!shout2send_protocol_type) {
132 shout2send_protocol_type =
133 g_enum_register_static ("GstShout2SendProtocol", shout2send_protocol);
137 return shout2send_protocol_type;
140 #define gst_shout2send_parent_class parent_class
141 G_DEFINE_TYPE_WITH_CODE (GstShout2send, gst_shout2send, GST_TYPE_BASE_SINK,
142 G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
145 gst_shout2send_class_init (GstShout2sendClass * klass)
147 GObjectClass *gobject_class;
148 GstElementClass *gstelement_class;
149 GstBaseSinkClass *gstbasesink_class;
151 gobject_class = (GObjectClass *) klass;
152 gstelement_class = (GstElementClass *) klass;
153 gstbasesink_class = (GstBaseSinkClass *) klass;
155 parent_class = g_type_class_peek_parent (klass);
157 gobject_class->set_property = gst_shout2send_set_property;
158 gobject_class->get_property = gst_shout2send_get_property;
159 gobject_class->finalize = (GObjectFinalizeFunc) gst_shout2send_finalize;
161 /* FIXME: 2.0 Should probably change this prop name to "server" */
162 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP,
163 g_param_spec_string ("ip", "ip", "IP address or hostname", DEFAULT_IP,
164 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
165 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
166 g_param_spec_int ("port", "port", "port", 1, G_MAXUSHORT, DEFAULT_PORT,
167 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
169 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PASSWORD,
170 g_param_spec_string ("password", "password", "password", DEFAULT_PASSWORD,
171 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
173 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USERNAME,
174 g_param_spec_string ("username", "username", "username", DEFAULT_USERNAME,
175 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
178 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PUBLIC,
179 g_param_spec_boolean ("public", "public",
180 "If the stream should be listed on the server's stream directory",
181 DEFAULT_PUBLIC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
183 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STREAMNAME,
184 g_param_spec_string ("streamname", "streamname", "name of the stream",
185 DEFAULT_STREAMNAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
187 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DESCRIPTION,
188 g_param_spec_string ("description", "description", "description",
189 DEFAULT_DESCRIPTION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
191 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENRE,
192 g_param_spec_string ("genre", "genre", "genre", DEFAULT_GENRE,
193 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
195 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PROTOCOL,
196 g_param_spec_enum ("protocol", "protocol", "Connection Protocol to use",
197 GST_TYPE_SHOUT_PROTOCOL, DEFAULT_PROTOCOL,
198 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
202 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOUNT,
203 g_param_spec_string ("mount", "mount", "mount", DEFAULT_MOUNT,
204 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
206 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_URL,
207 g_param_spec_string ("url", "url", "the stream's homepage URL",
208 DEFAULT_URL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
211 gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM] =
212 g_signal_new ("connection-problem", G_TYPE_FROM_CLASS (klass),
213 G_SIGNAL_RUN_CLEANUP, G_STRUCT_OFFSET (GstShout2sendClass,
214 connection_problem), NULL, NULL, g_cclosure_marshal_VOID__INT,
215 G_TYPE_NONE, 1, G_TYPE_INT);
217 gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_shout2send_start);
218 gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_shout2send_stop);
219 gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_shout2send_unlock);
220 gstbasesink_class->unlock_stop =
221 GST_DEBUG_FUNCPTR (gst_shout2send_unlock_stop);
222 gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_shout2send_render);
223 gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_shout2send_event);
224 gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_shout2send_setcaps);
226 gst_element_class_add_static_pad_template (gstelement_class, &sink_template);
228 gst_element_class_set_static_metadata (gstelement_class,
229 "Icecast network sink",
230 "Sink/Network", "Sends data to an icecast server",
231 "Wim Taymans <wim.taymans@chello.be>, "
232 "Pedro Corte-Real <typo@netcabo.pt>, "
233 "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
235 GST_DEBUG_CATEGORY_INIT (shout2_debug, "shout2", 0, "shout2send element");
239 gst_shout2send_init (GstShout2send * shout2send)
241 gst_base_sink_set_sync (GST_BASE_SINK (shout2send), FALSE);
243 shout2send->timer = gst_poll_new (TRUE);
245 shout2send->ip = g_strdup (DEFAULT_IP);
246 shout2send->port = DEFAULT_PORT;
247 shout2send->password = g_strdup (DEFAULT_PASSWORD);
248 shout2send->username = g_strdup (DEFAULT_USERNAME);
249 shout2send->streamname = g_strdup (DEFAULT_STREAMNAME);
250 shout2send->description = g_strdup (DEFAULT_DESCRIPTION);
251 shout2send->genre = g_strdup (DEFAULT_GENRE);
252 shout2send->mount = g_strdup (DEFAULT_MOUNT);
253 shout2send->url = g_strdup (DEFAULT_URL);
254 shout2send->protocol = DEFAULT_PROTOCOL;
255 shout2send->ispublic = DEFAULT_PUBLIC;
257 shout2send->format = -1;
258 shout2send->tags = gst_tag_list_new_empty ();
259 shout2send->conn = NULL;
260 shout2send->connected = FALSE;
261 shout2send->songmetadata = NULL;
262 shout2send->songartist = NULL;
263 shout2send->songtitle = NULL;
267 gst_shout2send_finalize (GstShout2send * shout2send)
269 g_free (shout2send->ip);
270 g_free (shout2send->password);
271 g_free (shout2send->username);
272 g_free (shout2send->streamname);
273 g_free (shout2send->description);
274 g_free (shout2send->genre);
275 g_free (shout2send->mount);
276 g_free (shout2send->url);
278 gst_tag_list_unref (shout2send->tags);
280 gst_poll_free (shout2send->timer);
282 G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (shout2send));
286 set_shout_metadata (const GstTagList * list, const gchar * tag,
289 GstShout2send *shout2send = (GstShout2send *) user_data;
290 char **shout_metadata = &(shout2send->songmetadata);
291 char **song_artist = &(shout2send->songartist);
292 char **song_title = &(shout2send->songtitle);
296 GST_DEBUG ("tag: %s being added", tag);
297 if (strcmp (tag, GST_TAG_ARTIST) == 0) {
298 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
299 if (!gst_tag_list_get_string (list, tag, &value)) {
300 GST_DEBUG ("Error reading \"%s\" tag value", tag);
304 if (*song_artist != NULL)
305 g_free (*song_artist);
307 *song_artist = g_strdup (value);
309 } else if (strcmp (tag, GST_TAG_TITLE) == 0) {
310 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
311 if (!gst_tag_list_get_string (list, tag, &value)) {
312 GST_DEBUG ("Error reading \"%s\" tag value", tag);
316 if (*song_title != NULL)
317 g_free (*song_title);
319 *song_title = g_strdup (value);
323 if (*shout_metadata != NULL)
324 g_free (*shout_metadata);
327 if (*song_title && *song_artist) {
328 *shout_metadata = g_strdup_printf ("%s - %s", *song_artist, *song_title);
329 } else if (*song_title && *song_artist == NULL) {
330 *shout_metadata = g_strdup_printf ("Unknown - %s", *song_title);
331 } else if (*song_title == NULL && *song_artist) {
332 *shout_metadata = g_strdup_printf ("%s - Unknown", *song_artist);
334 *shout_metadata = g_strdup_printf ("Unknown - Unknown");
337 GST_LOG ("shout metadata is now: %s", *shout_metadata);
342 gst_shout2send_set_metadata (GstShout2send * shout2send)
344 const GstTagList *user_tags;
347 shout_metadata_t *pmetadata;
349 g_return_if_fail (shout2send != NULL);
350 user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (shout2send));
351 if ((shout2send->tags == NULL) && (user_tags == NULL)) {
354 copy = gst_tag_list_merge (user_tags, shout2send->tags,
355 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
356 /* lets get the artist and song tags */
358 gst_tag_list_foreach ((GstTagList *) copy, set_shout_metadata,
359 (gpointer) & tempmetadata);
361 pmetadata = shout_metadata_new ();
362 shout_metadata_add (pmetadata, "song", tempmetadata);
363 shout_set_metadata (shout2send->conn, pmetadata);
364 shout_metadata_free (pmetadata);
367 gst_tag_list_unref (copy);
373 gst_shout2send_event (GstBaseSink * sink, GstEvent * event)
375 GstShout2send *shout2send;
378 shout2send = GST_SHOUT2SEND (sink);
380 GST_LOG_OBJECT (shout2send, "got %s event", GST_EVENT_TYPE_NAME (event));
382 switch (GST_EVENT_TYPE (event)) {
384 /* vorbis audio doesn't need metadata setting on the icecast level, only mp3 */
385 if (shout2send->tags && shout2send->format == SHOUT_FORMAT_MP3) {
388 gst_event_parse_tag (event, &list);
389 GST_DEBUG_OBJECT (shout2send, "tags=%" GST_PTR_FORMAT, list);
390 gst_tag_list_insert (shout2send->tags,
392 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
393 /* lets get the artist and song tags */
394 gst_tag_list_foreach ((GstTagList *) list,
395 set_shout_metadata, shout2send);
396 if (shout2send->songmetadata && shout2send->connected) {
397 shout_metadata_t *pmetadata;
399 GST_DEBUG_OBJECT (shout2send, "metadata now: %s",
400 shout2send->songmetadata);
402 pmetadata = shout_metadata_new ();
403 shout_metadata_add (pmetadata, "song", shout2send->songmetadata);
404 shout_set_metadata (shout2send->conn, pmetadata);
405 shout_metadata_free (pmetadata);
411 GST_LOG_OBJECT (shout2send, "let base class handle event");
412 if (GST_BASE_SINK_CLASS (parent_class)->event) {
413 event = gst_event_ref (event);
414 ret = GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
424 gst_shout2send_start (GstBaseSink * basesink)
426 GstShout2send *sink = GST_SHOUT2SEND (basesink);
427 const gchar *cur_prop;
429 gchar *version_string;
431 GST_DEBUG_OBJECT (sink, "starting");
433 sink->conn = shout_new ();
435 switch (sink->protocol) {
436 case SHOUT2SEND_PROTOCOL_XAUDIOCAST:
437 proto = SHOUT_PROTOCOL_XAUDIOCAST;
439 case SHOUT2SEND_PROTOCOL_ICY:
440 proto = SHOUT_PROTOCOL_ICY;
442 case SHOUT2SEND_PROTOCOL_HTTP:
443 proto = SHOUT_PROTOCOL_HTTP;
447 cur_prop = "protocol";
448 GST_DEBUG_OBJECT (sink, "setting protocol: %d", sink->protocol);
449 if (shout_set_protocol (sink->conn, proto) != SHOUTERR_SUCCESS)
453 GST_DEBUG_OBJECT (sink, "setting IP/hostname: %s", sink->ip);
454 if (shout_set_host (sink->conn, sink->ip) != SHOUTERR_SUCCESS)
458 GST_DEBUG_OBJECT (sink, "setting port: %u", sink->port);
459 if (shout_set_port (sink->conn, sink->port) != SHOUTERR_SUCCESS)
462 cur_prop = "password";
463 GST_DEBUG_OBJECT (sink, "setting password: %s", sink->password);
464 if (shout_set_password (sink->conn, sink->password) != SHOUTERR_SUCCESS)
468 GST_DEBUG_OBJECT (sink, "setting %s: %u", cur_prop, sink->ispublic);
469 if (shout_set_public (sink->conn,
470 (sink->ispublic ? 1 : 0)) != SHOUTERR_SUCCESS)
473 cur_prop = "streamname";
474 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->streamname);
475 if (shout_set_name (sink->conn, sink->streamname) != SHOUTERR_SUCCESS)
478 cur_prop = "description";
479 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->description);
480 if (shout_set_description (sink->conn, sink->description) != SHOUTERR_SUCCESS)
484 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->genre);
485 if (shout_set_genre (sink->conn, sink->genre) != SHOUTERR_SUCCESS)
489 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->mount);
490 if (shout_set_mount (sink->conn, sink->mount) != SHOUTERR_SUCCESS)
493 cur_prop = "username";
494 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, "source");
495 if (shout_set_user (sink->conn, sink->username) != SHOUTERR_SUCCESS)
498 version_string = gst_version_string ();
500 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, version_string);
501 if (shout_set_agent (sink->conn, version_string) != SHOUTERR_SUCCESS) {
502 g_free (version_string);
506 g_free (version_string);
512 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
513 ("Error setting %s: %s", cur_prop, shout_get_error (sink->conn)));
519 gst_shout2send_connect (GstShout2send * sink)
521 GST_DEBUG_OBJECT (sink, "Connection format is: %d", sink->format);
523 if (sink->format == -1)
526 if (shout_set_format (sink->conn, sink->format) != SHOUTERR_SUCCESS)
527 goto could_not_set_format;
529 if (shout_open (sink->conn) != SHOUTERR_SUCCESS)
530 goto could_not_connect;
532 GST_DEBUG_OBJECT (sink, "connected to server");
533 sink->connected = TRUE;
535 /* let's set metadata */
536 if (sink->songmetadata) {
537 shout_metadata_t *pmetadata;
539 GST_DEBUG_OBJECT (sink, "shout metadata now: %s", sink->songmetadata);
540 pmetadata = shout_metadata_new ();
541 shout_metadata_add (pmetadata, "song", sink->songmetadata);
542 shout_set_metadata (sink->conn, pmetadata);
543 shout_metadata_free (pmetadata);
551 GST_ELEMENT_ERROR (sink, CORE, NEGOTIATION, (NULL),
552 ("No input caps received."));
553 return GST_FLOW_NOT_NEGOTIATED;
556 could_not_set_format:
558 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
559 ("Error setting connection format: %s", shout_get_error (sink->conn)));
560 return GST_FLOW_ERROR;
565 GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
566 (_("Could not connect to server")),
567 ("shout_open() failed: err=%s", shout_get_error (sink->conn)));
568 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
569 shout_get_errno (sink->conn));
570 return GST_FLOW_ERROR;
575 gst_shout2send_stop (GstBaseSink * basesink)
577 GstShout2send *sink = GST_SHOUT2SEND (basesink);
581 shout_close (sink->conn);
582 shout_free (sink->conn);
586 if (sink->songmetadata) {
587 g_free (sink->songmetadata);
588 sink->songmetadata = NULL;
591 sink->connected = FALSE;
598 gst_shout2send_unlock (GstBaseSink * basesink)
602 sink = GST_SHOUT2SEND (basesink);
604 GST_DEBUG_OBJECT (basesink, "unlock");
605 gst_poll_set_flushing (sink->timer, TRUE);
611 gst_shout2send_unlock_stop (GstBaseSink * basesink)
615 sink = GST_SHOUT2SEND (basesink);
617 GST_DEBUG_OBJECT (basesink, "unlock_stop");
618 gst_poll_set_flushing (sink->timer, FALSE);
624 gst_shout2send_render (GstBaseSink * basesink, GstBuffer * buf)
629 GstFlowReturn fret = GST_FLOW_OK;
632 sink = GST_SHOUT2SEND (basesink);
634 /* we connect here because we need to know the format before we can set up
635 * the connection, which we don't know yet in _start(), and also because we
636 * don't want to block the application thread */
637 if (!sink->connected) {
638 fret = gst_shout2send_connect (sink);
639 if (fret != GST_FLOW_OK)
643 delay = shout_delay (sink->conn);
646 GST_LOG_OBJECT (sink, "waiting %d msec", delay);
647 if (gst_poll_wait (sink->timer, GST_MSECOND * delay) == -1) {
648 GST_LOG_OBJECT (sink, "unlocked");
650 fret = gst_base_sink_wait_preroll (basesink);
651 if (fret != GST_FLOW_OK)
655 GST_LOG_OBJECT (sink, "we're %d msec late", -delay);
658 gst_buffer_map (buf, &map, GST_MAP_READ);
659 GST_LOG_OBJECT (sink, "sending %u bytes of data", (guint) map.size);
660 ret = shout_send (sink->conn, map.data, map.size);
661 gst_buffer_unmap (buf, &map);
662 if (ret != SHOUTERR_SUCCESS)
672 GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
673 ("shout_send() failed: %s", shout_get_error (sink->conn)));
674 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
675 shout_get_errno (sink->conn));
676 return GST_FLOW_ERROR;
681 gst_shout2send_set_property (GObject * object, guint prop_id,
682 const GValue * value, GParamSpec * pspec)
684 GstShout2send *shout2send;
686 shout2send = GST_SHOUT2SEND (object);
690 g_free (shout2send->ip);
691 shout2send->ip = g_strdup (g_value_get_string (value));
694 shout2send->port = g_value_get_int (value);
697 g_free (shout2send->password);
698 shout2send->password = g_strdup (g_value_get_string (value));
701 g_free (shout2send->username);
702 shout2send->username = g_strdup (g_value_get_string (value));
705 shout2send->ispublic = g_value_get_boolean (value);
707 case ARG_STREAMNAME: /* Name of the stream */
708 g_free (shout2send->streamname);
709 shout2send->streamname = g_strdup (g_value_get_string (value));
711 case ARG_DESCRIPTION: /* Description of the stream */
712 g_free (shout2send->description);
713 shout2send->description = g_strdup (g_value_get_string (value));
715 case ARG_GENRE: /* Genre of the stream */
716 g_free (shout2send->genre);
717 shout2send->genre = g_strdup (g_value_get_string (value));
719 case ARG_PROTOCOL: /* protocol to connect with */
720 shout2send->protocol = g_value_get_enum (value);
722 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
723 g_free (shout2send->mount);
724 shout2send->mount = g_strdup (g_value_get_string (value));
726 case ARG_URL: /* the stream's homepage URL */
727 g_free (shout2send->url);
728 shout2send->url = g_strdup (g_value_get_string (value));
731 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
737 gst_shout2send_get_property (GObject * object, guint prop_id,
738 GValue * value, GParamSpec * pspec)
740 GstShout2send *shout2send;
742 shout2send = GST_SHOUT2SEND (object);
746 g_value_set_string (value, shout2send->ip);
749 g_value_set_int (value, shout2send->port);
752 g_value_set_string (value, shout2send->password);
755 g_value_set_string (value, shout2send->username);
758 g_value_set_boolean (value, shout2send->ispublic);
760 case ARG_STREAMNAME: /* Name of the stream */
761 g_value_set_string (value, shout2send->streamname);
763 case ARG_DESCRIPTION: /* Description of the stream */
764 g_value_set_string (value, shout2send->description);
766 case ARG_GENRE: /* Genre of the stream */
767 g_value_set_string (value, shout2send->genre);
769 case ARG_PROTOCOL: /* protocol to connect with */
770 g_value_set_enum (value, shout2send->protocol);
772 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
773 g_value_set_string (value, shout2send->mount);
775 case ARG_URL: /* the stream's homepage URL */
776 g_value_set_string (value, shout2send->url);
779 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
785 gst_shout2send_setcaps (GstBaseSink * basesink, GstCaps * caps)
787 const gchar *mimetype;
788 GstShout2send *shout2send;
791 shout2send = GST_SHOUT2SEND (basesink);
793 mimetype = gst_structure_get_name (gst_caps_get_structure (caps, 0));
795 GST_DEBUG_OBJECT (shout2send, "mimetype of caps given is: %s", mimetype);
797 if (!strcmp (mimetype, "audio/mpeg")) {
798 shout2send->format = SHOUT_FORMAT_MP3;
799 } else if (g_str_has_suffix (mimetype, "/ogg")) {
800 shout2send->format = SHOUT_FORMAT_OGG;
801 #ifdef SHOUT_FORMAT_WEBM
802 } else if (g_str_has_suffix (mimetype, "/webm")) {
803 shout2send->format = SHOUT_FORMAT_WEBM;
813 plugin_init (GstPlugin * plugin)
816 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
817 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
818 #endif /* ENABLE_NLS */
820 return gst_element_register (plugin, "shout2send", GST_RANK_NONE,
821 GST_TYPE_SHOUT2SEND);
824 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
827 "Sends data to an icecast server using libshout2",
828 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)