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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nack.js","sourceRoot":"","sources":["../../../../../src/media/receiver/nack.ts"],"names":[],"mappings":";;;AAAA,iDAAwD;AACxD,2CAK2B;AAG3B,MAAM,GAAG,GAAG,IAAA,WAAK,EAAC,mDAAmD,CAAC,CAAC;AAEvE,MAAM,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;AAEzB,MAAa,WAAW;IAYtB,YAAY,QAAwB;QAX5B;;;;;WAAyB;QAEzB;;;;mBAAe,CAAC;WAAC;QACjB;;;;mBAAsC,EAAE;WAAC;QACzC;;;;;WAAc;QAEb;;;;mBAAe,IAAI,cAAK,EAAiB;WAAC;QACnD;;;;;WAAyB;QACzB;;;;mBAAa,EAAE;WAAC;QAChB;;;;mBAAS,KAAK;WAAC;QAoGP;;;;mBAAW,GAAG,EAAE,CACtB,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACnB,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;oBAC3D,MAAM,IAAI,GAAG,IAAI,iBAAW,CAAC;wBAC3B,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;wBAClC,eAAe,EAAE,IAAI,CAAC,eAAe;wBACrC,IAAI,EAAE,IAAI,CAAC,cAAc;qBAC1B,CAAC,CAAC;oBAEH,MAAM,IAAI,GAAG,IAAI,gCAA0B,CAAC;wBAC1C,QAAQ,EAAE,IAAI;qBACf,CAAC,CAAC;oBACH,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,QAA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iBACpC,KAAK,CAAC,CAAC,SAAS,CAAC;iBACjB,MAAM,CACL,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE;gBAChB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACb,OAAO,GAAG,CAAC;YACb,CAAC,EACD,EAAkC,CACnC,CAAC;QACN,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAClC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC5B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;gBACrB,OAAO,GAAG,CAAC;YACb,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CAoBF;AAhID,kCAgIC","sourcesContent":["import { Event, uint16Add } from \"../../imports/common\";\nimport {\n debug,\n GenericNack,\n RtcpTransportLayerFeedback,\n type RtpPacket,\n} from \"../../imports/rtp\";\nimport type { RTCRtpReceiver } from \"../rtpReceiver\";\n\nconst log = debug(\"werift:packages/webrtc/src/media/receiver/nack.ts\");\n\nconst LOST_SIZE = 30 * 5;\n\nexport class NackHandler {\n private receiver: RTCRtpReceiver;\n\n private newEstSeqNum = 0;\n private _lost: { [seqNum: number]: number } = {};\n private nackLoop: any;\n\n readonly onPacketLost = new Event<[GenericNack]>();\n mediaSourceSsrc?: number;\n retryCount = 10;\n closed = false;\n\n constructor(receiver: RTCRtpReceiver) {\n this.receiver = receiver;\n }\n\n get lostSeqNumbers() {\n return Object.keys(this._lost).map(Number).sort();\n }\n\n private getLost(seq: number) {\n return this._lost[seq];\n }\n\n private setLost(seq: number, count: number) {\n this._lost[seq] = count;\n\n if (this.nackLoop || this.closed) {\n return;\n }\n this.nackLoop = setInterval(async () => {\n try {\n await this.sendNack();\n if (!Object.keys(this._lost).length) {\n clearInterval(this.nackLoop);\n this.nackLoop = undefined;\n }\n } catch (error) {\n log(\"failed to send nack\", error);\n }\n }, 5);\n }\n\n private removeLost(sequenceNumber: number) {\n delete this._lost[sequenceNumber];\n }\n\n addPacket(packet: RtpPacket) {\n const { sequenceNumber, ssrc } = packet.header;\n this.mediaSourceSsrc = ssrc;\n\n if (this.newEstSeqNum === 0) {\n this.newEstSeqNum = sequenceNumber;\n return;\n }\n\n if (this.getLost(sequenceNumber)) {\n // log(\"packetLoss resolved\", { sequenceNumber });\n this.removeLost(sequenceNumber);\n return;\n }\n\n if (sequenceNumber === uint16Add(this.newEstSeqNum, 1)) {\n this.newEstSeqNum = sequenceNumber;\n } else if (sequenceNumber > uint16Add(this.newEstSeqNum, 1)) {\n // packet lost detected\n for (\n let i = uint16Add(this.newEstSeqNum, 1);\n i < sequenceNumber;\n i = uint16Add(i, 1)\n ) {\n this.setLost(i, 1);\n }\n // this.receiver.sendRtcpPLI(this.mediaSourceSsrc);\n\n this.newEstSeqNum = sequenceNumber;\n this.pruneLost();\n }\n }\n\n private pruneLost() {\n if (this.lostSeqNumbers.length > LOST_SIZE) {\n this._lost = Object.entries(this._lost)\n .slice(-LOST_SIZE)\n .reduce(\n (acc, [key, v]) => {\n acc[key] = v;\n return acc;\n },\n {} as { [seqNum: number]: number },\n );\n }\n }\n\n close() {\n this.closed = true;\n clearInterval(this.nackLoop);\n this._lost = {};\n }\n\n private updateRetryCount() {\n this.lostSeqNumbers.forEach((seq) => {\n const count = this._lost[seq]++;\n if (count > this.retryCount) {\n this.removeLost(seq);\n return seq;\n }\n });\n }\n\n private sendNack = () =>\n new Promise((r, f) => {\n if (this.lostSeqNumbers.length > 0 && this.mediaSourceSsrc) {\n const nack = new GenericNack({\n senderSsrc: this.receiver.rtcpSsrc,\n mediaSourceSsrc: this.mediaSourceSsrc,\n lost: this.lostSeqNumbers,\n });\n\n const rtcp = new RtcpTransportLayerFeedback({\n feedback: nack,\n });\n this.receiver.dtlsTransport.sendRtcp([rtcp]).then(r).catch(f);\n\n this.updateRetryCount();\n this.onPacketLost.execute(nack);\n }\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nack.js","sourceRoot":"","sources":["../../../../../src/media/receiver/nack.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,2CAK2B;AAG3B,MAAM,GAAG,GAAG,IAAA,WAAK,EAAC,mDAAmD,CAAC,CAAC;AAEvE,qDAAqD;AACrD,MAAM,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;AACzB;;;;GAIG;AACU,QAAA,SAAS,GAAG,IAAI,CAAC;AAC9B;;;;;GAKG;AACU,QAAA,gBAAgB,GAAG,EAAE,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAa,WAAW;IAUtB,YAAY,QAAwB;QATnB;;;;;WAAyB;QACzB;;;;mBAAU,IAAI,GAAG,EAAsB;WAAC;QAEhD;;;;mBAAe,IAAI,cAAK,EAAiB;WAAC;QACnD,uCAAuC;QACvC;;;;;WAAyB;QACzB;;;;mBAAa,EAAE;WAAC;QAChB;;;;mBAAS,KAAK;WAAC;QAGb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,sDAAsD;IACtD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,KAAK,SAAS;YACvC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClD,CAAC;IAED,gBAAgB,CAAC,IAAY;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,cAAc,IAAI,EAAE,CAAC;IACtD,CAAC;IAED,mCAA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K,EAAE,CAAC;gBACf,GAAG,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAEO,QAAQ;QACd,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,QAAQ;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC;QACjC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;gBAAE,SAAS;YAC1C,IAAI,EAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;gBAAE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC3E,CAAC;QACD,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import { Event } from \"../../imports/common\";\nimport {\n debug,\n GenericNack,\n RtcpTransportLayerFeedback,\n type RtpPacket,\n} from \"../../imports/rtp\";\nimport type { RTCRtpReceiver } from \"../rtpReceiver\";\n\nconst log = debug(\"werift:packages/webrtc/src/media/receiver/nack.ts\");\n\n/** Holes NACK asks for at once (the newest ones). */\nconst LOST_SIZE = 30 * 5;\n/**\n * Holes kept per media SSRC for RTX verification. At least {@link LOST_SIZE},\n * so every requested hole is kept; holes past NACK's retries stay\n * verifiable until this bound, for an RTX that answers an earlier NACK late.\n */\nexport const MAX_HOLES = 1024;\n/**\n * Media SSRCs with NACK state at once. A receiver has a few live SSRCs (one\n * per simulcast layer); a sender that keeps changing SSRCs must not grow the\n * state for the receiver's lifetime, so the least recently received SSRC is\n * dropped (its timer stopped) beyond this. Its next packet starts afresh.\n */\nexport const MAX_NACK_STREAMS = 16;\n\n/**\n * Generic NACK (RFC 4585 section 6.2.1) for the media SSRCs of one receiver.\n * Loss detection and retransmission requests are kept per media SSRC, so the\n * layers of a simulcast receiver (one SSRC each) never compare their sequence\n * numbers with each other and each NACK names the SSRC that lost the packets.\n * At most {@link MAX_NACK_STREAMS} SSRCs keep state (least recently received\n * evicted first).\n */\nexport class NackHandler {\n private readonly receiver: RTCRtpReceiver;\n private readonly streams = new Map<number, NackStream>();\n\n readonly onPacketLost = new Event<[GenericNack]>();\n /** Media SSRC of the latest packet. */\n mediaSourceSsrc?: number;\n retryCount = 10;\n closed = false;\n\n constructor(receiver: RTCRtpReceiver) {\n this.receiver = receiver;\n }\n\n /** Lost sequence numbers of the latest media SSRC. */\n get lostSeqNumbers() {\n return this.mediaSourceSsrc === undefined\n ? []\n : this.lostSeqNumbersOf(this.mediaSourceSsrc);\n }\n\n lostSeqNumbersOf(ssrc: number) {\n return this.streams.get(ssrc)?.lostSeqNumbers ?? [];\n }\n\n /** Media SSRCs with NACK state. */\n get ssrcs() {\n return [...this.streams.keys()];\n }\n\n /** `packet` is a media packet (RTX already restored to its media SSRC). */\n addPacket(packet: RtpPacket) {\n const { ssrc } = packet.header;\n this.mediaSourceSsrc = ssrc;\n if (this.closed) return;\n\n let stream = this.streams.get(ssrc);\n if (stream) {\n // Map の挿入順を受信順に保ち、先頭を最も古い SSRC にする。\n this.streams.delete(ssrc);\n } else {\n stream = new NackStream(ssrc, this);\n }\n this.streams.set(ssrc, stream);\n if (this.streams.size > MAX_NACK_STREAMS) {\n const [oldest, evicted] = this.streams.entries().next().value!;\n evicted.close();\n this.streams.delete(oldest);\n }\n stream.addPacket(packet.header.sequenceNumber, packet.header.timestamp);\n }\n\n /**\n * Whether an RTX packet restoring `sequenceNumber` / `timestamp` on `ssrc`\n * fills a hole this handler detected: its number is a hole of `ssrc` (NACK\n * asks for it, or asked and still keeps it) and its timestamp lies within\n * the timestamps of the packets received around the gap, in either order\n * (frames sent out of display order) and widened by `slack`.\n */\n canRepair(\n ssrc: number,\n sequenceNumber: number,\n timestamp: number,\n slack: number,\n ) {\n return (\n this.streams.get(ssrc)?.canRepair(sequenceNumber, timestamp, slack) ??\n false\n );\n }\n\n /** Reset `ssrc`: its NACK requests and holes end together. */\n forget(ssrc: number) {\n this.streams.get(ssrc)?.close();\n this.streams.delete(ssrc);\n }\n\n /** Holes kept for `ssrc` (requested or not). */\n holeCountOf(ssrc: number) {\n return this.streams.get(ssrc)?.holeCount ?? 0;\n }\n\n close() {\n this.closed = true;\n for (const stream of this.streams.values()) stream.close();\n this.streams.clear();\n }\n\n /** Internal: send one NACK for `ssrc` and notify {@link onPacketLost}. */\n async sendNack(ssrc: number, lost: number[]) {\n const nack = new GenericNack({\n senderSsrc: this.receiver.rtcpSsrc,\n mediaSourceSsrc: ssrc,\n lost,\n });\n const rtcp = new RtcpTransportLayerFeedback({ feedback: nack });\n const sent = this.receiver.dtlsTransport.sendRtcp([rtcp]);\n this.onPacketLost.execute(nack);\n await sent;\n }\n}\n\n/** A missing packet of a media SSRC, from the moment NACK detected it. */\ninterface Hole {\n sequenceNumber: number;\n /** Timestamps of the received packets before and after the gap. */\n timestampBefore: number;\n timestampAfter: number;\n /** NACKs sent for it, or `undefined` once NACK stopped asking for it. */\n requests?: number;\n}\n\n/**\n * Loss state of one media SSRC: one ledger of holes serves both NACK (the\n * holes still requested) and RTX verification (every hole kept, see\n * {@link NackHandler.canRepair}). A hole leaves the ledger only when its\n * packet arrives, when it falls out of the bounds below, or when the stream\n * is reset; NACK stops asking for it at that moment at the latest, so a\n * requested packet can always be verified when its RTX arrives.\n */\nclass NackStream {\n /** Extended (wrap-counting) sequence number and timestamp of the newest packet. */\n private newestExt?: number;\n private newestTimestamp = 0;\n /** Holes by extended sequence number, oldest first (insertion order). */\n private readonly holes = new Map<number, Hole>();\n private nackLoop?: ReturnType<typeof setInterval>;\n private readonly ssrc: number;\n private readonly handler: NackHandler;\n\n constructor(ssrc: number, handler: NackHandler) {\n this.ssrc = ssrc;\n this.handler = handler;\n }\n\n /** Sequence numbers NACK still asks for, oldest first. */\n get lostSeqNumbers() {\n const lost: number[] = [];\n for (const hole of this.holes.values()) {\n if (hole.requests !== undefined) lost.push(hole.sequenceNumber);\n }\n return lost;\n }\n\n get holeCount() {\n return this.holes.size;\n }\n\n addPacket(sequenceNumber: number, timestamp: number) {\n if (this.newestExt === undefined) {\n this.newestExt = sequenceNumber;\n this.newestTimestamp = timestamp;\n return;\n }\n const ext = this.extend(sequenceNumber);\n if (ext <= this.newestExt) {\n // 遅着・再送で欠落が埋まった。台帳にない番号は重複か要求外なので何もしない。\n this.holes.delete(ext);\n if (this.holes.size === 0) this.stopLoop();\n return;\n }\n\n // 新しい欠落: 台帳に入るのは末尾 MAX_HOLES 個まで (それ以前は要求も検証もしない)。\n const from = Math.max(this.newestExt + 1, ext - MAX_HOLES);\n for (let missing = from; missing < ext; missing++) {\n this.holes.set(missing, {\n sequenceNumber: missing & 0xffff,\n timestampBefore: this.newestTimestamp,\n timestampAfter: timestamp,\n requests: 0,\n });\n }\n this.newestExt = ext;\n this.newestTimestamp = timestamp;\n this.pruneHoles();\n if (from < ext) this.startLoop();\n }\n\n /** Whether an RTX packet with this original number and timestamp fills a hole. */\n canRepair(sequenceNumber: number, timestamp: number, slack: number) {\n if (this.newestExt === undefined) return false;\n const hole = this.holes.get(this.extend(sequenceNumber));\n if (!hole) return false;\n // 時刻は欠落直後の受信パケットからの符号付き差で比べる (32 bit の折り返しに依存しない)。\n const before = (hole.timestampBefore - hole.timestampAfter) | 0;\n const offset = (timestamp - hole.timestampAfter) | 0;\n return (\n offset >= Math.min(before, 0) - slack &&\n offset <= Math.max(before, 0) + slack\n );\n }\n\n /**\n * Bounds of the ledger. Each removal removes the hole itself, so NACK stops\n * asking for it at the same moment; NACK's own limits (LOST_SIZE requests,\n * `retryCount`) only stop the request and keep the hole verifiable.\n */\n private pruneHoles() {\n const newest = this.newestExt!;\n for (const [ext] of this.holes) {\n // 16 bit の番号は 0x8000 以上離れると前後を区別できない。\n if (this.holes.size <= MAX_HOLES && newest - ext < 0x8000) break;\n this.holes.delete(ext);\n }\n let requested = 0;\n const holes = [...this.holes.values()];\n for (let i = holes.length - 1; i >= 0; i--) {\n if (holes[i].requests === undefined) continue;\n if (++requested > LOST_SIZE) holes[i].requests = undefined;\n }\n }\n\n /** `sequenceNumber` as the extended number nearest the newest. */\n private extend(sequenceNumber: number) {\n const newest = this.newestExt!;\n const delta = (sequenceNumber - newest) & 0xffff;\n return newest + (delta < 0x8000 ? delta : delta - 0x10000);\n }\n\n private startLoop() {\n if (this.nackLoop) return;\n this.nackLoop = setInterval(async () => {\n try {\n await this.sendNack();\n } catch (error) {\n log(\"failed to send nack\", error);\n }\n }, 5);\n }\n\n close() {\n this.stopLoop();\n this.holes.clear();\n }\n\n private stopLoop() {\n clearInterval(this.nackLoop);\n this.nackLoop = undefined;\n }\n\n private async sendNack() {\n const lost = this.lostSeqNumbers;\n if (lost.length === 0) {\n this.stopLoop();\n return;\n }\n for (const hole of this.holes.values()) {\n if (hole.requests === undefined) continue;\n if (++hole.requests > this.handler.retryCount) hole.requests = undefined;\n }\n await this.handler.sendNack(this.ssrc, lost);\n }\n}\n"]}
|
|
@@ -2,26 +2,14 @@ import { type RtcpPacket, type RtpPacket } from "../imports/rtp";
|
|
|
2
2
|
import { type RouterSnapshot } from "../negotiation/internalState";
|
|
3
3
|
import type { RTCDtlsTransport } from "../transport/dtls";
|
|
4
4
|
import type { RTCRtpReceiveParameters, RTCRtpSimulcastParameters } from "./parameters";
|
|
5
|
+
import { type StagedRoutes } from "./routing/pendingRoutes";
|
|
6
|
+
import { type Endpoint, RouteOrigin } from "./routing/routeTable";
|
|
7
|
+
import { type KeyFrameRequestRouting } from "./routing/rtcpRouting";
|
|
5
8
|
import { RTCRtpReceiver } from "./rtpReceiver";
|
|
6
9
|
import type { RTCRtpSender } from "./rtpSender";
|
|
7
10
|
import type { RTCRtpTransceiver } from "./rtpTransceiver";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* - `"compatible"` (default): the sender whose RTX SSRC it is, else the only
|
|
11
|
-
* video sender of the PeerConnection, so that a request naming the RTX
|
|
12
|
-
* stream, SSRC 0 or a stale SSRC still gets a keyframe.
|
|
13
|
-
* - `"strict"`: not delivered (RFC 4585 section 6.1 / RFC 5104 section 4.3.1).
|
|
14
|
-
*
|
|
15
|
-
* A registered target SSRC is routed as is in both modes, and the sender SSRC
|
|
16
|
-
* of the request is never used: it names the requesting peer's own stream.
|
|
17
|
-
*/
|
|
18
|
-
export type KeyFrameRequestRouting = "compatible" | "strict";
|
|
19
|
-
export declare const KeyFrameRequestRoutingModes: readonly KeyFrameRequestRouting[];
|
|
20
|
-
type StagedRoutes = {
|
|
21
|
-
ssrc: [number, RTCRtpReceiver][];
|
|
22
|
-
rid: [string, RTCRtpReceiver][];
|
|
23
|
-
provisional?: [number, RTCRtpReceiver][];
|
|
24
|
-
};
|
|
11
|
+
import { MediaStreamTrack } from "./track";
|
|
12
|
+
export { type KeyFrameRequestRouting, KeyFrameRequestRoutingModes, } from "./routing/rtcpRouting";
|
|
25
13
|
/**
|
|
26
14
|
* RTP routing tables shared by the current session and a pending proposal.
|
|
27
15
|
* One rule covers every key: a pending remote offer or pranswer may **add**
|
|
@@ -34,10 +22,91 @@ type StagedRoutes = {
|
|
|
34
22
|
* | --- | --- | --- |
|
|
35
23
|
* | Payload type → codec | receiver codec table | remap rejected (RFC 3264 section 8.3.2); fmtp / rtcp-fb change staged |
|
|
36
24
|
* | Header extension ID → URI | `extIdUriMap` | remap of an ID in use rejected (RFC 8285 section 7); a URI on a new ID is an addition |
|
|
37
|
-
* | SSRC → receiver | `
|
|
25
|
+
* | SSRC → receiver | `routes` (origin `sdp`) | move to another m-line staged |
|
|
38
26
|
* | RTX SSRC → media SSRC | receiver RTX table | changed pairing staged |
|
|
39
27
|
* | MID+RID → receiver | `ridTable` | RIDs are scoped to their m-line (RFC 8851): no conflict |
|
|
40
|
-
* | Sender SSRC → sender | `
|
|
28
|
+
* | Sender SSRC → sender | `routes` (origin `sender`) | application state: rollback keeps every live sender's route |
|
|
29
|
+
*
|
|
30
|
+
* Packet-driven routes are not description state: an SSRC first seen with
|
|
31
|
+
* `rtp-stream-id` / `repaired-rtp-stream-id` gets a route of origin
|
|
32
|
+
* `learned`, and the receiver learns RID → media SSRC and RTX
|
|
33
|
+
* SSRC → RID (`mediaSsrcByRid` / `ridByRtxSsrc`). Commit and rollback keep them.
|
|
34
|
+
* They are bounded per RID: an SSRC the receiver retires (a media SSRC change
|
|
35
|
+
* of the RID) or evicts loses its learned route here (`takeForgottenSsrcs`),
|
|
36
|
+
* and unregistering a transceiver drops its learned SSRCs.
|
|
37
|
+
*
|
|
38
|
+
* | Packet-driven key | Learned when | Bound |
|
|
39
|
+
* | --- | --- | --- |
|
|
40
|
+
* | SSRC → receiver (RID) | `rtp-stream-id` / `repaired-rtp-stream-id` names a route | per RID (receiver) |
|
|
41
|
+
* | SSRC → receiver (simulcast) | the SSRC is a learned track SSRC of a RID receiver on the packet's transport | as above |
|
|
42
|
+
* | SSRC → receiver (fallback, RFC 9143 section 9.2) | see {@link learnUnknownSsrc} | 8 per receiver, oldest forgotten first |
|
|
43
|
+
*
|
|
44
|
+
* The fallback serves remote m-lines without `a=ssrc` and RIDs (SIP gateways,
|
|
45
|
+
* SBCs, media servers): an SSRC no route, RID or simulcast track knows is
|
|
46
|
+
* learned for the receiver the packet's MID names, or else for the receiver
|
|
47
|
+
* of the only m-line on the packet's transport that receives the payload type
|
|
48
|
+
* (one with `a=ssrc` or RIDs counts too, and then nothing is learned); when
|
|
49
|
+
* that is ambiguous, or the packet comes without a
|
|
50
|
+
* transport (`routeRtp(packet)`), it is dropped. A learned SSRC maps to the
|
|
51
|
+
* default track `ontrack` announced (`RTCRtpReceiver.bindFallbackSsrc`). A
|
|
52
|
+
* new SSRC (a SIP re-INVITE, a media server switch) is learned beside the
|
|
53
|
+
* earlier ones, which keep mapping to the same track: a late packet of a
|
|
54
|
+
* replaced stream is delivered there and resets nothing; `track.ssrc` is the
|
|
55
|
+
* newest, and the oldest beyond 8 is forgotten. Like the other packet-driven
|
|
56
|
+
* routes they are added at once while a description is pending, and commit
|
|
57
|
+
* and rollback keep them while the m-line stays without SSRC and RID (a
|
|
58
|
+
* rollback forgets those learned with a payload type only the rolled-back
|
|
59
|
+
* description gave).
|
|
60
|
+
*
|
|
61
|
+
* A pending description does not touch an m-line whose current session is
|
|
62
|
+
* without SSRC and RID: its SSRCs and RIDs wait in
|
|
63
|
+
* `RTCRtpReceiver.deferredRemote` and register at the commit
|
|
64
|
+
* (`commitStaged`), as an answer's would; rollback drops them with the rest
|
|
65
|
+
* of the description. Until then the current session's track, statistics,
|
|
66
|
+
* routes and learning stay as they are: a packet of the pending SSRC is
|
|
67
|
+
* learned like any unknown SSRC, and one with a pending RID is the current
|
|
68
|
+
* stream's. At the commit the learned SSRCs go (the description's SSRCs and
|
|
69
|
+
* RIDs route from now on), except one that already carried a committed RID,
|
|
70
|
+
* which becomes that RID's media SSRC. The first SSRC of the description
|
|
71
|
+
* binds the announced track (`RTCRtpReceiver.adoptDefaultTrack`), so `ontrack`
|
|
72
|
+
* does not fire again for it; a RID track replacing it is announced after
|
|
73
|
+
* the commit. Unregistering the transceiver drops the learned SSRCs.
|
|
74
|
+
*
|
|
75
|
+
* A MID updates the mapping of a learned SSRC (RFC 9143 section 9.2) only
|
|
76
|
+
* from a packet whose extended sequence number is newer than the one of the
|
|
77
|
+
* last update: an older packet is delivered through the mapping it finds.
|
|
78
|
+
* A newer MID naming another m-line moves the SSRC there when that m-line may
|
|
79
|
+
* learn it, else the packet is dropped. Routes from SDP, RIDs and simulcast
|
|
80
|
+
* keep their receiver whatever the MID (existing behaviour). A rollback keeps
|
|
81
|
+
* the receiver packets taught last, even over a baseline route packets
|
|
82
|
+
* taught another receiver.
|
|
83
|
+
*
|
|
84
|
+
* Every identifier of a packet — SSRC, RID (`rtp-stream-id`), RRID
|
|
85
|
+
* (`repaired-rtp-stream-id`) and MID — resolves within the packet's RTP
|
|
86
|
+
* session (its DTLS transport) only: a route, RID route or m-line of another
|
|
87
|
+
* transport is never reached, and a MID naming one drops the packet.
|
|
88
|
+
*
|
|
89
|
+
* An SSRC is unique per RTP session only, so `routes` keeps, per SSRC, a
|
|
90
|
+
* set of routes `{ endpoint, origin }`, each belonging to its endpoint's
|
|
91
|
+
* current `dtlsTransport` (a transceiver moved to another transport takes
|
|
92
|
+
* it along; a sender without a transport yet belongs to every one). A
|
|
93
|
+
* packet, RTP or RTCP (SR, RR and every feedback naming an SSRC), resolves
|
|
94
|
+
* to the highest ranked route of its transport ({@link endpointBySsrc}):
|
|
95
|
+
*
|
|
96
|
+
* | Origin | Added by | Rank in one RTP session | Other transports |
|
|
97
|
+
* | --- | --- | --- | --- |
|
|
98
|
+
* | `sender` | `registerRtpSender` | 1: a remote stream using it is a collision (RFC 3550 section 8.2): its RTP is dropped and nothing is learned, whatever RID, repaired RID or MID it carries | other streams, routed there |
|
|
99
|
+
* | `sdp` | `registerRtpReceiver` (an answer, a commit, or a pending description without conflict) | 2: a learned owner forgets the SSRC; another receiver's description route of the SSRC goes (the later description wins) | other streams, routed there |
|
|
100
|
+
* | `learned` | packets (RID, simulcast, fallback) | 3: never beside a `sender` / `sdp` route of another endpoint | other streams, routed there |
|
|
101
|
+
*
|
|
102
|
+
* A receiver that loses its learned SSRC — a fallback SSRC, a RID's media
|
|
103
|
+
* SSRC or a RID's RTX SSRC — because a sender or description of its session
|
|
104
|
+
* registers it, or a BUNDLE merge brings it into such a session, forgets it
|
|
105
|
+
* (`RTCRtpReceiver.releaseLearnedSsrc`), so its track and statistics agree
|
|
106
|
+
* with the table. A description route a pending description added in one
|
|
107
|
+
* session is taken again in the session its receiver has at the commit.
|
|
108
|
+
* Sender enumeration (TWCC fan-out, keyframe fallback) reads the same
|
|
109
|
+
* routes, within the packet's session.
|
|
41
110
|
*
|
|
42
111
|
* A payload type or extension ID counts as in use only when both current
|
|
43
112
|
* descriptions carry it for the m-line. RID lookup uses MID+RID when the
|
|
@@ -47,9 +116,14 @@ type StagedRoutes = {
|
|
|
47
116
|
* omits stays routed; only SSRCs a replaced pranswer alone added are dropped.
|
|
48
117
|
*/
|
|
49
118
|
export declare class RtpRouter {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
119
|
+
/**
|
|
120
|
+
* SSRC → its routes. An SSRC is unique per RTP session only, so one SSRC
|
|
121
|
+
* may have a route on each transport: a route belongs to its endpoint's
|
|
122
|
+
* current `dtlsTransport` (a sender without one yet to every transport),
|
|
123
|
+
* and a packet resolves to the highest ranked route of its transport
|
|
124
|
+
* ({@link endpointBySsrc}, `RouteOrigin`).
|
|
125
|
+
*/
|
|
126
|
+
private routes;
|
|
53
127
|
/** Keyed by {@link ridRouteKey} (MID + RID). */
|
|
54
128
|
ridTable: {
|
|
55
129
|
[midAndRid: string]: RTCRtpReceiver | RTCRtpSender;
|
|
@@ -57,28 +131,83 @@ export declare class RtpRouter {
|
|
|
57
131
|
/**
|
|
58
132
|
* Routes a pending offer or pranswer would move away from the receiver the
|
|
59
133
|
* current session uses. They apply at commit; until then current RTP keeps
|
|
60
|
-
* its route, and rollback drops them.
|
|
134
|
+
* its route, and rollback drops them. Keyed by SSRC and RTP session: one
|
|
135
|
+
* entry per SSRC per transport (`PendingSsrcRoutes`).
|
|
61
136
|
*/
|
|
62
137
|
private stagedSsrc;
|
|
63
138
|
private stagedRid;
|
|
64
139
|
/**
|
|
65
140
|
* New SSRC routes a pending description added at once (no conflict). A
|
|
66
141
|
* later remote pranswer / answer replaces them, the commit keeps them.
|
|
142
|
+
* Keyed like `stagedSsrc`.
|
|
67
143
|
*/
|
|
68
144
|
private provisionalSsrc;
|
|
69
145
|
extIdUriMap: {
|
|
70
146
|
[id: number]: string;
|
|
71
147
|
};
|
|
148
|
+
keyFrameRequestRouting: KeyFrameRequestRouting;
|
|
72
149
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
150
|
+
* Internal: the transceivers of the PeerConnection, for the fallback of
|
|
151
|
+
* {@link learnUnknownSsrc}. Set by the TransceiverManager; the router keeps
|
|
152
|
+
* no table of its own for it, so negotiation snapshots stay as they are.
|
|
75
153
|
*/
|
|
76
|
-
readonly
|
|
77
|
-
|
|
154
|
+
transceivers: () => readonly RTCRtpTransceiver[];
|
|
155
|
+
/**
|
|
156
|
+
* Internal: the track `ontrack` last announced for a transceiver (set by
|
|
157
|
+
* the TransceiverManager). A replacement offer resets `firedReceiving`
|
|
158
|
+
* before it applies, while the announcement of the default track stands.
|
|
159
|
+
*/
|
|
160
|
+
announcedTrack: (transceiver: RTCRtpTransceiver) => MediaStreamTrack | undefined;
|
|
161
|
+
/** Last logged drop of an unknown SSRC, so a stream logs a reason once. */
|
|
162
|
+
private lastUnknownSsrcDrop?;
|
|
78
163
|
constructor();
|
|
164
|
+
/**
|
|
165
|
+
* Test / observation view: SSRC → the endpoint a packet without a
|
|
166
|
+
* transport reaches (the highest ranked route, the first of a rank).
|
|
167
|
+
*/
|
|
168
|
+
get ssrcTable(): {
|
|
169
|
+
[ssrc: number]: Endpoint;
|
|
170
|
+
};
|
|
171
|
+
/** Test / observation view: SSRCs that have a route packets taught. */
|
|
172
|
+
get learnedSsrcs(): ReadonlySet<number>;
|
|
173
|
+
/**
|
|
174
|
+
* Test / observation view: learned receiver routes beside the route a
|
|
175
|
+
* packet without a transport reaches (the same SSRC on another transport).
|
|
176
|
+
*/
|
|
177
|
+
private get collidingRoutes();
|
|
178
|
+
/** Test / observation view: every route with its SSRC. */
|
|
179
|
+
get routeEntries(): {
|
|
180
|
+
ssrc: number;
|
|
181
|
+
endpoint: Endpoint;
|
|
182
|
+
origin: RouteOrigin;
|
|
183
|
+
}[];
|
|
184
|
+
/**
|
|
185
|
+
* A local sender's own SSRC. In its RTP session it outranks a receiver
|
|
186
|
+
* route: a learned SSRC there is a remote collision (RFC 3550 section 8.2)
|
|
187
|
+
* and is forgotten; an SDP route there stays but receives nothing. Routes
|
|
188
|
+
* of other transports are other streams and stay.
|
|
189
|
+
*/
|
|
79
190
|
registerRtpSender(sender: RTCRtpSender): void;
|
|
80
191
|
/** Internal: the negotiation committed, staged routes replace current ones. */
|
|
81
192
|
commitStaged(): void;
|
|
193
|
+
/**
|
|
194
|
+
* The commit of a description `deferRemote` kept from an m-line without
|
|
195
|
+
* SSRC and RID: its RIDs and SSRCs register as an answer's would. A
|
|
196
|
+
* fallback SSRC that already carried one of its RIDs is that RID's media
|
|
197
|
+
* SSRC from now on and keeps its learned route.
|
|
198
|
+
*/
|
|
199
|
+
private applyDeferredRemote;
|
|
200
|
+
/** A learned fallback SSRC that carried `rid` becomes that RID's media SSRC. */
|
|
201
|
+
private adoptCarriedRid;
|
|
202
|
+
/**
|
|
203
|
+
* A pending description (`deferConflicts`) does not touch an m-line whose
|
|
204
|
+
* current session announced the default track and is without SSRC and RID:
|
|
205
|
+
* its SSRCs and RIDs wait in `RTCRtpReceiver.deferredRemote` for the
|
|
206
|
+
* commit, so until then the track, its statistics, the routes and the
|
|
207
|
+
* learning of unknown SSRCs stay the current session's (a new SSRC of the
|
|
208
|
+
* pending description is learned like any other unknown SSRC).
|
|
209
|
+
*/
|
|
210
|
+
private defersRemote;
|
|
82
211
|
/** Internal: drop the routes an earlier pending description added at once. */
|
|
83
212
|
discardProvisional(): void;
|
|
84
213
|
/** Internal: capture staged routes for a transaction baseline or checkpoint. */
|
|
@@ -87,9 +216,11 @@ export declare class RtpRouter {
|
|
|
87
216
|
restoreStaged(snapshot: StagedRoutes): void;
|
|
88
217
|
/** Internal: every route a negotiation may change, for a rollback baseline. */
|
|
89
218
|
snapshotRoutes(): {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
219
|
+
/** Every route (description, sender and packet-driven ones). */
|
|
220
|
+
routes: (readonly [number, {
|
|
221
|
+
endpoint: Endpoint;
|
|
222
|
+
origin: RouteOrigin;
|
|
223
|
+
}[]])[];
|
|
93
224
|
ridTable: {
|
|
94
225
|
[midAndRid: string]: RTCRtpReceiver | RTCRtpSender;
|
|
95
226
|
};
|
|
@@ -102,7 +233,10 @@ export declare class RtpRouter {
|
|
|
102
233
|
* Internal: return to a negotiation baseline. Two kinds of route are not
|
|
103
234
|
* description state and survive: SSRCs learned from packets for an endpoint
|
|
104
235
|
* still attached, and the own SSRC of every live sender (including one the
|
|
105
|
-
* application added while the description was pending).
|
|
236
|
+
* application added while the description was pending). Likewise a route
|
|
237
|
+
* packets taught before the baseline and later dropped (an SSRC retired by
|
|
238
|
+
* a media SSRC change of its RID, or evicted) stays dropped: the baseline
|
|
239
|
+
* does not bring packet-driven routes back.
|
|
106
240
|
*/
|
|
107
241
|
restoreRoutes(snapshot: RouterSnapshot, { endpoints, liveSenders, }: {
|
|
108
242
|
endpoints: Set<RTCRtpReceiver | RTCRtpSender>;
|
|
@@ -120,30 +254,84 @@ export declare class RtpRouter {
|
|
|
120
254
|
registerRtpReceiverBySsrc(transceiver: RTCRtpTransceiver, params: RTCRtpReceiveParameters, { deferConflicts }?: {
|
|
121
255
|
deferConflicts?: boolean;
|
|
122
256
|
}): void;
|
|
257
|
+
private registerHeaderExtensions;
|
|
123
258
|
registerRtpReceiverByRid(transceiver: RTCRtpTransceiver, param: RTCRtpSimulcastParameters, params: RTCRtpReceiveParameters, { deferConflicts }?: {
|
|
124
259
|
deferConflicts?: boolean;
|
|
125
260
|
}): void;
|
|
126
261
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
262
|
+
* Simulcast (RFC 8852): a packet with `rtp-stream-id` is a layer's media,
|
|
263
|
+
* one with `repaired-rtp-stream-id` is the RTX stream repairing that layer.
|
|
264
|
+
* The first such packet registers its SSRC as a learned route, because the
|
|
265
|
+
* sender may stop sending these extensions (libwebrtc does once it receives
|
|
266
|
+
* an RTCP RR); later packets of the SSRC are routed by SSRC alone.
|
|
130
267
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
268
|
+
routeRtp: (packet: RtpPacket, dtlsTransport?: RTCDtlsTransport) => void;
|
|
269
|
+
/**
|
|
270
|
+
* Route an SSRC learned from a packet. Packet-driven, not a description:
|
|
271
|
+
* staged routes stay as they are, and an SSRC a description routes keeps
|
|
272
|
+
* that route.
|
|
273
|
+
*/
|
|
274
|
+
private learnSsrc;
|
|
275
|
+
/**
|
|
276
|
+
* Add a route a packet taught `receiver`, in the RTP session of its
|
|
277
|
+
* transport. False when `receiver` already has a route for `ssrc`.
|
|
278
|
+
*/
|
|
279
|
+
private addLearnedRoute;
|
|
134
280
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
private
|
|
146
|
-
/**
|
|
147
|
-
|
|
281
|
+
* RFC 9143 section 9.2 for an SSRC that no route, RID or simulcast track
|
|
282
|
+
* knows: the receiver `unknownSsrcCandidate` (`routing/unknownSsrc.ts`)
|
|
283
|
+
* chooses learns it as a fallback SSRC, with a learned route on the
|
|
284
|
+
* packet's transport; otherwise the packet is dropped and the reason logged
|
|
285
|
+
* once per SSRC. A learned SSRC stays learned (see
|
|
286
|
+
* {@link routeFallbackPacket}), so a late packet never comes here. The same
|
|
287
|
+
* SSRC on another transport is another stream with its own route
|
|
288
|
+
* (`routes`), so each transport keeps its own receiver. With `handover` a
|
|
289
|
+
* newer MID moves the SSRC here from another m-line.
|
|
290
|
+
*/
|
|
291
|
+
private learnUnknownSsrc;
|
|
292
|
+
/**
|
|
293
|
+
* The endpoint `ssrc` names for a packet of `transport`, for RTP and RTCP
|
|
294
|
+
* alike: the highest ranked route of that RTP session (a local sender, a
|
|
295
|
+
* description's receiver, a receiver packets taught; the first of a
|
|
296
|
+
* rank). Routes of other transports are other streams and are not
|
|
297
|
+
* reached. A learned route whose receiver no longer knows the SSRC (or
|
|
298
|
+
* stopped) is dropped on the way. Without a transport every route counts.
|
|
299
|
+
*/
|
|
300
|
+
private endpointBySsrc;
|
|
301
|
+
/**
|
|
302
|
+
* A packet of a fallback SSRC `owner` learned. RFC 9143 section 9.2: a MID
|
|
303
|
+
* updates the mapping only from a packet newer (extended sequence number)
|
|
304
|
+
* than the last update; an older packet keeps the mapping and is delivered
|
|
305
|
+
* through it. A newer MID naming another m-line moves the SSRC there when
|
|
306
|
+
* that m-line may learn it; otherwise the packet is dropped (it belongs to
|
|
307
|
+
* neither). Returns the receiver and whether the route changed.
|
|
308
|
+
*/
|
|
309
|
+
private routeFallbackPacket;
|
|
310
|
+
/**
|
|
311
|
+
* Receivers other than `endpoint` in its RTP session that learned `ssrc`
|
|
312
|
+
* from packets: as a fallback SSRC, as a RID's media SSRC or as a RID's
|
|
313
|
+
* RTX SSRC.
|
|
314
|
+
*/
|
|
315
|
+
private learnedOwnersIn;
|
|
316
|
+
/**
|
|
317
|
+
* A description routes `ssrc` to `receiver`. A learned owner in the same
|
|
318
|
+
* RTP session forgets it (the description wins); learned routes of other
|
|
319
|
+
* transports stay, they are other streams. Another receiver's description
|
|
320
|
+
* route in the same RTP session goes (the later description wins); one of
|
|
321
|
+
* another transport stays. A sender keeps its route.
|
|
322
|
+
*/
|
|
323
|
+
private takeSsrcRoute;
|
|
324
|
+
/** Forget one learned fallback SSRC of `receiver` and its route. */
|
|
325
|
+
private releaseFallbackSsrc;
|
|
326
|
+
/**
|
|
327
|
+
* `receiver` forgets what packets taught it about `ssrc` (a fallback SSRC,
|
|
328
|
+
* a RID's media or RTX SSRC) and its learned route goes.
|
|
329
|
+
*/
|
|
330
|
+
private releaseLearnedSsrc;
|
|
331
|
+
/** Forget every learned fallback SSRC of `receiver` and their routes. */
|
|
332
|
+
private releaseFallbackSsrcs;
|
|
333
|
+
/** Drop a learned route of `receiver`; a description's route stays. */
|
|
334
|
+
private unlearnSsrc;
|
|
335
|
+
/** Deliver an RTCP packet within the RTP session of `dtlsTransport` (`routing/rtcpRouting.ts`). */
|
|
336
|
+
routeRtcp: (packet: RtcpPacket, dtlsTransport?: RTCDtlsTransport) => void;
|
|
148
337
|
}
|
|
149
|
-
export {};
|