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 #ifdef SHOUT_FORMAT_WEBM
73 #define WEBM_CAPS "; video/webm"
77 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
80 GST_STATIC_CAPS ("application/ogg; audio/ogg; video/ogg; "
81 "audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]" WEBM_CAPS));
83 static void gst_shout2send_finalize (GstShout2send * shout2send);
85 static gboolean gst_shout2send_event (GstBaseSink * sink, GstEvent * event);
86 static gboolean gst_shout2send_unlock (GstBaseSink * basesink);
87 static gboolean gst_shout2send_unlock_stop (GstBaseSink * basesink);
88 static GstFlowReturn gst_shout2send_render (GstBaseSink * sink,
90 static gboolean gst_shout2send_start (GstBaseSink * basesink);
91 static gboolean gst_shout2send_stop (GstBaseSink * basesink);
93 static void gst_shout2send_set_property (GObject * object, guint prop_id,
94 const GValue * value, GParamSpec * pspec);
95 static void gst_shout2send_get_property (GObject * object, guint prop_id,
96 GValue * value, GParamSpec * pspec);
98 static gboolean gst_shout2send_setcaps (GstBaseSink * basesink, GstCaps * caps);
100 static guint gst_shout2send_signals[LAST_SIGNAL] = { 0 };
102 #define GST_TYPE_SHOUT_PROTOCOL (gst_shout2send_protocol_get_type())
104 gst_shout2send_protocol_get_type (void)
106 static GType shout2send_protocol_type = 0;
107 static const GEnumValue shout2send_protocol[] = {
108 {SHOUT2SEND_PROTOCOL_XAUDIOCAST,
109 "Xaudiocast Protocol (icecast 1.3.x)", "xaudiocast"},
110 {SHOUT2SEND_PROTOCOL_ICY, "Icy Protocol (ShoutCast)", "icy"},
111 {SHOUT2SEND_PROTOCOL_HTTP, "Http Protocol (icecast 2.x)", "http"},
115 if (!shout2send_protocol_type) {
116 shout2send_protocol_type =
117 g_enum_register_static ("GstShout2SendProtocol", shout2send_protocol);
121 return shout2send_protocol_type;
124 #define gst_shout2send_parent_class parent_class
125 G_DEFINE_TYPE_WITH_CODE (GstShout2send, gst_shout2send, GST_TYPE_BASE_SINK,
126 G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
129 gst_shout2send_class_init (GstShout2sendClass * klass)
131 GObjectClass *gobject_class;
132 GstElementClass *gstelement_class;
133 GstBaseSinkClass *gstbasesink_class;
135 gobject_class = (GObjectClass *) klass;
136 gstelement_class = (GstElementClass *) klass;
137 gstbasesink_class = (GstBaseSinkClass *) klass;
139 parent_class = g_type_class_peek_parent (klass);
141 gobject_class->set_property = gst_shout2send_set_property;
142 gobject_class->get_property = gst_shout2send_get_property;
143 gobject_class->finalize = (GObjectFinalizeFunc) gst_shout2send_finalize;
145 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP,
146 g_param_spec_string ("ip", "ip", "ip", DEFAULT_IP,
147 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
148 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
149 g_param_spec_int ("port", "port", "port", 1, G_MAXUSHORT, DEFAULT_PORT,
150 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
152 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PASSWORD,
153 g_param_spec_string ("password", "password", "password", DEFAULT_PASSWORD,
154 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
156 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USERNAME,
157 g_param_spec_string ("username", "username", "username", DEFAULT_USERNAME,
158 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
161 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PUBLIC,
162 g_param_spec_boolean ("public", "public",
163 "If the stream should be listed on the server's stream directory",
164 DEFAULT_PUBLIC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
166 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STREAMNAME,
167 g_param_spec_string ("streamname", "streamname", "name of the stream",
168 DEFAULT_STREAMNAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
170 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DESCRIPTION,
171 g_param_spec_string ("description", "description", "description",
172 DEFAULT_DESCRIPTION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
174 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENRE,
175 g_param_spec_string ("genre", "genre", "genre", DEFAULT_GENRE,
176 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
178 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PROTOCOL,
179 g_param_spec_enum ("protocol", "protocol", "Connection Protocol to use",
180 GST_TYPE_SHOUT_PROTOCOL, DEFAULT_PROTOCOL,
181 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
185 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOUNT,
186 g_param_spec_string ("mount", "mount", "mount", DEFAULT_MOUNT,
187 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
189 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_URL,
190 g_param_spec_string ("url", "url", "url", DEFAULT_URL,
191 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
194 gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM] =
195 g_signal_new ("connection-problem", G_TYPE_FROM_CLASS (klass),
196 G_SIGNAL_RUN_CLEANUP, G_STRUCT_OFFSET (GstShout2sendClass,
197 connection_problem), NULL, NULL, g_cclosure_marshal_VOID__INT,
198 G_TYPE_NONE, 1, G_TYPE_INT);
200 gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_shout2send_start);
201 gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_shout2send_stop);
202 gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_shout2send_unlock);
203 gstbasesink_class->unlock_stop =
204 GST_DEBUG_FUNCPTR (gst_shout2send_unlock_stop);
205 gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_shout2send_render);
206 gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_shout2send_event);
207 gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_shout2send_setcaps);
209 gst_element_class_add_pad_template (gstelement_class,
210 gst_static_pad_template_get (&sink_template));
212 gst_element_class_set_static_metadata (gstelement_class,
213 "Icecast network sink",
214 "Sink/Network", "Sends data to an icecast server",
215 "Wim Taymans <wim.taymans@chello.be>, "
216 "Pedro Corte-Real <typo@netcabo.pt>, "
217 "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
219 GST_DEBUG_CATEGORY_INIT (shout2_debug, "shout2", 0, "shout2send element");
223 gst_shout2send_init (GstShout2send * shout2send)
225 gst_base_sink_set_sync (GST_BASE_SINK (shout2send), FALSE);
227 shout2send->timer = gst_poll_new_timer ();
229 shout2send->ip = g_strdup (DEFAULT_IP);
230 shout2send->port = DEFAULT_PORT;
231 shout2send->password = g_strdup (DEFAULT_PASSWORD);
232 shout2send->username = g_strdup (DEFAULT_USERNAME);
233 shout2send->streamname = g_strdup (DEFAULT_STREAMNAME);
234 shout2send->description = g_strdup (DEFAULT_DESCRIPTION);
235 shout2send->genre = g_strdup (DEFAULT_GENRE);
236 shout2send->mount = g_strdup (DEFAULT_MOUNT);
237 shout2send->url = g_strdup (DEFAULT_URL);
238 shout2send->protocol = DEFAULT_PROTOCOL;
239 shout2send->ispublic = DEFAULT_PUBLIC;
241 shout2send->tags = gst_tag_list_new_empty ();
242 shout2send->conn = NULL;
243 shout2send->audio_format = SHOUT_FORMAT_VORBIS;
244 shout2send->connected = FALSE;
245 shout2send->songmetadata = NULL;
246 shout2send->songartist = NULL;
247 shout2send->songtitle = NULL;
251 gst_shout2send_finalize (GstShout2send * shout2send)
253 g_free (shout2send->ip);
254 g_free (shout2send->password);
255 g_free (shout2send->username);
256 g_free (shout2send->streamname);
257 g_free (shout2send->description);
258 g_free (shout2send->genre);
259 g_free (shout2send->mount);
260 g_free (shout2send->url);
262 gst_tag_list_free (shout2send->tags);
264 gst_poll_free (shout2send->timer);
266 G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (shout2send));
270 set_shout_metadata (const GstTagList * list, const gchar * tag,
273 GstShout2send *shout2send = (GstShout2send *) user_data;
274 char **shout_metadata = &(shout2send->songmetadata);
275 char **song_artist = &(shout2send->songartist);
276 char **song_title = &(shout2send->songtitle);
280 GST_DEBUG ("tag: %s being added", tag);
281 if (strcmp (tag, GST_TAG_ARTIST) == 0) {
282 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
283 if (!gst_tag_list_get_string (list, tag, &value)) {
284 GST_DEBUG ("Error reading \"%s\" tag value", tag);
288 if (*song_artist != NULL)
289 g_free (*song_artist);
291 *song_artist = g_strdup (value);
293 } else if (strcmp (tag, GST_TAG_TITLE) == 0) {
294 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
295 if (!gst_tag_list_get_string (list, tag, &value)) {
296 GST_DEBUG ("Error reading \"%s\" tag value", tag);
300 if (*song_title != NULL)
301 g_free (*song_title);
303 *song_title = g_strdup (value);
307 if (*shout_metadata != NULL)
308 g_free (*shout_metadata);
311 if (*song_title && *song_artist) {
312 *shout_metadata = g_strdup_printf ("%s - %s", *song_artist, *song_title);
313 } else if (*song_title && *song_artist == NULL) {
314 *shout_metadata = g_strdup_printf ("Unknown - %s", *song_title);
315 } else if (*song_title == NULL && *song_artist) {
316 *shout_metadata = g_strdup_printf ("%s - Unknown", *song_artist);
318 *shout_metadata = g_strdup_printf ("Unknown - Unknown");
321 GST_LOG ("shout metadata is now: %s", *shout_metadata);
326 gst_shout2send_set_metadata (GstShout2send * shout2send)
328 const GstTagList *user_tags;
331 shout_metadata_t *pmetadata;
333 g_return_if_fail (shout2send != NULL);
334 user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (shout2send));
335 if ((shout2send->tags == NULL) && (user_tags == NULL)) {
338 copy = gst_tag_list_merge (user_tags, shout2send->tags,
339 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
340 /* lets get the artist and song tags */
342 gst_tag_list_foreach ((GstTagList *) copy, set_shout_metadata,
343 (gpointer) & tempmetadata);
345 pmetadata = shout_metadata_new ();
346 shout_metadata_add (pmetadata, "song", tempmetadata);
347 shout_set_metadata (shout2send->conn, pmetadata);
348 shout_metadata_free (pmetadata);
351 gst_tag_list_free (copy);
357 gst_shout2send_event (GstBaseSink * sink, GstEvent * event)
359 GstShout2send *shout2send;
362 shout2send = GST_SHOUT2SEND (sink);
364 GST_LOG_OBJECT (shout2send, "got %s event", GST_EVENT_TYPE_NAME (event));
366 switch (GST_EVENT_TYPE (event)) {
368 /* vorbis audio doesnt need metadata setting on the icecast level, only mp3 */
369 if (shout2send->tags && shout2send->audio_format == SHOUT_FORMAT_MP3) {
372 gst_event_parse_tag (event, &list);
373 GST_DEBUG_OBJECT (shout2send, "tags=%" GST_PTR_FORMAT, list);
374 gst_tag_list_insert (shout2send->tags,
376 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
377 /* lets get the artist and song tags */
378 gst_tag_list_foreach ((GstTagList *) list,
379 set_shout_metadata, shout2send);
380 if (shout2send->songmetadata && shout2send->connected) {
381 shout_metadata_t *pmetadata;
383 GST_DEBUG_OBJECT (shout2send, "metadata now: %s",
384 shout2send->songmetadata);
386 pmetadata = shout_metadata_new ();
387 shout_metadata_add (pmetadata, "song", shout2send->songmetadata);
388 shout_set_metadata (shout2send->conn, pmetadata);
389 shout_metadata_free (pmetadata);
395 GST_LOG_OBJECT (shout2send, "let base class handle event");
396 if (GST_BASE_SINK_CLASS (parent_class)->event) {
397 event = gst_event_ref (event);
398 ret = GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
408 gst_shout2send_start (GstBaseSink * basesink)
410 GstShout2send *sink = GST_SHOUT2SEND (basesink);
411 const gchar *cur_prop;
413 gchar *version_string;
415 GST_DEBUG_OBJECT (sink, "starting");
417 sink->conn = shout_new ();
419 switch (sink->protocol) {
420 case SHOUT2SEND_PROTOCOL_XAUDIOCAST:
421 proto = SHOUT_PROTOCOL_XAUDIOCAST;
423 case SHOUT2SEND_PROTOCOL_ICY:
424 proto = SHOUT_PROTOCOL_ICY;
426 case SHOUT2SEND_PROTOCOL_HTTP:
427 proto = SHOUT_PROTOCOL_HTTP;
431 cur_prop = "protocol";
432 GST_DEBUG_OBJECT (sink, "setting protocol: %d", sink->protocol);
433 if (shout_set_protocol (sink->conn, proto) != SHOUTERR_SUCCESS)
436 /* --- FIXME: shout requires an ip, and fails if it is given a host. */
437 /* may want to put convert_to_ip(shout2send->ip) here */
439 GST_DEBUG_OBJECT (sink, "setting ip: %s", sink->ip);
440 if (shout_set_host (sink->conn, sink->ip) != SHOUTERR_SUCCESS)
444 GST_DEBUG_OBJECT (sink, "setting port: %u", sink->port);
445 if (shout_set_port (sink->conn, sink->port) != SHOUTERR_SUCCESS)
448 cur_prop = "password";
449 GST_DEBUG_OBJECT (sink, "setting password: %s", sink->password);
450 if (shout_set_password (sink->conn, sink->password) != SHOUTERR_SUCCESS)
454 GST_DEBUG_OBJECT (sink, "setting %s: %u", cur_prop, sink->ispublic);
455 if (shout_set_public (sink->conn,
456 (sink->ispublic ? 1 : 0)) != SHOUTERR_SUCCESS)
459 cur_prop = "streamname";
460 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->streamname);
461 if (shout_set_name (sink->conn, sink->streamname) != SHOUTERR_SUCCESS)
464 cur_prop = "description";
465 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->description);
466 if (shout_set_description (sink->conn, sink->description) != SHOUTERR_SUCCESS)
470 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->genre);
471 if (shout_set_genre (sink->conn, sink->genre) != SHOUTERR_SUCCESS)
475 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->mount);
476 if (shout_set_mount (sink->conn, sink->mount) != SHOUTERR_SUCCESS)
479 cur_prop = "username";
480 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, "source");
481 if (shout_set_user (sink->conn, sink->username) != SHOUTERR_SUCCESS)
484 version_string = gst_version_string ();
486 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, version_string);
487 if (shout_set_agent (sink->conn, version_string) != SHOUTERR_SUCCESS) {
488 g_free (version_string);
492 g_free (version_string);
498 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
499 ("Error setting %s: %s", cur_prop, shout_get_error (sink->conn)));
505 gst_shout2send_connect (GstShout2send * sink)
508 (sink->audio_format == SHOUT_FORMAT_VORBIS) ? "vorbis" :
509 ((sink->audio_format == SHOUT_FORMAT_MP3) ? "mp3" : "unknown");
510 #ifdef SHOUT_FORMAT_WEBM
511 if (sink->audio_format == SHOUT_FORMAT_WEBM)
514 GST_DEBUG_OBJECT (sink, "Connection format is: %s", format);
516 if (shout_set_format (sink->conn, sink->audio_format) != SHOUTERR_SUCCESS)
517 goto could_not_set_format;
519 if (shout_open (sink->conn) != SHOUTERR_SUCCESS)
520 goto could_not_connect;
522 GST_DEBUG_OBJECT (sink, "connected to server");
523 sink->connected = TRUE;
525 /* let's set metadata */
526 if (sink->songmetadata) {
527 shout_metadata_t *pmetadata;
529 GST_DEBUG_OBJECT (sink, "shout metadata now: %s", sink->songmetadata);
530 pmetadata = shout_metadata_new ();
531 shout_metadata_add (pmetadata, "song", sink->songmetadata);
532 shout_set_metadata (sink->conn, pmetadata);
533 shout_metadata_free (pmetadata);
539 could_not_set_format:
541 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
542 ("Error setting connection format: %s", shout_get_error (sink->conn)));
548 GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
549 (_("Could not connect to server")),
550 ("shout_open() failed: err=%s", shout_get_error (sink->conn)));
551 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
552 shout_get_errno (sink->conn));
558 gst_shout2send_stop (GstBaseSink * basesink)
560 GstShout2send *sink = GST_SHOUT2SEND (basesink);
564 shout_close (sink->conn);
565 shout_free (sink->conn);
569 if (sink->songmetadata) {
570 g_free (sink->songmetadata);
571 sink->songmetadata = NULL;
574 sink->connected = FALSE;
580 gst_shout2send_unlock (GstBaseSink * basesink)
584 sink = GST_SHOUT2SEND (basesink);
586 GST_DEBUG_OBJECT (basesink, "unlock");
587 gst_poll_set_flushing (sink->timer, TRUE);
593 gst_shout2send_unlock_stop (GstBaseSink * basesink)
597 sink = GST_SHOUT2SEND (basesink);
599 GST_DEBUG_OBJECT (basesink, "unlock_stop");
600 gst_poll_set_flushing (sink->timer, FALSE);
606 gst_shout2send_render (GstBaseSink * basesink, GstBuffer * buf)
614 sink = GST_SHOUT2SEND (basesink);
616 /* presumably we connect here because we need to know the format before
617 * we can set up the connection, which we don't know yet in _start() */
618 if (!sink->connected) {
619 if (!gst_shout2send_connect (sink))
620 return GST_FLOW_ERROR;
623 delay = shout_delay (sink->conn);
626 GST_LOG_OBJECT (sink, "waiting %d msec", delay);
627 if (gst_poll_wait (sink->timer, GST_MSECOND * delay) == -1) {
628 GST_LOG_OBJECT (sink, "unlocked");
630 fret = gst_base_sink_wait_preroll (basesink);
631 if (fret != GST_FLOW_OK)
635 GST_LOG_OBJECT (sink, "we're %d msec late", -delay);
638 gst_buffer_map (buf, &map, GST_MAP_READ);
639 GST_LOG_OBJECT (sink, "sending %u bytes of data", (guint) map.size);
640 ret = shout_send (sink->conn, map.data, map.size);
641 gst_buffer_unmap (buf, &map);
642 if (ret != SHOUTERR_SUCCESS)
650 GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
651 ("shout_send() failed: %s", shout_get_error (sink->conn)));
652 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
653 shout_get_errno (sink->conn));
654 return GST_FLOW_ERROR;
659 gst_shout2send_set_property (GObject * object, guint prop_id,
660 const GValue * value, GParamSpec * pspec)
662 GstShout2send *shout2send;
664 shout2send = GST_SHOUT2SEND (object);
669 g_free (shout2send->ip);
670 shout2send->ip = g_strdup (g_value_get_string (value));
673 shout2send->port = g_value_get_int (value);
676 if (shout2send->password)
677 g_free (shout2send->password);
678 shout2send->password = g_strdup (g_value_get_string (value));
681 if (shout2send->username)
682 g_free (shout2send->username);
683 shout2send->username = g_strdup (g_value_get_string (value));
686 shout2send->ispublic = g_value_get_boolean (value);
688 case ARG_STREAMNAME: /* Name of the stream */
689 if (shout2send->streamname)
690 g_free (shout2send->streamname);
691 shout2send->streamname = g_strdup (g_value_get_string (value));
693 case ARG_DESCRIPTION: /* Description of the stream */
694 if (shout2send->description)
695 g_free (shout2send->description);
696 shout2send->description = g_strdup (g_value_get_string (value));
698 case ARG_GENRE: /* Genre of the stream */
699 if (shout2send->genre)
700 g_free (shout2send->genre);
701 shout2send->genre = g_strdup (g_value_get_string (value));
703 case ARG_PROTOCOL: /* protocol to connect with */
704 shout2send->protocol = g_value_get_enum (value);
706 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
707 if (shout2send->mount)
708 g_free (shout2send->mount);
709 shout2send->mount = g_strdup (g_value_get_string (value));
711 case ARG_URL: /* Url of the stream (I'm guessing) */
713 g_free (shout2send->url);
714 shout2send->url = g_strdup (g_value_get_string (value));
717 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
723 gst_shout2send_get_property (GObject * object, guint prop_id,
724 GValue * value, GParamSpec * pspec)
726 GstShout2send *shout2send;
728 shout2send = GST_SHOUT2SEND (object);
732 g_value_set_string (value, shout2send->ip);
735 g_value_set_int (value, shout2send->port);
738 g_value_set_string (value, shout2send->password);
741 g_value_set_string (value, shout2send->username);
744 g_value_set_boolean (value, shout2send->ispublic);
746 case ARG_STREAMNAME: /* Name of the stream */
747 g_value_set_string (value, shout2send->streamname);
749 case ARG_DESCRIPTION: /* Description of the stream */
750 g_value_set_string (value, shout2send->description);
752 case ARG_GENRE: /* Genre of the stream */
753 g_value_set_string (value, shout2send->genre);
755 case ARG_PROTOCOL: /* protocol to connect with */
756 g_value_set_enum (value, shout2send->protocol);
758 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
759 g_value_set_string (value, shout2send->mount);
761 case ARG_URL: /* Url of stream (I'm guessing) */
762 g_value_set_string (value, shout2send->url);
765 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
771 gst_shout2send_setcaps (GstBaseSink * basesink, GstCaps * caps)
773 const gchar *mimetype;
774 GstShout2send *shout2send;
777 shout2send = GST_SHOUT2SEND (basesink);
779 mimetype = gst_structure_get_name (gst_caps_get_structure (caps, 0));
781 GST_DEBUG_OBJECT (shout2send, "mimetype of caps given is: %s", mimetype);
783 if (!strcmp (mimetype, "audio/mpeg")) {
784 shout2send->audio_format = SHOUT_FORMAT_MP3;
785 } else if (!strcmp (mimetype, "application/ogg")) {
786 shout2send->audio_format = SHOUT_FORMAT_VORBIS;
787 #ifdef SHOUT_FORMAT_WEBM
788 } else if (!strcmp (mimetype, "video/webm")) {
789 shout2send->audio_format = SHOUT_FORMAT_WEBM;
799 plugin_init (GstPlugin * plugin)
802 setlocale (LC_ALL, "");
803 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
804 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
805 #endif /* ENABLE_NLS */
807 return gst_element_register (plugin, "shout2send", GST_RANK_NONE,
808 GST_TYPE_SHOUT2SEND);
811 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
814 "Sends data to an icecast server using libshout2",
816 VERSION, "LGPL", "libshout2", "http://www.icecast.org/download.html")