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":"codecCompatibility.js","sourceRoot":"","sources":["../../../../src/media/codecCompatibility.ts"],"names":[],"mappings":";;AASA,wDAGC;AAkBD,8CA4BC;AAWD,kDAiBC;AAMD,4DAaC;AAmCD,0CAUC;AAaD,sDA0BC;AAED,sCASC;AAMD,sDAuBC;AArOD,sCAAqD;AACrD,gCAAmD;AAInD;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC;AAED,SAAS,SAAS,CAAC,KAA4B;IAC7C,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,aAAa,CAAI,IAAmB,EAAE,KAAoB;IACjE,OAAO,IAAI,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS,IAAI,IAAI,KAAK,KAAK,CAAC;AACnE,CAAC;AAED,SAAS,cAAc,CAAC,KAA4B;IAClD,MAAM,UAAU,GAAG,IAAA,+BAAyB,EAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IACrE,OAAO;QACL,iBAAiB,EAAE,UAAU,CAAC,oBAAoB,CAAC;QACnD,cAAc,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE;KACzE,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB,CAC/B,MAA6B,EAC7B,UAAiC;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{ createWebRtcDomException } from \"../errors\";\nimport { codecParametersFromString } from \"../sdp\";\nimport type { Kind } from \"../types/domain\";\nimport type { RTCRtpCodecParameters } from \"./parameters\";\n\n/**\n * Lower-cased MIME type with the legacy `video/AV1X` name folded into\n * `video/av1`, so both names negotiate with each other.\n */\nexport function normalizeCodecMimeType(mimeType: string) {\n const lower = mimeType.toLowerCase();\n return lower === \"video/av1x\" ? \"video/av1\" : lower;\n}\n\nfunction codecName(codec: RTCRtpCodecParameters) {\n return codec.name.toLowerCase();\n}\n\nfunction optionalEqual<T>(left: T | undefined, right: T | undefined) {\n return left == undefined || right == undefined || left === right;\n}\n\nfunction h264Parameters(codec: RTCRtpCodecParameters) {\n const parameters = codecParametersFromString(codec.parameters ?? \"\");\n return {\n packetizationMode: parameters[\"packetization-mode\"],\n profileLevelId: parameters[\"profile-level-id\"]?.toString().toLowerCase(),\n };\n}\n\nexport function isCodecCompatible(\n source: RTCRtpCodecParameters,\n configured: RTCRtpCodecParameters,\n) {\n if (\n normalizeCodecMimeType(source.mimeType) !==\n normalizeCodecMimeType(configured.mimeType)\n ) {\n return false;\n }\n if (source.clockRate !== configured.clockRate) return false;\n if (!optionalEqual(source.channels, configured.channels)) return false;\n if (codecName(source) !== \"h264\") return true;\n\n const sourceParameters = h264Parameters(source);\n const configuredParameters = h264Parameters(configured);\n if (\n !optionalEqual(\n sourceParameters.packetizationMode,\n configuredParameters.packetizationMode,\n )\n ) {\n return false;\n }\n return optionalEqual(\n sourceParameters.profileLevelId,\n configuredParameters.profileLevelId,\n );\n}\n\nfunction isAuxiliary(codec: RTCRtpCodecParameters) {\n return [\"rtx\", \"red\"].includes(codecName(codec));\n}\n\n/**\n * remote track が実際に配信する codec を返す。\n * audio の RED は RTCRtpReceiver が primary へ展開してから track へ渡すため、\n * RED が参照する primary codec (不明なら先頭の primary) を track の codec とする。\n */\nexport function deliveredTrackCodec(\n kind: string,\n codec: RTCRtpCodecParameters | undefined,\n negotiated: readonly RTCRtpCodecParameters[],\n) {\n if (kind !== \"audio\" || codec == undefined || codecName(codec) !== \"red\") {\n return codec;\n }\n const [primaryPayloadType] = referencedPayloadTypes(codec);\n return (\n negotiated.find(\n (candidate) =>\n !isAuxiliary(candidate) && candidate.payloadType === primaryPayloadType,\n ) ??\n negotiated.find((candidate) => !isAuxiliary(candidate)) ??\n codec\n );\n}\n\n/**\n * RTX / RED を除く primary codec に MIME 一致が 1 つでもあるか。\n * remote m-line を local capability で扱えるかの判定 (Issue #705) に使う。\n */\nexport function hasCommonPrimaryMimeType(\n local: readonly RTCRtpCodecParameters[],\n remote: readonly RTCRtpCodecParameters[],\n) {\n return local.some(\n (localCodec) =>\n !isAuxiliary(localCodec) &&\n remote.some(\n (remoteCodec) =>\n normalizeCodecMimeType(remoteCodec.mimeType) ===\n normalizeCodecMimeType(localCodec.mimeType),\n ),\n );\n}\n\nfunction referencedPayloadTypes(codec: RTCRtpCodecParameters) {\n const parameters = codec.parameters ?? \"\";\n if (codecName(codec) === \"rtx\") {\n const apt = Number(codecParametersFromString(parameters).apt);\n return Number.isNaN(apt) ? [] : [apt];\n }\n if (codecName(codec) === \"red\") {\n return parameters\n .split(\"/\")\n .map(Number)\n .filter((value) => !Number.isNaN(value));\n }\n return [];\n}\n\nfunction withAuxiliaryCodecs(\n configured: RTCRtpCodecParameters[],\n primary: RTCRtpCodecParameters[],\n) {\n const keptPayloadTypes = new Set(primary.map((codec) => codec.payloadType));\n const auxiliary = configured.filter((codec) => {\n if (!isAuxiliary(codec)) return false;\n const referenced = referencedPayloadTypes(codec);\n return (\n referenced.length > 0 &&\n referenced.every((payloadType) => keptPayloadTypes.has(payloadType))\n );\n });\n return configured.filter(\n (codec) => primary.includes(codec) || auxiliary.includes(codec),\n );\n}\n\nexport function intersectCodecs(\n configured: RTCRtpCodecParameters[],\n source: readonly RTCRtpCodecParameters[],\n) {\n const primary = configured.filter(\n (codec) =>\n !isAuxiliary(codec) &&\n source.some((sourceCodec) => isCodecCompatible(sourceCodec, codec)),\n );\n return withAuxiliaryCodecs(configured, primary);\n}\n\nfunction matchesPreference(\n candidate: RTCRtpCodecParameters,\n preference: RTCRtpCodecParameters,\n) {\n return (\n normalizeCodecMimeType(candidate.mimeType) ===\n normalizeCodecMimeType(preference.mimeType) &&\n optionalEqual(candidate.clockRate, preference.clockRate)\n );\n}\n\nexport function applyCodecPreferences(\n configured: RTCRtpCodecParameters[],\n preferences: readonly RTCRtpCodecParameters[] | undefined,\n) {\n if (preferences == undefined) return configured;\n const preferred = preferences.flatMap((preference) => {\n const match = configured.find((codec) =>\n matchesPreference(codec, preference),\n );\n return match ? [match] : [];\n });\n const uniquePreferred = [...new Set(preferred)];\n const referencedByPreferredAuxiliary = new Set(\n uniquePreferred.filter(isAuxiliary).flatMap(referencedPayloadTypes),\n );\n const primary = configured.filter(\n (codec) =>\n !isAuxiliary(codec) &&\n (uniquePreferred.includes(codec) ||\n referencedByPreferredAuxiliary.has(codec.payloadType)),\n );\n const allowed = withAuxiliaryCodecs(configured, primary);\n return [\n ...uniquePreferred.filter((codec) => allowed.includes(codec)),\n ...allowed.filter((codec) => !uniquePreferred.includes(codec)),\n ];\n}\n\nexport function resolveCodecs(\n configured: RTCRtpCodecParameters[],\n source: readonly RTCRtpCodecParameters[] | undefined,\n preferences: readonly RTCRtpCodecParameters[] | undefined,\n) {\n return applyCodecPreferences(\n source == undefined ? configured : intersectCodecs(configured, source),\n preferences,\n );\n}\n\nfunction list(codecs: readonly RTCRtpCodecParameters[] | undefined) {\n return codecs?.map((codec) => codec.mimeType).join(\", \") || \"(none)\";\n}\n\nexport function assertCodecsSupported(options: {\n kind: Kind;\n configured: RTCRtpCodecParameters[];\n source: readonly RTCRtpCodecParameters[] | undefined;\n preferences: readonly RTCRtpCodecParameters[] | undefined;\n}) {\n const { kind, configured, source, preferences } = options;\n const sourceCompatible =\n source == undefined ? configured : intersectCodecs(configured, source);\n if (source != undefined && sourceCompatible.length === 0) {\n throw createWebRtcDomException(\n \"NotSupportedError\",\n `Track codec ${list(source)} is not supported by this RTCPeerConnection. Configured ${kind} codecs: ${list(configured)}`,\n );\n }\n const effective = applyCodecPreferences(sourceCompatible, preferences);\n if (effective.length === 0) {\n throw createWebRtcDomException(\n \"NotSupportedError\",\n `No codec remains after applying codec preferences. Source codecs: ${list(source)} Configured codecs: ${list(configured)} Preferred codecs: ${list(preferences)}`,\n );\n }\n return effective;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"codecCompatibility.js","sourceRoot":"","sources":["../../../../src/media/codecCompatibility.ts"],"names":[],"mappings":";;AASA,wDAGC;AAqCD,8CAiBC;AAUD,oCAQC;AAyBD,gCAgCC;AAWD,kDAiBC;AAOD,8CAYC;AAMD,4DAaC;AAqCD,0CAUC;AAaD,sDA0BC;AAED,sCASC;AAMD,sDAuBC;AAiBD,oDAsDC;AAiID,gEA+FC;AApnBD,sCAAqD;AACrD,gCAAmD;AAEnD,6CAAqD;AAErD;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC;AAED,SAAS,SAAS,CAAC,KAA4B;IAC7C,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,aAAa,CAAI,IAAmB,EAAE,KAAoB;IACjE,OAAO,IAAI,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS,IAAI,IAAI,KAAK,KAAK,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,iBAAiB,GAAmD;IACxE,IAAI,EAAE,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;IAChD,GAAG,EAAE,CAAC,YAAY,CAAC;IACnB,GAAG,EAAE,CAAC,SAAS,CAAC;IAChB,IAAI,EAAE,CAAC,SAAS,CAAC;CAClB,CAAC;AAEF,SAAS,cAA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Ae,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACxE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACvD,IAAI,WAAW,IAAI,SAAS;YAAE,OAAO;QACrC,KAAK,CAAC,KAAK,EAAE,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { createWebRtcDomException } from \"../errors\";\nimport { codecParametersFromString } from \"../sdp\";\nimport type { Kind } from \"../types/domain\";\nimport { RTCRtpCodecParameters } from \"./parameters\";\n\n/**\n * Lower-cased MIME type with the legacy `video/AV1X` name folded into\n * `video/av1`, so both names negotiate with each other.\n */\nexport function normalizeCodecMimeType(mimeType: string) {\n const lower = mimeType.toLowerCase();\n return lower === \"video/av1x\" ? \"video/av1\" : lower;\n}\n\nfunction codecName(codec: RTCRtpCodecParameters) {\n return codec.name.toLowerCase();\n}\n\nfunction optionalEqual<T>(left: T | undefined, right: T | undefined) {\n return left == undefined || right == undefined || left === right;\n}\n\n/**\n * The `a=fmtp` parameters that tell the formats of one MIME type apart (a\n * decoder for one cannot take the other): H264 `packetization-mode` and\n * `profile-level-id` (RFC 6184), VP9 `profile-id` (RFC 9628) and AV1\n * `profile` (AV1 RTP payload format). Values are compared case-insensitively.\n */\nconst FORMAT_PARAMETERS: { readonly [name: string]: readonly string[] } = {\n h264: [\"packetization-mode\", \"profile-level-id\"],\n vp9: [\"profile-id\"],\n av1: [\"profile\"],\n av1x: [\"profile\"],\n};\n\nfunction formatIdentity(codec: RTCRtpCodecParameters) {\n const parameters = codecParametersFromString(codec.parameters ?? \"\");\n return (FORMAT_PARAMETERS[codecName(codec)] ?? []).map((name) =>\n parameters[name]?.toString().toLowerCase(),\n );\n}\n\n/**\n * Whether `source` (a track's codec or a remote codec) can be carried as\n * `configured`: the same MIME type, clock rate and channels, and the same\n * format-identifying parameters (`FORMAT_PARAMETERS`: H264 mode / profile,\n * VP9 profile, AV1 profile). A parameter omitted on either side matches any\n * value.\n */\nexport function isCodecCompatible(\n source: RTCRtpCodecParameters,\n configured: RTCRtpCodecParameters,\n) {\n if (\n normalizeCodecMimeType(source.mimeType) !==\n normalizeCodecMimeType(configured.mimeType)\n ) {\n return false;\n }\n if (source.clockRate !== configured.clockRate) return false;\n if (!optionalEqual(source.channels, configured.channels)) return false;\n const sourceIdentity = formatIdentity(source);\n const configuredIdentity = formatIdentity(configured);\n return sourceIdentity.every((value, index) =>\n optionalEqual(value, configuredIdentity[index]),\n );\n}\n\n/**\n * The fallback predicate negotiation pairs a configured codec with a remote\n * one by when no remote codec has its format (`pairCodecs`): the same MIME\n * type. The negotiated codec is then in the remote's form (payload type,\n * fmtp, rtcp-fb), which may differ from the configured one, but it is what\n * the configured codec negotiated, so a later offer lists it as it is\n * (RFC 3264 §8.3.2).\n */\nexport function negotiatesAs(\n configured: RTCRtpCodecParameters,\n negotiated: RTCRtpCodecParameters,\n) {\n return (\n normalizeCodecMimeType(configured.mimeType) ===\n normalizeCodecMimeType(negotiated.mimeType)\n );\n}\n\n/**\n * Pair each configured primary codec with at most one of `others` (and each\n * of `others` with at most one configured codec), the rule negotiation\n * (`setRemoteDescription()` / `createAnswer()`) and a later offer share,\n * in three passes over the configured codecs, each pass only for the codecs\n * still unpaired:\n *\n * 1. the codec of exactly the same format (`sameFormat`: MIME type, clock\n * rate, channels and every `a=fmtp` parameter, for any codec: VP9\n * `profile-id`, AV1 `profile`, H264 `packetization-mode` /\n * `profile-level-id`, Opus parameters, ...);\n * 2. a compatible one (`isCodecCompatible`: the same format-identifying\n * parameters, H264 mode / profile, VP9 / AV1 profile, where an omitted\n * one matches any value);\n * 3. one of the same MIME type (`negotiatesAs`, for instance an H264 of\n * another level or a VP9 of another profile).\n *\n * So when the configured codecs hold several formats of one MIME type (H264\n * mode 0 and mode 1, VP9 profile 0 and profile 2), each pairs with its own\n * format whatever the order, and an answer does not switch the format the\n * offer meant. RTX / RED are not paired. `accept` limits the candidates (a\n * fixed track source).\n */\nexport function pairCodecs(\n configured: readonly RTCRtpCodecParameters[],\n others: readonly RTCRtpCodecParameters[],\n accept: (\n configured: RTCRtpCodecParameters,\n other: RTCRtpCodecParameters,\n ) => boolean = () => true,\n): Map<RTCRtpCodecParameters, RTCRtpCodecParameters> {\n const pairs = new Map<RTCRtpCodecParameters, RTCRtpCodecParameters>();\n const used = new Set<RTCRtpCodecParameters>();\n const passes = [\n sameFormat,\n (codec: RTCRtpCodecParameters, other: RTCRtpCodecParameters) =>\n isCodecCompatible(other, codec),\n negotiatesAs,\n ];\n for (const matches of passes) {\n for (const codec of configured) {\n if (isAuxiliary(codec) || pairs.has(codec)) continue;\n const other = others.find(\n (candidate) =>\n !isAuxiliary(candidate) &&\n !used.has(candidate) &&\n matches(codec, candidate) &&\n accept(codec, candidate),\n );\n if (!other) continue;\n pairs.set(codec, other);\n used.add(other);\n }\n }\n return pairs;\n}\n\nfunction isAuxiliary(codec: RTCRtpCodecParameters) {\n return [\"rtx\", \"red\"].includes(codecName(codec));\n}\n\n/**\n * remote track が実際に配信する codec を返す。\n * audio の RED は RTCRtpReceiver が primary へ展開してから track へ渡すため、\n * RED が参照する primary codec (不明なら先頭の primary) を track の codec とする。\n */\nexport function deliveredTrackCodec(\n kind: string,\n codec: RTCRtpCodecParameters | undefined,\n negotiated: readonly RTCRtpCodecParameters[],\n) {\n if (kind !== \"audio\" || codec == undefined || codecName(codec) !== \"red\") {\n return codec;\n }\n const [primaryPayloadType] = referencedPayloadTypes(codec);\n return (\n negotiated.find(\n (candidate) =>\n !isAuxiliary(candidate) && candidate.payloadType === primaryPayloadType,\n ) ??\n negotiated.find((candidate) => !isAuxiliary(candidate)) ??\n codec\n );\n}\n\n/**\n * 交渉済み codec 列から remote track の codec を決める。\n * 先頭の RTX (と video の RED / FEC) は飛ばし、audio の RED は\n * {@link deliveredTrackCodec} と同じく primary へ解決する。\n */\nexport function primaryTrackCodec(\n kind: string,\n negotiated: readonly RTCRtpCodecParameters[],\n) {\n const first =\n negotiated.find((codec) =>\n kind === \"audio\"\n ? codecName(codec) !== \"rtx\"\n : !isAuxiliary(codec) &&\n ![\"ulpfec\", \"flexfec-03\"].includes(codecName(codec)),\n ) ?? negotiated[0];\n return deliveredTrackCodec(kind, first, negotiated);\n}\n\n/**\n * RTX / RED を除く primary codec に MIME 一致が 1 つでもあるか。\n * remote m-line を local capability で扱えるかの判定 (Issue #705) に使う。\n */\nexport function hasCommonPrimaryMimeType(\n local: readonly RTCRtpCodecParameters[],\n remote: readonly RTCRtpCodecParameters[],\n) {\n return local.some(\n (localCodec) =>\n !isAuxiliary(localCodec) &&\n remote.some(\n (remoteCodec) =>\n normalizeCodecMimeType(remoteCodec.mimeType) ===\n normalizeCodecMimeType(localCodec.mimeType),\n ),\n );\n}\n\nfunction referencedPayloadTypes(codec: RTCRtpCodecParameters) {\n const parameters = codec.parameters ?? \"\";\n if (codecName(codec) === \"rtx\") {\n const apt = Number(codecParametersFromString(parameters).apt);\n return Number.isNaN(apt) ? [] : [apt];\n }\n if (codecName(codec) === \"red\") {\n // `Number(\"\")` is 0: a RED without fmtp references nothing.\n return parameters\n .split(\"/\")\n .filter((value) => value.trim() !== \"\")\n .map(Number)\n .filter((value) => !Number.isNaN(value));\n }\n return [];\n}\n\nfunction withAuxiliaryCodecs(\n configured: RTCRtpCodecParameters[],\n primary: RTCRtpCodecParameters[],\n) {\n const keptPayloadTypes = new Set(primary.map((codec) => codec.payloadType));\n const auxiliary = configured.filter((codec) => {\n if (!isAuxiliary(codec)) return false;\n const referenced = referencedPayloadTypes(codec);\n return (\n referenced.length > 0 &&\n referenced.every((payloadType) => keptPayloadTypes.has(payloadType))\n );\n });\n return configured.filter(\n (codec) => primary.includes(codec) || auxiliary.includes(codec),\n );\n}\n\nexport function intersectCodecs(\n configured: RTCRtpCodecParameters[],\n source: readonly RTCRtpCodecParameters[],\n) {\n const primary = configured.filter(\n (codec) =>\n !isAuxiliary(codec) &&\n source.some((sourceCodec) => isCodecCompatible(sourceCodec, codec)),\n );\n return withAuxiliaryCodecs(configured, primary);\n}\n\nfunction matchesPreference(\n candidate: RTCRtpCodecParameters,\n preference: RTCRtpCodecParameters,\n) {\n return (\n normalizeCodecMimeType(candidate.mimeType) ===\n normalizeCodecMimeType(preference.mimeType) &&\n optionalEqual(candidate.clockRate, preference.clockRate)\n );\n}\n\nexport function applyCodecPreferences(\n configured: RTCRtpCodecParameters[],\n preferences: readonly RTCRtpCodecParameters[] | undefined,\n) {\n if (preferences == undefined) return configured;\n const preferred = preferences.flatMap((preference) => {\n const match = configured.find((codec) =>\n matchesPreference(codec, preference),\n );\n return match ? [match] : [];\n });\n const uniquePreferred = [...new Set(preferred)];\n const referencedByPreferredAuxiliary = new Set(\n uniquePreferred.filter(isAuxiliary).flatMap(referencedPayloadTypes),\n );\n const primary = configured.filter(\n (codec) =>\n !isAuxiliary(codec) &&\n (uniquePreferred.includes(codec) ||\n referencedByPreferredAuxiliary.has(codec.payloadType)),\n );\n const allowed = withAuxiliaryCodecs(configured, primary);\n return [\n ...uniquePreferred.filter((codec) => allowed.includes(codec)),\n ...allowed.filter((codec) => !uniquePreferred.includes(codec)),\n ];\n}\n\nexport function resolveCodecs(\n configured: RTCRtpCodecParameters[],\n source: readonly RTCRtpCodecParameters[] | undefined,\n preferences: readonly RTCRtpCodecParameters[] | undefined,\n) {\n return applyCodecPreferences(\n source == undefined ? configured : intersectCodecs(configured, source),\n preferences,\n );\n}\n\nfunction list(codecs: readonly RTCRtpCodecParameters[] | undefined) {\n return codecs?.map((codec) => codec.mimeType).join(\", \") || \"(none)\";\n}\n\nexport function assertCodecsSupported(options: {\n kind: Kind;\n configured: RTCRtpCodecParameters[];\n source: readonly RTCRtpCodecParameters[] | undefined;\n preferences: readonly RTCRtpCodecParameters[] | undefined;\n}) {\n const { kind, configured, source, preferences } = options;\n const sourceCompatible =\n source == undefined ? configured : intersectCodecs(configured, source);\n if (source != undefined && sourceCompatible.length === 0) {\n throw createWebRtcDomException(\n \"NotSupportedError\",\n `Track codec ${list(source)} is not supported by this RTCPeerConnection. Configured ${kind} codecs: ${list(configured)}`,\n );\n }\n const effective = applyCodecPreferences(sourceCompatible, preferences);\n if (effective.length === 0) {\n throw createWebRtcDomException(\n \"NotSupportedError\",\n `No codec remains after applying codec preferences. Source codecs: ${list(source)} Configured codecs: ${list(configured)} Preferred codecs: ${list(preferences)}`,\n );\n }\n return effective;\n}\n\n/**\n * Configured codecs a negotiated m-line offers, before payload types are\n * mapped (`keepNegotiatedPayloadTypes`): `capability` plus the configured\n * counterpart (`pairCodecs`, the rule negotiation pairs by) of every\n * negotiated codec that `capability` lacks.\n *\n * `eligible` is every configured codec of the kind with the fixed source and\n * the codec preferences applied but no direction filter, and `capability` is\n * the same for the current direction. A direction change (`direction`,\n * `removeTrack()`) therefore never takes a negotiated codec off the m-line;\n * only an answer does. Preferences and a fixed source still exclude one. An\n * RTX / RED is kept when its primaries are and it is in `capability` or\n * negotiated for the same primaries. The order is that of `eligible`\n * (preferences, then configuration), the order of a first offer.\n */\nexport function withNegotiatedCodecs(\n eligible: readonly RTCRtpCodecParameters[],\n capability: readonly RTCRtpCodecParameters[],\n negotiated: readonly RTCRtpCodecParameters[],\n): RTCRtpCodecParameters[] {\n const candidates = [\n ...eligible,\n ...capability.filter((codec) => !eligible.includes(codec)),\n ];\n const primaryOf = (\n codecs: readonly RTCRtpCodecParameters[],\n payloadType: number,\n ) =>\n codecs.find(\n (codec) => !isAuxiliary(codec) && codec.payloadType === payloadType,\n );\n const pairs = pairCodecs(candidates, negotiated);\n const kept = new Set(\n candidates.filter(\n (codec) =>\n !isAuxiliary(codec) && (capability.includes(codec) || pairs.has(codec)),\n ),\n );\n const negotiatedForSamePrimaries = (codec: RTCRtpCodecParameters) => {\n const primaries = referencedPayloadTypes(codec).map((payloadType) =>\n primaryOf(candidates, payloadType),\n );\n return negotiated.some((other) => {\n if (codecName(other) !== codecName(codec)) return false;\n const otherPrimaries = referencedPayloadTypes(other).map((payloadType) =>\n primaryOf(negotiated, payloadType),\n );\n return (\n otherPrimaries.length === primaries.length &&\n primaries.every((primary, index) => {\n const otherPrimary = otherPrimaries[index];\n return (\n primary != undefined &&\n otherPrimary != undefined &&\n pairs.get(primary) === otherPrimary\n );\n })\n );\n });\n };\n return candidates.filter((codec) => {\n if (!isAuxiliary(codec)) return kept.has(codec);\n const primaries = referencedPayloadTypes(codec).map((payloadType) =>\n primaryOf(candidates, payloadType),\n );\n if (primaries.some((primary) => primary == undefined || !kept.has(primary)))\n return false;\n return capability.includes(codec) || negotiatedForSamePrimaries(codec);\n });\n}\n\n/**\n * The format parameters (`a=fmtp`) a payload type stands for, in a form that\n * compares equal when the parameters mean the same: parameter names are\n * case-insensitive and unordered, and H264 gets its RFC 6184 §8.1 defaults\n * (`packetization-mode` 0, `profile-level-id` 42000A, case-insensitive), so\n * an omitted parameter and its default are the same format. Anything else\n * (an RTX `apt`, the primaries of a RED `110/110`) is compared as written.\n */\nfunction formatParameters(codec: RTCRtpCodecParameters) {\n const entries = new Map<string, string>();\n for (const item of (codec.parameters ?? \"\").split(\";\")) {\n const parameter = item.trim();\n if (parameter.length === 0) continue;\n const separator = parameter.indexOf(\"=\");\n if (separator < 0) {\n entries.set(parameter, \"\");\n continue;\n }\n entries.set(\n parameter.slice(0, separator).trim().toLowerCase(),\n parameter.slice(separator + 1).trim(),\n );\n }\n if (codecName(codec) === \"h264\") {\n entries.set(\"packetization-mode\", entries.get(\"packetization-mode\") ?? \"0\");\n entries.set(\n \"profile-level-id\",\n (entries.get(\"profile-level-id\") ?? \"42000a\").toLowerCase(),\n );\n }\n return [...entries]\n .map(([name, value]) => `${name}=${value}`)\n .sort()\n .join(\";\");\n}\n\n/**\n * The RTCP feedback (`a=rtcp-fb`) a payload type stands for, unordered and\n * without duplicates, with the type and parameter compared case-insensitively.\n */\nfunction feedbackTypes(codec: RTCRtpCodecParameters) {\n return [\n ...new Set(\n codec.rtcpFeedback.map((feedback) =>\n `${feedback.type} ${feedback.parameter ?? \"\"}`.trim().toLowerCase(),\n ),\n ),\n ]\n .sort()\n .join(\";\");\n}\n\n/**\n * Whether two codecs can share a payload type in one BUNDLE group (RFC 3264\n * §8.3.2, RFC 8843 §9.1): the same codec with the same format parameters and\n * RTCP feedback, the attributes RFC 8859 puts in the IDENTICAL-PER-PT\n * category (`a=fmtp`, `a=rtcp-fb`). So an H264 format with another\n * `packetization-mode` or `profile-level-id`, an RTX for another `apt`, a RED\n * with other primaries or a VP8 with other feedback is another codec.\n */\nfunction samePayloadMapping(\n left: RTCRtpCodecParameters,\n right: RTCRtpCodecParameters,\n) {\n return (\n sameFormat(left, right) && feedbackTypes(left) === feedbackTypes(right)\n );\n}\n\n/**\n * The same media format (`a=rtpmap` and `a=fmtp`, RFC 4566): MIME type,\n * clock rate, channels and the format parameters (`formatParameters`), for\n * every codec. RTCP feedback is not part of the format.\n */\nfunction sameFormat(left: RTCRtpCodecParameters, right: RTCRtpCodecParameters) {\n return (\n normalizeCodecMimeType(left.mimeType) ===\n normalizeCodecMimeType(right.mimeType) &&\n left.clockRate === right.clockRate &&\n (left.channels ?? 1) === (right.channels ?? 1) &&\n formatParameters(left) === formatParameters(right)\n );\n}\n\nfunction withPayloadType(\n codec: RTCRtpCodecParameters,\n payloadType: number,\n parameters = codec.parameters,\n) {\n if (codec.payloadType === payloadType && codec.parameters === parameters) {\n return codec;\n }\n const next = new RTCRtpCodecParameters({\n mimeType: codec.mimeType,\n clockRate: codec.clockRate,\n ...(codec.channels != undefined ? { channels: codec.channels } : {}),\n payloadType,\n rtcpFeedback: codec.rtcpFeedback.map((feedback) => ({ ...feedback })),\n ...(parameters != undefined ? { parameters } : {}),\n direction: codec.direction,\n });\n return next;\n}\n\n/**\n * Offer codecs for a negotiated m-line (RFC 8829 §5.2.2, RFC 3264 §8.3.2):\n * `capability` (configured codecs, in offer order) with each configured codec\n * that is already negotiated replaced by the negotiated codec itself, so its\n * payload type, fmtp and rtcp-fb stay as negotiated (also when the remote's\n * form differs from the configured one). Configured and negotiated codecs\n * pair as negotiation pairs them (`pairCodecs`: the same format first, then\n * the same MIME type). Another format of a negotiated MIME type that the\n * answer left out (H264 mode 1 next to a negotiated mode 0) is offered again\n * like any other codec, so a later answer can move to it; an answer that\n * still has the negotiated format pairs with it, since negotiation prefers\n * the same format. A negotiated RTX / RED for the offered primaries is\n * offered as negotiated too.\n *\n * A codec offered again keeps its configured payload type unless that type is\n * already used on this m-line or maps to another codec in `taken` (every\n * payload type the session uses; the same codec with other format parameters\n * or RTCP feedback, such as a RED with other primaries, is another codec);\n * then it takes a free dynamic type (96-127,\n * then 35-63). RTX `apt` and RED references follow their primaries, and an\n * RTX / RED whose primary is not offered is dropped. The order of\n * `capability` is kept.\n */\nexport function keepNegotiatedPayloadTypes(\n capability: readonly RTCRtpCodecParameters[],\n negotiated: readonly RTCRtpCodecParameters[],\n taken: ReadonlyMap<number, RTCRtpCodecParameters>,\n): RTCRtpCodecParameters[] {\n const offered: (RTCRtpCodecParameters | undefined)[] = capability.map(\n () => undefined,\n );\n const used = new Set<number>();\n const primaryPayloadType = new Map<number, number>();\n const matched = new Set<RTCRtpCodecParameters>();\n const isFree = (payloadType: number, codec: RTCRtpCodecParameters) => {\n if (used.has(payloadType)) return false;\n const owner = taken.get(payloadType);\n return owner == undefined || samePayloadMapping(owner, codec);\n };\n const pick = (preferred: number, codec: RTCRtpCodecParameters) => {\n if (isFree(preferred, codec)) return preferred;\n for (const [from, to] of [\n [96, 127],\n [35, 63],\n ]) {\n for (let payloadType = from; payloadType <= to; payloadType++) {\n if (isFree(payloadType, codec)) return payloadType;\n }\n }\n return undefined;\n };\n const place = (index: number, codec: RTCRtpCodecParameters) => {\n offered[index] = codec;\n used.add(codec.payloadType);\n };\n\n // 1. Negotiated primaries are offered as negotiated (payload type, fmtp,\n // rtcp-fb), each in place of the configured codec it pairs with\n // (`pairCodecs`: the same format first, then the same MIME type).\n for (const [codec, match] of pairCodecs(capability, negotiated)) {\n if (used.has(match.payloadType)) continue;\n matched.add(match);\n primaryPayloadType.set(codec.payloadType, match.payloadType);\n place(capability.indexOf(codec), match);\n }\n // 2. Primaries offered again.\n capability.forEach((codec, index) => {\n if (isAuxiliary(codec) || offered[index]) return;\n const payloadType = pick(codec.payloadType, codec);\n if (payloadType == undefined) return;\n primaryPayloadType.set(codec.payloadType, payloadType);\n place(index, withPayloadType(codec, payloadType));\n });\n // 3. RTX / RED follow their primaries.\n capability.forEach((codec, index) => {\n if (!isAuxiliary(codec)) return;\n const references = referencedPayloadTypes(codec).map((payloadType) =>\n primaryPayloadType.get(payloadType),\n );\n // A video RED has no fmtp (nothing references a primary): it is offered\n // as configured. An RTX, or a RED that names primaries, needs them offered.\n const standalone = codecName(codec) === \"red\" && references.length === 0;\n if (\n !standalone &&\n (references.length === 0 ||\n references.some((payloadType) => payloadType == undefined))\n ) {\n return;\n }\n const parameters = standalone\n ? codec.parameters\n : codecName(codec) === \"rtx\"\n ? (codec.parameters ?? \"\").replace(\n /(^|;)\\s*apt=\\d+/,\n `$1apt=${references[0]}`,\n )\n : references.join(\"/\");\n // The RTX / RED negotiated for these primaries is offered as negotiated.\n const negotiatedAuxiliary = negotiated.find(\n (other) =>\n codecName(other) === codecName(codec) &&\n !matched.has(other) &&\n !used.has(other.payloadType) &&\n (codecName(codec) === \"rtx\"\n ? referencedPayloadTypes(other)[0] === references[0]\n : (other.parameters ?? \"\") === (parameters ?? \"\")),\n );\n if (negotiatedAuxiliary) {\n matched.add(negotiatedAuxiliary);\n place(index, negotiatedAuxiliary);\n return;\n }\n const candidate = withPayloadType(codec, codec.payloadType, parameters);\n const payloadType = pick(codec.payloadType, candidate);\n if (payloadType == undefined) return;\n place(index, withPayloadType(candidate, payloadType));\n });\n return offered.filter((codec) => codec != undefined);\n}\n"]}
|
|
@@ -1,23 +1,56 @@
|
|
|
1
1
|
import { Event } from "../../imports/common";
|
|
2
2
|
import { GenericNack, type RtpPacket } from "../../imports/rtp";
|
|
3
3
|
import type { RTCRtpReceiver } from "../rtpReceiver";
|
|
4
|
+
/**
|
|
5
|
+
* Holes kept per media SSRC for RTX verification. At least {@link LOST_SIZE},
|
|
6
|
+
* so every requested hole is kept; holes past NACK's retries stay
|
|
7
|
+
* verifiable until this bound, for an RTX that answers an earlier NACK late.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MAX_HOLES = 1024;
|
|
10
|
+
/**
|
|
11
|
+
* Media SSRCs with NACK state at once. A receiver has a few live SSRCs (one
|
|
12
|
+
* per simulcast layer); a sender that keeps changing SSRCs must not grow the
|
|
13
|
+
* state for the receiver's lifetime, so the least recently received SSRC is
|
|
14
|
+
* dropped (its timer stopped) beyond this. Its next packet starts afresh.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_NACK_STREAMS = 16;
|
|
17
|
+
/**
|
|
18
|
+
* Generic NACK (RFC 4585 section 6.2.1) for the media SSRCs of one receiver.
|
|
19
|
+
* Loss detection and retransmission requests are kept per media SSRC, so the
|
|
20
|
+
* layers of a simulcast receiver (one SSRC each) never compare their sequence
|
|
21
|
+
* numbers with each other and each NACK names the SSRC that lost the packets.
|
|
22
|
+
* At most {@link MAX_NACK_STREAMS} SSRCs keep state (least recently received
|
|
23
|
+
* evicted first).
|
|
24
|
+
*/
|
|
4
25
|
export declare class NackHandler {
|
|
5
|
-
private receiver;
|
|
6
|
-
private
|
|
7
|
-
private _lost;
|
|
8
|
-
private nackLoop;
|
|
26
|
+
private readonly receiver;
|
|
27
|
+
private readonly streams;
|
|
9
28
|
readonly onPacketLost: Event<[GenericNack]>;
|
|
29
|
+
/** Media SSRC of the latest packet. */
|
|
10
30
|
mediaSourceSsrc?: number;
|
|
11
31
|
retryCount: number;
|
|
12
32
|
closed: boolean;
|
|
13
33
|
constructor(receiver: RTCRtpReceiver);
|
|
34
|
+
/** Lost sequence numbers of the latest media SSRC. */
|
|
14
35
|
get lostSeqNumbers(): number[];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
lostSeqNumbersOf(ssrc: number): number[];
|
|
37
|
+
/** Media SSRCs with NACK state. */
|
|
38
|
+
get ssrcs(): number[];
|
|
39
|
+
/** `packet` is a media packet (RTX already restored to its media SSRC). */
|
|
18
40
|
addPacket(packet: RtpPacket): void;
|
|
19
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Whether an RTX packet restoring `sequenceNumber` / `timestamp` on `ssrc`
|
|
43
|
+
* fills a hole this handler detected: its number is a hole of `ssrc` (NACK
|
|
44
|
+
* asks for it, or asked and still keeps it) and its timestamp lies within
|
|
45
|
+
* the timestamps of the packets received around the gap, in either order
|
|
46
|
+
* (frames sent out of display order) and widened by `slack`.
|
|
47
|
+
*/
|
|
48
|
+
canRepair(ssrc: number, sequenceNumber: number, timestamp: number, slack: number): boolean;
|
|
49
|
+
/** Reset `ssrc`: its NACK requests and holes end together. */
|
|
50
|
+
forget(ssrc: number): void;
|
|
51
|
+
/** Holes kept for `ssrc` (requested or not). */
|
|
52
|
+
holeCountOf(ssrc: number): number;
|
|
20
53
|
close(): void;
|
|
21
|
-
|
|
22
|
-
|
|
54
|
+
/** Internal: send one NACK for `ssrc` and notify {@link onPacketLost}. */
|
|
55
|
+
sendNack(ssrc: number, lost: number[]): Promise<void>;
|
|
23
56
|
}
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NackHandler = void 0;
|
|
3
|
+
exports.NackHandler = exports.MAX_NACK_STREAMS = exports.MAX_HOLES = void 0;
|
|
4
4
|
const common_1 = require("../../imports/common");
|
|
5
5
|
const rtp_1 = require("../../imports/rtp");
|
|
6
6
|
const log = (0, rtp_1.debug)("werift:packages/webrtc/src/media/receiver/nack.ts");
|
|
7
|
+
/** Holes NACK asks for at once (the newest ones). */
|
|
7
8
|
const LOST_SIZE = 30 * 5;
|
|
9
|
+
/**
|
|
10
|
+
* Holes kept per media SSRC for RTX verification. At least {@link LOST_SIZE},
|
|
11
|
+
* so every requested hole is kept; holes past NACK's retries stay
|
|
12
|
+
* verifiable until this bound, for an RTX that answers an earlier NACK late.
|
|
13
|
+
*/
|
|
14
|
+
exports.MAX_HOLES = 1024;
|
|
15
|
+
/**
|
|
16
|
+
* Media SSRCs with NACK state at once. A receiver has a few live SSRCs (one
|
|
17
|
+
* per simulcast layer); a sender that keeps changing SSRCs must not grow the
|
|
18
|
+
* state for the receiver's lifetime, so the least recently received SSRC is
|
|
19
|
+
* dropped (its timer stopped) beyond this. Its next packet starts afresh.
|
|
20
|
+
*/
|
|
21
|
+
exports.MAX_NACK_STREAMS = 16;
|
|
22
|
+
/**
|
|
23
|
+
* Generic NACK (RFC 4585 section 6.2.1) for the media SSRCs of one receiver.
|
|
24
|
+
* Loss detection and retransmission requests are kept per media SSRC, so the
|
|
25
|
+
* layers of a simulcast receiver (one SSRC each) never compare their sequence
|
|
26
|
+
* numbers with each other and each NACK names the SSRC that lost the packets.
|
|
27
|
+
* At most {@link MAX_NACK_STREAMS} SSRCs keep state (least recently received
|
|
28
|
+
* evicted first).
|
|
29
|
+
*/
|
|
8
30
|
class NackHandler {
|
|
9
31
|
constructor(receiver) {
|
|
10
32
|
Object.defineProperty(this, "receiver", {
|
|
@@ -13,146 +35,281 @@ class NackHandler {
|
|
|
13
35
|
writable: true,
|
|
14
36
|
value: void 0
|
|
15
37
|
});
|
|
16
|
-
Object.defineProperty(this, "
|
|
38
|
+
Object.defineProperty(this, "streams", {
|
|
17
39
|
enumerable: true,
|
|
18
40
|
configurable: true,
|
|
19
41
|
writable: true,
|
|
20
|
-
value:
|
|
42
|
+
value: new Map()
|
|
21
43
|
});
|
|
22
|
-
Object.defineProperty(this, "
|
|
44
|
+
Object.defineProperty(this, "onPacketLost", {
|
|
23
45
|
enumerable: true,
|
|
24
46
|
configurable: true,
|
|
25
47
|
writable: true,
|
|
26
|
-
value:
|
|
48
|
+
value: new common_1.Event()
|
|
27
49
|
});
|
|
28
|
-
|
|
50
|
+
/** Media SSRC of the latest packet. */
|
|
51
|
+
Object.defineProperty(this, "mediaSourceSsrc", {
|
|
29
52
|
enumerable: true,
|
|
30
53
|
configurable: true,
|
|
31
54
|
writable: true,
|
|
32
55
|
value: void 0
|
|
33
56
|
});
|
|
34
|
-
Object.defineProperty(this, "
|
|
57
|
+
Object.defineProperty(this, "retryCount", {
|
|
35
58
|
enumerable: true,
|
|
36
59
|
configurable: true,
|
|
37
60
|
writable: true,
|
|
38
|
-
value:
|
|
61
|
+
value: 10
|
|
39
62
|
});
|
|
40
|
-
Object.defineProperty(this, "
|
|
63
|
+
Object.defineProperty(this, "closed", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: false
|
|
68
|
+
});
|
|
69
|
+
this.receiver = receiver;
|
|
70
|
+
}
|
|
71
|
+
/** Lost sequence numbers of the latest media SSRC. */
|
|
72
|
+
get lostSeqNumbers() {
|
|
73
|
+
return this.mediaSourceSsrc === undefined
|
|
74
|
+
? []
|
|
75
|
+
: this.lostSeqNumbersOf(this.mediaSourceSsrc);
|
|
76
|
+
}
|
|
77
|
+
lostSeqNumbersOf(ssrc) {
|
|
78
|
+
return this.streams.get(ssrc)?.lostSeqNumbers ?? [];
|
|
79
|
+
}
|
|
80
|
+
/** Media SSRCs with NACK state. */
|
|
81
|
+
get ssrcs() {
|
|
82
|
+
return [...this.streams.keys()];
|
|
83
|
+
}
|
|
84
|
+
/** `packet` is a media packet (RTX already restored to its media SSRC). */
|
|
85
|
+
addPacket(packet) {
|
|
86
|
+
const { ssrc } = packet.header;
|
|
87
|
+
this.mediaSourceSsrc = ssrc;
|
|
88
|
+
if (this.closed)
|
|
89
|
+
return;
|
|
90
|
+
let stream = this.streams.get(ssrc);
|
|
91
|
+
if (stream) {
|
|
92
|
+
// Map の挿入順を受信順に保ち、先頭を最も古い SSRC にする。
|
|
93
|
+
this.streams.delete(ssrc);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
stream = new NackStream(ssrc, this);
|
|
97
|
+
}
|
|
98
|
+
this.streams.set(ssrc, stream);
|
|
99
|
+
if (this.streams.size > exports.MAX_NACK_STREAMS) {
|
|
100
|
+
const [oldest, evicted] = this.streams.entries().next().value;
|
|
101
|
+
evicted.close();
|
|
102
|
+
this.streams.delete(oldest);
|
|
103
|
+
}
|
|
104
|
+
stream.addPacket(packet.header.sequenceNumber, packet.header.timestamp);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether an RTX packet restoring `sequenceNumber` / `timestamp` on `ssrc`
|
|
108
|
+
* fills a hole this handler detected: its number is a hole of `ssrc` (NACK
|
|
109
|
+
* asks for it, or asked and still keeps it) and its timestamp lies within
|
|
110
|
+
* the timestamps of the packets received around the gap, in either order
|
|
111
|
+
* (frames sent out of display order) and widened by `slack`.
|
|
112
|
+
*/
|
|
113
|
+
canRepair(ssrc, sequenceNumber, timestamp, slack) {
|
|
114
|
+
return (this.streams.get(ssrc)?.canRepair(sequenceNumber, timestamp, slack) ??
|
|
115
|
+
false);
|
|
116
|
+
}
|
|
117
|
+
/** Reset `ssrc`: its NACK requests and holes end together. */
|
|
118
|
+
forget(ssrc) {
|
|
119
|
+
this.streams.get(ssrc)?.close();
|
|
120
|
+
this.streams.delete(ssrc);
|
|
121
|
+
}
|
|
122
|
+
/** Holes kept for `ssrc` (requested or not). */
|
|
123
|
+
holeCountOf(ssrc) {
|
|
124
|
+
return this.streams.get(ssrc)?.holeCount ?? 0;
|
|
125
|
+
}
|
|
126
|
+
close() {
|
|
127
|
+
this.closed = true;
|
|
128
|
+
for (const stream of this.streams.values())
|
|
129
|
+
stream.close();
|
|
130
|
+
this.streams.clear();
|
|
131
|
+
}
|
|
132
|
+
/** Internal: send one NACK for `ssrc` and notify {@link onPacketLost}. */
|
|
133
|
+
async sendNack(ssrc, lost) {
|
|
134
|
+
const nack = new rtp_1.GenericNack({
|
|
135
|
+
senderSsrc: this.receiver.rtcpSsrc,
|
|
136
|
+
mediaSourceSsrc: ssrc,
|
|
137
|
+
lost,
|
|
138
|
+
});
|
|
139
|
+
const rtcp = new rtp_1.RtcpTransportLayerFeedback({ feedback: nack });
|
|
140
|
+
const sent = this.receiver.dtlsTransport.sendRtcp([rtcp]);
|
|
141
|
+
this.onPacketLost.execute(nack);
|
|
142
|
+
await sent;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.NackHandler = NackHandler;
|
|
146
|
+
/**
|
|
147
|
+
* Loss state of one media SSRC: one ledger of holes serves both NACK (the
|
|
148
|
+
* holes still requested) and RTX verification (every hole kept, see
|
|
149
|
+
* {@link NackHandler.canRepair}). A hole leaves the ledger only when its
|
|
150
|
+
* packet arrives, when it falls out of the bounds below, or when the stream
|
|
151
|
+
* is reset; NACK stops asking for it at that moment at the latest, so a
|
|
152
|
+
* requested packet can always be verified when its RTX arrives.
|
|
153
|
+
*/
|
|
154
|
+
class NackStream {
|
|
155
|
+
constructor(ssrc, handler) {
|
|
156
|
+
/** Extended (wrap-counting) sequence number and timestamp of the newest packet. */
|
|
157
|
+
Object.defineProperty(this, "newestExt", {
|
|
41
158
|
enumerable: true,
|
|
42
159
|
configurable: true,
|
|
43
160
|
writable: true,
|
|
44
161
|
value: void 0
|
|
45
162
|
});
|
|
46
|
-
Object.defineProperty(this, "
|
|
163
|
+
Object.defineProperty(this, "newestTimestamp", {
|
|
47
164
|
enumerable: true,
|
|
48
165
|
configurable: true,
|
|
49
166
|
writable: true,
|
|
50
|
-
value:
|
|
167
|
+
value: 0
|
|
51
168
|
});
|
|
52
|
-
|
|
169
|
+
/** Holes by extended sequence number, oldest first (insertion order). */
|
|
170
|
+
Object.defineProperty(this, "holes", {
|
|
53
171
|
enumerable: true,
|
|
54
172
|
configurable: true,
|
|
55
173
|
writable: true,
|
|
56
|
-
value:
|
|
174
|
+
value: new Map()
|
|
57
175
|
});
|
|
58
|
-
Object.defineProperty(this, "
|
|
176
|
+
Object.defineProperty(this, "nackLoop", {
|
|
59
177
|
enumerable: true,
|
|
60
178
|
configurable: true,
|
|
61
179
|
writable: true,
|
|
62
|
-
value:
|
|
63
|
-
if (this.lostSeqNumbers.length > 0 && this.mediaSourceSsrc) {
|
|
64
|
-
const nack = new rtp_1.GenericNack({
|
|
65
|
-
senderSsrc: this.receiver.rtcpSsrc,
|
|
66
|
-
mediaSourceSsrc: this.mediaSourceSsrc,
|
|
67
|
-
lost: this.lostSeqNumbers,
|
|
68
|
-
});
|
|
69
|
-
const rtcp = new rtp_1.RtcpTransportLayerFeedback({
|
|
70
|
-
feedback: nack,
|
|
71
|
-
});
|
|
72
|
-
this.receiver.dtlsTransport.sendRtcp([rtcp]).then(r).catch(f);
|
|
73
|
-
this.updateRetryCount();
|
|
74
|
-
this.onPacketLost.execute(nack);
|
|
75
|
-
}
|
|
76
|
-
})
|
|
180
|
+
value: void 0
|
|
77
181
|
});
|
|
78
|
-
this
|
|
182
|
+
Object.defineProperty(this, "ssrc", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
configurable: true,
|
|
185
|
+
writable: true,
|
|
186
|
+
value: void 0
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(this, "handler", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
configurable: true,
|
|
191
|
+
writable: true,
|
|
192
|
+
value: void 0
|
|
193
|
+
});
|
|
194
|
+
this.ssrc = ssrc;
|
|
195
|
+
this.handler = handler;
|
|
79
196
|
}
|
|
197
|
+
/** Sequence numbers NACK still asks for, oldest first. */
|
|
80
198
|
get lostSeqNumbers() {
|
|
81
|
-
|
|
199
|
+
const lost = [];
|
|
200
|
+
for (const hole of this.holes.values()) {
|
|
201
|
+
if (hole.requests !== undefined)
|
|
202
|
+
lost.push(hole.sequenceNumber);
|
|
203
|
+
}
|
|
204
|
+
return lost;
|
|
82
205
|
}
|
|
83
|
-
|
|
84
|
-
return this.
|
|
206
|
+
get holeCount() {
|
|
207
|
+
return this.holes.size;
|
|
85
208
|
}
|
|
86
|
-
|
|
87
|
-
this.
|
|
88
|
-
|
|
209
|
+
addPacket(sequenceNumber, timestamp) {
|
|
210
|
+
if (this.newestExt === undefined) {
|
|
211
|
+
this.newestExt = sequenceNumber;
|
|
212
|
+
this.newestTimestamp = timestamp;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const ext = this.extend(sequenceNumber);
|
|
216
|
+
if (ext <= this.newestExt) {
|
|
217
|
+
// 遅着・再送で欠落が埋まった。台帳にない番号は重複か要求外なので何もしない。
|
|
218
|
+
this.holes.delete(ext);
|
|
219
|
+
if (this.holes.size === 0)
|
|
220
|
+
this.stopLoop();
|
|
89
221
|
return;
|
|
90
222
|
}
|
|
223
|
+
// 新しい欠落: 台帳に入るのは末尾 MAX_HOLES 個まで (それ以前は要求も検証もしない)。
|
|
224
|
+
const from = Math.max(this.newestExt + 1, ext - exports.MAX_HOLES);
|
|
225
|
+
for (let missing = from; missing < ext; missing++) {
|
|
226
|
+
this.holes.set(missing, {
|
|
227
|
+
sequenceNumber: missing & 0xffff,
|
|
228
|
+
timestampBefore: this.newestTimestamp,
|
|
229
|
+
timestampAfter: timestamp,
|
|
230
|
+
requests: 0,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
this.newestExt = ext;
|
|
234
|
+
this.newestTimestamp = timestamp;
|
|
235
|
+
this.pruneHoles();
|
|
236
|
+
if (from < ext)
|
|
237
|
+
this.startLoop();
|
|
238
|
+
}
|
|
239
|
+
/** Whether an RTX packet with this original number and timestamp fills a hole. */
|
|
240
|
+
canRepair(sequenceNumber, timestamp, slack) {
|
|
241
|
+
if (this.newestExt === undefined)
|
|
242
|
+
return false;
|
|
243
|
+
const hole = this.holes.get(this.extend(sequenceNumber));
|
|
244
|
+
if (!hole)
|
|
245
|
+
return false;
|
|
246
|
+
// 時刻は欠落直後の受信パケットからの符号付き差で比べる (32 bit の折り返しに依存しない)。
|
|
247
|
+
const before = (hole.timestampBefore - hole.timestampAfter) | 0;
|
|
248
|
+
const offset = (timestamp - hole.timestampAfter) | 0;
|
|
249
|
+
return (offset >= Math.min(before, 0) - slack &&
|
|
250
|
+
offset <= Math.max(before, 0) + slack);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Bounds of the ledger. Each removal removes the hole itself, so NACK stops
|
|
254
|
+
* asking for it at the same moment; NACK's own limits (LOST_SIZE requests,
|
|
255
|
+
* `retryCount`) only stop the request and keep the hole verifiable.
|
|
256
|
+
*/
|
|
257
|
+
pruneHoles() {
|
|
258
|
+
const newest = this.newestExt;
|
|
259
|
+
for (const [ext] of this.holes) {
|
|
260
|
+
// 16 bit の番号は 0x8000 以上離れると前後を区別できない。
|
|
261
|
+
if (this.holes.size <= exports.MAX_HOLES && newest - ext < 0x8000)
|
|
262
|
+
break;
|
|
263
|
+
this.holes.delete(ext);
|
|
264
|
+
}
|
|
265
|
+
let requested = 0;
|
|
266
|
+
const holes = [...this.holes.values()];
|
|
267
|
+
for (let i = holes.length - 1; i >= 0; i--) {
|
|
268
|
+
if (holes[i].requests === undefined)
|
|
269
|
+
continue;
|
|
270
|
+
if (++requested > LOST_SIZE)
|
|
271
|
+
holes[i].requests = undefined;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/** `sequenceNumber` as the extended number nearest the newest. */
|
|
275
|
+
extend(sequenceNumber) {
|
|
276
|
+
const newest = this.newestExt;
|
|
277
|
+
const delta = (sequenceNumber - newest) & 0xffff;
|
|
278
|
+
return newest + (delta < 0x8000 ? delta : delta - 0x10000);
|
|
279
|
+
}
|
|
280
|
+
startLoop() {
|
|
281
|
+
if (this.nackLoop)
|
|
282
|
+
return;
|
|
91
283
|
this.nackLoop = setInterval(async () => {
|
|
92
284
|
try {
|
|
93
285
|
await this.sendNack();
|
|
94
|
-
if (!Object.keys(this._lost).length) {
|
|
95
|
-
clearInterval(this.nackLoop);
|
|
96
|
-
this.nackLoop = undefined;
|
|
97
|
-
}
|
|
98
286
|
}
|
|
99
287
|
catch (error) {
|
|
100
288
|
log("failed to send nack", error);
|
|
101
289
|
}
|
|
102
290
|
}, 5);
|
|
103
291
|
}
|
|
104
|
-
|
|
105
|
-
|
|
292
|
+
close() {
|
|
293
|
+
this.stopLoop();
|
|
294
|
+
this.holes.clear();
|
|
106
295
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// log("packetLoss resolved", { sequenceNumber });
|
|
116
|
-
this.removeLost(sequenceNumber);
|
|
296
|
+
stopLoop() {
|
|
297
|
+
clearInterval(this.nackLoop);
|
|
298
|
+
this.nackLoop = undefined;
|
|
299
|
+
}
|
|
300
|
+
async sendNack() {
|
|
301
|
+
const lost = this.lostSeqNumbers;
|
|
302
|
+
if (lost.length === 0) {
|
|
303
|
+
this.stopLoop();
|
|
117
304
|
return;
|
|
118
305
|
}
|
|
119
|
-
|
|
120
|
-
|
|
306
|
+
for (const hole of this.holes.values()) {
|
|
307
|
+
if (hole.requests === undefined)
|
|
308
|
+
continue;
|
|
309
|
+
if (++hole.requests > this.handler.retryCount)
|
|
310
|
+
hole.requests = undefined;
|
|
121
311
|
}
|
|
122
|
-
|
|
123
|
-
// packet lost detected
|
|
124
|
-
for (let i = (0, common_1.uint16Add)(this.newEstSeqNum, 1); i < sequenceNumber; i = (0, common_1.uint16Add)(i, 1)) {
|
|
125
|
-
this.setLost(i, 1);
|
|
126
|
-
}
|
|
127
|
-
// this.receiver.sendRtcpPLI(this.mediaSourceSsrc);
|
|
128
|
-
this.newEstSeqNum = sequenceNumber;
|
|
129
|
-
this.pruneLost();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
pruneLost() {
|
|
133
|
-
if (this.lostSeqNumbers.length > LOST_SIZE) {
|
|
134
|
-
this._lost = Object.entries(this._lost)
|
|
135
|
-
.slice(-LOST_SIZE)
|
|
136
|
-
.reduce((acc, [key, v]) => {
|
|
137
|
-
acc[key] = v;
|
|
138
|
-
return acc;
|
|
139
|
-
}, {});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
close() {
|
|
143
|
-
this.closed = true;
|
|
144
|
-
clearInterval(this.nackLoop);
|
|
145
|
-
this._lost = {};
|
|
146
|
-
}
|
|
147
|
-
updateRetryCount() {
|
|
148
|
-
this.lostSeqNumbers.forEach((seq) => {
|
|
149
|
-
const count = this._lost[seq]++;
|
|
150
|
-
if (count > this.retryCount) {
|
|
151
|
-
this.removeLost(seq);
|
|
152
|
-
return seq;
|
|
153
|
-
}
|
|
154
|
-
});
|
|
312
|
+
await this.handler.sendNack(this.ssrc, lost);
|
|
155
313
|
}
|
|
156
314
|
}
|
|
157
|
-
exports.NackHandler = NackHandler;
|
|
158
315
|
//# sourceMappingURL=nack.js.map
|