From 94fba1fc353d6c96695720445303f2cbecffcafe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Mon, 23 Dec 2024 18:33:33 +0100 Subject: [PATCH 1/2] Rename attribute to a more accurate name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SDP constraints should be set when the MCU is used, but only for publisher connections; receiver connections should use the general SDP constraints. Signed-off-by: Daniel Calviño Sánchez --- .../com/nextcloud/talk/activities/CallActivity.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt index 3bcc7611b..ac5259bdd 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt @@ -204,7 +204,7 @@ class CallActivity : CallBaseActivity() { private var audioConstraints: MediaConstraints? = null private var videoConstraints: MediaConstraints? = null private var sdpConstraints: MediaConstraints? = null - private var sdpConstraintsForMCU: MediaConstraints? = null + private var sdpConstraintsForMCUPublisher: MediaConstraints? = null private var videoSource: VideoSource? = null private var localVideoTrack: VideoTrack? = null private var audioSource: AudioSource? = null @@ -809,7 +809,7 @@ class CallActivity : CallBaseActivity() { // create sdpConstraints sdpConstraints = MediaConstraints() - sdpConstraintsForMCU = MediaConstraints() + sdpConstraintsForMCUPublisher = MediaConstraints() sdpConstraints!!.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true")) var offerToReceiveVideoString = "true" if (isVoiceOnlyCall) { @@ -818,10 +818,10 @@ class CallActivity : CallBaseActivity() { sdpConstraints!!.mandatory.add( MediaConstraints.KeyValuePair("OfferToReceiveVideo", offerToReceiveVideoString) ) - sdpConstraintsForMCU!!.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveAudio", "false")) - sdpConstraintsForMCU!!.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveVideo", "false")) - sdpConstraintsForMCU!!.optional.add(MediaConstraints.KeyValuePair("internalSctpDataChannels", "true")) - sdpConstraintsForMCU!!.optional.add(MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")) + sdpConstraintsForMCUPublisher!!.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveAudio", "false")) + sdpConstraintsForMCUPublisher!!.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveVideo", "false")) + sdpConstraintsForMCUPublisher!!.optional.add(MediaConstraints.KeyValuePair("internalSctpDataChannels", "true")) + sdpConstraintsForMCUPublisher!!.optional.add(MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")) sdpConstraints!!.optional.add(MediaConstraints.KeyValuePair("internalSctpDataChannels", "true")) sdpConstraints!!.optional.add(MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")) if (!isVoiceOnlyCall) { @@ -2374,7 +2374,7 @@ class CallActivity : CallBaseActivity() { return PeerConnectionWrapper( peerConnectionFactory, iceServers, - sdpConstraintsForMCU, + sdpConstraintsForMCUPublisher, sessionId, callSession, tempLocalStream, From 7287a45907b53aaa724880617876c6d6c8ac87ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Mon, 23 Dec 2024 18:40:06 +0100 Subject: [PATCH 2/2] Fix SDP constraints used by PeerConnectionWrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SDP constraints for publisher connections when the MCU is used were set for all connections. Those constraints set "OfferToReceiveAudio" and "OfferToReceiveVideo" to false, which disables receiving audio and video when the local participant is the one sending the offer. Therefore, audio and video was not received when the MCU was not used and the local participant was the one initiating the connection. The "OfferToReceiveXXX" configurations have no effect when set on an answer (and thus are not even set, an empty MediaConstraints is used in that case). However, when "OfferToReceiveVideo = false" is set the video transceiver is explicitly stopped (which is used to avoid receiving video when joining a call with audio only). Therefore, as "OfferToReceiveVideo = false" was always set, video was never received in subscriber connections when the MCU is used, or connections initiated by the other peer when the MCU is not used. Signed-off-by: Daniel Calviño Sánchez --- .../main/java/com/nextcloud/talk/activities/CallActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt index ac5259bdd..84a746225 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt @@ -2350,18 +2350,22 @@ class CallActivity : CallBaseActivity() { sessionId: String?, type: String ): PeerConnectionWrapper { + val tempSdpConstraints: MediaConstraints? val tempIsMCUPublisher: Boolean val tempHasMCU: Boolean val tempLocalStream: MediaStream? if (hasMCU && publisher) { + tempSdpConstraints = sdpConstraintsForMCUPublisher tempIsMCUPublisher = true tempHasMCU = true tempLocalStream = localStream } else if (hasMCU) { + tempSdpConstraints = sdpConstraints tempIsMCUPublisher = false tempHasMCU = true tempLocalStream = null } else { + tempSdpConstraints = sdpConstraints tempIsMCUPublisher = false tempHasMCU = false tempLocalStream = if ("screen" != type) { @@ -2374,7 +2378,7 @@ class CallActivity : CallBaseActivity() { return PeerConnectionWrapper( peerConnectionFactory, iceServers, - sdpConstraintsForMCUPublisher, + tempSdpConstraints, sessionId, callSession, tempLocalStream,