werift 0.27.0 → 0.28.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/README.md +119 -8
- package/lib/common/src/event.d.ts +26 -0
- package/lib/common/src/event.js +87 -2
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/network.d.ts +6 -1
- package/lib/common/src/network.js +8 -2
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/transport.d.ts +12 -5
- package/lib/common/src/transport.js +3 -2
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/alert.d.ts +49 -0
- package/lib/dtls/src/alert.js +103 -0
- package/lib/dtls/src/alert.js.map +1 -0
- package/lib/dtls/src/client.js +15 -1
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +2 -0
- package/lib/dtls/src/context/dtls.js +7 -0
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +17 -1
- package/lib/dtls/src/context/transport.js +38 -2
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +4 -1
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +5 -0
- package/lib/dtls/src/flight/flight.js +10 -1
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +4 -1
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/index.d.ts +3 -1
- package/lib/dtls/src/index.js +10 -1
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +9 -0
- package/lib/dtls/src/record/const.js +9 -1
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +50 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +19 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +134 -2
- package/lib/dtls/src/socket.js +322 -6
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidateError.d.ts +155 -0
- package/lib/ice/src/candidateError.js +246 -0
- package/lib/ice/src/candidateError.js.map +1 -0
- package/lib/ice/src/candidateGatherer.d.ts +127 -0
- package/lib/ice/src/candidateGatherer.js +745 -0
- package/lib/ice/src/candidateGatherer.js.map +1 -0
- package/lib/ice/src/consent.d.ts +49 -0
- package/lib/ice/src/consent.js +258 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/ice.d.ts +223 -71
- package/lib/ice/src/ice.js +873 -975
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +207 -8
- package/lib/ice/src/iceBase.js +94 -31
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +1 -0
- package/lib/ice/src/index.js +1 -0
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/checkMessages.d.ts +41 -0
- package/lib/ice/src/internal/checkMessages.js +63 -0
- package/lib/ice/src/internal/checkMessages.js.map +1 -0
- package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
- package/lib/ice/src/internal/defaultRoute.js +134 -0
- package/lib/ice/src/internal/defaultRoute.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +17 -0
- package/lib/ice/src/internal/hostInterfaces.js +77 -0
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
- package/lib/ice/src/internal/hostPreference.d.ts +24 -0
- package/lib/ice/src/internal/hostPreference.js +38 -0
- package/lib/ice/src/internal/hostPreference.js.map +1 -0
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
- package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
- package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
- package/lib/ice/src/internal/selectAddresses.js +37 -18
- package/lib/ice/src/internal/selectAddresses.js.map +1 -1
- package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
- package/lib/ice/src/nomination/regularNomination.js +311 -0
- package/lib/ice/src/nomination/regularNomination.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +138 -0
- package/lib/ice/src/nomination/selectionReplacement.js +371 -0
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
- package/lib/ice/src/provisional.d.ts +139 -0
- package/lib/ice/src/provisional.js +468 -0
- package/lib/ice/src/provisional.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +9 -2
- package/lib/ice/src/stun/protocol.js +16 -17
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +1 -1
- package/lib/ice/src/stun/tcpProtocol.js +7 -7
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.js +4 -2
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/protocol.d.ts +2 -2
- package/lib/ice/src/turn/protocol.js +6 -3
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +16 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.js +4 -0
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +20 -1
- package/lib/ice-server/src/stun/const.js +9 -1
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +28 -1
- package/lib/ice-server/src/stun/message.js +102 -15
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/index.mjs +13394 -7732
- package/lib/nonstandard/index.mjs +680 -286
- package/lib/polyfill/dom.mjs +19605 -14243
- package/lib/polyfill/index.mjs +19605 -14243
- package/lib/rtp/src/index.d.ts +1 -0
- package/lib/rtp/src/index.js +1 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +14 -1
- package/lib/rtp/src/rtp/continuity.js +24 -4
- package/lib/rtp/src/rtp/continuity.js.map +1 -1
- package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
- package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
- package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
- package/lib/sctp/src/sctp.d.ts +5 -0
- package/lib/sctp/src/sctp.js +81 -47
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +348 -34
- package/lib/webrtc/src/api/peerConfig.js +90 -24
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +77 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/helper.d.ts +8 -0
- package/lib/webrtc/src/helper.js +40 -4
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
- package/lib/webrtc/src/media/codecCompatibility.js +338 -12
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +245 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +239 -51
- package/lib/webrtc/src/media/router.js +664 -237
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
- package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
- package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
- package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
- package/lib/webrtc/src/media/routing/routeTable.js +95 -0
- package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
- package/lib/webrtc/src/media/rtpReceiver.d.ts +222 -0
- package/lib/webrtc/src/media/rtpReceiver.js +668 -28
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +7 -0
- package/lib/webrtc/src/media/rtpSender.js +9 -3
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +18 -0
- package/lib/webrtc/src/media/rtpTransceiver.js +64 -2
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderStats.d.ts +6 -5
- package/lib/webrtc/src/media/sender/senderStats.js +14 -19
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -1
- package/lib/webrtc/src/media/track.d.ts +9 -0
- package/lib/webrtc/src/media/track.js +9 -0
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +23 -6
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +46 -22
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +8 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +21 -0
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +35 -4
- package/lib/webrtc/src/negotiationTransaction.js +111 -8
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +65 -6
- package/lib/webrtc/src/peerConnection.js +283 -28
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +2 -1
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +2 -0
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/sctpManager.js +4 -0
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +69 -0
- package/lib/webrtc/src/sdp.js +139 -14
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +85 -4
- package/lib/webrtc/src/sdpManager.js +214 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +38 -1
- package/lib/webrtc/src/secureTransportManager.js +82 -7
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +82 -4
- package/lib/webrtc/src/transceiverManager.js +231 -38
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +95 -1
- package/lib/webrtc/src/transport/dtls.js +324 -28
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +61 -4
- package/lib/webrtc/src/transport/ice.js +180 -11
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +23 -0
- package/lib/webrtc/src/transport/sctp.js +87 -2
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +33 -0
- package/lib/webrtc/src/utils.js +52 -3
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PeerConfig, type RTCPeerConnectionConfig } from "./api/peerConfig";
|
|
2
|
-
import { type RTCDataChannelEvent, type RTCPeerConnectionIceEvent, RTCTrackEvent } from "./api/peerConnectionEvents";
|
|
2
|
+
import { type RTCDataChannelEvent, RTCPeerConnectionIceErrorEvent, type RTCPeerConnectionIceEvent, RTCTrackEvent } from "./api/peerConnectionEvents";
|
|
3
3
|
import { type RTCDataChannel } from "./dataChannel";
|
|
4
4
|
import { EventTarget } from "./helper";
|
|
5
5
|
import { Event } from "./imports/common";
|
|
@@ -11,8 +11,9 @@ import type { RTCDtlsTransport } from "./transport/dtls";
|
|
|
11
11
|
import type { RTCIceCandidate, RTCIceCandidateInit, RTCIceTransport } from "./transport/ice";
|
|
12
12
|
import type { Kind, RTCSignalingState } from "./types/domain";
|
|
13
13
|
import type { Callback, CallbackWithValue } from "./types/util";
|
|
14
|
-
export { type
|
|
15
|
-
export { type
|
|
14
|
+
export { type CompatibilityOption, type CompatibilityOptionValue, CompatibilityOptionValues, } from "./api/compatibilityOptions";
|
|
15
|
+
export { type CertificateScope, CertificateScopeModes, type CompatibilityPreset, CompatibilityPresets, type DebugConfig, type DeprecatedCertificateScope, DeprecatedCompatibilityValues, type DeprecatedKeyFrameRequestRouting, type DeprecatedMLineReuse, defaultPeerConfig, findCodecByMimeType, MLineReuseModes, type PeerConfig, type RTCBundlePolicy, type RTCConfiguration, type RTCIceServer, type RTCPeerConnectionConfig, type RTCRtcpMuxPolicy, type RTCSctpConfiguration, type TransceiverPairing, TransceiverPairingModes, } from "./api/peerConfig";
|
|
16
|
+
export { type RTCDataChannelEvent, RTCPeerConnectionIceErrorEvent, type RTCPeerConnectionIceErrorEventInit, type RTCPeerConnectionIceEvent, RTCTrackEvent, } from "./api/peerConnectionEvents";
|
|
16
17
|
/**
|
|
17
18
|
* W3C compatibility notes kept near the public RTCPeerConnection surface so the
|
|
18
19
|
* reviewable diff does not depend on external PR text.
|
|
@@ -62,6 +63,20 @@ export declare class RTCPeerConnection extends EventTarget {
|
|
|
62
63
|
private readonly activation;
|
|
63
64
|
private isClosed;
|
|
64
65
|
private applyingIceRestart;
|
|
66
|
+
/**
|
|
67
|
+
* The current gathering's STUN / TURN outcomes by URL, for the 701 of
|
|
68
|
+
* `icecandidateerror` (see RTCPeerConnectionIceErrorEvent): the
|
|
69
|
+
* transports that reached the server, and the 701s of the transports
|
|
70
|
+
* that tried and did not, in order. Judged once when `iceGatheringState`
|
|
71
|
+
* leaves "gathering" (fireUnreachableServerErrors) and cleared when it
|
|
72
|
+
* enters "gathering".
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* True while the 701s of the gathering that just ended are dispatched:
|
|
76
|
+
* `iceGatheringState` still reads "gathering" for their handlers.
|
|
77
|
+
*/
|
|
78
|
+
private firingGatheringErrors;
|
|
79
|
+
private gatheringServerOutcomes;
|
|
65
80
|
/**
|
|
66
81
|
* The last operation of the chain: `done` when it finished, `applied` when
|
|
67
82
|
* the description it applies is in place (setLocalDescription's gathering
|
|
@@ -90,6 +105,12 @@ export declare class RTCPeerConnection extends EventTarget {
|
|
|
90
105
|
readonly onRemoteTransceiverAdded: Event<[RTCRtpTransceiver]>;
|
|
91
106
|
readonly onTransceiverAdded: Event<[RTCRtpTransceiver]>;
|
|
92
107
|
readonly onIceCandidate: Event<[RTCIceCandidate | undefined]>;
|
|
108
|
+
/**
|
|
109
|
+
* `icecandidateerror` (see {@link RTCPeerConnectionIceErrorEvent}): the
|
|
110
|
+
* same event object is passed here, to `onicecandidateerror` and to the
|
|
111
|
+
* `icecandidateerror` listeners.
|
|
112
|
+
*/
|
|
113
|
+
readonly onIceCandidateError: Event<[RTCPeerConnectionIceErrorEvent]>;
|
|
93
114
|
readonly onNegotiationneeded: Event<[]>;
|
|
94
115
|
readonly onTrack: Event<[MediaStreamTrack]>;
|
|
95
116
|
private readonly eventHandlers;
|
|
@@ -97,8 +118,8 @@ export declare class RTCPeerConnection extends EventTarget {
|
|
|
97
118
|
set ondatachannel(value: CallbackWithValue<RTCDataChannelEvent> | null);
|
|
98
119
|
get onicecandidate(): CallbackWithValue<RTCPeerConnectionIceEvent> | null;
|
|
99
120
|
set onicecandidate(value: CallbackWithValue<RTCPeerConnectionIceEvent> | null);
|
|
100
|
-
get onicecandidateerror(): CallbackWithValue<
|
|
101
|
-
set onicecandidateerror(value: CallbackWithValue<
|
|
121
|
+
get onicecandidateerror(): CallbackWithValue<RTCPeerConnectionIceErrorEvent> | null;
|
|
122
|
+
set onicecandidateerror(value: CallbackWithValue<RTCPeerConnectionIceErrorEvent> | null);
|
|
102
123
|
get onicegatheringstatechange(): CallbackWithValue<any> | null;
|
|
103
124
|
set onicegatheringstatechange(value: CallbackWithValue<any> | null);
|
|
104
125
|
get onnegotiationneeded(): CallbackWithValue<any> | null;
|
|
@@ -121,6 +142,30 @@ export declare class RTCPeerConnection extends EventTarget {
|
|
|
121
142
|
get sctp(): import(".").RTCSctpTransport | null;
|
|
122
143
|
get sctpRemotePort(): number | undefined;
|
|
123
144
|
get iceTransports(): RTCIceTransport[];
|
|
145
|
+
/** The outcome record of `url` in the current gathering. */
|
|
146
|
+
private gatheringServerOutcome;
|
|
147
|
+
/**
|
|
148
|
+
* Judge the gathering that just ended (W3C: a 701 means no host candidate
|
|
149
|
+
* reached the server, once per URL per gathering): fire one 701 for each
|
|
150
|
+
* URL some transport tried without reaching it and none reached. Only
|
|
151
|
+
* transports still live count (not closed, not pending only), with the
|
|
152
|
+
* ICE generation they had: one that left during the gathering, or whose
|
|
153
|
+
* generation an ICE restart replaced, neither reached nor failed for it.
|
|
154
|
+
* The event carries the first counted failure (its local address and
|
|
155
|
+
* text). Stops as soon as the connection is closed (a handler may close
|
|
156
|
+
* it).
|
|
157
|
+
*/
|
|
158
|
+
private fireUnreachableServerErrors;
|
|
159
|
+
private judgeUnreachableServers;
|
|
160
|
+
/**
|
|
161
|
+
* Dispatch an `icecandidateerror` to `onIceCandidateError`,
|
|
162
|
+
* `onicecandidateerror` and the listeners, in that order, with one event
|
|
163
|
+
* object. A handler calling `stopImmediatePropagation()` stops the ones
|
|
164
|
+
* after it (also the later subscribers of onIceCandidateError); a
|
|
165
|
+
* listener removed during the dispatch is not called, one added during it
|
|
166
|
+
* is not called this time.
|
|
167
|
+
*/
|
|
168
|
+
private dispatchIceCandidateError;
|
|
124
169
|
get extIdUriMap(): {
|
|
125
170
|
[id: number]: string;
|
|
126
171
|
};
|
|
@@ -132,6 +177,12 @@ export declare class RTCPeerConnection extends EventTarget {
|
|
|
132
177
|
get currentRemoteDescription(): RTCSessionDescription | null;
|
|
133
178
|
get pendingRemoteDescription(): RTCSessionDescription | null;
|
|
134
179
|
get canTrickleIceCandidates(): boolean | null;
|
|
180
|
+
/**
|
|
181
|
+
* Whether the remote description declares the `ice2` ice-option (an
|
|
182
|
+
* RFC 8445 agent, RFC 8839 §5.6), or null without a remote description.
|
|
183
|
+
* Informational: werift runs the RFC 8445 procedures either way.
|
|
184
|
+
*/
|
|
185
|
+
get remoteIceOptionIce2(): boolean | null;
|
|
135
186
|
get remoteIsBundled(): import("./sdp").GroupDescription | undefined;
|
|
136
187
|
/**@private */
|
|
137
188
|
get _localDescription(): SessionDescription | undefined;
|
|
@@ -214,6 +265,9 @@ export declare class RTCPeerConnection extends EventTarget {
|
|
|
214
265
|
iceTcpPassive: boolean;
|
|
215
266
|
iceStunGatherTimeout: number | undefined;
|
|
216
267
|
iceTurnConnectTimeout: number | undefined;
|
|
268
|
+
iceNominationDelayMs: number | undefined;
|
|
269
|
+
iceNomination: "semi-aggressive" | "regular" | undefined;
|
|
270
|
+
iceRenomination: boolean;
|
|
217
271
|
turnTransport: "udp" | "tcp" | "tls" | undefined;
|
|
218
272
|
turnTlsOptions: import(".").TlsConnectionOptions | undefined;
|
|
219
273
|
turnUdpFamily: 4 | 6 | undefined;
|
|
@@ -221,17 +275,22 @@ export declare class RTCPeerConnection extends EventTarget {
|
|
|
221
275
|
iceUseLinkLocalAddress: boolean | undefined;
|
|
222
276
|
iceFilterStunResponse: ((message: import(".").Message, addr: import(".").Address, protocol: import(".").Protocol) => boolean) | undefined;
|
|
223
277
|
iceFilterCandidatePair: ((pair: import(".").CandidatePair) => boolean) | undefined;
|
|
278
|
+
iceMessageIntegrity: import(".").MessageIntegrityMode | undefined;
|
|
279
|
+
iceOptionIce2: boolean;
|
|
224
280
|
icePasswordPrefix: string | undefined;
|
|
225
281
|
bundlePolicy: import("./sdp").BundlePolicy;
|
|
226
282
|
rtcpMuxPolicy: "require";
|
|
227
283
|
iceCandidatePoolSize: number;
|
|
228
|
-
certificateScope: import("./
|
|
284
|
+
certificateScope: import("./peerConnection").CertificateScope;
|
|
229
285
|
midSuffix: boolean;
|
|
230
286
|
maxMessageSize: number;
|
|
231
287
|
filterProbePaddingOnReceiveRtp: boolean;
|
|
232
288
|
bandwidthEstimator: import("./media").BandwidthEstimatorOption;
|
|
233
289
|
mLineReuse: import("./sdpManager").MLineReuse;
|
|
290
|
+
transceiverPairing: import("./peerConnection").TransceiverPairing;
|
|
234
291
|
keyFrameRequestRouting: import("./media").KeyFrameRequestRouting;
|
|
292
|
+
bundleCandidates: import("./sdpManager").BundleCandidates;
|
|
293
|
+
compatibility: import("./peerConnection").CompatibilityPreset | undefined;
|
|
235
294
|
};
|
|
236
295
|
/**
|
|
237
296
|
* W3C operations chain: createOffer runs after every earlier description
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RTCPeerConnection = exports.RTCTrackEvent = exports.findCodecByMimeType = exports.defaultPeerConfig = void 0;
|
|
3
|
+
exports.RTCPeerConnection = exports.RTCTrackEvent = exports.RTCPeerConnectionIceErrorEvent = exports.TransceiverPairingModes = exports.MLineReuseModes = exports.findCodecByMimeType = exports.defaultPeerConfig = exports.DeprecatedCompatibilityValues = exports.CompatibilityPresets = exports.CertificateScopeModes = exports.CompatibilityOptionValues = void 0;
|
|
4
4
|
const node_util_1 = require("node:util");
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const peerConfig_1 = require("./api/peerConfig");
|
|
@@ -24,10 +24,18 @@ const sdp_1 = require("./sdp");
|
|
|
24
24
|
const sdpManager_1 = require("./sdpManager");
|
|
25
25
|
const secureTransportManager_1 = require("./secureTransportManager");
|
|
26
26
|
const utils_1 = require("./utils");
|
|
27
|
+
var compatibilityOptions_1 = require("./api/compatibilityOptions");
|
|
28
|
+
Object.defineProperty(exports, "CompatibilityOptionValues", { enumerable: true, get: function () { return compatibilityOptions_1.CompatibilityOptionValues; } });
|
|
27
29
|
var peerConfig_2 = require("./api/peerConfig");
|
|
30
|
+
Object.defineProperty(exports, "CertificateScopeModes", { enumerable: true, get: function () { return peerConfig_2.CertificateScopeModes; } });
|
|
31
|
+
Object.defineProperty(exports, "CompatibilityPresets", { enumerable: true, get: function () { return peerConfig_2.CompatibilityPresets; } });
|
|
32
|
+
Object.defineProperty(exports, "DeprecatedCompatibilityValues", { enumerable: true, get: function () { return peerConfig_2.DeprecatedCompatibilityValues; } });
|
|
28
33
|
Object.defineProperty(exports, "defaultPeerConfig", { enumerable: true, get: function () { return peerConfig_2.defaultPeerConfig; } });
|
|
29
34
|
Object.defineProperty(exports, "findCodecByMimeType", { enumerable: true, get: function () { return peerConfig_2.findCodecByMimeType; } });
|
|
35
|
+
Object.defineProperty(exports, "MLineReuseModes", { enumerable: true, get: function () { return peerConfig_2.MLineReuseModes; } });
|
|
36
|
+
Object.defineProperty(exports, "TransceiverPairingModes", { enumerable: true, get: function () { return peerConfig_2.TransceiverPairingModes; } });
|
|
30
37
|
var peerConnectionEvents_2 = require("./api/peerConnectionEvents");
|
|
38
|
+
Object.defineProperty(exports, "RTCPeerConnectionIceErrorEvent", { enumerable: true, get: function () { return peerConnectionEvents_2.RTCPeerConnectionIceErrorEvent; } });
|
|
31
39
|
Object.defineProperty(exports, "RTCTrackEvent", { enumerable: true, get: function () { return peerConnectionEvents_2.RTCTrackEvent; } });
|
|
32
40
|
const log = (0, common_1.debug)("werift:packages/webrtc/src/peerConnection.ts");
|
|
33
41
|
/**
|
|
@@ -252,6 +260,30 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
252
260
|
writable: true,
|
|
253
261
|
value: false
|
|
254
262
|
});
|
|
263
|
+
/**
|
|
264
|
+
* The current gathering's STUN / TURN outcomes by URL, for the 701 of
|
|
265
|
+
* `icecandidateerror` (see RTCPeerConnectionIceErrorEvent): the
|
|
266
|
+
* transports that reached the server, and the 701s of the transports
|
|
267
|
+
* that tried and did not, in order. Judged once when `iceGatheringState`
|
|
268
|
+
* leaves "gathering" (fireUnreachableServerErrors) and cleared when it
|
|
269
|
+
* enters "gathering".
|
|
270
|
+
*/
|
|
271
|
+
/**
|
|
272
|
+
* True while the 701s of the gathering that just ended are dispatched:
|
|
273
|
+
* `iceGatheringState` still reads "gathering" for their handlers.
|
|
274
|
+
*/
|
|
275
|
+
Object.defineProperty(this, "firingGatheringErrors", {
|
|
276
|
+
enumerable: true,
|
|
277
|
+
configurable: true,
|
|
278
|
+
writable: true,
|
|
279
|
+
value: false
|
|
280
|
+
});
|
|
281
|
+
Object.defineProperty(this, "gatheringServerOutcomes", {
|
|
282
|
+
enumerable: true,
|
|
283
|
+
configurable: true,
|
|
284
|
+
writable: true,
|
|
285
|
+
value: new Map()
|
|
286
|
+
});
|
|
255
287
|
/**
|
|
256
288
|
* The last operation of the chain: `done` when it finished, `applied` when
|
|
257
289
|
* the description it applies is in place (setLocalDescription's gathering
|
|
@@ -348,6 +380,19 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
348
380
|
writable: true,
|
|
349
381
|
value: new common_1.Event()
|
|
350
382
|
});
|
|
383
|
+
/**
|
|
384
|
+
* `icecandidateerror` (see {@link RTCPeerConnectionIceErrorEvent}): the
|
|
385
|
+
* same event object is passed here, to `onicecandidateerror` and to the
|
|
386
|
+
* `icecandidateerror` listeners.
|
|
387
|
+
*/
|
|
388
|
+
Object.defineProperty(this, "onIceCandidateError", {
|
|
389
|
+
enumerable: true,
|
|
390
|
+
configurable: true,
|
|
391
|
+
writable: true,
|
|
392
|
+
value: new common_1.Event({
|
|
393
|
+
onListenerError: (error) => log("onIceCandidateError subscriber threw", error),
|
|
394
|
+
})
|
|
395
|
+
});
|
|
351
396
|
Object.defineProperty(this, "onNegotiationneeded", {
|
|
352
397
|
enumerable: true,
|
|
353
398
|
configurable: true,
|
|
@@ -380,6 +425,9 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
380
425
|
cname: this.cname,
|
|
381
426
|
bundlePolicy: this.config.bundlePolicy,
|
|
382
427
|
mLineReuse: this.config.mLineReuse,
|
|
428
|
+
bundleCandidates: this.config.bundleCandidates,
|
|
429
|
+
iceRenomination: this.config.iceRenomination,
|
|
430
|
+
iceOptionIce2: this.config.iceOptionIce2,
|
|
383
431
|
});
|
|
384
432
|
this.transceiverManager = new media_1.TransceiverManager(this.cname, this.config, this.router);
|
|
385
433
|
this.transceiverManager.onTransceiverAdded.pipe(this.onTransceiverAdded);
|
|
@@ -406,7 +454,7 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
406
454
|
createTransport: () => this.findOrCreateTransport(),
|
|
407
455
|
createOwnerTransport: () => this.createOwnerTransport(),
|
|
408
456
|
onRemoteTransceiverAdded: (transceiver) => this.onRemoteTransceiverAdded.execute(transceiver),
|
|
409
|
-
});
|
|
457
|
+
}, this.config.transceiverPairing);
|
|
410
458
|
this.validator = new descriptionValidation_1.DescriptionValidation(this.config, this.sdpManager, this.transceiverManager, this.sctpManager, this.negotiation, this.topology);
|
|
411
459
|
this.sctpManager.onDataChannel.subscribe((channel) => {
|
|
412
460
|
this.onDataChannel.execute(channel);
|
|
@@ -428,6 +476,17 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
428
476
|
createTransport: () => this.findOrCreateTransport(),
|
|
429
477
|
});
|
|
430
478
|
this.secureManager.iceGatheringStateChange.subscribe((state) => {
|
|
479
|
+
if (state === "gathering") {
|
|
480
|
+
this.gatheringServerOutcomes = new Map();
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
// The gathering ended: its 701s fire before the state change.
|
|
484
|
+
this.fireUnreachableServerErrors();
|
|
485
|
+
}
|
|
486
|
+
// A closed connection fires no event (also when a handler of those
|
|
487
|
+
// 701s closed it, or a transport closing mid-gathering ends it).
|
|
488
|
+
if (this.isClosed)
|
|
489
|
+
return;
|
|
431
490
|
this.iceGatheringStateChange.execute(state);
|
|
432
491
|
this.onicegatheringstatechange?.(new globalThis.Event("icegatheringstatechange"));
|
|
433
492
|
this.emit("icegatheringstatechange");
|
|
@@ -440,10 +499,13 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
440
499
|
this.oniceconnectionstatechange?.();
|
|
441
500
|
this.emit("iceconnectionstatechange");
|
|
442
501
|
});
|
|
502
|
+
// Each notification is isolated: an application listener that throws
|
|
503
|
+
// must not stop the others nor the transport state propagation that
|
|
504
|
+
// triggered it (e.g. SCTP closing after a DTLS failure).
|
|
443
505
|
this.secureManager.connectionStateChange.subscribe((state) => {
|
|
444
|
-
this.connectionStateChange.
|
|
445
|
-
this.onconnectionstatechange?.();
|
|
446
|
-
this.
|
|
506
|
+
this.connectionStateChange.executeIsolated((error) => log("connectionStateChange listener failed", error), state);
|
|
507
|
+
(0, helper_1.notifySafely)(log, "onconnectionstatechange", () => this.onconnectionstatechange?.());
|
|
508
|
+
this.emitIsolated((error) => log("connectionstatechange listener failed", error), "connectionstatechange");
|
|
447
509
|
});
|
|
448
510
|
this.secureManager.onIceCandidate.subscribe((candidate) => {
|
|
449
511
|
const iceCandidate = candidate ? candidate.toJSON() : undefined;
|
|
@@ -466,6 +528,10 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
466
528
|
return this.secureManager.iceGatheringState;
|
|
467
529
|
}
|
|
468
530
|
get iceGatheringState() {
|
|
531
|
+
// The 701s of a gathering fire while it is still "gathering" (W3C): the
|
|
532
|
+
// ended state shows only from its icegatheringstatechange on.
|
|
533
|
+
if (this.firingGatheringErrors)
|
|
534
|
+
return "gathering";
|
|
469
535
|
return this.secureManager.iceGatheringState;
|
|
470
536
|
}
|
|
471
537
|
get dtlsTransports() {
|
|
@@ -483,6 +549,134 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
483
549
|
get iceTransports() {
|
|
484
550
|
return this.secureManager.iceTransports;
|
|
485
551
|
}
|
|
552
|
+
/** The outcome record of `url` in the current gathering. */
|
|
553
|
+
gatheringServerOutcome(url) {
|
|
554
|
+
let outcome = this.gatheringServerOutcomes.get(url);
|
|
555
|
+
if (!outcome) {
|
|
556
|
+
outcome = { reached: [], unreached: [] };
|
|
557
|
+
this.gatheringServerOutcomes.set(url, outcome);
|
|
558
|
+
}
|
|
559
|
+
return outcome;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Judge the gathering that just ended (W3C: a 701 means no host candidate
|
|
563
|
+
* reached the server, once per URL per gathering): fire one 701 for each
|
|
564
|
+
* URL some transport tried without reaching it and none reached. Only
|
|
565
|
+
* transports still live count (not closed, not pending only), with the
|
|
566
|
+
* ICE generation they had: one that left during the gathering, or whose
|
|
567
|
+
* generation an ICE restart replaced, neither reached nor failed for it.
|
|
568
|
+
* The event carries the first counted failure (its local address and
|
|
569
|
+
* text). Stops as soon as the connection is closed (a handler may close
|
|
570
|
+
* it).
|
|
571
|
+
*/
|
|
572
|
+
fireUnreachableServerErrors() {
|
|
573
|
+
this.firingGatheringErrors = true;
|
|
574
|
+
try {
|
|
575
|
+
this.judgeUnreachableServers();
|
|
576
|
+
}
|
|
577
|
+
finally {
|
|
578
|
+
this.firingGatheringErrors = false;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
judgeUnreachableServers() {
|
|
582
|
+
const outcomes = this.gatheringServerOutcomes;
|
|
583
|
+
this.gatheringServerOutcomes = new Map();
|
|
584
|
+
if (this.isClosed)
|
|
585
|
+
return;
|
|
586
|
+
const live = new Set(this.secureManager.iceTransports.filter((transport) => transport.state !== "closed" &&
|
|
587
|
+
!this.negotiation.isPendingOnlyTransport(transport.id)));
|
|
588
|
+
const counts = (entry) => live.has(entry.transport) &&
|
|
589
|
+
entry.transport.connection.generation === entry.generation;
|
|
590
|
+
for (const { reached, unreached } of outcomes.values()) {
|
|
591
|
+
// A handler of an earlier 701 may have closed the connection: a
|
|
592
|
+
// closed connection fires nothing more.
|
|
593
|
+
if (this.isClosed)
|
|
594
|
+
return;
|
|
595
|
+
if (reached.some(counts))
|
|
596
|
+
continue;
|
|
597
|
+
const first = unreached.find(counts);
|
|
598
|
+
if (first)
|
|
599
|
+
this.dispatchIceCandidateError(first.details);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Dispatch an `icecandidateerror` to `onIceCandidateError`,
|
|
604
|
+
* `onicecandidateerror` and the listeners, in that order, with one event
|
|
605
|
+
* object. A handler calling `stopImmediatePropagation()` stops the ones
|
|
606
|
+
* after it (also the later subscribers of onIceCandidateError); a
|
|
607
|
+
* listener removed during the dispatch is not called, one added during it
|
|
608
|
+
* is not called this time.
|
|
609
|
+
*/
|
|
610
|
+
dispatchIceCandidateError(details) {
|
|
611
|
+
const event = new peerConnectionEvents_1.RTCPeerConnectionIceErrorEvent("icecandidateerror", details);
|
|
612
|
+
// Not dispatched through a native EventTarget, so set what a listener
|
|
613
|
+
// sees of the dispatch itself (W3C DOM: target, currentTarget, phase).
|
|
614
|
+
const setDispatchState = (currentTarget, eventPhase) => {
|
|
615
|
+
for (const [key, value] of Object.entries({
|
|
616
|
+
target: this,
|
|
617
|
+
currentTarget,
|
|
618
|
+
eventPhase,
|
|
619
|
+
})) {
|
|
620
|
+
Object.defineProperty(event, key, {
|
|
621
|
+
value,
|
|
622
|
+
configurable: true,
|
|
623
|
+
enumerable: false,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
setDispatchState(this, 2);
|
|
628
|
+
// Fired by the connection (the user agent), not constructed by the
|
|
629
|
+
// application: a trusted event (W3C DOM `isTrusted`).
|
|
630
|
+
Object.defineProperty(event, "isTrusted", {
|
|
631
|
+
value: true,
|
|
632
|
+
enumerable: true,
|
|
633
|
+
});
|
|
634
|
+
// stopImmediatePropagation() stops the listeners after the caller (W3C
|
|
635
|
+
// DOM), in the order below.
|
|
636
|
+
let stopped = false;
|
|
637
|
+
const stopImmediatePropagation = event.stopImmediatePropagation.bind(event);
|
|
638
|
+
Object.defineProperty(event, "stopImmediatePropagation", {
|
|
639
|
+
value: () => {
|
|
640
|
+
stopped = true;
|
|
641
|
+
stopImmediatePropagation();
|
|
642
|
+
},
|
|
643
|
+
configurable: true,
|
|
644
|
+
enumerable: false,
|
|
645
|
+
writable: true,
|
|
646
|
+
});
|
|
647
|
+
const onError = (error) => log("icecandidateerror handler threw", error);
|
|
648
|
+
// The listeners when the dispatch starts (W3C DOM): one added meanwhile
|
|
649
|
+
// is not called this time.
|
|
650
|
+
const listeners = this.rawListeners("icecandidateerror");
|
|
651
|
+
// One throwing handler must not hide the event from the others, and the
|
|
652
|
+
// stop is checked before each one (also between the subscribers of
|
|
653
|
+
// onIceCandidateError).
|
|
654
|
+
this.onIceCandidateError.executeUntil(() => stopped, onError, event);
|
|
655
|
+
if (!stopped) {
|
|
656
|
+
try {
|
|
657
|
+
this.onicecandidateerror?.(event);
|
|
658
|
+
}
|
|
659
|
+
catch (error) {
|
|
660
|
+
onError(error);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
// EventEmitter stops at the first throwing listener: call each one.
|
|
664
|
+
for (const listener of listeners) {
|
|
665
|
+
if (stopped)
|
|
666
|
+
break;
|
|
667
|
+
// Removed meanwhile (removeEventListener): not called (W3C DOM).
|
|
668
|
+
if (!this.rawListeners("icecandidateerror").includes(listener)) {
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
try {
|
|
672
|
+
listener.call(this, event);
|
|
673
|
+
}
|
|
674
|
+
catch (error) {
|
|
675
|
+
onError(error);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
setDispatchState(null, 0);
|
|
679
|
+
}
|
|
486
680
|
get extIdUriMap() {
|
|
487
681
|
return this.router.extIdUriMap;
|
|
488
682
|
}
|
|
@@ -512,13 +706,19 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
512
706
|
if (!remoteDescription) {
|
|
513
707
|
return null;
|
|
514
708
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
709
|
+
return (0, sdp_1.descriptionIceOptions)(remoteDescription).includes("trickle");
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Whether the remote description declares the `ice2` ice-option (an
|
|
713
|
+
* RFC 8445 agent, RFC 8839 §5.6), or null without a remote description.
|
|
714
|
+
* Informational: werift runs the RFC 8445 procedures either way.
|
|
715
|
+
*/
|
|
716
|
+
get remoteIceOptionIce2() {
|
|
717
|
+
const remoteDescription = this.sdpManager._remoteDescription;
|
|
718
|
+
if (!remoteDescription) {
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
721
|
+
return (0, sdp_1.descriptionIceOptions)(remoteDescription).includes("ice2");
|
|
522
722
|
}
|
|
523
723
|
get remoteIsBundled() {
|
|
524
724
|
return this.sdpManager.remoteIsBundled;
|
|
@@ -647,11 +847,12 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
647
847
|
// generation the answer would commit: applied once that answer made the
|
|
648
848
|
// session stable, its credentials are the live ones.
|
|
649
849
|
await this.secureManager.ensureCerts();
|
|
850
|
+
// Every offer lists what each transceiver can use now, whatever an earlier
|
|
851
|
+
// answer narrowed (RFC 8829 5.2.2); a negotiated transceiver keeps its
|
|
852
|
+
// negotiated codecs live until an answer commits new ones
|
|
853
|
+
// (TransceiverManager.resolveOfferCodecs).
|
|
854
|
+
const offerCodecs = this.transceiverManager.resolveOfferCodecs();
|
|
650
855
|
for (const transceiver of this.transceiverManager.getTransceivers()) {
|
|
651
|
-
if (transceiver.codecs.length === 0 ||
|
|
652
|
-
transceiver.codecPreferencesNeedResolution) {
|
|
653
|
-
this.transceiverManager.assignTransceiverCodecs(transceiver);
|
|
654
|
-
}
|
|
655
856
|
if (transceiver.headerExtensions.length === 0) {
|
|
656
857
|
transceiver.headerExtensions =
|
|
657
858
|
this.config.headerExtensions[transceiver.kind] ?? [];
|
|
@@ -667,7 +868,7 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
667
868
|
const positions = transceivers.map((t) => [t.mid, t.mLineIndex]);
|
|
668
869
|
const sctp = this.sctpTransport;
|
|
669
870
|
const sctpPosition = sctp && [sctp.mid, sctp.mLineIndex];
|
|
670
|
-
const description = this.sdpManager.buildOfferSdp(transceivers, this.sctpTransport);
|
|
871
|
+
const description = this.sdpManager.buildOfferSdp(transceivers, this.sctpTransport, offerCodecs);
|
|
671
872
|
const transceiverByMid = new Map(transceivers
|
|
672
873
|
.filter((t) => t.mid != undefined)
|
|
673
874
|
.map((t) => [t.mid, t]));
|
|
@@ -827,7 +1028,7 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
827
1028
|
}
|
|
828
1029
|
const dtlsTransport = this.secureManager.createTransport(forceNew);
|
|
829
1030
|
dtlsTransport.onRtp.subscribe((rtp) => {
|
|
830
|
-
this.router.routeRtp(rtp);
|
|
1031
|
+
this.router.routeRtp(rtp, dtlsTransport);
|
|
831
1032
|
});
|
|
832
1033
|
dtlsTransport.onRtcp.subscribe((rtcp) => {
|
|
833
1034
|
this.router.routeRtcp(rtcp, dtlsTransport);
|
|
@@ -837,6 +1038,37 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
837
1038
|
iceTransport.onNegotiationNeeded.subscribe(() => {
|
|
838
1039
|
this.needNegotiation();
|
|
839
1040
|
});
|
|
1041
|
+
iceTransport.onIceServerReached.subscribe((urls) => {
|
|
1042
|
+
if (this.isClosed ||
|
|
1043
|
+
this.negotiation.isPendingOnlyTransport(iceTransport.id)) {
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
for (const url of urls) {
|
|
1047
|
+
this.gatheringServerOutcome(url).reached.push({
|
|
1048
|
+
transport: iceTransport,
|
|
1049
|
+
generation: iceTransport.connection.generation,
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
iceTransport.onIceCandidateError.subscribe((details) => {
|
|
1054
|
+
// A closed connection fires nothing; a transport a rollback discards
|
|
1055
|
+
// (pending only) is not announced, as for its candidates.
|
|
1056
|
+
if (this.isClosed ||
|
|
1057
|
+
this.negotiation.isPendingOnlyTransport(iceTransport.id)) {
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
// A 701 waits for the end of the gathering (fireUnreachableServerErrors);
|
|
1061
|
+
// a server's error response (300-699) fires now.
|
|
1062
|
+
if (details.errorCode === 701) {
|
|
1063
|
+
this.gatheringServerOutcome(details.url).unreached.push({
|
|
1064
|
+
transport: iceTransport,
|
|
1065
|
+
generation: iceTransport.connection.generation,
|
|
1066
|
+
details,
|
|
1067
|
+
});
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
this.dispatchIceCandidateError(details);
|
|
1071
|
+
});
|
|
840
1072
|
iceTransport.onIceCandidate.subscribe((candidate) => {
|
|
841
1073
|
if (this.applyingIceRestart ||
|
|
842
1074
|
this.negotiation.isPendingOnlyTransport(iceTransport.id))
|
|
@@ -1096,8 +1328,9 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1096
1328
|
if (!answered || answered.rtp.codecs.length === 0)
|
|
1097
1329
|
continue;
|
|
1098
1330
|
const resolved = transceiver.codecs;
|
|
1331
|
+
const stale = transceiver.negotiatedCodecsStale;
|
|
1099
1332
|
transceiver.codecs = [...answered.rtp.codecs];
|
|
1100
|
-
if (!sameCodecList(resolved, transceiver.codecs)) {
|
|
1333
|
+
if (stale || !sameCodecList(resolved, transceiver.codecs)) {
|
|
1101
1334
|
resolveAfterAnswer.push(transceiver);
|
|
1102
1335
|
}
|
|
1103
1336
|
}
|
|
@@ -1205,7 +1438,7 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1205
1438
|
if (description.type === "answer") {
|
|
1206
1439
|
// answer の確定で拒否予定の m-line を停止し、RTP pipeline を解放する
|
|
1207
1440
|
this.transceiverManager.commitRemoteOffer();
|
|
1208
|
-
// port 0 で答えた m-line (aggressive の inactive など) は offerer 側で拒否として
|
|
1441
|
+
// port 0 で答えた m-line (mLineReuse: "aggressive" の inactive など) は offerer 側で拒否として
|
|
1209
1442
|
// 停止が確定する。answerer 側も同じ位置を停止確定にし、offerer が新 MID で再利用できるようにする
|
|
1210
1443
|
for (const media of description.media) {
|
|
1211
1444
|
if (!["audio", "video"].includes(media.kind) || media.port !== 0) {
|
|
@@ -1307,7 +1540,17 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1307
1540
|
this.iceRestartRequest.settle(this.sdpManager.currentLocalDescription);
|
|
1308
1541
|
// answerer の stop() は次の自分の offer で交渉する
|
|
1309
1542
|
const hasUnnegotiatedStop = description.type === "answer" && this.settleStoppingTransceivers();
|
|
1310
|
-
if
|
|
1543
|
+
// W3C "check if negotiation is needed": under "standard" pairing a remote
|
|
1544
|
+
// offer leaves an addTransceiver() transceiver unassociated (JSEP
|
|
1545
|
+
// 5.10), so returning to stable fires negotiationneeded for it.
|
|
1546
|
+
const hasUnassociatedTransceiver = description.type === "answer" &&
|
|
1547
|
+
this.config.transceiverPairing === "standard" &&
|
|
1548
|
+
this.transceiverManager
|
|
1549
|
+
.getTransceivers()
|
|
1550
|
+
.some((t) => t.mid == null && !t.stopping && !t.stopped);
|
|
1551
|
+
if (this.negotiationNeed.recheck ||
|
|
1552
|
+
hasUnnegotiatedStop ||
|
|
1553
|
+
hasUnassociatedTransceiver) {
|
|
1311
1554
|
this.negotiationNeed.schedule();
|
|
1312
1555
|
}
|
|
1313
1556
|
this.invalidateLastCreatedDescriptions();
|
|
@@ -1419,9 +1662,20 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1419
1662
|
type: sessionDescription.type,
|
|
1420
1663
|
});
|
|
1421
1664
|
this.validator.validateRemote(remoteSdp, this.signalingState);
|
|
1665
|
+
const needsImplicitLocalRollback = sessionDescription.type === "offer" &&
|
|
1666
|
+
["have-local-offer", "have-local-pranswer"].includes(this.signalingState);
|
|
1422
1667
|
// Resolve codec compatibility before implicit rollback or any transaction
|
|
1423
1668
|
// mutation, then pass the same plan into the staged m-line application.
|
|
1424
|
-
|
|
1669
|
+
// The plan pairs m-lines with the transceivers as the application will
|
|
1670
|
+
// see them after the implicit rollback / replacement / revert, so both
|
|
1671
|
+
// pair every m-line with the same transceiver.
|
|
1672
|
+
const codecPlan = this.remoteMedia.planCodecs(remoteSdp, remoteSdp.type === "offer"
|
|
1673
|
+
? this.negotiation.pairingViewForRemoteOffer(remoteSdp, needsImplicitLocalRollback
|
|
1674
|
+
? "rollback"
|
|
1675
|
+
: this.signalingState === "have-remote-offer"
|
|
1676
|
+
? "replace"
|
|
1677
|
+
: undefined)
|
|
1678
|
+
: undefined);
|
|
1425
1679
|
// Queued candidates are placed against the parsed proposal before any
|
|
1426
1680
|
// state changes or application events (track, transceiver) fire.
|
|
1427
1681
|
// Only a non-empty queue awaits, so ordinary offers keep their timing.
|
|
@@ -1429,8 +1683,6 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1429
1683
|
await this.remoteCandidates.validateQueued(remoteSdp);
|
|
1430
1684
|
this.assertOpenAfterYield();
|
|
1431
1685
|
}
|
|
1432
|
-
const needsImplicitLocalRollback = sessionDescription.type === "offer" &&
|
|
1433
|
-
["have-local-offer", "have-local-pranswer"].includes(this.signalingState);
|
|
1434
1686
|
if (needsImplicitLocalRollback) {
|
|
1435
1687
|
this.negotiation.retireRemoteGeneration(this.sdpManager.pendingRemoteDescription);
|
|
1436
1688
|
this.sdpManager.rollbackLocalDescription(this.signalingState);
|
|
@@ -1636,7 +1888,7 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1636
1888
|
if (this.isClosed) {
|
|
1637
1889
|
throw (0, errors_1.createWebRtcDomException)("InvalidStateError", "is closed");
|
|
1638
1890
|
}
|
|
1639
|
-
const transceiver = this.transceiverManager.addTrack(track, streams);
|
|
1891
|
+
const transceiver = this.transceiverManager.addTrack(track, streams, () => this.findOrCreateTransport());
|
|
1640
1892
|
if (!transceiver.dtlsTransport) {
|
|
1641
1893
|
const dtlsTransport = this.findOrCreateTransport();
|
|
1642
1894
|
transceiver.setDtlsTransport(dtlsTransport);
|
|
@@ -1678,10 +1930,8 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1678
1930
|
// setCodecPreferences() は negotiated codec と分けて保持される。
|
|
1679
1931
|
// Answer SDP 用の候補だけを再解決し、送受信の live table は commit まで触らない。
|
|
1680
1932
|
for (const transceiver of this.transceiverManager.getTransceivers()) {
|
|
1681
|
-
if (transceiver.
|
|
1682
|
-
!transceiver.codecPreferencesNeedResolution) {
|
|
1933
|
+
if (!transceiver.needsCodecResolution)
|
|
1683
1934
|
continue;
|
|
1684
|
-
}
|
|
1685
1935
|
if (transceiver.pendingRejection ||
|
|
1686
1936
|
transceiver.stopping ||
|
|
1687
1937
|
transceiver.stopped) {
|
|
@@ -1787,6 +2037,10 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1787
2037
|
this.remoteCandidates.queued.length = 0;
|
|
1788
2038
|
this.setSignalingState("closed");
|
|
1789
2039
|
this.transceiverManager.close();
|
|
2040
|
+
// W3C close(): SCTP / DTLS / connectionState は同期に closed(statechange なし)。
|
|
2041
|
+
// 送信(SCTP ABORT → close_notify → ICE 停止)はこの後の非同期部分で行う。
|
|
2042
|
+
this.sctpManager.markClosed();
|
|
2043
|
+
this.secureManager.markClosed();
|
|
1790
2044
|
// SCTP ABORT は DTLS/ICE が生きている間に送る(close は abrupt であり SHUTDOWN ではない)
|
|
1791
2045
|
await this.sctpManager.close();
|
|
1792
2046
|
await this.negotiation.dispose();
|
|
@@ -1805,6 +2059,7 @@ class RTCPeerConnection extends helper_1.EventTarget {
|
|
|
1805
2059
|
this.onTransceiverAdded,
|
|
1806
2060
|
this.onRemoteTransceiverAdded,
|
|
1807
2061
|
this.onIceCandidate,
|
|
2062
|
+
this.onIceCandidateError,
|
|
1808
2063
|
this.onNegotiationneeded,
|
|
1809
2064
|
];
|
|
1810
2065
|
for (const event of events) {
|