From bad5b5f9bccae7f88eb533cf900094956487849f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Kr=C3=BCger?= Date: Thu, 20 Jan 2022 18:05:24 +0100 Subject: [PATCH] Update WebRTC library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The updated libwebrtc will be load from the talk-clients-webrtc repository [1] and not from a dependency repository. The 'lint' task must now depend on the 'perBuild' task to make sure that the WebRTC library is downloaded from the configured URL. To get the new version to work a change is needed because of this announcement: > Google is planning to transition Chrome’s WebRTC implementation from the > current SDP format (called “Plan B”) to a standards conformant format > (“Unified Plan”, draft-ietf-rtcweb-jsep) over the next couple of quarters. > > - [2] Currently we are in phase 4 of the transition [3]. So actually 'Plan B' must be used to avoid bigger changes to our code base at this time. But 'Plan B' is depracted and will be removed in phase 5 of the transition [4]. Resolves: #1773 See: - [1] https://github.com/nextcloud-releases/talk-clients-webrtc - [2] https://webrtc.org/getting-started/unified-plan-transition-guide - [3] https://webrtc.org/getting-started/unified-plan-transition-guide#phase_4_make_%E2%80%9Cplan_b%E2%80%9D_throw - [4] https://webrtc.org/getting-started/unified-plan-transition-guide#phase_5_remove_%E2%80%9Cplan_b%E2%80%9D Signed-off-by: Tim Krüger --- app/build.gradle | 20 ++++++++++++++++++- .../webrtc/MagicPeerConnectionWrapper.java | 9 ++++++--- scripts/analysis/lint-up.rb | 4 ++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 661bf3cce..6b894348c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,9 +4,11 @@ * @author Mario Danic * @author Andy Scherzinger * @author Marcel Hibbe + * @author Tim Krüger * Copyright (C) 2021 Andy Scherzinger * Copyright (C) 2017-2019 Mario Danic * Copyright (C) 2021 Marcel Hibbe + * Copyright (C) 2022 Tim Krüger * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +36,20 @@ configurations { ktlint } +def urlFile = { url, fileName -> + File file = new File("$buildDir/download/${fileName}") + file.parentFile.mkdirs() + if (!file.exists()) { + new URL(url).withInputStream { downloadStream -> + file.withOutputStream { fileOut -> + fileOut << downloadStream + } + } + } + files(file.absolutePath) +} + + android { compileSdkVersion 30 buildToolsVersion '30.0.3' @@ -134,6 +150,7 @@ android { } check.dependsOn 'spotbugsGplayDebugReport', 'lint', 'ktlint', 'detekt' + lint.dependsOn 'preBuild' compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -240,7 +257,8 @@ dependencies { kapt "com.jakewharton:butterknife-compiler:${butterknifeVersion}" implementation 'eu.davidea:flexible-adapter:5.1.0' implementation 'eu.davidea:flexible-adapter-ui:1.0.0' - implementation 'org.webrtc:google-webrtc:1.0.32006' + implementation urlFile('https://github.com/nextcloud-releases/talk-clients-webrtc/releases/download/96.4664.0-RC1/libwebrtc-96.4664.0.aar', + 'libwebrtc-96.4664.0.aar') implementation 'com.yarolegovich:lovely-dialog:1.1.1' implementation 'com.yarolegovich:mp:1.1.6' implementation 'me.zhanghai.android.effortlesspermissions:library:1.1.0' diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java index 4d29af22b..f9467d809 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java @@ -105,9 +105,12 @@ public class MagicPeerConnectionWrapper { magicSdpObserver = new MagicSdpObserver(); hasInitiated = sessionId.compareTo(localSession) < 0; this.isMCUPublisher = isMCUPublisher; - - peerConnection = peerConnectionFactory.createPeerConnection(iceServerList, sdpConstraints, - new MagicPeerConnectionObserver()); + + PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(iceServerList); + configuration.sdpSemantics = PeerConnection.SdpSemantics.PLAN_B; + + peerConnection = peerConnectionFactory.createPeerConnection(configuration, sdpConstraints, + new MagicPeerConnectionObserver()); if (peerConnection != null) { if (localMediaStream != null) { diff --git a/scripts/analysis/lint-up.rb b/scripts/analysis/lint-up.rb index 245866521..44eb132d8 100644 --- a/scripts/analysis/lint-up.rb +++ b/scripts/analysis/lint-up.rb @@ -56,12 +56,12 @@ end # run Lint puts "running Lint..." -system './gradlew --console=plain clean lintGplayDebug' +system './gradlew --console=plain lintGplayDebug' # confirm that Lint ran w/out error result = $?.to_i if result != 0 - puts "FAIL: failed to run ./gradlew --console=plain clean lintGplayDebug" + puts "FAIL: failed to run ./gradlew --console=plain lintGplayDebug" exit 1 end