2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
25 #include "gstshout2.h"
29 #include "gst/gst-i18n-plugin.h"
31 GST_DEBUG_CATEGORY_STATIC (shout2_debug);
32 #define GST_CAT_DEFAULT shout2_debug
34 static const GstElementDetails shout2send_details =
35 GST_ELEMENT_DETAILS ("Icecast network sink",
37 "Sends data to an icecast server",
38 "Wim Taymans <wim.taymans@chello.be>\n"
39 "Pedro Corte-Real <typo@netcabo.pt>\n"
40 "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
45 SIGNAL_CONNECTION_PROBLEM, /* 0.11 FIXME: remove this */
52 ARG_IP, /* the ip of the server */
53 ARG_PORT, /* the encoder port number on the server */
54 ARG_PASSWORD, /* the encoder password on the server */
55 ARG_USERNAME, /* the encoder username on the server */
56 ARG_PUBLIC, /* is this stream public? */
57 ARG_STREAMNAME, /* Name of the stream */
58 ARG_DESCRIPTION, /* Description of the stream */
59 ARG_GENRE, /* Genre of the stream */
61 ARG_PROTOCOL, /* Protocol to connect with */
63 ARG_MOUNT, /* mountpoint of stream (icecast only) */
64 ARG_URL /* Url of stream (I'm guessing) */
67 #define DEFAULT_IP "127.0.0.1"
68 #define DEFAULT_PORT 8000
69 #define DEFAULT_PASSWORD "hackme"
70 #define DEFAULT_USERNAME "source"
71 #define DEFAULT_PUBLIC FALSE
72 #define DEFAULT_STREAMNAME ""
73 #define DEFAULT_DESCRIPTION ""
74 #define DEFAULT_GENRE ""
75 #define DEFAULT_MOUNT ""
76 #define DEFAULT_URL ""
77 #define DEFAULT_PROTOCOL SHOUT2SEND_PROTOCOL_HTTP
79 static GstElementClass *parent_class = NULL;
81 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
84 GST_STATIC_CAPS ("application/ogg; "
85 "audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]")
87 static void gst_shout2send_class_init (GstShout2sendClass * klass);
88 static void gst_shout2send_base_init (GstShout2sendClass * klass);
89 static void gst_shout2send_init (GstShout2send * shout2send);
90 static void gst_shout2send_finalize (GstShout2send * shout2send);
92 static gboolean gst_shout2send_event (GstBaseSink * sink, GstEvent * event);
93 static gboolean gst_shout2send_unlock (GstBaseSink * basesink);
94 static gboolean gst_shout2send_unlock_stop (GstBaseSink * basesink);
95 static GstFlowReturn gst_shout2send_render (GstBaseSink * sink,
97 static gboolean gst_shout2send_start (GstBaseSink * basesink);
98 static gboolean gst_shout2send_stop (GstBaseSink * basesink);
100 static void gst_shout2send_set_property (GObject * object, guint prop_id,
101 const GValue * value, GParamSpec * pspec);
102 static void gst_shout2send_get_property (GObject * object, guint prop_id,
103 GValue * value, GParamSpec * pspec);
105 static gboolean gst_shout2send_setcaps (GstPad * pad, GstCaps * caps);
107 static guint gst_shout2send_signals[LAST_SIGNAL] = { 0 };
109 #define GST_TYPE_SHOUT_PROTOCOL (gst_shout2send_protocol_get_type())
111 gst_shout2send_protocol_get_type (void)
113 static GType shout2send_protocol_type = 0;
114 static const GEnumValue shout2send_protocol[] = {
115 {SHOUT2SEND_PROTOCOL_XAUDIOCAST,
116 "Xaudiocast Protocol (icecast 1.3.x)", "xaudiocast"},
117 {SHOUT2SEND_PROTOCOL_ICY, "Icy Protocol (ShoutCast)", "icy"},
118 {SHOUT2SEND_PROTOCOL_HTTP, "Http Protocol (icecast 2.x)", "http"},
122 if (!shout2send_protocol_type) {
123 shout2send_protocol_type =
124 g_enum_register_static ("GstShout2SendProtocol", shout2send_protocol);
128 return shout2send_protocol_type;
132 gst_shout2send_get_type (void)
134 static GType shout2send_type = 0;
136 if (!shout2send_type) {
137 static const GTypeInfo shout2send_info = {
138 sizeof (GstShout2sendClass),
139 (GBaseInitFunc) gst_shout2send_base_init,
141 (GClassInitFunc) gst_shout2send_class_init,
144 sizeof (GstShout2send),
146 (GInstanceInitFunc) gst_shout2send_init,
149 static const GInterfaceInfo tag_setter_info = {
156 g_type_register_static (GST_TYPE_BASE_SINK, "GstShout2send",
157 &shout2send_info, 0);
159 g_type_add_interface_static (shout2send_type, GST_TYPE_TAG_SETTER,
163 return shout2send_type;
167 gst_shout2send_base_init (GstShout2sendClass * klass)
169 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
171 gst_element_class_add_pad_template (element_class,
172 gst_static_pad_template_get (&sink_template));
173 gst_element_class_set_details (element_class, &shout2send_details);
175 GST_DEBUG_CATEGORY_INIT (shout2_debug, "shout2", 0, "shout2send element");
179 gst_shout2send_class_init (GstShout2sendClass * klass)
181 GObjectClass *gobject_class;
182 GstBaseSinkClass *gstbasesink_class;
184 gobject_class = (GObjectClass *) klass;
185 gstbasesink_class = (GstBaseSinkClass *) klass;
187 parent_class = g_type_class_peek_parent (klass);
189 gobject_class->set_property = gst_shout2send_set_property;
190 gobject_class->get_property = gst_shout2send_get_property;
191 gobject_class->finalize = (GObjectFinalizeFunc) gst_shout2send_finalize;
193 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP,
194 g_param_spec_string ("ip", "ip", "ip", DEFAULT_IP, G_PARAM_READWRITE));
195 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
196 g_param_spec_int ("port", "port", "port", 1, G_MAXUSHORT, DEFAULT_PORT,
199 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PASSWORD,
200 g_param_spec_string ("password", "password", "password", DEFAULT_PASSWORD,
203 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USERNAME,
204 g_param_spec_string ("username", "username", "username", DEFAULT_USERNAME,
208 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PUBLIC,
209 g_param_spec_boolean ("public", "public",
210 "If the stream should be listed on the server's stream directory",
211 DEFAULT_PUBLIC, G_PARAM_READWRITE));
213 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STREAMNAME,
214 g_param_spec_string ("streamname", "streamname", "name of the stream",
215 DEFAULT_STREAMNAME, G_PARAM_READWRITE));
217 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DESCRIPTION,
218 g_param_spec_string ("description", "description", "description",
219 DEFAULT_DESCRIPTION, G_PARAM_READWRITE));
221 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENRE,
222 g_param_spec_string ("genre", "genre", "genre", DEFAULT_GENRE,
225 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PROTOCOL,
226 g_param_spec_enum ("protocol", "protocol", "Connection Protocol to use",
227 GST_TYPE_SHOUT_PROTOCOL, DEFAULT_PROTOCOL, G_PARAM_READWRITE));
231 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOUNT,
232 g_param_spec_string ("mount", "mount", "mount", DEFAULT_MOUNT,
235 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_URL,
236 g_param_spec_string ("url", "url", "url", DEFAULT_URL,
240 gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM] =
241 g_signal_new ("connection-problem", G_TYPE_FROM_CLASS (klass),
242 G_SIGNAL_RUN_CLEANUP, G_STRUCT_OFFSET (GstShout2sendClass,
243 connection_problem), NULL, NULL, g_cclosure_marshal_VOID__INT,
244 G_TYPE_NONE, 1, G_TYPE_INT);
246 gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_shout2send_start);
247 gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_shout2send_stop);
248 gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_shout2send_unlock);
249 gstbasesink_class->unlock_stop =
250 GST_DEBUG_FUNCPTR (gst_shout2send_unlock_stop);
251 gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_shout2send_render);
252 gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_shout2send_event);
256 gst_shout2send_init (GstShout2send * shout2send)
258 gst_base_sink_set_sync (GST_BASE_SINK (shout2send), FALSE);
260 gst_pad_set_setcaps_function (GST_BASE_SINK_PAD (shout2send),
261 GST_DEBUG_FUNCPTR (gst_shout2send_setcaps));
263 shout2send->timer = gst_poll_new_timer ();
265 shout2send->ip = g_strdup (DEFAULT_IP);
266 shout2send->port = DEFAULT_PORT;
267 shout2send->password = g_strdup (DEFAULT_PASSWORD);
268 shout2send->username = g_strdup (DEFAULT_USERNAME);
269 shout2send->streamname = g_strdup (DEFAULT_STREAMNAME);
270 shout2send->description = g_strdup (DEFAULT_DESCRIPTION);
271 shout2send->genre = g_strdup (DEFAULT_GENRE);
272 shout2send->mount = g_strdup (DEFAULT_MOUNT);
273 shout2send->url = g_strdup (DEFAULT_URL);
274 shout2send->protocol = DEFAULT_PROTOCOL;
275 shout2send->ispublic = DEFAULT_PUBLIC;
277 shout2send->tags = gst_tag_list_new ();
278 shout2send->conn = NULL;
279 shout2send->audio_format = SHOUT_FORMAT_VORBIS;
280 shout2send->connected = FALSE;
281 shout2send->songmetadata = NULL;
282 shout2send->songartist = NULL;
283 shout2send->songtitle = NULL;
287 gst_shout2send_finalize (GstShout2send * shout2send)
289 g_free (shout2send->ip);
290 g_free (shout2send->password);
291 g_free (shout2send->username);
292 g_free (shout2send->streamname);
293 g_free (shout2send->description);
294 g_free (shout2send->genre);
295 g_free (shout2send->mount);
296 g_free (shout2send->url);
298 gst_tag_list_free (shout2send->tags);
300 gst_poll_free (shout2send->timer);
302 G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (shout2send));
306 set_shout_metadata (const GstTagList * list, const gchar * tag,
309 GstShout2send *shout2send = (GstShout2send *) user_data;
310 char **shout_metadata = &(shout2send->songmetadata);
311 char **song_artist = &(shout2send->songartist);
312 char **song_title = &(shout2send->songtitle);
316 GST_DEBUG ("tag: %s being added", tag);
317 if (strcmp (tag, GST_TAG_ARTIST) == 0) {
318 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
319 if (!gst_tag_list_get_string (list, tag, &value)) {
320 GST_DEBUG ("Error reading \"%s\" tag value", tag);
324 if (*song_artist != NULL)
325 g_free (*song_artist);
327 *song_artist = g_strdup (value);
329 } else if (strcmp (tag, GST_TAG_TITLE) == 0) {
330 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
331 if (!gst_tag_list_get_string (list, tag, &value)) {
332 GST_DEBUG ("Error reading \"%s\" tag value", tag);
336 if (*song_title != NULL)
337 g_free (*song_title);
339 *song_title = g_strdup (value);
343 if (*shout_metadata != NULL)
344 g_free (*shout_metadata);
347 if (*song_title && *song_artist) {
348 *shout_metadata = g_strdup_printf ("%s - %s", *song_artist, *song_title);
349 } else if (*song_title && *song_artist == NULL) {
350 *shout_metadata = g_strdup_printf ("Unknown - %s", *song_title);
351 } else if (*song_title == NULL && *song_artist) {
352 *shout_metadata = g_strdup_printf ("%s - Unknown", *song_artist);
354 *shout_metadata = g_strdup_printf ("Unknown - Unknown");
357 GST_LOG ("shout metadata is now: %s", *shout_metadata);
362 gst_shout2send_set_metadata (GstShout2send * shout2send)
364 const GstTagList *user_tags;
367 shout_metadata_t *pmetadata;
369 g_return_if_fail (shout2send != NULL);
370 user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (shout2send));
371 if ((shout2send->tags == NULL) && (user_tags == NULL)) {
374 copy = gst_tag_list_merge (user_tags, shout2send->tags,
375 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
376 /* lets get the artist and song tags */
378 gst_tag_list_foreach ((GstTagList *) copy, set_shout_metadata,
379 (gpointer) & tempmetadata);
381 pmetadata = shout_metadata_new ();
382 shout_metadata_add (pmetadata, "song", tempmetadata);
383 shout_set_metadata (shout2send->conn, pmetadata);
384 shout_metadata_free (pmetadata);
387 gst_tag_list_free (copy);
393 gst_shout2send_event (GstBaseSink * sink, GstEvent * event)
395 GstShout2send *shout2send;
398 shout2send = GST_SHOUT2SEND (sink);
400 GST_LOG_OBJECT (shout2send, "got %s event", GST_EVENT_TYPE_NAME (event));
402 switch (GST_EVENT_TYPE (event)) {
404 /* vorbis audio doesnt need metadata setting on the icecast level, only mp3 */
405 if (shout2send->tags && shout2send->audio_format == SHOUT_FORMAT_MP3) {
408 gst_event_parse_tag (event, &list);
409 GST_DEBUG_OBJECT (shout2send, "tags=%" GST_PTR_FORMAT, list);
410 gst_tag_list_insert (shout2send->tags,
412 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
413 /* lets get the artist and song tags */
414 gst_tag_list_foreach ((GstTagList *) list,
415 set_shout_metadata, shout2send);
416 if (shout2send->songmetadata && shout2send->connected) {
417 shout_metadata_t *pmetadata;
419 GST_DEBUG_OBJECT (shout2send, "metadata now: %s",
420 shout2send->songmetadata);
422 pmetadata = shout_metadata_new ();
423 shout_metadata_add (pmetadata, "song", shout2send->songmetadata);
424 shout_set_metadata (shout2send->conn, pmetadata);
425 shout_metadata_free (pmetadata);
431 GST_LOG_OBJECT (shout2send, "let base class handle event");
432 if (GST_BASE_SINK_CLASS (parent_class)->event) {
433 event = gst_event_ref (event);
434 ret = GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
444 gst_shout2send_start (GstBaseSink * basesink)
446 GstShout2send *sink = GST_SHOUT2SEND (basesink);
447 const gchar *cur_prop;
449 gchar *version_string;
451 GST_DEBUG_OBJECT (sink, "starting");
453 sink->conn = shout_new ();
455 switch (sink->protocol) {
456 case SHOUT2SEND_PROTOCOL_XAUDIOCAST:
457 proto = SHOUT_PROTOCOL_XAUDIOCAST;
459 case SHOUT2SEND_PROTOCOL_ICY:
460 proto = SHOUT_PROTOCOL_ICY;
462 case SHOUT2SEND_PROTOCOL_HTTP:
463 proto = SHOUT_PROTOCOL_HTTP;
467 cur_prop = "protocol";
468 GST_DEBUG_OBJECT (sink, "setting protocol: %d", sink->protocol);
469 if (shout_set_protocol (sink->conn, proto) != SHOUTERR_SUCCESS)
472 /* --- FIXME: shout requires an ip, and fails if it is given a host. */
473 /* may want to put convert_to_ip(shout2send->ip) here */
475 GST_DEBUG_OBJECT (sink, "setting ip: %s", sink->ip);
476 if (shout_set_host (sink->conn, sink->ip) != SHOUTERR_SUCCESS)
480 GST_DEBUG_OBJECT (sink, "setting port: %u", sink->port);
481 if (shout_set_port (sink->conn, sink->port) != SHOUTERR_SUCCESS)
484 cur_prop = "password";
485 GST_DEBUG_OBJECT (sink, "setting password: %s", sink->password);
486 if (shout_set_password (sink->conn, sink->password) != SHOUTERR_SUCCESS)
490 GST_DEBUG_OBJECT (sink, "setting %s: %u", cur_prop, sink->ispublic);
491 if (shout_set_public (sink->conn,
492 (sink->ispublic ? 1 : 0)) != SHOUTERR_SUCCESS)
495 cur_prop = "streamname";
496 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->streamname);
497 if (shout_set_name (sink->conn, sink->streamname) != SHOUTERR_SUCCESS)
500 cur_prop = "description";
501 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->description);
502 if (shout_set_description (sink->conn, sink->description) != SHOUTERR_SUCCESS)
506 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->genre);
507 if (shout_set_genre (sink->conn, sink->genre) != SHOUTERR_SUCCESS)
511 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->mount);
512 if (shout_set_mount (sink->conn, sink->mount) != SHOUTERR_SUCCESS)
515 cur_prop = "username";
516 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, "source");
517 if (shout_set_user (sink->conn, sink->username) != SHOUTERR_SUCCESS)
520 version_string = gst_version_string ();
522 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, version_string);
523 if (shout_set_agent (sink->conn, version_string) != SHOUTERR_SUCCESS) {
524 g_free (version_string);
528 g_free (version_string);
534 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
535 ("Error setting %s: %s", cur_prop, shout_get_error (sink->conn)));
541 gst_shout2send_connect (GstShout2send * sink)
543 GST_DEBUG_OBJECT (sink, "Connection format is: %s",
544 (sink->audio_format == SHOUT_FORMAT_VORBIS) ? "vorbis" :
545 ((sink->audio_format == SHOUT_FORMAT_MP3) ? "mp3" : "unknown"));
547 if (shout_set_format (sink->conn, sink->audio_format) != SHOUTERR_SUCCESS)
548 goto could_not_set_format;
550 if (shout_open (sink->conn) != SHOUTERR_SUCCESS)
551 goto could_not_connect;
553 GST_DEBUG_OBJECT (sink, "connected to server");
554 sink->connected = TRUE;
556 /* let's set metadata */
557 if (sink->songmetadata) {
558 shout_metadata_t *pmetadata;
560 GST_DEBUG_OBJECT (sink, "shout metadata now: %s", sink->songmetadata);
561 pmetadata = shout_metadata_new ();
562 shout_metadata_add (pmetadata, "song", sink->songmetadata);
563 shout_set_metadata (sink->conn, pmetadata);
564 shout_metadata_free (pmetadata);
570 could_not_set_format:
572 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
573 ("Error setting connection format: %s", shout_get_error (sink->conn)));
579 GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
580 (_("Could not connect to server")),
581 ("shout_open() failed: err=%s", shout_get_error (sink->conn)));
582 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
583 shout_get_errno (sink->conn));
589 gst_shout2send_stop (GstBaseSink * basesink)
591 GstShout2send *sink = GST_SHOUT2SEND (basesink);
595 shout_close (sink->conn);
596 shout_free (sink->conn);
600 if (sink->songmetadata) {
601 g_free (sink->songmetadata);
602 sink->songmetadata = NULL;
605 sink->connected = FALSE;
611 gst_shout2send_unlock (GstBaseSink * basesink)
615 sink = GST_SHOUT2SEND (basesink);
617 GST_DEBUG_OBJECT (basesink, "unlock");
618 gst_poll_set_flushing (sink->timer, TRUE);
624 gst_shout2send_unlock_stop (GstBaseSink * basesink)
628 sink = GST_SHOUT2SEND (basesink);
630 GST_DEBUG_OBJECT (basesink, "unlock_stop");
631 gst_poll_set_flushing (sink->timer, FALSE);
637 gst_shout2send_render (GstBaseSink * basesink, GstBuffer * buf)
644 sink = GST_SHOUT2SEND (basesink);
646 /* presumably we connect here because we need to know the format before
647 * we can set up the connection, which we don't know yet in _start() */
648 if (!sink->connected) {
649 if (!gst_shout2send_connect (sink))
650 return GST_FLOW_ERROR;
653 delay = shout_delay (sink->conn);
655 GST_LOG_OBJECT (sink, "waiting %d msec", delay);
656 if (gst_poll_wait (sink->timer, GST_MSECOND * delay) == -1) {
657 GST_LOG_OBJECT (sink, "unlocked");
659 fret = gst_base_sink_wait_preroll (basesink);
660 if (fret != GST_FLOW_OK)
664 GST_LOG_OBJECT (sink, "sending %u bytes of data", GST_BUFFER_SIZE (buf));
665 ret = shout_send (sink->conn, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
666 if (ret != SHOUTERR_SUCCESS)
674 GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
675 ("shout_send() failed: %s", shout_get_error (sink->conn)));
676 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
677 shout_get_errno (sink->conn));
678 return GST_FLOW_ERROR;
683 gst_shout2send_set_property (GObject * object, guint prop_id,
684 const GValue * value, GParamSpec * pspec)
686 GstShout2send *shout2send;
688 shout2send = GST_SHOUT2SEND (object);
693 g_free (shout2send->ip);
694 shout2send->ip = g_strdup (g_value_get_string (value));
697 shout2send->port = g_value_get_int (value);
700 if (shout2send->password)
701 g_free (shout2send->password);
702 shout2send->password = g_strdup (g_value_get_string (value));
705 if (shout2send->username)
706 g_free (shout2send->username);
707 shout2send->username = g_strdup (g_value_get_string (value));
710 shout2send->ispublic = g_value_get_boolean (value);
712 case ARG_STREAMNAME: /* Name of the stream */
713 if (shout2send->streamname)
714 g_free (shout2send->streamname);
715 shout2send->streamname = g_strdup (g_value_get_string (value));
717 case ARG_DESCRIPTION: /* Description of the stream */
718 if (shout2send->description)
719 g_free (shout2send->description);
720 shout2send->description = g_strdup (g_value_get_string (value));
722 case ARG_GENRE: /* Genre of the stream */
723 if (shout2send->genre)
724 g_free (shout2send->genre);
725 shout2send->genre = g_strdup (g_value_get_string (value));
727 case ARG_PROTOCOL: /* protocol to connect with */
728 shout2send->protocol = g_value_get_enum (value);
730 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
731 if (shout2send->mount)
732 g_free (shout2send->mount);
733 shout2send->mount = g_strdup (g_value_get_string (value));
735 case ARG_URL: /* Url of the stream (I'm guessing) */
737 g_free (shout2send->url);
738 shout2send->url = g_strdup (g_value_get_string (value));
741 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
747 gst_shout2send_get_property (GObject * object, guint prop_id,
748 GValue * value, GParamSpec * pspec)
750 GstShout2send *shout2send;
752 shout2send = GST_SHOUT2SEND (object);
756 g_value_set_string (value, shout2send->ip);
759 g_value_set_int (value, shout2send->port);
762 g_value_set_string (value, shout2send->password);
765 g_value_set_string (value, shout2send->username);
768 g_value_set_boolean (value, shout2send->ispublic);
770 case ARG_STREAMNAME: /* Name of the stream */
771 g_value_set_string (value, shout2send->streamname);
773 case ARG_DESCRIPTION: /* Description of the stream */
774 g_value_set_string (value, shout2send->description);
776 case ARG_GENRE: /* Genre of the stream */
777 g_value_set_string (value, shout2send->genre);
779 case ARG_PROTOCOL: /* protocol to connect with */
780 g_value_set_enum (value, shout2send->protocol);
782 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
783 g_value_set_string (value, shout2send->mount);
785 case ARG_URL: /* Url of stream (I'm guessing) */
786 g_value_set_string (value, shout2send->url);
789 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
795 gst_shout2send_setcaps (GstPad * pad, GstCaps * caps)
797 const gchar *mimetype;
798 GstShout2send *shout2send;
801 shout2send = GST_SHOUT2SEND (GST_OBJECT_PARENT (pad));
803 mimetype = gst_structure_get_name (gst_caps_get_structure (caps, 0));
805 GST_DEBUG_OBJECT (shout2send, "mimetype of caps given is: %s", mimetype);
807 if (!strcmp (mimetype, "audio/mpeg")) {
808 shout2send->audio_format = SHOUT_FORMAT_MP3;
809 } else if (!strcmp (mimetype, "application/ogg")) {
810 shout2send->audio_format = SHOUT_FORMAT_VORBIS;
819 plugin_init (GstPlugin * plugin)
822 setlocale (LC_ALL, "");
823 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
824 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
825 #endif /* ENABLE_NLS */
827 return gst_element_register (plugin, "shout2send", GST_RANK_NONE,
828 GST_TYPE_SHOUT2SEND);
831 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
834 "Sends data to an icecast server using libshout2",
836 VERSION, "LGPL", "libshout2", "http://www.icecast.org/download.html")