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 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/pipelines.c') 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)) -- cgit v1.2.3