Created
December 22, 2023 05:40
-
-
Save rajneeshksoni/3e250eeabb213064dd2884892acdcd4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 00dd5d443ff11f29489ea8a580803818ad440005 Mon Sep 17 00:00:00 2001 | |
From: Arun Raghavan <arun@asymptotic.io> | |
Date: Mon, 9 Jan 2023 21:17:27 -0500 | |
Subject: [PATCH 2/3] webrtcbin: Fix default value when SDP direction is unspecified | |
According to RFC 4566 (section 6), if sendrecv/sendonly/recvonly are not | |
specified, the default is sendrecv, except for broadcast and H332 conference | |
types. | |
--- | |
.../gst-plugins-bad/ext/webrtc/webrtcsdp.c | 26 ++++++++++++++----- | |
1 file changed, 20 insertions(+), 6 deletions(-) | |
diff --git a/subprojects/gst-plugins-bad/ext/webrtc/webrtcsdp.c b/subprojects/gst-plugins-bad/ext/webrtc/webrtcsdp.c | |
index 82a7c5fc79..4f0f07a0d9 100644 | |
--- a/subprojects/gst-plugins-bad/ext/webrtc/webrtcsdp.c | |
+++ b/subprojects/gst-plugins-bad/ext/webrtc/webrtcsdp.c | |
@@ -348,50 +348,64 @@ validate_sdp (GstWebRTCSignalingState state, SDPSource source, | |
fail: | |
g_strfreev (group_members); | |
return FALSE; | |
} | |
GstWebRTCRTPTransceiverDirection | |
_get_direction_from_media (const GstSDPMedia * media) | |
{ | |
- GstWebRTCRTPTransceiverDirection new_dir = | |
- GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE; | |
+ GstWebRTCRTPTransceiverDirection new_dir; | |
int i; | |
+ gboolean have_direction = FALSE, default_recvonly = FALSE; | |
for (i = 0; i < gst_sdp_media_attributes_len (media); i++) { | |
const GstSDPAttribute *attr = gst_sdp_media_get_attribute (media, i); | |
if (g_strcmp0 (attr->key, "sendonly") == 0) { | |
- if (new_dir != GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE) { | |
+ if (have_direction) { | |
GST_ERROR ("Multiple direction attributes"); | |
return GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE; | |
} | |
new_dir = GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDONLY; | |
+ have_direction = TRUE; | |
} else if (g_strcmp0 (attr->key, "sendrecv") == 0) { | |
- if (new_dir != GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE) { | |
+ if (have_direction) { | |
GST_ERROR ("Multiple direction attributes"); | |
return GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE; | |
} | |
new_dir = GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV; | |
+ have_direction = TRUE; | |
} else if (g_strcmp0 (attr->key, "recvonly") == 0) { | |
- if (new_dir != GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE) { | |
+ if (have_direction) { | |
GST_ERROR ("Multiple direction attributes"); | |
return GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE; | |
} | |
new_dir = GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY; | |
+ have_direction = TRUE; | |
} else if (g_strcmp0 (attr->key, "inactive") == 0) { | |
- if (new_dir != GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE) { | |
+ if (have_direction) { | |
GST_ERROR ("Multiple direction attributes"); | |
return GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE; | |
} | |
new_dir = GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_INACTIVE; | |
+ have_direction = TRUE; | |
+ } else if (g_str_has_prefix (attr->key, "type:") == 0) { | |
+ if (g_strcmp0 (&attr->key[5], "H332") == 0 || | |
+ g_strcmp0 (&attr->key[5], "broadcast") == 0) { | |
+ default_recvonly = TRUE; | |
+ } | |
} | |
} | |
+ if (!have_direction) { | |
+ new_dir = default_recvonly ? GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY : | |
+ GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV; | |
+ } | |
+ | |
return new_dir; | |
} | |
#define DIR(val) GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_ ## val | |
GstWebRTCRTPTransceiverDirection | |
_intersect_answer_directions (GstWebRTCRTPTransceiverDirection offer, | |
GstWebRTCRTPTransceiverDirection answer) | |
{ | |
-- | |
2.41.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment