[Pkg-voip-commits] [janus] 24/163: Added placeholder code for simulcasting in RecordPlay and SIP plugins

Jonas Smedegaard dr at jones.dk
Sat Oct 28 01:22:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.2.5-1
in repository janus.

commit 7013506ca1ad5402ddc4f64d1f0c0649c36bc99f
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Tue Jul 11 14:36:05 2017 +0200

    Added placeholder code for simulcasting in RecordPlay and SIP plugins
---
 plugins/janus_recordplay.c | 17 +++++++++++++++++
 plugins/janus_sip.c        | 25 +++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/plugins/janus_recordplay.c b/plugins/janus_recordplay.c
index 02cd7dd..5ba9388 100644
--- a/plugins/janus_recordplay.c
+++ b/plugins/janus_recordplay.c
@@ -404,6 +404,7 @@ typedef struct janus_recordplay_session {
 	guint video_keyframe_interval; /* keyframe request interval (ms) */
 	guint64 video_keyframe_request_last; /* timestamp of last keyframe request sent */
 	gint video_fir_seq;
+	guint32 simulcast_ssrc;	/* We don't support Simulcast in this plugin, so we'll stick to the base substream */
 	volatile gint hangingup;
 	gint64 destroyed;	/* Time at which this session was marked as destroyed */
 } janus_recordplay_session;
@@ -951,6 +952,15 @@ void janus_recordplay_incoming_rtp(janus_plugin_session *handle, int video, char
 		}
 		if(session->destroyed)
 			return;
+		if(video && session->simulcast_ssrc) {
+			/* The user is simulcasting: drop everything except the base layer */
+			rtp_header *header = (rtp_header *)buf;
+			uint32_t ssrc = ntohl(header->ssrc);
+			if(ssrc != session->simulcast_ssrc) {
+				JANUS_LOG(LOG_DBG, "Dropping packet (not base simulcast substream)\n");
+				return;
+			}
+		}
 		/* Are we recording? */
 		if(session->recorder) {
 			janus_recorder_save_frame(video ? session->vrc : session->arc, buf, len);
@@ -1005,6 +1015,7 @@ void janus_recordplay_hangup_media(janus_plugin_session *handle) {
 		return;
 	if(g_atomic_int_add(&session->hangingup, 1))
 		return;
+	session->simulcast_ssrc = 0;
 
 	/* Send an event to the browser and tell it's over */
 	json_t *event = json_object();
@@ -1172,6 +1183,12 @@ static void *janus_recordplay_handler(void *data) {
 			janus_sdp_free(offer);
 			janus_sdp_free(answer);
 			JANUS_LOG(LOG_VERB, "Going to answer this SDP:\n%s\n", sdp);
+			/* If the user negotiated simulcasting, just stick with the base substream */
+			json_t *msg_simulcast = json_object_get(msg->jsep, "simulcast");
+			if(msg_simulcast) {
+				JANUS_LOG(LOG_WARN, "Recording client negotiated simulcasting, falling back to base substream...\n");
+				session->simulcast_ssrc = json_integer_value(json_object_get(msg_simulcast, "ssrc-0"));
+			}
 			/* Done! */
 			result = json_object();
 			json_object_set_new(result, "status", json_string("recording"));
diff --git a/plugins/janus_sip.c b/plugins/janus_sip.c
index 9fdcac1..e38edca 100644
--- a/plugins/janus_sip.c
+++ b/plugins/janus_sip.c
@@ -333,6 +333,7 @@ typedef struct janus_sip_media {
 	int local_video_rtp_port, remote_video_rtp_port;
 	int local_video_rtcp_port, remote_video_rtcp_port;
 	guint32 video_ssrc, video_ssrc_peer;
+	guint32 simulcast_ssrc;
 	int video_pt;
 	const char *video_pt_name;
 	srtp_t video_srtp_in, video_srtp_out;
@@ -1007,6 +1008,7 @@ void janus_sip_create_session(janus_plugin_session *handle, int *error) {
 	session->media.remote_video_rtcp_port = 0;
 	session->media.video_ssrc = 0;
 	session->media.video_ssrc_peer = 0;
+	session->media.simulcast_ssrc = 0;
 	session->media.video_pt = -1;
 	session->media.video_pt_name = NULL;
 	session->media.video_srtp_suite_in = 0;
@@ -1147,6 +1149,15 @@ void janus_sip_incoming_rtp(janus_plugin_session *handle, int video, char *buf,
 				/* Dropping video packet, peer doesn't want to receive it */
 				return;
 			}
+			if(session->media.simulcast_ssrc) {
+				/* The user is simulcasting: drop everything except the base layer */
+				rtp_header *header = (rtp_header *)buf;
+				uint32_t ssrc = ntohl(header->ssrc);
+				if(ssrc != session->media.simulcast_ssrc) {
+					JANUS_LOG(LOG_DBG, "Dropping packet (not base simulcast substream)\n");
+					return;
+				}
+			}
 			if(session->media.video_ssrc == 0) {
 				rtp_header *header = (rtp_header *)buf;
 				session->media.video_ssrc = ntohl(header->ssrc);
@@ -1291,6 +1302,7 @@ void janus_sip_hangup_media(janus_plugin_session *handle) {
 		return;
 	if(g_atomic_int_add(&session->hangingup, 1))
 		return;
+	session->media.simulcast_ssrc = 0;
 	if(!(session->status == janus_sip_call_status_inviting ||
 		 session->status == janus_sip_call_status_invited ||
 		 session->status == janus_sip_call_status_incall))
@@ -1908,6 +1920,12 @@ static void *janus_sip_handler(void *data) {
 				json_object_set_new(info, "sdp", json_string(sdp));
 				gateway->notify_event(&janus_sip_plugin, session->handle, info);
 			}
+			/* If the user negotiated simulcasting, just stick with the base substream */
+			json_t *msg_simulcast = json_object_get(msg->jsep, "simulcast");
+			if(msg_simulcast) {
+				JANUS_LOG(LOG_WARN, "Client negotiated simulcasting, falling back to base substream...\n");
+				session->media.simulcast_ssrc = json_integer_value(json_object_get(msg_simulcast, "ssrc-0"));
+			}
 			/* Send INVITE */
 			session->callee = g_strdup(uri_text);
 			session->callid = g_strdup(callid);
@@ -2040,6 +2058,12 @@ static void *janus_sip_handler(void *data) {
 			janus_sdp_free(session->sdp);
 			session->sdp = parsed_sdp;
 			JANUS_LOG(LOG_VERB, "Prepared SDP for 200 OK:\n%s", sdp);
+			/* If the user negotiated simulcasting, just stick with the base substream */
+			json_t *msg_simulcast = json_object_get(msg->jsep, "simulcast");
+			if(msg_simulcast) {
+				JANUS_LOG(LOG_WARN, "Client negotiated simulcasting, falling back to base substream...\n");
+				session->media.simulcast_ssrc = json_integer_value(json_object_get(msg_simulcast, "ssrc-0"));
+			}
 			/* Also notify event handlers */
 			if(notify_events && gateway->events_is_enabled()) {
 				json_t *info = json_object();
@@ -3867,6 +3891,7 @@ static void *janus_sip_relay_thread(void *data) {
 	session->media.local_video_rtp_port = 0;
 	session->media.local_video_rtcp_port = 0;
 	session->media.video_ssrc = 0;
+	session->media.simulcast_ssrc = 0;
 	if(session->media.pipefd[0] > 0) {
 		close(session->media.pipefd[0]);
 		session->media.pipefd[0] = -1;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git



More information about the Pkg-voip-commits mailing list