Icecast reconnect

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Icecast reconnect

bomba
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?
Reply | Threaded
Open this post in threaded view
|

Re: Icecast reconnect

bomba
The shout2send element description at

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-shout2send.html

says:

The “connection-problem” signal
void user_function (GstShout2send *gstshout2send, gint arg1, gpointer user_data)

So I guess my callback:
void on_connection_problem (STREAM_INFO * si)

wont work. How should it be written?
Reply | Threaded
Open this post in threaded view
|

Re: Icecast reconnect

saepia
It should not behave like this. You should get an error message on the bus. What GStreamer version are you using?

m.

2016-07-05 14:53 GMT+02:00 bomba <[hidden email]>:
The shout2send element description at

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-shout2send.html

says:

The “connection-problem” signal
void user_function (GstShout2send *gstshout2send, gint arg1, gpointer
user_data)

So I guess my callback:
void on_connection_problem (STREAM_INFO * si)

wont work. How should it be written?



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Icecast-reconnect-tp4678417p4678418.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Icecast reconnect

bomba
This post was updated on .
saepia wrote
It should not behave like this. You should get an error message on the bus.
GStreamer 1.8.1


I've managed to catch the signal when trying to reach an unreacheable server - not when losing an already estabilished connection.

Still not satisfied
Reply | Threaded
Open this post in threaded view
|

Re: Icecast reconnect

saepia
Hm strange, I think you have to share more code, preferably using gist.github.com or service like this

m.

2016-07-08 11:27 GMT+02:00 bomba <[hidden email]>:
GStreamer 1.8.1




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Icecast-reconnect-tp4678417p4678528.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Icecast reconnect

bomba
https://gist.github.com/anonymous/dbfdb78aa79b25dea0bcfd0cdcb17c3f

Here you can take a look at my code. I've been cleaning up the non-working signal handler.
The behaviour of the code I'm posting is:

- Fails to connect if can't reach Icecast server (OK)
- Stalls if the connection is lost (absolutely not OK)

My question is: how to get notified when the connection to icecast server is not working anymore, how to try to reconnect.
Reply | Threaded
Open this post in threaded view
|

Re: Icecast reconnect

saepia

Does this happen both when you use filesrc and alsasrc? (both ways are mentioned in the code)

M.

11.07.2016 11:07 AM "bomba" <[hidden email]> napisał(a):
https://gist.github.com/anonymous/dbfdb78aa79b25dea0bcfd0cdcb17c3f

Here you can take a look at my code. I've been cleaning up the non-working
signal handler.
The behaviour of the code I'm posting is:

- Fails to connect if can't reach Icecast server (OK)
- Stalls if the connection is lost (absolutely not OK)

My question is: how to get notified when the connection to icecast server is
not working anymore, how to try to reconnect.



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Icecast-reconnect-tp4678417p4678590.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Icecast reconnect

bomba
saepia wrote
Does this happen both when you use filesrc and alsasrc? (both ways are
mentioned in the code
Yes, both of sources