Icecast reconnect
bomba
jhonata.poma at gmail.com
Tue Jul 5 11:17:18 UTC 2016
Hello,
I'm trying to stream to an Icecast server using shout2send element.
It works pretty nice but, if the connection goes down, the pipeline stalls
without trying to reconnect.
Digging into the element specs, I've found "connection-problem" signal which
would give an advice if the server
could not be reached. With that in mind, I've implemented this callback
function:
GstElement
*new_save_bin (GstElement * shout2send, gchar * hostname)
{
GstElement *bin;
GstElement *oggmux;
GstPad *pad;
gchar *mount;
mount = g_strdup_printf("%s.ogg", hostname);
bin = my_gst_bin_new ("savebin");
oggmux = my_gst_element_factory_make ("oggmux", "oggmux");
g_object_set (G_OBJECT (shout2send), "ip", SRV_ADDRESS, NULL);
g_object_set (G_OBJECT (shout2send), "port", SRV_PORT, NULL);
g_object_set (G_OBJECT (shout2send), "password", SRV_PASSWORD,
NULL);
g_object_set (G_OBJECT (shout2send), "mount", mount, NULL);
gst_bin_add_many (GST_BIN(bin), oggmux, shout2send, NULL);
gst_element_link_many (oggmux, shout2send, NULL);
pad = my_gst_element_get_request_pad (oggmux, "audio_%u");
gst_element_add_pad (bin, gst_ghost_pad_new ("audio_sink", pad));
gst_object_unref (GST_OBJECT (pad));
return bin;
}
void
on_connection_problem (STREAM_INFO * si)
{
gboolean connected = FALSE;
gst_element_set_state (si->savebin, GST_STATE_NULL);
gst_bin_remove (GST_BIN (si->pipeline), si->savebin);
do
{
si->savebin = new_save_bin (si->shout2send, si->hostname);
if (si->savebin) {
gst_bin_add (GST_BIN (si->pipeline), si->savebin);
gst_element_link (si->queue, si->savebin);
gst_element_set_state (si->savebin,
GST_STATE_PLAYING);
connected = TRUE;
g_print ("Reconnected.\n");
}
else
{
g_printerr ("Can't connect to Icecast server,
retrying in %d\"\n", RETRY_SECONDS);
sleep (RETRY_SECONDS);
}
} while (!connected);
}
int
main (int argc, char *argv[])
{
[..]
g_signal_connect (si.shout2send, "connection-problem", G_CALLBACK
(on_connection_problem), &si);
But with no chance to catch the signal.
Any thoughts?
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Icecast-reconnect-tp4678417.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list