From 0cc548592de9611655f4c680d56ce73bcb38ab9a Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 6 Oct 2014 23:08:13 +0200 Subject: closing application when new SSRC shows up (although all depayloader are already connected) closing application when session times out --- src/pipelines.c | 32 +++++++++++++++++++++++++++++++- src/sydra-rtp.c | 12 ++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/pipelines.c b/src/pipelines.c index 55054f8..c08c11f 100644 --- a/src/pipelines.c +++ b/src/pipelines.c @@ -496,11 +496,39 @@ static void rtpbin_pad_added(GstElement* rtp, GstPad* pad, gpointer user_data) break; } if(!gst_pad_is_linked(pad)) { - log_printf(ERROR, "rtpbin: no compatible depayloader found for pad %s", src_pad_name); + log_printf(ERROR, "rtpbin: no compatible depayloader found for pad %s (or all depayloader already connected)", src_pad_name); + GstStructure* ms = gst_structure_new("sydra-rtp", "quit", G_TYPE_BOOLEAN, TRUE, "reason", + G_TYPE_STRING, "New RTP Session but all depayloader are already connected or none compatible found", NULL); + GstMessage* msg = gst_message_new_application(GST_OBJECT(rtp), ms); + if(!ms || ! msg) + log_printf(ERROR, "rtpbin: message creation failed!"); + else { + if(!gst_element_post_message(rtp, msg)) + log_printf(ERROR, "rtpbin: sending message to the application failed: no bus"); + } } g_free(src_pad_name); } +static void rtp_new_ssrc(GstElement *rtp, guint session, guint ssrc, gpointer user_data) +{ + log_printf(INFO, "rtpbin: new SSRC %u for session %u", ssrc, session); +} + +static void rtp_ssrc_timeout(GstElement *rtp, guint session, guint ssrc, gpointer user_data) +{ + log_printf(INFO, "rtpbin: SSRC %u of session %u timed out", ssrc, session); + GstStructure* ms = gst_structure_new("sydra-rtp", "quit", G_TYPE_BOOLEAN, TRUE, "reason", + G_TYPE_STRING, "RTP session timed out", NULL); + GstMessage* msg = gst_message_new_application(GST_OBJECT(rtp), ms); + if(!ms || ! msg) + log_printf(ERROR, "rtpbin: message creation failed!"); + else { + if(!gst_element_post_message(rtp, msg)) + log_printf(ERROR, "rtpbin: sending message to the application failed: no bus"); + } +} + GstElement* create_receiver_pipeline(options_t* opt, struct udp_sources *udp) { GstElement *pipeline = gst_pipeline_new ("sydra-rtp-receiver"); @@ -531,6 +559,8 @@ GstElement* create_receiver_pipeline(options_t* opt, struct udp_sources *udp) depays[0] = video.payloader_; depays[1] = audio.payloader_; g_signal_connect_closure(rtp, "pad-added", g_cclosure_new(G_CALLBACK(rtpbin_pad_added), depays, NULL), FALSE); + g_signal_connect(rtp, "on-new-ssrc", G_CALLBACK(rtp_new_ssrc), NULL); + g_signal_connect(rtp, "on-timeout", G_CALLBACK(rtp_ssrc_timeout), NULL); if(opt->rec_mux_) { if(!create_recorder_elements(opt, pipeline, &video, &audio)) diff --git a/src/sydra-rtp.c b/src/sydra-rtp.c index de65e25..dc6c3c7 100644 --- a/src/sydra-rtp.c +++ b/src/sydra-rtp.c @@ -72,6 +72,18 @@ static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) g_main_loop_quit(loop); break; } + case GST_MESSAGE_APPLICATION: { + log_printf(DEBUG, "Got Application Message!"); + const GstStructure* ms = gst_message_get_structure(msg); + gboolean quit; + gst_structure_get_boolean(ms, "quit", &quit); + if(quit) { + const gchar* reason = gst_structure_get_string (ms, "reason"); + log_printf(NOTICE, "closing due to message: %s", reason); + g_main_loop_quit(loop); + } + break; + } case GST_MESSAGE_INFO: { GError *info; gst_message_parse_info(msg, &info, NULL); -- cgit v1.2.3