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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
26 #include "gstshout2.h"
30 #include "gst/gst-i18n-plugin.h"
32 GST_DEBUG_CATEGORY_STATIC (shout2_debug);
33 #define GST_CAT_DEFAULT shout2_debug
38 SIGNAL_CONNECTION_PROBLEM, /* 0.11 FIXME: remove this */
45 ARG_IP, /* the ip of the server */
46 ARG_PORT, /* the encoder port number on the server */
47 ARG_PASSWORD, /* the encoder password on the server */
48 ARG_USERNAME, /* the encoder username on the server */
49 ARG_PUBLIC, /* is this stream public? */
50 ARG_STREAMNAME, /* Name of the stream */
51 ARG_DESCRIPTION, /* Description of the stream */
52 ARG_GENRE, /* Genre of the stream */
54 ARG_PROTOCOL, /* Protocol to connect with */
56 ARG_MOUNT, /* mountpoint of stream (icecast only) */
57 ARG_URL /* Url of stream (I'm guessing) */
60 #define DEFAULT_IP "127.0.0.1"
61 #define DEFAULT_PORT 8000
62 #define DEFAULT_PASSWORD "hackme"
63 #define DEFAULT_USERNAME "source"
64 #define DEFAULT_PUBLIC FALSE
65 #define DEFAULT_STREAMNAME ""
66 #define DEFAULT_DESCRIPTION ""
67 #define DEFAULT_GENRE ""
68 #define DEFAULT_MOUNT ""
69 #define DEFAULT_URL ""
70 #define DEFAULT_PROTOCOL SHOUT2SEND_PROTOCOL_HTTP
72 static GstElementClass *parent_class = NULL;
74 #ifdef SHOUT_FORMAT_WEBM
75 #define WEBM_CAPS "; video/webm"
79 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
82 GST_STATIC_CAPS ("application/ogg; "
83 "audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]" WEBM_CAPS));
85 static void gst_shout2send_class_init (GstShout2sendClass * klass);
86 static void gst_shout2send_init (GstShout2send * shout2send);
87 static void gst_shout2send_finalize (GstShout2send * shout2send);
89 static gboolean gst_shout2send_event (GstBaseSink * sink, GstEvent * event);
90 static gboolean gst_shout2send_unlock (GstBaseSink * basesink);
91 static gboolean gst_shout2send_unlock_stop (GstBaseSink * basesink);
92 static GstFlowReturn gst_shout2send_render (GstBaseSink * sink,
94 static gboolean gst_shout2send_start (GstBaseSink * basesink);
95 static gboolean gst_shout2send_stop (GstBaseSink * basesink);
97 static void gst_shout2send_set_property (GObject * object, guint prop_id,
98 const GValue * value, GParamSpec * pspec);
99 static void gst_shout2send_get_property (GObject * object, guint prop_id,
100 GValue * value, GParamSpec * pspec);
102 static gboolean gst_shout2send_setcaps (GstBaseSink * basesink, GstCaps * caps);
104 static guint gst_shout2send_signals[LAST_SIGNAL] = { 0 };
106 #define GST_TYPE_SHOUT_PROTOCOL (gst_shout2send_protocol_get_type())
108 gst_shout2send_protocol_get_type (void)
110 static GType shout2send_protocol_type = 0;
111 static const GEnumValue shout2send_protocol[] = {
112 {SHOUT2SEND_PROTOCOL_XAUDIOCAST,
113 "Xaudiocast Protocol (icecast 1.3.x)", "xaudiocast"},
114 {SHOUT2SEND_PROTOCOL_ICY, "Icy Protocol (ShoutCast)", "icy"},
115 {SHOUT2SEND_PROTOCOL_HTTP, "Http Protocol (icecast 2.x)", "http"},
119 if (!shout2send_protocol_type) {
120 shout2send_protocol_type =
121 g_enum_register_static ("GstShout2SendProtocol", shout2send_protocol);
125 return shout2send_protocol_type;
129 gst_shout2send_get_type (void)
131 static GType shout2send_type = 0;
133 if (!shout2send_type) {
134 static const GTypeInfo shout2send_info = {
135 sizeof (GstShout2sendClass),
138 (GClassInitFunc) gst_shout2send_class_init,
141 sizeof (GstShout2send),
143 (GInstanceInitFunc) gst_shout2send_init,
146 static const GInterfaceInfo tag_setter_info = {
153 g_type_register_static (GST_TYPE_BASE_SINK, "GstShout2send",
154 &shout2send_info, 0);
156 g_type_add_interface_static (shout2send_type, GST_TYPE_TAG_SETTER,
160 return shout2send_type;
164 gst_shout2send_class_init (GstShout2sendClass * klass)
166 GObjectClass *gobject_class;
167 GstElementClass *gstelement_class;
168 GstBaseSinkClass *gstbasesink_class;
170 gobject_class = (GObjectClass *) klass;
171 gstelement_class = (GstElementClass *) klass;
172 gstbasesink_class = (GstBaseSinkClass *) klass;
174 parent_class = g_type_class_peek_parent (klass);
176 gobject_class->set_property = gst_shout2send_set_property;
177 gobject_class->get_property = gst_shout2send_get_property;
178 gobject_class->finalize = (GObjectFinalizeFunc) gst_shout2send_finalize;
180 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP,
181 g_param_spec_string ("ip", "ip", "ip", DEFAULT_IP,
182 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
183 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
184 g_param_spec_int ("port", "port", "port", 1, G_MAXUSHORT, DEFAULT_PORT,
185 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
187 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PASSWORD,
188 g_param_spec_string ("password", "password", "password", DEFAULT_PASSWORD,
189 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
191 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USERNAME,
192 g_param_spec_string ("username", "username", "username", DEFAULT_USERNAME,
193 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
196 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PUBLIC,
197 g_param_spec_boolean ("public", "public",
198 "If the stream should be listed on the server's stream directory",
199 DEFAULT_PUBLIC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
201 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STREAMNAME,
202 g_param_spec_string ("streamname", "streamname", "name of the stream",
203 DEFAULT_STREAMNAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
205 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DESCRIPTION,
206 g_param_spec_string ("description", "description", "description",
207 DEFAULT_DESCRIPTION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
209 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENRE,
210 g_param_spec_string ("genre", "genre", "genre", DEFAULT_GENRE,
211 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
213 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PROTOCOL,
214 g_param_spec_enum ("protocol", "protocol", "Connection Protocol to use",
215 GST_TYPE_SHOUT_PROTOCOL, DEFAULT_PROTOCOL,
216 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
220 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOUNT,
221 g_param_spec_string ("mount", "mount", "mount", DEFAULT_MOUNT,
222 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
224 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_URL,
225 g_param_spec_string ("url", "url", "url", DEFAULT_URL,
226 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
229 gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM] =
230 g_signal_new ("connection-problem", G_TYPE_FROM_CLASS (klass),
231 G_SIGNAL_RUN_CLEANUP, G_STRUCT_OFFSET (GstShout2sendClass,
232 connection_problem), NULL, NULL, g_cclosure_marshal_VOID__INT,
233 G_TYPE_NONE, 1, G_TYPE_INT);
235 gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_shout2send_start);
236 gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_shout2send_stop);
237 gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_shout2send_unlock);
238 gstbasesink_class->unlock_stop =
239 GST_DEBUG_FUNCPTR (gst_shout2send_unlock_stop);
240 gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_shout2send_render);
241 gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_shout2send_event);
242 gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_shout2send_setcaps);
244 gst_element_class_add_pad_template (gstelement_class,
245 gst_static_pad_template_get (&sink_template));
247 gst_element_class_set_details_simple (gstelement_class,
248 "Icecast network sink",
249 "Sink/Network", "Sends data to an icecast server",
250 "Wim Taymans <wim.taymans@chello.be>, "
251 "Pedro Corte-Real <typo@netcabo.pt>, "
252 "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
254 GST_DEBUG_CATEGORY_INIT (shout2_debug, "shout2", 0, "shout2send element");
258 gst_shout2send_init (GstShout2send * shout2send)
260 gst_base_sink_set_sync (GST_BASE_SINK (shout2send), FALSE);
262 shout2send->timer = gst_poll_new_timer ();
264 shout2send->ip = g_strdup (DEFAULT_IP);
265 shout2send->port = DEFAULT_PORT;
266 shout2send->password = g_strdup (DEFAULT_PASSWORD);
267 shout2send->username = g_strdup (DEFAULT_USERNAME);
268 shout2send->streamname = g_strdup (DEFAULT_STREAMNAME);
269 shout2send->description = g_strdup (DEFAULT_DESCRIPTION);
270 shout2send->genre = g_strdup (DEFAULT_GENRE);
271 shout2send->mount = g_strdup (DEFAULT_MOUNT);
272 shout2send->url = g_strdup (DEFAULT_URL);
273 shout2send->protocol = DEFAULT_PROTOCOL;
274 shout2send->ispublic = DEFAULT_PUBLIC;
276 shout2send->tags = gst_tag_list_new_empty ();
277 shout2send->conn = NULL;
278 shout2send->audio_format = SHOUT_FORMAT_VORBIS;
279 shout2send->connected = FALSE;
280 shout2send->songmetadata = NULL;
281 shout2send->songartist = NULL;
282 shout2send->songtitle = NULL;
286 gst_shout2send_finalize (GstShout2send * shout2send)
288 g_free (shout2send->ip);
289 g_free (shout2send->password);
290 g_free (shout2send->username);
291 g_free (shout2send->streamname);
292 g_free (shout2send->description);
293 g_free (shout2send->genre);
294 g_free (shout2send->mount);
295 g_free (shout2send->url);
297 gst_tag_list_free (shout2send->tags);
299 gst_poll_free (shout2send->timer);
301 G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (shout2send));
305 set_shout_metadata (const GstTagList * list, const gchar * tag,
308 GstShout2send *shout2send = (GstShout2send *) user_data;
309 char **shout_metadata = &(shout2send->songmetadata);
310 char **song_artist = &(shout2send->songartist);
311 char **song_title = &(shout2send->songtitle);
315 GST_DEBUG ("tag: %s being added", tag);
316 if (strcmp (tag, GST_TAG_ARTIST) == 0) {
317 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
318 if (!gst_tag_list_get_string (list, tag, &value)) {
319 GST_DEBUG ("Error reading \"%s\" tag value", tag);
323 if (*song_artist != NULL)
324 g_free (*song_artist);
326 *song_artist = g_strdup (value);
328 } else if (strcmp (tag, GST_TAG_TITLE) == 0) {
329 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
330 if (!gst_tag_list_get_string (list, tag, &value)) {
331 GST_DEBUG ("Error reading \"%s\" tag value", tag);
335 if (*song_title != NULL)
336 g_free (*song_title);
338 *song_title = g_strdup (value);
342 if (*shout_metadata != NULL)
343 g_free (*shout_metadata);
346 if (*song_title && *song_artist) {
347 *shout_metadata = g_strdup_printf ("%s - %s", *song_artist, *song_title);
348 } else if (*song_title && *song_artist == NULL) {
349 *shout_metadata = g_strdup_printf ("Unknown - %s", *song_title);
350 } else if (*song_title == NULL && *song_artist) {
351 *shout_metadata = g_strdup_printf ("%s - Unknown", *song_artist);
353 *shout_metadata = g_strdup_printf ("Unknown - Unknown");
356 GST_LOG ("shout metadata is now: %s", *shout_metadata);
361 gst_shout2send_set_metadata (GstShout2send * shout2send)
363 const GstTagList *user_tags;
366 shout_metadata_t *pmetadata;
368 g_return_if_fail (shout2send != NULL);
369 user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (shout2send));
370 if ((shout2send->tags == NULL) && (user_tags == NULL)) {
373 copy = gst_tag_list_merge (user_tags, shout2send->tags,
374 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
375 /* lets get the artist and song tags */
377 gst_tag_list_foreach ((GstTagList *) copy, set_shout_metadata,
378 (gpointer) & tempmetadata);
380 pmetadata = shout_metadata_new ();
381 shout_metadata_add (pmetadata, "song", tempmetadata);
382 shout_set_metadata (shout2send->conn, pmetadata);
383 shout_metadata_free (pmetadata);
386 gst_tag_list_free (copy);
392 gst_shout2send_event (GstBaseSink * sink, GstEvent * event)
394 GstShout2send *shout2send;
397 shout2send = GST_SHOUT2SEND (sink);
399 GST_LOG_OBJECT (shout2send, "got %s event", GST_EVENT_TYPE_NAME (event));
401 switch (GST_EVENT_TYPE (event)) {
403 /* vorbis audio doesnt need metadata setting on the icecast level, only mp3 */
404 if (shout2send->tags && shout2send->audio_format == SHOUT_FORMAT_MP3) {
407 gst_event_parse_tag (event, &list);
408 GST_DEBUG_OBJECT (shout2send, "tags=%" GST_PTR_FORMAT, list);
409 gst_tag_list_insert (shout2send->tags,
411 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
412 /* lets get the artist and song tags */
413 gst_tag_list_foreach ((GstTagList *) list,
414 set_shout_metadata, shout2send);
415 if (shout2send->songmetadata && shout2send->connected) {
416 shout_metadata_t *pmetadata;
418 GST_DEBUG_OBJECT (shout2send, "metadata now: %s",
419 shout2send->songmetadata);
421 pmetadata = shout_metadata_new ();
422 shout_metadata_add (pmetadata, "song", shout2send->songmetadata);
423 shout_set_metadata (shout2send->conn, pmetadata);
424 shout_metadata_free (pmetadata);
430 GST_LOG_OBJECT (shout2send, "let base class handle event");
431 if (GST_BASE_SINK_CLASS (parent_class)->event) {
432 event = gst_event_ref (event);
433 ret = GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
443 gst_shout2send_start (GstBaseSink * basesink)
445 GstShout2send *sink = GST_SHOUT2SEND (basesink);
446 const gchar *cur_prop;
448 gchar *version_string;
450 GST_DEBUG_OBJECT (sink, "starting");
452 sink->conn = shout_new ();
454 switch (sink->protocol) {
455 case SHOUT2SEND_PROTOCOL_XAUDIOCAST:
456 proto = SHOUT_PROTOCOL_XAUDIOCAST;
458 case SHOUT2SEND_PROTOCOL_ICY:
459 proto = SHOUT_PROTOCOL_ICY;
461 case SHOUT2SEND_PROTOCOL_HTTP:
462 proto = SHOUT_PROTOCOL_HTTP;
466 cur_prop = "protocol";
467 GST_DEBUG_OBJECT (sink, "setting protocol: %d", sink->protocol);
468 if (shout_set_protocol (sink->conn, proto) != SHOUTERR_SUCCESS)
471 /* --- FIXME: shout requires an ip, and fails if it is given a host. */
472 /* may want to put convert_to_ip(shout2send->ip) here */
474 GST_DEBUG_OBJECT (sink, "setting ip: %s", sink->ip);
475 if (shout_set_host (sink->conn, sink->ip) != SHOUTERR_SUCCESS)
479 GST_DEBUG_OBJECT (sink, "setting port: %u", sink->port);
480 if (shout_set_port (sink->conn, sink->port) != SHOUTERR_SUCCESS)
483 cur_prop = "password";
484 GST_DEBUG_OBJECT (sink, "setting password: %s", sink->password);
485 if (shout_set_password (sink->conn, sink->password) != SHOUTERR_SUCCESS)
489 GST_DEBUG_OBJECT (sink, "setting %s: %u", cur_prop, sink->ispublic);
490 if (shout_set_public (sink->conn,
491 (sink->ispublic ? 1 : 0)) != SHOUTERR_SUCCESS)
494 cur_prop = "streamname";
495 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->streamname);
496 if (shout_set_name (sink->conn, sink->streamname) != SHOUTERR_SUCCESS)
499 cur_prop = "description";
500 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->description);
501 if (shout_set_description (sink->conn, sink->description) != SHOUTERR_SUCCESS)
505 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->genre);
506 if (shout_set_genre (sink->conn, sink->genre) != SHOUTERR_SUCCESS)
510 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->mount);
511 if (shout_set_mount (sink->conn, sink->mount) != SHOUTERR_SUCCESS)
514 cur_prop = "username";
515 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, "source");
516 if (shout_set_user (sink->conn, sink->username) != SHOUTERR_SUCCESS)
519 version_string = gst_version_string ();
521 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, version_string);
522 if (shout_set_agent (sink->conn, version_string) != SHOUTERR_SUCCESS) {
523 g_free (version_string);
527 g_free (version_string);
533 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
534 ("Error setting %s: %s", cur_prop, shout_get_error (sink->conn)));
540 gst_shout2send_connect (GstShout2send * sink)
543 (sink->audio_format == SHOUT_FORMAT_VORBIS) ? "vorbis" :
544 ((sink->audio_format == SHOUT_FORMAT_MP3) ? "mp3" : "unknown");
545 #ifdef SHOUT_FORMAT_WEBM
546 if (sink->audio_format == SHOUT_FORMAT_WEBM)
549 GST_DEBUG_OBJECT (sink, "Connection format is: %s", format);
551 if (shout_set_format (sink->conn, sink->audio_format) != SHOUTERR_SUCCESS)
552 goto could_not_set_format;
554 if (shout_open (sink->conn) != SHOUTERR_SUCCESS)
555 goto could_not_connect;
557 GST_DEBUG_OBJECT (sink, "connected to server");
558 sink->connected = TRUE;
560 /* let's set metadata */
561 if (sink->songmetadata) {
562 shout_metadata_t *pmetadata;
564 GST_DEBUG_OBJECT (sink, "shout metadata now: %s", sink->songmetadata);
565 pmetadata = shout_metadata_new ();
566 shout_metadata_add (pmetadata, "song", sink->songmetadata);
567 shout_set_metadata (sink->conn, pmetadata);
568 shout_metadata_free (pmetadata);
574 could_not_set_format:
576 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
577 ("Error setting connection format: %s", shout_get_error (sink->conn)));
583 GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
584 (_("Could not connect to server")),
585 ("shout_open() failed: err=%s", shout_get_error (sink->conn)));
586 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
587 shout_get_errno (sink->conn));
593 gst_shout2send_stop (GstBaseSink * basesink)
595 GstShout2send *sink = GST_SHOUT2SEND (basesink);
599 shout_close (sink->conn);
600 shout_free (sink->conn);
604 if (sink->songmetadata) {
605 g_free (sink->songmetadata);
606 sink->songmetadata = NULL;
609 sink->connected = FALSE;
615 gst_shout2send_unlock (GstBaseSink * basesink)
619 sink = GST_SHOUT2SEND (basesink);
621 GST_DEBUG_OBJECT (basesink, "unlock");
622 gst_poll_set_flushing (sink->timer, TRUE);
628 gst_shout2send_unlock_stop (GstBaseSink * basesink)
632 sink = GST_SHOUT2SEND (basesink);
634 GST_DEBUG_OBJECT (basesink, "unlock_stop");
635 gst_poll_set_flushing (sink->timer, FALSE);
641 gst_shout2send_render (GstBaseSink * basesink, GstBuffer * buf)
649 sink = GST_SHOUT2SEND (basesink);
651 /* presumably we connect here because we need to know the format before
652 * we can set up the connection, which we don't know yet in _start() */
653 if (!sink->connected) {
654 if (!gst_shout2send_connect (sink))
655 return GST_FLOW_ERROR;
658 delay = shout_delay (sink->conn);
661 GST_LOG_OBJECT (sink, "waiting %d msec", delay);
662 if (gst_poll_wait (sink->timer, GST_MSECOND * delay) == -1) {
663 GST_LOG_OBJECT (sink, "unlocked");
665 fret = gst_base_sink_wait_preroll (basesink);
666 if (fret != GST_FLOW_OK)
670 GST_LOG_OBJECT (sink, "we're %d msec late", -delay);
673 gst_buffer_map (buf, &map, GST_MAP_READ);
674 GST_LOG_OBJECT (sink, "sending %u bytes of data", (guint) map.size);
675 ret = shout_send (sink->conn, map.data, map.size);
676 gst_buffer_unmap (buf, &map);
677 if (ret != SHOUTERR_SUCCESS)
685 GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
686 ("shout_send() failed: %s", shout_get_error (sink->conn)));
687 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
688 shout_get_errno (sink->conn));
689 return GST_FLOW_ERROR;
694 gst_shout2send_set_property (GObject * object, guint prop_id,
695 const GValue * value, GParamSpec * pspec)
697 GstShout2send *shout2send;
699 shout2send = GST_SHOUT2SEND (object);
704 g_free (shout2send->ip);
705 shout2send->ip = g_strdup (g_value_get_string (value));
708 shout2send->port = g_value_get_int (value);
711 if (shout2send->password)
712 g_free (shout2send->password);
713 shout2send->password = g_strdup (g_value_get_string (value));
716 if (shout2send->username)
717 g_free (shout2send->username);
718 shout2send->username = g_strdup (g_value_get_string (value));
721 shout2send->ispublic = g_value_get_boolean (value);
723 case ARG_STREAMNAME: /* Name of the stream */
724 if (shout2send->streamname)
725 g_free (shout2send->streamname);
726 shout2send->streamname = g_strdup (g_value_get_string (value));
728 case ARG_DESCRIPTION: /* Description of the stream */
729 if (shout2send->description)
730 g_free (shout2send->description);
731 shout2send->description = g_strdup (g_value_get_string (value));
733 case ARG_GENRE: /* Genre of the stream */
734 if (shout2send->genre)
735 g_free (shout2send->genre);
736 shout2send->genre = g_strdup (g_value_get_string (value));
738 case ARG_PROTOCOL: /* protocol to connect with */
739 shout2send->protocol = g_value_get_enum (value);
741 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
742 if (shout2send->mount)
743 g_free (shout2send->mount);
744 shout2send->mount = g_strdup (g_value_get_string (value));
746 case ARG_URL: /* Url of the stream (I'm guessing) */
748 g_free (shout2send->url);
749 shout2send->url = g_strdup (g_value_get_string (value));
752 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
758 gst_shout2send_get_property (GObject * object, guint prop_id,
759 GValue * value, GParamSpec * pspec)
761 GstShout2send *shout2send;
763 shout2send = GST_SHOUT2SEND (object);
767 g_value_set_string (value, shout2send->ip);
770 g_value_set_int (value, shout2send->port);
773 g_value_set_string (value, shout2send->password);
776 g_value_set_string (value, shout2send->username);
779 g_value_set_boolean (value, shout2send->ispublic);
781 case ARG_STREAMNAME: /* Name of the stream */
782 g_value_set_string (value, shout2send->streamname);
784 case ARG_DESCRIPTION: /* Description of the stream */
785 g_value_set_string (value, shout2send->description);
787 case ARG_GENRE: /* Genre of the stream */
788 g_value_set_string (value, shout2send->genre);
790 case ARG_PROTOCOL: /* protocol to connect with */
791 g_value_set_enum (value, shout2send->protocol);
793 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
794 g_value_set_string (value, shout2send->mount);
796 case ARG_URL: /* Url of stream (I'm guessing) */
797 g_value_set_string (value, shout2send->url);
800 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
806 gst_shout2send_setcaps (GstBaseSink * basesink, GstCaps * caps)
808 const gchar *mimetype;
809 GstShout2send *shout2send;
812 shout2send = GST_SHOUT2SEND (basesink);
814 mimetype = gst_structure_get_name (gst_caps_get_structure (caps, 0));
816 GST_DEBUG_OBJECT (shout2send, "mimetype of caps given is: %s", mimetype);
818 if (!strcmp (mimetype, "audio/mpeg")) {
819 shout2send->audio_format = SHOUT_FORMAT_MP3;
820 } else if (!strcmp (mimetype, "application/ogg")) {
821 shout2send->audio_format = SHOUT_FORMAT_VORBIS;
822 #ifdef SHOUT_FORMAT_WEBM
823 } else if (!strcmp (mimetype, "video/webm")) {
824 shout2send->audio_format = SHOUT_FORMAT_WEBM;
834 plugin_init (GstPlugin * plugin)
837 setlocale (LC_ALL, "");
838 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
839 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
840 #endif /* ENABLE_NLS */
842 return gst_element_register (plugin, "shout2send", GST_RANK_NONE,
843 GST_TYPE_SHOUT2SEND);
846 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
849 "Sends data to an icecast server using libshout2",
851 VERSION, "LGPL", "libshout2", "http://www.icecast.org/download.html")