2002-03-20 21:45:04 +00:00
|
|
|
/* GStreamer
|
2001-12-23 15:24:07 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-23 15:24:07 +00:00
|
|
|
#include "gstshout.h"
|
|
|
|
|
|
|
|
static char *SHOUT_ERRORS[] = {
|
|
|
|
"ok",
|
|
|
|
"insane",
|
|
|
|
"could not connect",
|
|
|
|
"could not login",
|
|
|
|
"socket error",
|
|
|
|
"could not allocate memory",
|
|
|
|
"metadata error",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IcecastSend signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 15:24:07 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 15:24:07 +00:00
|
|
|
ARG_0,
|
2004-03-15 19:32:27 +00:00
|
|
|
ARG_IP, /* the ip of the server */
|
|
|
|
ARG_PORT, /* the encoder port number on the server */
|
|
|
|
ARG_PASSWORD, /* the encoder password on the server */
|
|
|
|
ARG_PUBLIC, /* is this stream public? */
|
|
|
|
ARG_NAME, /* Name of the stream */
|
|
|
|
ARG_DESCRIPTION, /* Description of the stream */
|
|
|
|
ARG_GENRE, /* Genre of the stream */
|
|
|
|
ARG_MOUNT, /* mountpoint of stream (icecast only) */
|
|
|
|
ARG_DUMPFILE, /* Dumpfile on the server for this stream (icecast only) */
|
|
|
|
ARG_ICY, /* use icy headers for login? (for use with shoutcast) */
|
|
|
|
ARG_AIM, /* AIM number (shoutcast only) */
|
|
|
|
ARG_ICQ, /* ICQ number (shoutcast only) */
|
2004-05-21 23:28:57 +00:00
|
|
|
ARG_IRC /* IRC server (shoutcast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
};
|
|
|
|
|
2004-01-06 20:42:03 +00:00
|
|
|
static GstStaticPadTemplate sink_template_factory =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/mpeg, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"mpegversion = (int) 1, " "layer = (int) [ 1, 3 ]")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_icecastsend_class_init (GstIcecastSendClass * klass);
|
|
|
|
static void gst_icecastsend_base_init (GstIcecastSendClass * klass);
|
|
|
|
static void gst_icecastsend_init (GstIcecastSend * icecastsend);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_icecastsend_chain (GstPad * pad, GstData * _data);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_icecastsend_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_icecastsend_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static
|
2005-09-05 17:20:29 +00:00
|
|
|
GstStateChangeReturn gst_icecastsend_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-03-19 04:10:06 +00:00
|
|
|
/*static guint gst_icecastsend_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
|
|
|
GType
|
2002-10-02 08:01:04 +00:00
|
|
|
gst_icecastsend_get_type (void)
|
2001-12-23 15:24:07 +00:00
|
|
|
{
|
|
|
|
static GType icecastsend_type = 0;
|
|
|
|
|
|
|
|
if (!icecastsend_type) {
|
|
|
|
static const GTypeInfo icecastsend_info = {
|
2003-11-02 14:32:08 +00:00
|
|
|
sizeof (GstIcecastSendClass),
|
2003-11-25 19:11:56 +00:00
|
|
|
(GBaseInitFunc) gst_icecastsend_base_init, NULL,
|
2002-10-02 08:01:04 +00:00
|
|
|
(GClassInitFunc) gst_icecastsend_class_init, NULL, NULL,
|
|
|
|
sizeof (GstIcecastSend), 0,
|
|
|
|
(GInstanceInitFunc) gst_icecastsend_init,
|
2001-12-23 15:24:07 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
icecastsend_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstIcecastSend",
|
|
|
|
&icecastsend_info, 0);
|
2001-12-23 15:24:07 +00:00
|
|
|
}
|
|
|
|
return icecastsend_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 14:32:08 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_icecastsend_base_init (GstIcecastSendClass * klass)
|
2003-11-02 14:32:08 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
2004-01-06 20:42:03 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&sink_template_factory));
|
2010-03-18 16:30:26 +00:00
|
|
|
gst_element_class_set_details_simple (element_class, "Icecast network sink",
|
|
|
|
"Sink/Network",
|
|
|
|
"Sends data to an icecast server using libshout",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>");
|
2003-11-02 14:32:08 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 15:24:07 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_icecastsend_class_init (GstIcecastSendClass * klass)
|
2001-12-23 15:24:07 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2006-04-08 21:48:01 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP, g_param_spec_string ("ip", "ip", "ip", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT, g_param_spec_int ("port", "port", "port", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PASSWORD, g_param_spec_string ("password", "password", "password", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PUBLIC, g_param_spec_boolean ("public", "public", "public", TRUE, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2002-03-19 04:10:06 +00:00
|
|
|
/* metadata */
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DESCRIPTION, g_param_spec_string ("description", "description", "description", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENRE, g_param_spec_string ("genre", "genre", "genre", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2002-03-19 04:10:06 +00:00
|
|
|
/* icecast only */
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOUNT, g_param_spec_string ("mount", "mount", "mount", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMPFILE, g_param_spec_string ("dumpfile", "dumpfile", "dumpfile", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2002-03-19 04:10:06 +00:00
|
|
|
/* shoutcast only */
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ICY, g_param_spec_boolean ("icy", "icy", "icy", FALSE, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_AIM, g_param_spec_string ("aim", "aim", "aim", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ICQ, g_param_spec_string ("icq", "icq", "icq", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IRC, g_param_spec_string ("irc", "irc", "irc", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2001-12-23 15:24:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_icecastsend_set_property;
|
|
|
|
gobject_class->get_property = gst_icecastsend_get_property;
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_icecastsend_change_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_icecastsend_init (GstIcecastSend * icecastsend)
|
2001-12-23 15:24:07 +00:00
|
|
|
{
|
2004-01-06 20:42:03 +00:00
|
|
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (icecastsend);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
icecastsend->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
2004-03-15 19:32:27 +00:00
|
|
|
"sink"), "sink");
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (icecastsend), icecastsend->sinkpad);
|
|
|
|
gst_pad_set_chain_function (icecastsend->sinkpad, gst_icecastsend_chain);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
|
|
|
icecastsend->ip = g_strdup ("127.0.0.1");
|
|
|
|
icecastsend->port = 8000;
|
|
|
|
icecastsend->password = g_strdup ("hackme");
|
|
|
|
icecastsend->public = TRUE;
|
|
|
|
icecastsend->name = g_strdup ("");
|
|
|
|
icecastsend->description = g_strdup ("");
|
|
|
|
icecastsend->genre = g_strdup ("");
|
|
|
|
icecastsend->mount = g_strdup ("");
|
|
|
|
icecastsend->dumpfile = g_strdup ("");
|
|
|
|
icecastsend->icy = FALSE;
|
|
|
|
icecastsend->aim = g_strdup ("");
|
|
|
|
icecastsend->icq = g_strdup ("");
|
|
|
|
icecastsend->irc = g_strdup ("");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_icecastsend_chain (GstPad * pad, GstData * _data)
|
2001-12-23 15:24:07 +00:00
|
|
|
{
|
2003-10-08 16:08:19 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2001-12-23 15:24:07 +00:00
|
|
|
GstIcecastSend *icecastsend;
|
|
|
|
glong ret;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (buf != NULL);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
|
|
|
icecastsend = GST_ICECASTSEND (GST_OBJECT_PARENT (pad));
|
|
|
|
|
|
|
|
g_return_if_fail (icecastsend != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ICECASTSEND (icecastsend));
|
|
|
|
|
|
|
|
ret = shout_send_data (&icecastsend->conn, GST_BUFFER_DATA (buf),
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_BUFFER_SIZE (buf));
|
2001-12-23 15:24:07 +00:00
|
|
|
if (!ret) {
|
|
|
|
g_warning ("send error: %i...\n", icecastsend->conn.error);
|
|
|
|
}
|
|
|
|
|
|
|
|
shout_sleep (&icecastsend->conn);
|
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_icecastsend_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2001-12-23 15:24:07 +00:00
|
|
|
{
|
|
|
|
GstIcecastSend *icecastsend;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_ICECASTSEND (object));
|
|
|
|
icecastsend = GST_ICECASTSEND (object);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_IP:
|
|
|
|
if (icecastsend->ip)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->ip);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->ip = g_strdup (g_value_get_string (value));
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
2001-12-23 15:24:07 +00:00
|
|
|
case ARG_PORT:
|
|
|
|
icecastsend->port = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_PASSWORD:
|
|
|
|
if (icecastsend->password)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->password);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->password = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_PUBLIC: /* is this stream public? */
|
2004-03-14 22:34:33 +00:00
|
|
|
icecastsend->public = g_value_get_boolean (value);
|
2001-12-23 15:24:07 +00:00
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_NAME: /* Name of the stream */
|
2001-12-23 15:24:07 +00:00
|
|
|
if (icecastsend->name)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->name);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->name = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_DESCRIPTION: /* Description of the stream */
|
2001-12-23 15:24:07 +00:00
|
|
|
if (icecastsend->description)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->description);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->description = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_GENRE: /* Genre of the stream */
|
2001-12-23 15:24:07 +00:00
|
|
|
if (icecastsend->genre)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->genre);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->genre = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_MOUNT: /* mountpoint of stream (icecast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
if (icecastsend->mount)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->mount);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->mount = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
if (icecastsend->dumpfile)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->dumpfile);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->dumpfile = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->icy = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_AIM: /* AIM number (shoutcast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
if (icecastsend->aim)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->aim);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->aim = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_ICQ: /* ICQ number (shoutcast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
if (icecastsend->icq)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->icq);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->icq = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_IRC: /* IRC server (shoutcast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
if (icecastsend->irc)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (icecastsend->irc);
|
2001-12-23 15:24:07 +00:00
|
|
|
icecastsend->irc = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_icecastsend_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-23 15:24:07 +00:00
|
|
|
{
|
|
|
|
GstIcecastSend *icecastsend;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_ICECASTSEND (object));
|
|
|
|
icecastsend = GST_ICECASTSEND (object);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_IP:
|
|
|
|
g_value_set_string (value, icecastsend->ip);
|
|
|
|
break;
|
|
|
|
case ARG_PORT:
|
|
|
|
g_value_set_int (value, icecastsend->port);
|
|
|
|
break;
|
|
|
|
case ARG_PASSWORD:
|
|
|
|
g_value_set_string (value, icecastsend->password);
|
|
|
|
break;
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_PUBLIC: /* is this stream public? */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_boolean (value, icecastsend->public);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_NAME: /* Name of the stream */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_string (value, icecastsend->name);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_DESCRIPTION: /* Description of the stream */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_string (value, icecastsend->description);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_GENRE: /* Genre of the stream */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_string (value, icecastsend->genre);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_MOUNT: /* mountpoint of stream (icecast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_string (value, icecastsend->mount);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_string (value, icecastsend->dumpfile);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_boolean (value, icecastsend->icy);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_AIM: /* AIM number (shoutcast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_string (value, icecastsend->aim);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_ICQ: /* ICQ number (shoutcast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_string (value, icecastsend->icq);
|
|
|
|
break;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case ARG_IRC: /* IRC server (shoutcast only) */
|
2001-12-23 15:24:07 +00:00
|
|
|
g_value_set_string (value, icecastsend->irc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_icecastsend_change_state (GstElement * element, GstStateChange transition)
|
2001-12-23 15:24:07 +00:00
|
|
|
{
|
|
|
|
GstIcecastSend *icecastsend;
|
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ICECASTSEND (element), GST_STATE_CHANGE_FAILURE);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
icecastsend = GST_ICECASTSEND (element);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
GST_DEBUG ("state pending %d", GST_STATE_PENDING (element));
|
2001-12-23 15:24:07 +00:00
|
|
|
|
|
|
|
/* if going down into NULL state, close the file if it's open */
|
2005-09-05 17:20:29 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
2004-03-14 22:34:33 +00:00
|
|
|
shout_init_connection (&icecastsend->conn);
|
|
|
|
|
|
|
|
/* --- FIXME: shout requires an ip, and fails if it is given a host. */
|
|
|
|
/* may want to put convert_to_ip(icecastsend->ip) here */
|
|
|
|
icecastsend->conn.ip = icecastsend->ip;
|
|
|
|
/* --- */
|
|
|
|
|
|
|
|
icecastsend->conn.port = icecastsend->port;
|
|
|
|
icecastsend->conn.password = icecastsend->password;
|
|
|
|
icecastsend->conn.ispublic = icecastsend->public;
|
|
|
|
icecastsend->conn.name = icecastsend->name;
|
|
|
|
icecastsend->conn.description = icecastsend->description;
|
|
|
|
icecastsend->conn.genre = icecastsend->genre;
|
|
|
|
icecastsend->conn.mount = icecastsend->mount;
|
|
|
|
icecastsend->conn.dumpfile = icecastsend->dumpfile;
|
|
|
|
icecastsend->conn.icy_compat = icecastsend->icy;
|
|
|
|
/* --- FIXME: libshout 1.0.5 doesn't have the two next fields */
|
|
|
|
/* icecastsend->conn.aim = icecastsend->aim;
|
|
|
|
icecastsend->conn.irc = icecastsend->irc; */
|
|
|
|
|
|
|
|
if (shout_connect (&icecastsend->conn)) {
|
2004-03-15 19:32:27 +00:00
|
|
|
g_print ("connected to server...\n");
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
g_warning ("couldn't connect to server... (%i: %s)\n",
|
|
|
|
icecastsend->conn.error, SHOUT_ERRORS[icecastsend->conn.error]);
|
|
|
|
shout_disconnect (&icecastsend->conn);
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-09-05 17:20:29 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2004-03-14 22:34:33 +00:00
|
|
|
shout_disconnect (&icecastsend->conn);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2001-12-23 15:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if we haven't failed already, give the parent class a chance to ;-) */
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2001-12-23 15:24:07 +00:00
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_SUCCESS;
|
2001-12-23 15:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-23 15:24:07 +00:00
|
|
|
{
|
2003-11-02 14:32:08 +00:00
|
|
|
return gst_element_register (plugin, "icecastsend",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_RANK_NONE, GST_TYPE_ICECASTSEND);
|
2001-12-23 15:24:07 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"icecastsend",
|
|
|
|
"Sends data to an icecast server using libshout",
|
2008-03-13 14:25:20 +00:00
|
|
|
plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|