-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecoupling.diff
139 lines (123 loc) · 4.56 KB
/
decoupling.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
diff --git a/lib/dataconnection.ts b/lib/dataconnection.ts
index aec3c05..f0ca925 100644
--- a/lib/dataconnection.ts
+++ b/lib/dataconnection.ts
@@ -58,7 +58,7 @@ export class DataConnection extends BaseConnection implements IDataConnection {
this.options.connectionId || DataConnection.ID_PREFIX + util.randomToken();
this.label = this.options.label || this.connectionId;
- this.serialization = this.options.serialization || SerializationType.Binary;
+ this.serialization = this.options.serialization || SerializationType.JSON;
this.reliable = !!this.options.reliable;
this._encodingQueue.on('done', (ab: ArrayBuffer) => {
diff --git a/lib/exports.ts b/lib/exports.ts
index 5772d02..63a57e3 100644
--- a/lib/exports.ts
+++ b/lib/exports.ts
@@ -7,7 +7,3 @@ export const peerjs = {
};
export default Peer;
-
-(<any>window).peerjs = peerjs;
-/** @deprecated Should use peerjs namespace */
-(<any>window).Peer = Peer;
diff --git a/lib/negotiator.ts b/lib/negotiator.ts
index e2b3df9..c48efa3 100644
--- a/lib/negotiator.ts
+++ b/lib/negotiator.ts
@@ -142,10 +142,11 @@ export class Negotiator {
// MEDIACONNECTION.
logger.log("Listening for remote stream");
- peerConnection.ontrack = (evt) => {
- logger.log("Received remote stream");
+ // react-native-webrtc implements the old API.
+ peerConnection.onaddstream = (evt) => {
+ logger.log("Received remote stream", evt);
- const stream = evt.streams[0];
+ const stream = evt.stream;
const connection = provider.getConnection(peerId, connectionId);
if (connection.type === ConnectionType.Media) {
@@ -168,7 +169,7 @@ export class Negotiator {
this.connection.peerConnection = null;
//unsubscribe from all PeerConnection's events
- peerConnection.onicecandidate = peerConnection.oniceconnectionstatechange = peerConnection.ondatachannel = peerConnection.ontrack = () => { };
+ peerConnection.onicecandidate = peerConnection.oniceconnectionstatechange = peerConnection.ondatachannel = peerConnection.onaddstream = () => { };
const peerConnectionNotClosed = peerConnection.signalingState !== "closed";
let dataChannelNotClosed = false;
@@ -340,15 +341,14 @@ export class Negotiator {
): void {
logger.log(`add tracks from stream ${stream.id} to peer connection`);
- if (!peerConnection.addTrack) {
+ // react-native-webrtc implements the old API.
+ if (!peerConnection.addStream) {
return logger.error(
- `Your browser does't support RTCPeerConnection#addTrack. Ignored.`
+ `Your browser does't support RTCPeerConnection#addStream. Ignored.`
);
}
- stream.getTracks().forEach(track => {
- peerConnection.addTrack(track, stream);
- });
+ peerConnection.addStream(stream);
}
private _addStreamToMediaConnection(
diff --git a/lib/peer.ts b/lib/peer.ts
index 8f11659..1af0753 100644
--- a/lib/peer.ts
+++ b/lib/peer.ts
@@ -111,11 +111,6 @@ export class Peer extends EventEmitter {
};
this._options = options;
- // Detect relative URL host.
- if (this._options.host === "/") {
- this._options.host = window.location.hostname;
- }
-
// Set path correctly.
if (this._options.path) {
if (this._options.path[0] !== "/") {
diff --git a/lib/supports.ts b/lib/supports.ts
index 1801188..db1dc70 100644
--- a/lib/supports.ts
+++ b/lib/supports.ts
@@ -1,5 +1,3 @@
-import { webRTCAdapter } from './adapter';
-
export const Supports = new class {
readonly isIOS = ['iPad', 'iPhone', 'iPod'].includes(navigator.platform);
readonly supportedBrowsers = ['firefox', 'chrome', 'safari'];
@@ -28,36 +26,15 @@ export const Supports = new class {
}
getBrowser(): string {
- return webRTCAdapter.browserDetails.browser;
+ return 'chrome';
}
getVersion(): number {
- return webRTCAdapter.browserDetails.version || 0;
+ return this.minChromeVersion;
}
isUnifiedPlanSupported(): boolean {
- const browser = this.getBrowser();
- const version = webRTCAdapter.browserDetails.version || 0;
-
- if (browser === 'chrome' && version < 72) return false;
- if (browser === 'firefox' && version >= 59) return true;
- if (!window.RTCRtpTransceiver || !('currentDirection' in RTCRtpTransceiver.prototype)) return false;
-
- let tempPc: RTCPeerConnection;
- let supported = false;
-
- try {
- tempPc = new RTCPeerConnection();
- tempPc.addTransceiver('audio');
- supported = true;
- } catch (e) { }
- finally {
- if (tempPc) {
- tempPc.close();
- }
- }
-
- return supported;
+ return false;
}
toString(): string {