Explorar o código

Update WebRTC library

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 <t@timkrueger.me>
Tim Krüger %!s(int64=3) %!d(string=hai) anos
pai
achega
bad5b5f9bc

+ 19 - 1
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 <info@andy-scherzinger.de>
  * Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
  * Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
+ * Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
  *
  * 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'

+ 6 - 3
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) {

+ 2 - 2
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