8000 Merge pull request #274 from ened/android-embedding-v2 · hicodeboy/flutter-webrtc@d61e62b · GitHub
[go: up one dir, main page]

Skip to content

Commit d61e62b

Browse files
authored
Merge pull request flutter-webrtc#274 from ened/android-embedding-v2
Android embedding v2
2 parents 00cb509 + fb62b40 commit d61e62b

9 files changed

+2660
-2376
lines changed

android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.3.1'
11+
classpath 'com.android.tools.build:gradle:3.6.3'
1212
}
1313
}
1414

@@ -41,6 +41,6 @@ android {
4141
}
4242

4343
dependencies {
44-
api 'org.webrtc:google-webrtc:1.0.28262'
45-
implementation "androidx.annotation:annotation:1.0.1"
44+
api 'org.webrtc:google-webrtc:1.0.30039'
45+
implementation "androidx.annotation:annotation:1.1.0"
4646
}

android/src/main/java/com/cloudwebrtc/webrtc/DataChannelObserver.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
package com.cloudwebrtc.webrtc;
22

3-
import java.nio.charset.Charset;
4-
import android.util.Base64;
3+
import com.cloudwebrtc.webrtc.utils.AnyThreadSink;
4+
import com.cloudwebrtc.webrtc.utils.ConstraintsMap;
55

66
import org.webrtc.DataChannel;
7+
8+
import java.nio.charset.Charset;
9+
10+
import io.flutter.plugin.common.BinaryMessenger;
711
import io.flutter.plugin.common.EventChannel;
8-
import com.cloudwebrtc.webrtc.utils.AnyThreadSink;
9-
import com.cloudwebrtc.webrtc.utils.ConstraintsMap;
1012

1113
class DataChannelObserver implements DataChannel.Observer, EventChannel.StreamHandler {
14+
1215
private final int mId;
1316
private final DataChannel mDataChannel;
14-
private final String peerConnectionId;
15-
private final FlutterWebRTCPlugin plugin;
17+
1618
private EventChannel eventChannel;
1719
private EventChannel.EventSink eventSink;
1820

19-
DataChannelObserver(FlutterWebRTCPlugin plugin, String peerConnectionId, int id, DataChannel dataChannel) {
20-
this.peerConnectionId = peerConnectionId;
21+
DataChannelObserver(BinaryMessenger messenger, String peerConnectionId, int id,
22+
DataChannel dataChannel) {
2123
mId = id;
2224
mDataChannel = dataChannel;
23-
this.plugin = plugin;
24-
this.eventChannel =
25-
new EventChannel(
26-
plugin.registrar().messenger(),
27-
"FlutterWebRTC/dataChannelEvent" + peerConnectionId + String.valueOf(id));
25+
eventChannel =
26+
new EventChannel(messenger, "FlutterWebRTC/dataChannelEvent" + peerConnectionId + id);
2827
eventChannel.setStreamHandler(this);
2928
}
3029

@@ -53,7 +52,8 @@ public void onCancel(Object o) {
5352
}
5453

5554
@Override
56-
public void onBufferedAmountChange(long amount) { }
55+
public void onBufferedAmountChange(long amount) {
56+
}
5757

5858
@Override
5959
public void onStateChange() {
@@ -89,8 +89,9 @@ public void onMessage(DataChannel.Buffer buffer) {
8989
sendEvent(params);
9090
}
9191

92-
void sendEvent(ConstraintsMap params) {
93-
if(eventSink != null)
92+
private void sendEvent(ConstraintsMap params) {
93+
if (eventSink != null) {
9494
eventSink.success(params.toMap());
95+
}
9596
}
9697
}

0 commit comments

Comments
 (0)
0