werift 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/src/event.d.ts +45 -0
- package/lib/common/src/event.js +229 -0
- package/lib/common/src/event.js.map +1 -0
- package/lib/common/src/index.d.ts +1 -0
- package/lib/common/src/index.js +1 -0
- package/lib/common/src/index.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +6 -1
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/server/flight2.js +5 -3
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/imports/common.d.ts +1 -0
- package/lib/dtls/src/imports/common.js +18 -0
- package/lib/dtls/src/imports/common.js.map +1 -0
- package/lib/dtls/src/index.d.ts +1 -1
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/receive.js +1 -1
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +1 -1
- package/lib/dtls/src/socket.js +5 -5
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidate.d.ts +3 -2
- package/lib/ice/src/candidate.js +19 -5
- package/lib/ice/src/candidate.js.map +1 -1
- package/lib/ice/src/helper.d.ts +6 -6
- package/lib/ice/src/helper.js +20 -17
- package/lib/ice/src/helper.js.map +1 -1
- package/lib/ice/src/ice.d.ts +29 -71
- package/lib/ice/src/ice.js +417 -417
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +109 -0
- package/lib/ice/src/iceBase.js +166 -0
- package/lib/ice/src/iceBase.js.map +1 -0
- package/lib/ice/src/imports/common.d.ts +1 -0
- package/lib/ice/src/imports/common.js +18 -0
- package/lib/ice/src/imports/common.js.map +1 -0
- package/lib/ice/src/index.d.ts +5 -0
- package/lib/ice/src/index.js +5 -0
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/stun/message.d.ts +7 -0
- package/lib/ice/src/stun/message.js +20 -6
- package/lib/ice/src/stun/message.js.map +1 -1
- package/lib/ice/src/stun/protocol.d.ts +6 -6
- package/lib/ice/src/stun/protocol.js +29 -23
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.js +10 -4
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/transport.d.ts +21 -4
- package/lib/ice/src/transport.js +115 -7
- package/lib/ice/src/transport.js.map +1 -1
- package/lib/ice/src/turn/protocol.d.ts +54 -37
- package/lib/ice/src/turn/protocol.js +219 -94
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +9 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice/src/utils.d.ts +1 -0
- package/lib/ice/src/utils.js +15 -16
- package/lib/ice/src/utils.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/container.d.ts +1 -1
- package/lib/rtp/src/extra/container/mp4/container.js +2 -5
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/webm/container.d.ts +3 -1
- package/lib/rtp/src/extra/container/webm/container.js +8 -2
- package/lib/rtp/src/extra/container/webm/container.js.map +1 -1
- package/lib/rtp/src/extra/container/webm/ebml/id.d.ts +6 -0
- package/lib/rtp/src/extra/container/webm/ebml/id.js +6 -0
- package/lib/rtp/src/extra/container/webm/ebml/id.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.js +2 -2
- package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/extra/processor/mp4.d.ts +1 -1
- package/lib/rtp/src/extra/processor/mp4.js +2 -5
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/nack.d.ts +1 -1
- package/lib/rtp/src/extra/processor/nack.js +3 -3
- package/lib/rtp/src/extra/processor/nack.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtcpCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtcpCallback.js +2 -5
- package/lib/rtp/src/extra/processor/rtcpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtpCallback.js +2 -5
- package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/webm.d.ts +12 -17
- package/lib/rtp/src/extra/processor/webm.js +2 -5
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.d.ts +1 -10
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/imports/common.d.ts +1 -0
- package/lib/rtp/src/imports/common.js +18 -0
- package/lib/rtp/src/imports/common.js.map +1 -0
- package/lib/rtp/src/rtp/headerExtension.d.ts +45 -3
- package/lib/rtp/src/rtp/headerExtension.js +15 -0
- package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
- package/lib/sctp/src/helper.js +2 -5
- package/lib/sctp/src/helper.js.map +1 -1
- package/lib/sctp/src/imports/common.d.ts +1 -0
- package/lib/sctp/src/imports/common.js +18 -0
- package/lib/sctp/src/imports/common.js.map +1 -0
- package/lib/sctp/src/index.d.ts +1 -1
- package/lib/sctp/src/index.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +1 -1
- package/lib/sctp/src/sctp.js +3 -3
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/const.d.ts +2 -2
- package/lib/webrtc/src/const.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +1 -1
- package/lib/webrtc/src/dataChannel.js +5 -5
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/imports/common.d.ts +1 -0
- package/lib/webrtc/src/imports/common.js +18 -0
- package/lib/webrtc/src/imports/common.js.map +1 -0
- package/lib/webrtc/src/media/extension/rtpExtension.d.ts +1 -0
- package/lib/webrtc/src/media/extension/rtpExtension.js +6 -0
- package/lib/webrtc/src/media/extension/rtpExtension.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +1 -1
- package/lib/webrtc/src/media/receiver/nack.js +2 -2
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +0 -3
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.d.ts +3 -4
- package/lib/webrtc/src/media/rtpReceiver.js +4 -7
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +1 -1
- package/lib/webrtc/src/media/rtpSender.js +5 -5
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.js +2 -5
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderBWE.d.ts +1 -1
- package/lib/webrtc/src/media/sender/senderBWE.js +4 -7
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/track.d.ts +3 -3
- package/lib/webrtc/src/media/track.js +4 -7
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.d.ts +3 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js +2 -5
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +3 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +15 -8
- package/lib/webrtc/src/peerConnection.js +107 -93
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/sdp.js +15 -3
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +6 -6
- package/lib/webrtc/src/transport/dtls.js +19 -26
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +22 -11
- package/lib/webrtc/src/transport/ice.js +106 -38
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +1 -1
- package/lib/webrtc/src/transport/sctp.js +2 -2
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/package.json +1 -1
- package/src/const.ts +2 -2
- package/src/dataChannel.ts +1 -1
- package/src/imports/common.ts +1 -0
- package/src/media/extension/rtpExtension.ts +6 -0
- package/src/media/receiver/nack.ts +1 -1
- package/src/media/router.ts +2 -3
- package/src/media/rtpReceiver.ts +5 -4
- package/src/media/rtpSender.ts +1 -1
- package/src/media/rtpTransceiver.ts +1 -1
- package/src/media/sender/senderBWE.ts +1 -1
- package/src/media/track.ts +9 -4
- package/src/nonstandard/recorder/index.ts +4 -1
- package/src/nonstandard/recorder/writer/index.ts +1 -1
- package/src/nonstandard/recorder/writer/webm.ts +48 -44
- package/src/peerConnection.ts +122 -89
- package/src/sdp.ts +16 -3
- package/src/transport/dtls.ts +22 -14
- package/src/transport/ice.ts +83 -31
- package/src/transport/sctp.ts +1 -1
package/src/transport/dtls.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Certificate, PrivateKey } from "@fidm/x509";
|
|
2
2
|
import debug from "debug";
|
|
3
|
-
import Event from "rx.mini";
|
|
4
3
|
import { setTimeout } from "timers/promises";
|
|
5
4
|
import { v4 } from "uuid";
|
|
5
|
+
import { Event } from "../imports/common";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
DtlsClient,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "../../../dtls/src/cipher/const";
|
|
19
19
|
import { CipherContext } from "../../../dtls/src/context/cipher";
|
|
20
20
|
import type { Profile } from "../../../dtls/src/context/srtp";
|
|
21
|
-
import type {
|
|
21
|
+
import type { IceConnection } from "../../../ice/src";
|
|
22
22
|
import {
|
|
23
23
|
type RtcpPacket,
|
|
24
24
|
RtcpPacketConverter,
|
|
@@ -51,18 +51,18 @@ export class RTCDtlsTransport {
|
|
|
51
51
|
|
|
52
52
|
readonly onStateChange = new Event<[DtlsState]>();
|
|
53
53
|
|
|
54
|
-
localCertificate?: RTCCertificate;
|
|
55
|
-
localCertificatePromise?: Promise<RTCCertificate>;
|
|
54
|
+
static localCertificate?: RTCCertificate;
|
|
55
|
+
static localCertificatePromise?: Promise<RTCCertificate>;
|
|
56
56
|
private remoteParameters?: RTCDtlsParameters;
|
|
57
57
|
|
|
58
58
|
constructor(
|
|
59
59
|
readonly config: PeerConfig,
|
|
60
60
|
readonly iceTransport: RTCIceTransport,
|
|
61
61
|
readonly router: RtpRouter,
|
|
62
|
-
|
|
62
|
+
public localCertificate?: RTCCertificate,
|
|
63
63
|
private readonly srtpProfiles: Profile[] = [],
|
|
64
64
|
) {
|
|
65
|
-
this.localCertificate
|
|
65
|
+
this.localCertificate ??= RTCDtlsTransport.localCertificate;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
get localParameters() {
|
|
@@ -72,7 +72,7 @@ export class RTCDtlsTransport {
|
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
async
|
|
75
|
+
static async SetupCertificate() {
|
|
76
76
|
if (this.localCertificate) {
|
|
77
77
|
return this.localCertificate;
|
|
78
78
|
}
|
|
@@ -106,8 +106,12 @@ export class RTCDtlsTransport {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
async start() {
|
|
109
|
-
if (this.state !== "new")
|
|
110
|
-
|
|
109
|
+
if (this.state !== "new") {
|
|
110
|
+
throw new Error("state must be new");
|
|
111
|
+
}
|
|
112
|
+
if (this.remoteParameters?.fingerprints.length === 0) {
|
|
113
|
+
throw new Error("remote fingerprint not exist");
|
|
114
|
+
}
|
|
111
115
|
|
|
112
116
|
if (this.role === "auto") {
|
|
113
117
|
if (this.iceTransport.role === "controlling") {
|
|
@@ -119,7 +123,7 @@ export class RTCDtlsTransport {
|
|
|
119
123
|
|
|
120
124
|
this.setState("connecting");
|
|
121
125
|
|
|
122
|
-
await new Promise<void>(async (r) => {
|
|
126
|
+
await new Promise<void>(async (r, f) => {
|
|
123
127
|
if (this.role === "server") {
|
|
124
128
|
this.dtls = new DtlsServer({
|
|
125
129
|
cert: this.localCertificate?.certPem,
|
|
@@ -153,9 +157,10 @@ export class RTCDtlsTransport {
|
|
|
153
157
|
this.setState("closed");
|
|
154
158
|
});
|
|
155
159
|
this.dtls.onConnect.once(r);
|
|
156
|
-
this.dtls.onError.
|
|
160
|
+
this.dtls.onError.once((error) => {
|
|
157
161
|
this.setState("failed");
|
|
158
162
|
log("dtls failed", error);
|
|
163
|
+
f(error);
|
|
159
164
|
});
|
|
160
165
|
|
|
161
166
|
if (this.dtls instanceof DtlsClient) {
|
|
@@ -163,6 +168,7 @@ export class RTCDtlsTransport {
|
|
|
163
168
|
this.dtls.connect().catch((error) => {
|
|
164
169
|
this.setState("failed");
|
|
165
170
|
log("dtls connect failed", error);
|
|
171
|
+
f(error);
|
|
166
172
|
});
|
|
167
173
|
}
|
|
168
174
|
});
|
|
@@ -354,10 +360,12 @@ export class RTCDtlsParameters {
|
|
|
354
360
|
}
|
|
355
361
|
|
|
356
362
|
class IceTransport implements Transport {
|
|
357
|
-
constructor(private ice:
|
|
363
|
+
constructor(private ice: IceConnection) {
|
|
358
364
|
ice.onData.subscribe((buf) => {
|
|
359
365
|
if (isDtls(buf)) {
|
|
360
|
-
if (this.onData)
|
|
366
|
+
if (this.onData) {
|
|
367
|
+
this.onData(buf);
|
|
368
|
+
}
|
|
361
369
|
}
|
|
362
370
|
});
|
|
363
371
|
}
|
|
@@ -372,4 +380,4 @@ class IceTransport implements Transport {
|
|
|
372
380
|
}
|
|
373
381
|
}
|
|
374
382
|
|
|
375
|
-
const createIceTransport = (ice:
|
|
383
|
+
const createIceTransport = (ice: IceConnection) => new IceTransport(ice);
|
package/src/transport/ice.ts
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
|
-
import Event from "rx.mini";
|
|
3
2
|
import { v4 } from "uuid";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { Event } from "../imports/common";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Candidate,
|
|
7
|
+
Connection,
|
|
8
|
+
type IceConnection,
|
|
9
|
+
type IceOptions,
|
|
10
|
+
} from "../../../ice/src";
|
|
6
11
|
import { candidateFromSdp, candidateToSdp } from "../sdp";
|
|
7
12
|
|
|
8
13
|
const log = debug("werift:packages/webrtc/src/transport/ice.ts");
|
|
9
14
|
|
|
10
15
|
export class RTCIceTransport {
|
|
11
16
|
readonly id = v4();
|
|
12
|
-
connection:
|
|
17
|
+
connection: IceConnection;
|
|
13
18
|
state: RTCIceConnectionState = "new";
|
|
19
|
+
private waitStart?: Event<[]>;
|
|
20
|
+
private renominating = false;
|
|
14
21
|
|
|
15
22
|
readonly onStateChange = new Event<[RTCIceConnectionState]>();
|
|
23
|
+
readonly onIceCandidate = new Event<[IceCandidate | undefined]>();
|
|
24
|
+
readonly onNegotiationNeeded = new Event<[]>();
|
|
16
25
|
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
constructor(private gather: RTCIceGatherer) {
|
|
20
|
-
this.connection = this.gather.connection;
|
|
26
|
+
constructor(private iceGather: RTCIceGatherer) {
|
|
27
|
+
this.connection = this.iceGather.connection;
|
|
21
28
|
this.connection.stateChanged.subscribe((state) => {
|
|
22
29
|
this.setState(state);
|
|
23
30
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return this.gather;
|
|
31
|
+
this.iceGather.onIceCandidate = (candidate) => {
|
|
32
|
+
this.onIceCandidate.execute(candidate);
|
|
33
|
+
};
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
get role() {
|
|
@@ -32,21 +38,30 @@ export class RTCIceTransport {
|
|
|
32
38
|
else return "controlled";
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
get gatheringState() {
|
|
42
|
+
return this.iceGather.gatheringState;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get localCandidates() {
|
|
46
|
+
return this.iceGather.localCandidates;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get localParameters() {
|
|
50
|
+
return this.iceGather.localParameters;
|
|
51
|
+
}
|
|
52
|
+
|
|
35
53
|
private setState(state: RTCIceConnectionState) {
|
|
36
54
|
if (state !== this.state) {
|
|
37
55
|
this.state = state;
|
|
38
56
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (state === "closed") {
|
|
42
|
-
this.onStateChange.execute(state);
|
|
43
|
-
this.onStateChange.complete();
|
|
44
|
-
} else {
|
|
45
|
-
this.onStateChange.execute(state);
|
|
46
|
-
}
|
|
57
|
+
this.onStateChange.execute(state);
|
|
47
58
|
}
|
|
48
59
|
}
|
|
49
60
|
|
|
61
|
+
gather() {
|
|
62
|
+
return this.iceGather.gather();
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
addRemoteCandidate = (candidate?: IceCandidate) => {
|
|
51
66
|
if (!this.connection.remoteCandidatesEnd) {
|
|
52
67
|
if (!candidate) {
|
|
@@ -57,25 +72,47 @@ export class RTCIceTransport {
|
|
|
57
72
|
}
|
|
58
73
|
};
|
|
59
74
|
|
|
60
|
-
setRemoteParams(remoteParameters: RTCIceParameters) {
|
|
75
|
+
setRemoteParams(remoteParameters: RTCIceParameters, renomination = false) {
|
|
76
|
+
if (renomination) {
|
|
77
|
+
this.renominating = true;
|
|
78
|
+
}
|
|
61
79
|
if (
|
|
62
80
|
this.connection.remoteUsername &&
|
|
63
81
|
this.connection.remotePassword &&
|
|
64
82
|
(this.connection.remoteUsername !== remoteParameters.usernameFragment ||
|
|
65
83
|
this.connection.remotePassword !== remoteParameters.password)
|
|
66
84
|
) {
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
if (this.renominating) {
|
|
86
|
+
log("renomination", remoteParameters);
|
|
87
|
+
this.connection.resetNominatedPair();
|
|
88
|
+
this.renominating = false;
|
|
89
|
+
} else {
|
|
90
|
+
log("restart", remoteParameters);
|
|
91
|
+
this.restart();
|
|
92
|
+
}
|
|
69
93
|
}
|
|
70
94
|
this.connection.setRemoteParams(remoteParameters);
|
|
71
95
|
}
|
|
72
96
|
|
|
97
|
+
restart() {
|
|
98
|
+
this.connection.restart();
|
|
99
|
+
this.setState("new");
|
|
100
|
+
this.iceGather.gatheringState = "new";
|
|
101
|
+
this.waitStart = undefined;
|
|
102
|
+
this.onNegotiationNeeded.execute();
|
|
103
|
+
}
|
|
104
|
+
|
|
73
105
|
async start() {
|
|
74
|
-
if (this.state === "closed")
|
|
75
|
-
|
|
106
|
+
if (this.state === "closed") {
|
|
107
|
+
throw new Error("RTCIceTransport is closed");
|
|
108
|
+
}
|
|
109
|
+
if (!this.connection.remotePassword || !this.connection.remoteUsername) {
|
|
76
110
|
throw new Error("remoteParams missing");
|
|
111
|
+
}
|
|
77
112
|
|
|
78
|
-
if (this.waitStart)
|
|
113
|
+
if (this.waitStart) {
|
|
114
|
+
await this.waitStart.asPromise();
|
|
115
|
+
}
|
|
79
116
|
this.waitStart = new Event();
|
|
80
117
|
|
|
81
118
|
this.setState("checking");
|
|
@@ -87,7 +124,9 @@ export class RTCIceTransport {
|
|
|
87
124
|
throw error;
|
|
88
125
|
}
|
|
89
126
|
|
|
127
|
+
this.waitStart.execute();
|
|
90
128
|
this.waitStart.complete();
|
|
129
|
+
this.waitStart = undefined;
|
|
91
130
|
}
|
|
92
131
|
|
|
93
132
|
async stop() {
|
|
@@ -95,6 +134,9 @@ export class RTCIceTransport {
|
|
|
95
134
|
this.setState("closed");
|
|
96
135
|
await this.connection.close();
|
|
97
136
|
}
|
|
137
|
+
this.onStateChange.complete();
|
|
138
|
+
this.onIceCandidate.complete();
|
|
139
|
+
this.onNegotiationNeeded.complete();
|
|
98
140
|
}
|
|
99
141
|
}
|
|
100
142
|
|
|
@@ -115,20 +157,21 @@ export type IceGathererState = (typeof IceGathererStates)[number];
|
|
|
115
157
|
export class RTCIceGatherer {
|
|
116
158
|
onIceCandidate: (candidate: IceCandidate | undefined) => void = () => {};
|
|
117
159
|
gatheringState: IceGathererState = "new";
|
|
160
|
+
readonly connection: IceConnection;
|
|
118
161
|
|
|
119
162
|
readonly onGatheringStateChange = new Event<[IceGathererState]>();
|
|
120
|
-
readonly connection: Connection;
|
|
121
163
|
|
|
122
164
|
constructor(private options: Partial<IceOptions> = {}) {
|
|
123
165
|
this.connection = new Connection(false, this.options);
|
|
166
|
+
this.connection.onIceCandidate.subscribe((candidate) => {
|
|
167
|
+
this.onIceCandidate(candidateFromIce(candidate));
|
|
168
|
+
});
|
|
124
169
|
}
|
|
125
170
|
|
|
126
171
|
async gather() {
|
|
127
172
|
if (this.gatheringState === "new") {
|
|
128
173
|
this.setState("gathering");
|
|
129
|
-
await this.connection.gatherCandidates(
|
|
130
|
-
this.onIceCandidate(candidateFromIce(candidate));
|
|
131
|
-
});
|
|
174
|
+
await this.connection.gatherCandidates();
|
|
132
175
|
this.onIceCandidate(undefined);
|
|
133
176
|
this.setState("complete");
|
|
134
177
|
}
|
|
@@ -140,7 +183,7 @@ export class RTCIceGatherer {
|
|
|
140
183
|
|
|
141
184
|
get localParameters() {
|
|
142
185
|
const params = new RTCIceParameters({
|
|
143
|
-
usernameFragment: this.connection.
|
|
186
|
+
usernameFragment: this.connection.localUsername,
|
|
144
187
|
password: this.connection.localPassword,
|
|
145
188
|
});
|
|
146
189
|
|
|
@@ -164,6 +207,8 @@ export function candidateFromIce(c: Candidate) {
|
|
|
164
207
|
c.priority,
|
|
165
208
|
c.transport,
|
|
166
209
|
c.type,
|
|
210
|
+
c.generation,
|
|
211
|
+
c.ufrag,
|
|
167
212
|
);
|
|
168
213
|
candidate.relatedAddress = c.relatedAddress;
|
|
169
214
|
candidate.relatedPort = c.relatedPort;
|
|
@@ -183,6 +228,8 @@ export function candidateToIce(x: IceCandidate) {
|
|
|
183
228
|
x.relatedAddress,
|
|
184
229
|
x.relatedPort,
|
|
185
230
|
x.tcpType,
|
|
231
|
+
x.generation,
|
|
232
|
+
x.ufrag,
|
|
186
233
|
);
|
|
187
234
|
}
|
|
188
235
|
|
|
@@ -190,6 +237,7 @@ export class RTCIceCandidate {
|
|
|
190
237
|
candidate!: string;
|
|
191
238
|
sdpMid?: string;
|
|
192
239
|
sdpMLineIndex?: number;
|
|
240
|
+
usernameFragment?: string;
|
|
193
241
|
|
|
194
242
|
constructor(props: Partial<RTCIceCandidate>) {
|
|
195
243
|
Object.assign(this, props);
|
|
@@ -204,6 +252,7 @@ export class RTCIceCandidate {
|
|
|
204
252
|
candidate: this.candidate,
|
|
205
253
|
sdpMid: this.sdpMid,
|
|
206
254
|
sdpMLineIndex: this.sdpMLineIndex,
|
|
255
|
+
usernameFragment: this.usernameFragment,
|
|
207
256
|
};
|
|
208
257
|
}
|
|
209
258
|
}
|
|
@@ -228,6 +277,8 @@ export class IceCandidate {
|
|
|
228
277
|
public priority: number,
|
|
229
278
|
public protocol: string,
|
|
230
279
|
public type: string,
|
|
280
|
+
public generation?: number,
|
|
281
|
+
public ufrag?: string,
|
|
231
282
|
) {}
|
|
232
283
|
|
|
233
284
|
toJSON(): RTCIceCandidate {
|
|
@@ -235,6 +286,7 @@ export class IceCandidate {
|
|
|
235
286
|
candidate: candidateToSdp(this),
|
|
236
287
|
sdpMLineIndex: this.sdpMLineIndex,
|
|
237
288
|
sdpMid: this.sdpMid,
|
|
289
|
+
usernameFragment: this.ufrag,
|
|
238
290
|
});
|
|
239
291
|
}
|
|
240
292
|
|
package/src/transport/sctp.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jspack } from "@shinyoshiaki/jspack";
|
|
2
2
|
import debug from "debug";
|
|
3
|
-
import { Event } from "rx.mini";
|
|
4
3
|
import * as uuid from "uuid";
|
|
4
|
+
import { Event } from "../imports/common";
|
|
5
5
|
|
|
6
6
|
import { SCTP, SCTP_STATE, type Transport } from "../../../sctp/src";
|
|
7
7
|
import {
|