[Asterisk-code-review] added send_rtcp_nack setting to decouple avpf signalling from webrtc ... (asterisk[18.11])

Camillo Toselli asteriskteam at digium.com
Wed Nov 2 09:32:13 CDT 2022


Camillo Toselli has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19467 )


Change subject: added send_rtcp_nack setting to decouple avpf signalling from webrtc setting
......................................................................

added send_rtcp_nack setting to decouple avpf signalling from webrtc setting

Change-Id: I5d855494a2ad00eac82f18e80d2fae5418c4cdbe
---
M channels/chan_pjsip.c
M configs/samples/pjsip.conf.sample
M contrib/realtime/mysql/mysql_config.sql
M contrib/realtime/postgresql/postgresql_config.sql
M include/asterisk/res_pjsip.h
M res/res_pjsip/pjsip_config.xml
M res/res_pjsip/pjsip_configuration.c
M res/res_pjsip_sdp_rtp.c
8 files changed, 37 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/67/19467/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index e8fbb3d..87a85e4 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1697,7 +1697,7 @@
 				if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), ast_format_vp8) != AST_FORMAT_CMP_NOT_EQUAL ||
 					ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), ast_format_vp9) != AST_FORMAT_CMP_NOT_EQUAL ||
 					ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), ast_format_h265) != AST_FORMAT_CMP_NOT_EQUAL ||
-					(channel->session->endpoint->media.webrtc &&
+					((channel->session->endpoint->media.webrtc || channel->session->endpoint->media.send_rtcp_nack) &&
 					 ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), ast_format_h264) != AST_FORMAT_CMP_NOT_EQUAL)) {
 					/* FIXME Fake RTP write, this will be sent as an RTCP packet. Ideally the
 					 * RTP engine would provide a way to externally write/schedule RTCP
diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample
index b1c1657..1e31714 100644
--- a/configs/samples/pjsip.conf.sample
+++ b/configs/samples/pjsip.conf.sample
@@ -874,6 +874,7 @@
          ;     dtls_setup=actpass
          ; A dtls_cert_file and a dtls_ca_file still need to be specified.
          ; Default for this option is "no"
+;send_rtcp_nack= ; When set to "yes" enables rtcp nack passthrough in avpf to keep video streams synchronized
 ;incoming_mwi_mailbox = ; Mailbox name to use when incoming MWI NOTIFYs are
                         ; received.
                         ; If an MWI NOTIFY is received FROM this endpoint,
diff --git a/contrib/realtime/mysql/mysql_config.sql b/contrib/realtime/mysql/mysql_config.sql
index 67482a6..807afeb 100644
--- a/contrib/realtime/mysql/mysql_config.sql
+++ b/contrib/realtime/mysql/mysql_config.sql
@@ -1334,3 +1334,8 @@
 
 UPDATE alembic_version SET version_num='8f72185e437f' WHERE alembic_version.version_num = 'a06d8f8462d9';
 
+-- Running upgrade 8f72185e437f -> 33cccfd113cc
+
+ALTER TABLE ps_endpoints ADD COLUMN send_rtcp_nack ENUM('yes','no');
+
+UPDATE alembic_version SET version_num='33cccfd113cc' WHERE alembic_version.version_num = '8f72185e437f';
\ No newline at end of file
diff --git a/contrib/realtime/postgresql/postgresql_config.sql b/contrib/realtime/postgresql/postgresql_config.sql
index 293a4f9..460cef7 100644
--- a/contrib/realtime/postgresql/postgresql_config.sql
+++ b/contrib/realtime/postgresql/postgresql_config.sql
@@ -1446,3 +1446,8 @@
 
 COMMIT;
 
+-- Running upgrade 8f72185e437f -> 33cccfd113cc
+
+ALTER TABLE ps_endpoints ADD COLUMN send_rtcp_nack yesno_values;
+
+UPDATE alembic_version SET version_num='33cccfd113cc' WHERE alembic_version.version_num = '8f72185e437f';
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 209cdbf..e6b3598 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -834,6 +834,8 @@
 	unsigned int bundle;
 	/*! Enable webrtc settings and defaults */
 	unsigned int webrtc;
+	/*! Enable rtcp nack passthrough */
+	unsigned int send_rtcp_nack;
 	/*! Codec preference for an incoming offer */
 	struct ast_flags incoming_call_offer_pref;
 	/*! Codec preference for an outgoing offer */
diff --git a/res/res_pjsip/pjsip_config.xml b/res/res_pjsip/pjsip_config.xml
index ca5a266..d7f8cc0 100644
--- a/res/res_pjsip/pjsip_config.xml
+++ b/res/res_pjsip/pjsip_config.xml
@@ -1360,6 +1360,12 @@
 						<para>dtls_setup=actpass</para>
 					</description>
 				</configOption>
+				<configOption name="send_rtcp_nack" default="no">
+					<synopsis>Enable sending RTCP NACKs</synopsis>
+					<description><para>
+						When set to "yes" enables rtcp nack passthrough in avpf to keep video streams synchronized</para>
+					</description>
+				</configOption>
 				<configOption name="incoming_mwi_mailbox">
 					<synopsis>Mailbox name to use when incoming MWI NOTIFYs are received</synopsis>
 					<description><para>
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 39c3dab..975b8d8 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -2170,6 +2170,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "max_video_streams", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.max_video_streams));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "bundle", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.bundle));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "webrtc", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, media.webrtc));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_rtcp_nack", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, media.send_rtcp_nack));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "incoming_mwi_mailbox", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, incoming_mwi_mailbox));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "follow_early_media_fork", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.follow_early_media_fork));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "accept_multiple_sdp_answers", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.accept_multiple_sdp_answers));
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index e1d1701..0dbacc7 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -294,10 +294,10 @@
 		ast_rtp_instance_set_qos(session_media->rtp, session->endpoint->media.tos_audio,
 				session->endpoint->media.cos_audio, "SIP RTP Audio");
 	} else if (session_media->type == AST_MEDIA_TYPE_VIDEO) {
-		ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_RETRANS_RECV, session->endpoint->media.webrtc);
-		ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_RETRANS_SEND, session->endpoint->media.webrtc);
-		ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_REMB, session->endpoint->media.webrtc);
-		if (session->endpoint->media.webrtc) {
+		ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_RETRANS_RECV, session->endpoint->media.webrtc || session->endpoint->media.send_rtcp_nack);
+		ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_RETRANS_SEND, session->endpoint->media.webrtc || session->endpoint->media.send_rtcp_nack);
+		ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_REMB, session->endpoint->media.webrtc || session->endpoint->media.send_rtcp_nack);
+		if (session->endpoint->media.webrtc || session->endpoint->media.send_rtcp_nack) {
 			enable_rtp_extension(session, session_media, AST_RTP_EXTENSION_ABS_SEND_TIME, AST_RTP_EXTENSION_DIRECTION_SENDRECV, sdp);
 			enable_rtp_extension(session, session_media, AST_RTP_EXTENSION_TRANSPORT_WIDE_CC, AST_RTP_EXTENSION_DIRECTION_SENDRECV, sdp);
 		}
@@ -1329,7 +1329,7 @@
 	pj_str_t stmp;
 	pjmedia_sdp_attr *attr;
 
-	if (!session->endpoint->media.webrtc) {
+	if (!(session->endpoint->media.webrtc || session->endpoint->media.send_rtcp_nack)) {
 		return;
 	}
 
@@ -1364,7 +1364,7 @@
 	int idx;
 	char extmap_value[256];
 
-	if (!session->endpoint->media.webrtc || session_media->type != AST_MEDIA_TYPE_VIDEO) {
+	if (!(session->endpoint->media.webrtc || session->endpoint->media.send_rtcp_nack) || session_media->type != AST_MEDIA_TYPE_VIDEO) {
 		return;
 	}
 
@@ -1413,7 +1413,7 @@
 {
 	int index;
 
-	if (!session->endpoint->media.webrtc || session_media->type != AST_MEDIA_TYPE_VIDEO) {
+	if (!(session->endpoint->media.webrtc || session->endpoint->media.send_rtcp_nack) || session_media->type != AST_MEDIA_TYPE_VIDEO) {
 		return;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19467
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18.11
Gerrit-Change-Id: I5d855494a2ad00eac82f18e80d2fae5418c4cdbe
Gerrit-Change-Number: 19467
Gerrit-PatchSet: 1
Gerrit-Owner: Camillo Toselli <camillo.toselli at unibo.it>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221102/94ca1307/attachment.html>


More information about the asterisk-code-review mailing list