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
37 SIGNAL_CONNECTION_PROBLEM, /* 0.11 FIXME: remove this */
44 ARG_IP, /* the ip of the server */
45 ARG_PORT, /* the encoder port number on the server */
46 ARG_PASSWORD, /* the encoder password on the server */
47 ARG_USERNAME, /* the encoder username on the server */
48 ARG_PUBLIC, /* is this stream public? */
49 ARG_STREAMNAME, /* Name of the stream */
50 ARG_DESCRIPTION, /* Description of the stream */
51 ARG_GENRE, /* Genre of the stream */
53 ARG_PROTOCOL, /* Protocol to connect with */
55 ARG_MOUNT, /* mountpoint of stream (icecast only) */
56 ARG_URL /* Url of stream (I'm guessing) */
59 #define DEFAULT_IP "127.0.0.1"
60 #define DEFAULT_PORT 8000
61 #define DEFAULT_PASSWORD "hackme"
62 #define DEFAULT_USERNAME "source"
63 #define DEFAULT_PUBLIC FALSE
64 #define DEFAULT_STREAMNAME ""
65 #define DEFAULT_DESCRIPTION ""
66 #define DEFAULT_GENRE ""
67 #define DEFAULT_MOUNT ""
68 #define DEFAULT_URL ""
69 #define DEFAULT_PROTOCOL SHOUT2SEND_PROTOCOL_HTTP
71 static GstElementClass *parent_class = NULL;
73 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
76 GST_STATIC_CAPS ("application/ogg; "
77 "audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]")
79 static void gst_shout2send_class_init (GstShout2sendClass * klass);
80 static void gst_shout2send_base_init (GstShout2sendClass * klass);
81 static void gst_shout2send_init (GstShout2send * shout2send);
82 static void gst_shout2send_finalize (GstShout2send * shout2send);
84 static gboolean gst_shout2send_event (GstBaseSink * sink, GstEvent * event);
85 static gboolean gst_shout2send_unlock (GstBaseSink * basesink);
86 static gboolean gst_shout2send_unlock_stop (GstBaseSink * basesink);
87 static GstFlowReturn gst_shout2send_render (GstBaseSink * sink,
89 static gboolean gst_shout2send_start (GstBaseSink * basesink);
90 static gboolean gst_shout2send_stop (GstBaseSink * basesink);
92 static void gst_shout2send_set_property (GObject * object, guint prop_id,
93 const GValue * value, GParamSpec * pspec);
94 static void gst_shout2send_get_property (GObject * object, guint prop_id,
95 GValue * value, GParamSpec * pspec);
97 static gboolean gst_shout2send_setcaps (GstPad * pad, GstCaps * caps);
99 static guint gst_shout2send_signals[LAST_SIGNAL] = { 0 };
101 #define GST_TYPE_SHOUT_PROTOCOL (gst_shout2send_protocol_get_type())
103 gst_shout2send_protocol_get_type (void)
105 static GType shout2send_protocol_type = 0;
106 static const GEnumValue shout2send_protocol[] = {
107 {SHOUT2SEND_PROTOCOL_XAUDIOCAST,
108 "Xaudiocast Protocol (icecast 1.3.x)", "xaudiocast"},
109 {SHOUT2SEND_PROTOCOL_ICY, "Icy Protocol (ShoutCast)", "icy"},
110 {SHOUT2SEND_PROTOCOL_HTTP, "Http Protocol (icecast 2.x)", "http"},
114 if (!shout2send_protocol_type) {
115 shout2send_protocol_type =
116 g_enum_register_static ("GstShout2SendProtocol", shout2send_protocol);
120 return shout2send_protocol_type;
124 gst_shout2send_get_type (void)
126 static GType shout2send_type = 0;
128 if (!shout2send_type) {
129 static const GTypeInfo shout2send_info = {
130 sizeof (GstShout2sendClass),
131 (GBaseInitFunc) gst_shout2send_base_init,
133 (GClassInitFunc) gst_shout2send_class_init,
136 sizeof (GstShout2send),
138 (GInstanceInitFunc) gst_shout2send_init,
141 static const GInterfaceInfo tag_setter_info = {
148 g_type_register_static (GST_TYPE_BASE_SINK, "GstShout2send",
149 &shout2send_info, 0);
151 g_type_add_interface_static (shout2send_type, GST_TYPE_TAG_SETTER,
155 return shout2send_type;
159 gst_shout2send_base_init (GstShout2sendClass * klass)
161 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
163 gst_element_class_add_pad_template (element_class,
164 gst_static_pad_template_get (&sink_template));
165 gst_element_class_set_details_simple (element_class, "Icecast network sink",
166 "Sink/Network", "Sends data to an icecast server",
167 "Wim Taymans <wim.taymans@chello.be>, "
168 "Pedro Corte-Real <typo@netcabo.pt>, "
169 "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
171 GST_DEBUG_CATEGORY_INIT (shout2_debug, "shout2", 0, "shout2send element");
175 gst_shout2send_class_init (GstShout2sendClass * klass)
177 GObjectClass *gobject_class;
178 GstBaseSinkClass *gstbasesink_class;
180 gobject_class = (GObjectClass *) klass;
181 gstbasesink_class = (GstBaseSinkClass *) klass;
183 parent_class = g_type_class_peek_parent (klass);
185 gobject_class->set_property = gst_shout2send_set_property;
186 gobject_class->get_property = gst_shout2send_get_property;
187 gobject_class->finalize = (GObjectFinalizeFunc) gst_shout2send_finalize;
189 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP,
190 g_param_spec_string ("ip", "ip", "ip", DEFAULT_IP,
191 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
192 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
193 g_param_spec_int ("port", "port", "port", 1, G_MAXUSHORT, DEFAULT_PORT,
194 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
196 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PASSWORD,
197 g_param_spec_string ("password", "password", "password", DEFAULT_PASSWORD,
198 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
200 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USERNAME,
201 g_param_spec_string ("username", "username", "username", DEFAULT_USERNAME,
202 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
205 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PUBLIC,
206 g_param_spec_boolean ("public", "public",
207 "If the stream should be listed on the server's stream directory",
208 DEFAULT_PUBLIC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
210 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STREAMNAME,
211 g_param_spec_string ("streamname", "streamname", "name of the stream",
212 DEFAULT_STREAMNAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
214 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DESCRIPTION,
215 g_param_spec_string ("description", "description", "description",
216 DEFAULT_DESCRIPTION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
218 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENRE,
219 g_param_spec_string ("genre", "genre", "genre", DEFAULT_GENRE,
220 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
222 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PROTOCOL,
223 g_param_spec_enum ("protocol", "protocol", "Connection Protocol to use",
224 GST_TYPE_SHOUT_PROTOCOL, DEFAULT_PROTOCOL,
225 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
229 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOUNT,
230 g_param_spec_string ("mount", "mount", "mount", DEFAULT_MOUNT,
231 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
233 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_URL,
234 g_param_spec_string ("url", "url", "url", DEFAULT_URL,
235 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
238 gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM] =
239 g_signal_new ("connection-problem", G_TYPE_FROM_CLASS (klass),
240 G_SIGNAL_RUN_CLEANUP, G_STRUCT_OFFSET (GstShout2sendClass,
241 connection_problem), NULL, NULL, g_cclosure_marshal_VOID__INT,
242 G_TYPE_NONE, 1, G_TYPE_INT);
244 gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_shout2send_start);
245 gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_shout2send_stop);
246 gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_shout2send_unlock);
247 gstbasesink_class->unlock_stop =
248 GST_DEBUG_FUNCPTR (gst_shout2send_unlock_stop);
249 gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_shout2send_render);
250 gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_shout2send_event);
254 gst_shout2send_init (GstShout2send * shout2send)
256 gst_base_sink_set_sync (GST_BASE_SINK (shout2send), FALSE);
258 gst_pad_set_setcaps_function (GST_BASE_SINK_PAD (shout2send),
259 GST_DEBUG_FUNCPTR (gst_shout2send_setcaps));
261 shout2send->timer = gst_poll_new_timer ();
263 shout2send->ip = g_strdup (DEFAULT_IP);
264 shout2send->port = DEFAULT_PORT;
265 shout2send->password = g_strdup (DEFAULT_PASSWORD);
266 shout2send->username = g_strdup (DEFAULT_USERNAME);
267 shout2send->streamname = g_strdup (DEFAULT_STREAMNAME);
268 shout2send->description = g_strdup (DEFAULT_DESCRIPTION);
269 shout2send->genre = g_strdup (DEFAULT_GENRE);
270 shout2send->mount = g_strdup (DEFAULT_MOUNT);
271 shout2send->url = g_strdup (DEFAULT_URL);
272 shout2send->protocol = DEFAULT_PROTOCOL;
273 shout2send->ispublic = DEFAULT_PUBLIC;
275 shout2send->tags = gst_tag_list_new ();
276 shout2send->conn = NULL;
277 shout2send->audio_format = SHOUT_FORMAT_VORBIS;
278 shout2send->connected = FALSE;
279 shout2send->songmetadata = NULL;
280 shout2send->songartist = NULL;
281 shout2send->songtitle = NULL;
285 gst_shout2send_finalize (GstShout2send * shout2send)
287 g_free (shout2send->ip);
288 g_free (shout2send->password);
289 g_free (shout2send->username);
290 g_free (shout2send->streamname);
291 g_free (shout2send->description);
292 g_free (shout2send->genre);
293 g_free (shout2send->mount);
294 g_free (shout2send->url);
296 gst_tag_list_free (shout2send->tags);
298 gst_poll_free (shout2send->timer);
300 G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (shout2send));
304 set_shout_metadata (const GstTagList * list, const gchar * tag,
307 GstShout2send *shout2send = (GstShout2send *) user_data;
308 char **shout_metadata = &(shout2send->songmetadata);
309 char **song_artist = &(shout2send->songartist);
310 char **song_title = &(shout2send->songtitle);
314 GST_DEBUG ("tag: %s being added", tag);
315 if (strcmp (tag, GST_TAG_ARTIST) == 0) {
316 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
317 if (!gst_tag_list_get_string (list, tag, &value)) {
318 GST_DEBUG ("Error reading \"%s\" tag value", tag);
322 if (*song_artist != NULL)
323 g_free (*song_artist);
325 *song_artist = g_strdup (value);
327 } else if (strcmp (tag, GST_TAG_TITLE) == 0) {
328 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
329 if (!gst_tag_list_get_string (list, tag, &value)) {
330 GST_DEBUG ("Error reading \"%s\" tag value", tag);
334 if (*song_title != NULL)
335 g_free (*song_title);
337 *song_title = g_strdup (value);
341 if (*shout_metadata != NULL)
342 g_free (*shout_metadata);
345 if (*song_title && *song_artist) {
346 *shout_metadata = g_strdup_printf ("%s - %s", *song_artist, *song_title);
347 } else if (*song_title && *song_artist == NULL) {
348 *shout_metadata = g_strdup_printf ("Unknown - %s", *song_title);
349 } else if (*song_title == NULL && *song_artist) {
350 *shout_metadata = g_strdup_printf ("%s - Unknown", *song_artist);
352 *shout_metadata = g_strdup_printf ("Unknown - Unknown");
355 GST_LOG ("shout metadata is now: %s", *shout_metadata);
360 gst_shout2send_set_metadata (GstShout2send * shout2send)
362 const GstTagList *user_tags;
365 shout_metadata_t *pmetadata;
367 g_return_if_fail (shout2send != NULL);
368 user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (shout2send));
369 if ((shout2send->tags == NULL) && (user_tags == NULL)) {
372 copy = gst_tag_list_merge (user_tags, shout2send->tags,
373 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
374 /* lets get the artist and song tags */
376 gst_tag_list_foreach ((GstTagList *) copy, set_shout_metadata,
377 (gpointer) & tempmetadata);
379 pmetadata = shout_metadata_new ();
380 shout_metadata_add (pmetadata, "song", tempmetadata);
381 shout_set_metadata (shout2send->conn, pmetadata);
382 shout_metadata_free (pmetadata);
385 gst_tag_list_free (copy);
391 gst_shout2send_event (GstBaseSink * sink, GstEvent * event)
393 GstShout2send *shout2send;
396 shout2send = GST_SHOUT2SEND (sink);
398 GST_LOG_OBJECT (shout2send, "got %s event", GST_EVENT_TYPE_NAME (event));
400 switch (GST_EVENT_TYPE (event)) {
402 /* vorbis audio doesnt need metadata setting on the icecast level, only mp3 */
403 if (shout2send->tags && shout2send->audio_format == SHOUT_FORMAT_MP3) {
406 gst_event_parse_tag (event, &list);
407 GST_DEBUG_OBJECT (shout2send, "tags=%" GST_PTR_FORMAT, list);
408 gst_tag_list_insert (shout2send->tags,
410 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
411 /* lets get the artist and song tags */
412 gst_tag_list_foreach ((GstTagList *) list,
413 set_shout_metadata, shout2send);
414 if (shout2send->songmetadata && shout2send->connected) {
415 shout_metadata_t *pmetadata;
417 GST_DEBUG_OBJECT (shout2send, "metadata now: %s",
418 shout2send->songmetadata);
420 pmetadata = shout_metadata_new ();
421 shout_metadata_add (pmetadata, "song", shout2send->songmetadata);
422 shout_set_metadata (shout2send->conn, pmetadata);
423 shout_metadata_free (pmetadata);
429 GST_LOG_OBJECT (shout2send, "let base class handle event");
430 if (GST_BASE_SINK_CLASS (parent_class)->event) {
431 event = gst_event_ref (event);
432 ret = GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
442 gst_shout2send_start (GstBaseSink * basesink)
444 GstShout2send *sink = GST_SHOUT2SEND (basesink);
445 const gchar *cur_prop;
447 gchar *version_string;
449 GST_DEBUG_OBJECT (sink, "starting");
451 sink->conn = shout_new ();
453 switch (sink->protocol) {
454 case SHOUT2SEND_PROTOCOL_XAUDIOCAST:
455 proto = SHOUT_PROTOCOL_XAUDIOCAST;
457 case SHOUT2SEND_PROTOCOL_ICY:
458 proto = SHOUT_PROTOCOL_ICY;
460 case SHOUT2SEND_PROTOCOL_HTTP:
461 proto = SHOUT_PROTOCOL_HTTP;
465 cur_prop = "protocol";
466 GST_DEBUG_OBJECT (sink, "setting protocol: %d", sink->protocol);
467 if (shout_set_protocol (sink->conn, proto) != SHOUTERR_SUCCESS)
470 /* --- FIXME: shout requires an ip, and fails if it is given a host. */
471 /* may want to put convert_to_ip(shout2send->ip) here */
473 GST_DEBUG_OBJECT (sink, "setting ip: %s", sink->ip);
474 if (shout_set_host (sink->conn, sink->ip) != SHOUTERR_SUCCESS)
478 GST_DEBUG_OBJECT (sink, "setting port: %u", sink->port);
479 if (shout_set_port (sink->conn, sink->port) != SHOUTERR_SUCCESS)
482 cur_prop = "password";
483 GST_DEBUG_OBJECT (sink, "setting password: %s", sink->password);
484 if (shout_set_password (sink->conn, sink->password) != SHOUTERR_SUCCESS)
488 GST_DEBUG_OBJECT (sink, "setting %s: %u", cur_prop, sink->ispublic);
489 if (shout_set_public (sink->conn,
490 (sink->ispublic ? 1 : 0)) != SHOUTERR_SUCCESS)
493 cur_prop = "streamname";
494 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->streamname);
495 if (shout_set_name (sink->conn, sink->streamname) != SHOUTERR_SUCCESS)
498 cur_prop = "description";
499 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->description);
500 if (shout_set_description (sink->conn, sink->description) != SHOUTERR_SUCCESS)
504 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->genre);
505 if (shout_set_genre (sink->conn, sink->genre) != SHOUTERR_SUCCESS)
509 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->mount);
510 if (shout_set_mount (sink->conn, sink->mount) != SHOUTERR_SUCCESS)
513 cur_prop = "username";
514 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, "source");
515 if (shout_set_user (sink->conn, sink->username) != SHOUTERR_SUCCESS)
518 version_string = gst_version_string ();
520 GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, version_string);
521 if (shout_set_agent (sink->conn, version_string) != SHOUTERR_SUCCESS) {
522 g_free (version_string);
526 g_free (version_string);
532 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
533 ("Error setting %s: %s", cur_prop, shout_get_error (sink->conn)));
539 gst_shout2send_connect (GstShout2send * sink)
541 GST_DEBUG_OBJECT (sink, "Connection format is: %s",
542 (sink->audio_format == SHOUT_FORMAT_VORBIS) ? "vorbis" :
543 ((sink->audio_format == SHOUT_FORMAT_MP3) ? "mp3" : "unknown"));
545 if (shout_set_format (sink->conn, sink->audio_format) != SHOUTERR_SUCCESS)
546 goto could_not_set_format;
548 if (shout_open (sink->conn) != SHOUTERR_SUCCESS)
549 goto could_not_connect;
551 GST_DEBUG_OBJECT (sink, "connected to server");
552 sink->connected = TRUE;
554 /* let's set metadata */
555 if (sink->songmetadata) {
556 shout_metadata_t *pmetadata;
558 GST_DEBUG_OBJECT (sink, "shout metadata now: %s", sink->songmetadata);
559 pmetadata = shout_metadata_new ();
560 shout_metadata_add (pmetadata, "song", sink->songmetadata);
561 shout_set_metadata (sink->conn, pmetadata);
562 shout_metadata_free (pmetadata);
568 could_not_set_format:
570 GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
571 ("Error setting connection format: %s", shout_get_error (sink->conn)));
577 GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
578 (_("Could not connect to server")),
579 ("shout_open() failed: err=%s", shout_get_error (sink->conn)));
580 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
581 shout_get_errno (sink->conn));
587 gst_shout2send_stop (GstBaseSink * basesink)
589 GstShout2send *sink = GST_SHOUT2SEND (basesink);
593 shout_close (sink->conn);
594 shout_free (sink->conn);
598 if (sink->songmetadata) {
599 g_free (sink->songmetadata);
600 sink->songmetadata = NULL;
603 sink->connected = FALSE;
609 gst_shout2send_unlock (GstBaseSink * basesink)
613 sink = GST_SHOUT2SEND (basesink);
615 GST_DEBUG_OBJECT (basesink, "unlock");
616 gst_poll_set_flushing (sink->timer, TRUE);
622 gst_shout2send_unlock_stop (GstBaseSink * basesink)
626 sink = GST_SHOUT2SEND (basesink);
628 GST_DEBUG_OBJECT (basesink, "unlock_stop");
629 gst_poll_set_flushing (sink->timer, FALSE);
635 gst_shout2send_render (GstBaseSink * basesink, GstBuffer * buf)
642 sink = GST_SHOUT2SEND (basesink);
644 /* presumably we connect here because we need to know the format before
645 * we can set up the connection, which we don't know yet in _start() */
646 if (!sink->connected) {
647 if (!gst_shout2send_connect (sink))
648 return GST_FLOW_ERROR;
651 delay = shout_delay (sink->conn);
654 GST_LOG_OBJECT (sink, "waiting %d msec", delay);
655 if (gst_poll_wait (sink->timer, GST_MSECOND * delay) == -1) {
656 GST_LOG_OBJECT (sink, "unlocked");
658 fret = gst_base_sink_wait_preroll (basesink);
659 if (fret != GST_FLOW_OK)
663 GST_LOG_OBJECT (sink, "we're %d msec late", -delay);
666 GST_LOG_OBJECT (sink, "sending %u bytes of data", GST_BUFFER_SIZE (buf));
667 ret = shout_send (sink->conn, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
668 if (ret != SHOUTERR_SUCCESS)
676 GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
677 ("shout_send() failed: %s", shout_get_error (sink->conn)));
678 g_signal_emit (sink, gst_shout2send_signals[SIGNAL_CONNECTION_PROBLEM], 0,
679 shout_get_errno (sink->conn));
680 return GST_FLOW_ERROR;
685 gst_shout2send_set_property (GObject * object, guint prop_id,
686 const GValue * value, GParamSpec * pspec)
688 GstShout2send *shout2send;
690 shout2send = GST_SHOUT2SEND (object);
695 g_free (shout2send->ip);
696 shout2send->ip = g_strdup (g_value_get_string (value));
699 shout2send->port = g_value_get_int (value);
702 if (shout2send->password)
703 g_free (shout2send->password);
704 shout2send->password = g_strdup (g_value_get_string (value));
707 if (shout2send->username)
708 g_free (shout2send->username);
709 shout2send->username = g_strdup (g_value_get_string (value));
712 shout2send->ispublic = g_value_get_boolean (value);
714 case ARG_STREAMNAME: /* Name of the stream */
715 if (shout2send->streamname)
716 g_free (shout2send->streamname);
717 shout2send->streamname = g_strdup (g_value_get_string (value));
719 case ARG_DESCRIPTION: /* Description of the stream */
720 if (shout2send->description)
721 g_free (shout2send->description);
722 shout2send->description = g_strdup (g_value_get_string (value));
724 case ARG_GENRE: /* Genre of the stream */
725 if (shout2send->genre)
726 g_free (shout2send->genre);
727 shout2send->genre = g_strdup (g_value_get_string (value));
729 case ARG_PROTOCOL: /* protocol to connect with */
730 shout2send->protocol = g_value_get_enum (value);
732 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
733 if (shout2send->mount)
734 g_free (shout2send->mount);
735 shout2send->mount = g_strdup (g_value_get_string (value));
737 case ARG_URL: /* Url of the stream (I'm guessing) */
739 g_free (shout2send->url);
740 shout2send->url = g_strdup (g_value_get_string (value));
743 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
749 gst_shout2send_get_property (GObject * object, guint prop_id,
750 GValue * value, GParamSpec * pspec)
752 GstShout2send *shout2send;
754 shout2send = GST_SHOUT2SEND (object);
758 g_value_set_string (value, shout2send->ip);
761 g_value_set_int (value, shout2send->port);
764 g_value_set_string (value, shout2send->password);
767 g_value_set_string (value, shout2send->username);
770 g_value_set_boolean (value, shout2send->ispublic);
772 case ARG_STREAMNAME: /* Name of the stream */
773 g_value_set_string (value, shout2send->streamname);
775 case ARG_DESCRIPTION: /* Description of the stream */
776 g_value_set_string (value, shout2send->description);
778 case ARG_GENRE: /* Genre of the stream */
779 g_value_set_string (value, shout2send->genre);
781 case ARG_PROTOCOL: /* protocol to connect with */
782 g_value_set_enum (value, shout2send->protocol);
784 case ARG_MOUNT: /* mountpoint of stream (icecast only) */
785 g_value_set_string (value, shout2send->mount);
787 case ARG_URL: /* Url of stream (I'm guessing) */
788 g_value_set_string (value, shout2send->url);
791 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
797 gst_shout2send_setcaps (GstPad * pad, GstCaps * caps)
799 const gchar *mimetype;
800 GstShout2send *shout2send;
803 shout2send = GST_SHOUT2SEND (GST_OBJECT_PARENT (pad));
805 mimetype = gst_structure_get_name (gst_caps_get_structure (caps, 0));
807 GST_DEBUG_OBJECT (shout2send, "mimetype of caps given is: %s", mimetype);
809 if (!strcmp (mimetype, "audio/mpeg")) {
810 shout2send->audio_format = SHOUT_FORMAT_MP3;
811 } else if (!strcmp (mimetype, "application/ogg")) {
812 shout2send->audio_format = SHOUT_FORMAT_VORBIS;
821 plugin_init (GstPlugin * plugin)
824 setlocale (LC_ALL, "");
825 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
826 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
827 #endif /* ENABLE_NLS */
829 return gst_element_register (plugin, "shout2send", GST_RANK_NONE,
830 GST_TYPE_SHOUT2SEND);
833 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
836 "Sends data to an icecast server using libshout2",
838 VERSION, "LGPL", "libshout2", "http://www.icecast.org/download.html")