werift 0.25.1 → 0.26.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.
Files changed (371) hide show
  1. package/lib/common/src/asn1.d.ts +42 -0
  2. package/lib/common/src/asn1.js +163 -0
  3. package/lib/common/src/asn1.js.map +1 -0
  4. package/lib/common/src/binaryData.js.map +1 -1
  5. package/lib/common/src/index.d.ts +6 -5
  6. package/lib/common/src/index.js +6 -5
  7. package/lib/common/src/index.js.map +1 -1
  8. package/lib/common/src/log.d.ts +12 -1
  9. package/lib/common/src/log.js +137 -5
  10. package/lib/common/src/log.js.map +1 -1
  11. package/lib/common/src/network.js.map +1 -1
  12. package/lib/common/src/queue.d.ts +41 -0
  13. package/lib/common/src/queue.js +146 -0
  14. package/lib/common/src/queue.js.map +1 -0
  15. package/lib/common/src/transport.d.ts +15 -2
  16. package/lib/common/src/transport.js +98 -14
  17. package/lib/common/src/transport.js.map +1 -1
  18. package/lib/dtls/src/cipher/create.js.map +1 -1
  19. package/lib/dtls/src/cipher/ec.js +8 -8
  20. package/lib/dtls/src/cipher/ec.js.map +1 -1
  21. package/lib/dtls/src/cipher/namedCurve.js +6 -7
  22. package/lib/dtls/src/cipher/namedCurve.js.map +1 -1
  23. package/lib/dtls/src/cipher/prf.d.ts +2 -2
  24. package/lib/dtls/src/cipher/prf.js +29 -8
  25. package/lib/dtls/src/cipher/prf.js.map +1 -1
  26. package/lib/dtls/src/cipher/suites/aead.d.ts +1 -1
  27. package/lib/dtls/src/context/certificate.d.ts +32 -0
  28. package/lib/dtls/src/context/certificate.js +54 -0
  29. package/lib/dtls/src/context/certificate.js.map +1 -0
  30. package/lib/dtls/src/context/cipher.d.ts +12 -6
  31. package/lib/dtls/src/context/cipher.js +52 -103
  32. package/lib/dtls/src/context/cipher.js.map +1 -1
  33. package/lib/dtls/src/context/transport.d.ts +4 -0
  34. package/lib/dtls/src/context/transport.js +14 -0
  35. package/lib/dtls/src/context/transport.js.map +1 -1
  36. package/lib/dtls/src/flight/client/flight5.js.map +1 -1
  37. package/lib/dtls/src/flight/flight.js +8 -1
  38. package/lib/dtls/src/flight/flight.js.map +1 -1
  39. package/lib/dtls/src/flight/server/flight2.js.map +1 -1
  40. package/lib/dtls/src/flight/server/flight4.d.ts +2 -1
  41. package/lib/dtls/src/flight/server/flight4.js +8 -2
  42. package/lib/dtls/src/flight/server/flight4.js.map +1 -1
  43. package/lib/dtls/src/handshake/extensions/signature.d.ts +1 -1
  44. package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
  45. package/lib/dtls/src/handshake/message/alert.js +1 -1
  46. package/lib/dtls/src/handshake/message/alert.js.map +1 -1
  47. package/lib/dtls/src/handshake/message/certificate.js +1 -1
  48. package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
  49. package/lib/dtls/src/handshake/message/changeCipherSpec.js +2 -3
  50. package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
  51. package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +1 -1
  52. package/lib/dtls/src/handshake/message/client/certificateVerify.js +1 -1
  53. package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
  54. package/lib/dtls/src/handshake/message/client/hello.js +1 -1
  55. package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
  56. package/lib/dtls/src/handshake/message/client/keyExchange.js +1 -1
  57. package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
  58. package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +1 -1
  59. package/lib/dtls/src/handshake/message/server/certificateRequest.js +1 -1
  60. package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
  61. package/lib/dtls/src/handshake/message/server/hello.d.ts +1 -1
  62. package/lib/dtls/src/handshake/message/server/hello.js +2 -2
  63. package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
  64. package/lib/dtls/src/handshake/message/server/helloDone.js +1 -1
  65. package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
  66. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +1 -1
  67. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
  68. package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +1 -1
  69. package/lib/dtls/src/handshake/message/server/keyExchange.js +1 -1
  70. package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
  71. package/lib/dtls/src/handshake/random.d.ts +2 -2
  72. package/lib/dtls/src/handshake/random.js +2 -2
  73. package/lib/dtls/src/handshake/random.js.map +1 -1
  74. package/lib/dtls/src/imports/common.d.ts +1 -0
  75. package/lib/dtls/src/imports/common.js +1 -0
  76. package/lib/dtls/src/imports/common.js.map +1 -1
  77. package/lib/dtls/src/index.d.ts +2 -2
  78. package/lib/dtls/src/index.js +2 -2
  79. package/lib/dtls/src/index.js.map +1 -1
  80. package/lib/dtls/src/record/message/fragment.d.ts +1 -1
  81. package/lib/dtls/src/record/message/fragment.js +3 -3
  82. package/lib/dtls/src/record/message/fragment.js.map +1 -1
  83. package/lib/dtls/src/record/message/header.js +2 -2
  84. package/lib/dtls/src/record/message/header.js.map +1 -1
  85. package/lib/dtls/src/server.js +1 -1
  86. package/lib/dtls/src/server.js.map +1 -1
  87. package/lib/dtls/src/socket.d.ts +2 -2
  88. package/lib/dtls/src/socket.js +2 -2
  89. package/lib/dtls/src/socket.js.map +1 -1
  90. package/lib/ice/src/exceptions.d.ts +30 -0
  91. package/lib/ice/src/exceptions.js +43 -1
  92. package/lib/ice/src/exceptions.js.map +1 -1
  93. package/lib/ice/src/helper.d.ts +1 -1
  94. package/lib/ice/src/ice.d.ts +142 -0
  95. package/lib/ice/src/ice.js +809 -53
  96. package/lib/ice/src/ice.js.map +1 -1
  97. package/lib/ice/src/iceBase.d.ts +49 -0
  98. package/lib/ice/src/iceBase.js.map +1 -1
  99. package/lib/ice/src/index.d.ts +5 -5
  100. package/lib/ice/src/index.js +5 -5
  101. package/lib/ice/src/index.js.map +1 -1
  102. package/lib/ice/src/internal/resolveHostAddresses.d.ts +26 -0
  103. package/lib/ice/src/internal/resolveHostAddresses.js +45 -0
  104. package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -0
  105. package/lib/ice/src/stun/protocol.d.ts +3 -1
  106. package/lib/ice/src/stun/protocol.js +16 -0
  107. package/lib/ice/src/stun/protocol.js.map +1 -1
  108. package/lib/ice/src/stun/tcpProtocol.d.ts +2 -0
  109. package/lib/ice/src/stun/tcpProtocol.js +16 -1
  110. package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
  111. package/lib/ice/src/stun/transaction.d.ts +5 -0
  112. package/lib/ice/src/stun/transaction.js +7 -1
  113. package/lib/ice/src/stun/transaction.js.map +1 -1
  114. package/lib/ice/src/turn/protocol.d.ts +73 -4
  115. package/lib/ice/src/turn/protocol.js +241 -12
  116. package/lib/ice/src/turn/protocol.js.map +1 -1
  117. package/lib/ice/src/utils.js.map +1 -1
  118. package/lib/ice-server/src/stun/message.d.ts +5 -1
  119. package/lib/ice-server/src/stun/message.js +33 -2
  120. package/lib/ice-server/src/stun/message.js.map +1 -1
  121. package/lib/ice-server/src/turn/auth.d.ts +1 -1
  122. package/lib/index.mjs +24263 -16477
  123. package/lib/nonstandard/index.mjs +9272 -6178
  124. package/lib/polyfill/dom.mjs +24872 -20543
  125. package/lib/polyfill/index.mjs +24872 -20543
  126. package/lib/rtp/src/codec/av1.d.ts +61 -1
  127. package/lib/rtp/src/codec/av1.js +332 -33
  128. package/lib/rtp/src/codec/av1.js.map +1 -1
  129. package/lib/rtp/src/codec/base.d.ts +49 -1
  130. package/lib/rtp/src/codec/base.js +81 -1
  131. package/lib/rtp/src/codec/base.js.map +1 -1
  132. package/lib/rtp/src/codec/g711.d.ts +37 -0
  133. package/lib/rtp/src/codec/g711.js +109 -0
  134. package/lib/rtp/src/codec/g711.js.map +1 -0
  135. package/lib/rtp/src/codec/g722.d.ts +31 -0
  136. package/lib/rtp/src/codec/g722.js +82 -0
  137. package/lib/rtp/src/codec/g722.js.map +1 -0
  138. package/lib/rtp/src/codec/h264.d.ts +81 -7
  139. package/lib/rtp/src/codec/h264.js +382 -21
  140. package/lib/rtp/src/codec/h264.js.map +1 -1
  141. package/lib/rtp/src/codec/h265.d.ts +101 -0
  142. package/lib/rtp/src/codec/h265.js +615 -0
  143. package/lib/rtp/src/codec/h265.js.map +1 -0
  144. package/lib/rtp/src/codec/index.d.ts +6 -1
  145. package/lib/rtp/src/codec/index.js +25 -0
  146. package/lib/rtp/src/codec/index.js.map +1 -1
  147. package/lib/rtp/src/codec/mp4a.d.ts +88 -0
  148. package/lib/rtp/src/codec/mp4a.js +386 -0
  149. package/lib/rtp/src/codec/mp4a.js.map +1 -0
  150. package/lib/rtp/src/codec/opus.d.ts +14 -2
  151. package/lib/rtp/src/codec/opus.js +32 -2
  152. package/lib/rtp/src/codec/opus.js.map +1 -1
  153. package/lib/rtp/src/codec/telephoneEvent.d.ts +102 -0
  154. package/lib/rtp/src/codec/telephoneEvent.js +176 -0
  155. package/lib/rtp/src/codec/telephoneEvent.js.map +1 -0
  156. package/lib/rtp/src/codec/vp8.d.ts +26 -1
  157. package/lib/rtp/src/codec/vp8.js +76 -2
  158. package/lib/rtp/src/codec/vp8.js.map +1 -1
  159. package/lib/rtp/src/codec/vp9.d.ts +25 -1
  160. package/lib/rtp/src/codec/vp9.js +64 -2
  161. package/lib/rtp/src/codec/vp9.js.map +1 -1
  162. package/lib/rtp/src/const.d.ts +1 -0
  163. package/lib/rtp/src/const.js +5 -0
  164. package/lib/rtp/src/const.js.map +1 -0
  165. package/lib/rtp/src/extra/container/mp4/container.js +4 -1
  166. package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
  167. package/lib/rtp/src/extra/container/mp4/h264.d.ts +26 -0
  168. package/lib/rtp/src/extra/container/mp4/h264.js +54 -0
  169. package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
  170. package/lib/rtp/src/extra/container/webm/container.d.ts +1 -1
  171. package/lib/rtp/src/extra/container/webm/ebml/ebml.d.ts +6 -0
  172. package/lib/rtp/src/extra/container/webm/ebml/ebml.js +20 -1
  173. package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
  174. package/lib/rtp/src/extra/processor/depacketizer.d.ts +1 -1
  175. package/lib/rtp/src/extra/processor/depacketizer.js +1 -1
  176. package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
  177. package/lib/rtp/src/extra/processor/depacketizerCallback.d.ts +1 -11
  178. package/lib/rtp/src/extra/processor/depacketizerTransformer.d.ts +1 -1
  179. package/lib/rtp/src/extra/processor/dtxCallback.d.ts +1 -11
  180. package/lib/rtp/src/extra/processor/interface.d.ts +16 -11
  181. package/lib/rtp/src/extra/processor/interface.js.map +1 -1
  182. package/lib/rtp/src/extra/processor/jitterBufferCallback.d.ts +1 -11
  183. package/lib/rtp/src/extra/processor/jitterBufferTransformer.d.ts +1 -1
  184. package/lib/rtp/src/extra/processor/mp4.d.ts +16 -0
  185. package/lib/rtp/src/extra/processor/mp4.js +55 -21
  186. package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
  187. package/lib/rtp/src/extra/processor/nack.d.ts +1 -1
  188. package/lib/rtp/src/extra/processor/nack.js +1 -1
  189. package/lib/rtp/src/extra/processor/nack.js.map +1 -1
  190. package/lib/rtp/src/extra/processor/nackHandlerCallback.d.ts +1 -11
  191. package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
  192. package/lib/rtp/src/extra/processor/ntpTimeCallback.d.ts +1 -11
  193. package/lib/rtp/src/extra/processor/rtcpCallback.d.ts +1 -1
  194. package/lib/rtp/src/extra/processor/rtcpCallback.js.map +1 -1
  195. package/lib/rtp/src/extra/processor/rtpCallback.d.ts +1 -1
  196. package/lib/rtp/src/extra/processor/rtpCallback.js +1 -1
  197. package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
  198. package/lib/rtp/src/extra/processor/rtpStream.d.ts +2 -2
  199. package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
  200. package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
  201. package/lib/rtp/src/extra/processor/rtpTimeCallback.d.ts +1 -11
  202. package/lib/rtp/src/extra/processor/webm.d.ts +27 -0
  203. package/lib/rtp/src/extra/processor/webm.js +43 -16
  204. package/lib/rtp/src/extra/processor/webm.js.map +1 -1
  205. package/lib/rtp/src/extra/processor/webmCallback.js +6 -1
  206. package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
  207. package/lib/rtp/src/extra/processor/webmStream.js.map +1 -1
  208. package/lib/rtp/src/helper.d.ts +2 -2
  209. package/lib/rtp/src/helper.js +2 -6
  210. package/lib/rtp/src/helper.js.map +1 -1
  211. package/lib/rtp/src/index.d.ts +4 -2
  212. package/lib/rtp/src/index.js +4 -2
  213. package/lib/rtp/src/index.js.map +1 -1
  214. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +2 -1
  215. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
  216. package/lib/rtp/src/rtcp/rtcp.js +2 -1
  217. package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
  218. package/lib/rtp/src/rtcp/sr.d.ts +4 -3
  219. package/lib/rtp/src/rtcp/sr.js +3 -2
  220. package/lib/rtp/src/rtcp/sr.js.map +1 -1
  221. package/lib/rtp/src/rtp/mediaClock.d.ts +283 -0
  222. package/lib/rtp/src/rtp/mediaClock.js +655 -0
  223. package/lib/rtp/src/rtp/mediaClock.js.map +1 -0
  224. package/lib/rtp/src/srtp/cipher/ctr.d.ts +2 -2
  225. package/lib/rtp/src/srtp/cipher/ctr.js +1 -1
  226. package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
  227. package/lib/rtp/src/srtp/cipher/gcm.d.ts +1 -1
  228. package/lib/rtp/src/srtp/cipher/gcm.js +1 -1
  229. package/lib/rtp/src/srtp/cipher/gcm.js.map +1 -1
  230. package/lib/rtp/src/srtp/context/context.d.ts +29 -1
  231. package/lib/rtp/src/srtp/context/context.js +78 -24
  232. package/lib/rtp/src/srtp/context/context.js.map +1 -1
  233. package/lib/rtp/src/srtp/context/srtp.js +23 -15
  234. package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
  235. package/lib/rtp/src/util.d.ts +59 -6
  236. package/lib/rtp/src/util.js +88 -10
  237. package/lib/rtp/src/util.js.map +1 -1
  238. package/lib/sctp/src/index.d.ts +4 -3
  239. package/lib/sctp/src/index.js +10 -8
  240. package/lib/sctp/src/index.js.map +1 -1
  241. package/lib/sctp/src/sctp.d.ts +11 -2
  242. package/lib/sctp/src/sctp.js +47 -28
  243. package/lib/sctp/src/sctp.js.map +1 -1
  244. package/lib/webrtc/src/api/peerConfig.d.ts +264 -0
  245. package/lib/webrtc/src/api/peerConfig.js +250 -0
  246. package/lib/webrtc/src/api/peerConfig.js.map +1 -0
  247. package/lib/webrtc/src/api/peerConnectionEvents.d.ts +36 -0
  248. package/lib/webrtc/src/api/peerConnectionEvents.js +44 -0
  249. package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -0
  250. package/lib/webrtc/src/dataChannel.d.ts +1 -1
  251. package/lib/webrtc/src/dataChannel.js +1 -1
  252. package/lib/webrtc/src/dataChannel.js.map +1 -1
  253. package/lib/webrtc/src/index.d.ts +2 -2
  254. package/lib/webrtc/src/index.js +2 -2
  255. package/lib/webrtc/src/index.js.map +1 -1
  256. package/lib/webrtc/src/media/codec.d.ts +18 -0
  257. package/lib/webrtc/src/media/codec.js +43 -2
  258. package/lib/webrtc/src/media/codec.js.map +1 -1
  259. package/lib/webrtc/src/media/codecCompatibility.d.ts +5 -0
  260. package/lib/webrtc/src/media/codecCompatibility.js +15 -4
  261. package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
  262. package/lib/webrtc/src/media/index.d.ts +1 -1
  263. package/lib/webrtc/src/media/index.js +1 -1
  264. package/lib/webrtc/src/media/index.js.map +1 -1
  265. package/lib/webrtc/src/media/receiver/nack.js +3 -4
  266. package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
  267. package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
  268. package/lib/webrtc/src/media/router.d.ts +116 -5
  269. package/lib/webrtc/src/media/router.js +281 -29
  270. package/lib/webrtc/src/media/router.js.map +1 -1
  271. package/lib/webrtc/src/media/rtpReceiver.d.ts +107 -12
  272. package/lib/webrtc/src/media/rtpReceiver.js +255 -28
  273. package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
  274. package/lib/webrtc/src/media/rtpSender.d.ts +56 -3
  275. package/lib/webrtc/src/media/rtpSender.js +180 -21
  276. package/lib/webrtc/src/media/rtpSender.js.map +1 -1
  277. package/lib/webrtc/src/media/rtpTransceiver.d.ts +94 -1
  278. package/lib/webrtc/src/media/rtpTransceiver.js +111 -2
  279. package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
  280. package/lib/webrtc/src/media/sender/senderBWE.d.ts +2 -1
  281. package/lib/webrtc/src/media/sender/senderBWE.js +22 -10
  282. package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
  283. package/lib/webrtc/src/media/track.d.ts +1 -1
  284. package/lib/webrtc/src/media/track.js +1 -1
  285. package/lib/webrtc/src/media/track.js.map +1 -1
  286. package/lib/webrtc/src/negotiation/bundleTopology.d.ts +107 -0
  287. package/lib/webrtc/src/negotiation/bundleTopology.js +380 -0
  288. package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -0
  289. package/lib/webrtc/src/negotiation/descriptionValidation.d.ts +51 -0
  290. package/lib/webrtc/src/negotiation/descriptionValidation.js +261 -0
  291. package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -0
  292. package/lib/webrtc/src/negotiation/iceRestartRequest.d.ts +21 -0
  293. package/lib/webrtc/src/negotiation/iceRestartRequest.js +61 -0
  294. package/lib/webrtc/src/negotiation/iceRestartRequest.js.map +1 -0
  295. package/lib/webrtc/src/negotiation/internalState.d.ts +34 -0
  296. package/lib/webrtc/src/negotiation/internalState.js +21 -0
  297. package/lib/webrtc/src/negotiation/internalState.js.map +1 -0
  298. package/lib/webrtc/src/negotiation/negotiationNeeded.d.ts +44 -0
  299. package/lib/webrtc/src/negotiation/negotiationNeeded.js +118 -0
  300. package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -0
  301. package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +86 -0
  302. package/lib/webrtc/src/negotiation/remoteCandidates.js +344 -0
  303. package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -0
  304. package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +71 -0
  305. package/lib/webrtc/src/negotiation/remoteMediaApplication.js +398 -0
  306. package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -0
  307. package/lib/webrtc/src/negotiation/transportActivation.d.ts +59 -0
  308. package/lib/webrtc/src/negotiation/transportActivation.js +345 -0
  309. package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -0
  310. package/lib/webrtc/src/negotiationTransaction.d.ts +233 -0
  311. package/lib/webrtc/src/negotiationTransaction.js +591 -0
  312. package/lib/webrtc/src/negotiationTransaction.js.map +1 -0
  313. package/lib/webrtc/src/nonstandard/dummyMedia.js +20 -6
  314. package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
  315. package/lib/webrtc/src/nonstandard/index.d.ts +1 -1
  316. package/lib/webrtc/src/nonstandard/index.js +1 -1
  317. package/lib/webrtc/src/nonstandard/index.js.map +1 -1
  318. package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
  319. package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +1 -1
  320. package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
  321. package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +2 -2
  322. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +2 -2
  323. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
  324. package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +4 -4
  325. package/lib/webrtc/src/nonstandard/userMedia/packetizer.js +61 -306
  326. package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
  327. package/lib/webrtc/src/nonstandard/userMedia.d.ts +4 -2
  328. package/lib/webrtc/src/nonstandard/userMedia.js +43 -9
  329. package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
  330. package/lib/webrtc/src/peerConnection.d.ts +132 -237
  331. package/lib/webrtc/src/peerConnection.js +971 -906
  332. package/lib/webrtc/src/peerConnection.js.map +1 -1
  333. package/lib/webrtc/src/polyfill/api.d.ts +5 -5
  334. package/lib/webrtc/src/polyfill/api.js.map +1 -1
  335. package/lib/webrtc/src/polyfill/index.js.map +1 -1
  336. package/lib/webrtc/src/polyfill/install.js +1 -1
  337. package/lib/webrtc/src/polyfill/install.js.map +1 -1
  338. package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
  339. package/lib/webrtc/src/polyfill/registers/mp4Webm.js.map +1 -1
  340. package/lib/webrtc/src/polyfill/registers/rtpRtcp.js.map +1 -1
  341. package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
  342. package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
  343. package/lib/webrtc/src/sctpManager.d.ts +66 -2
  344. package/lib/webrtc/src/sctpManager.js +122 -5
  345. package/lib/webrtc/src/sctpManager.js.map +1 -1
  346. package/lib/webrtc/src/sdp.js.map +1 -1
  347. package/lib/webrtc/src/sdpManager.d.ts +55 -11
  348. package/lib/webrtc/src/sdpManager.js +367 -89
  349. package/lib/webrtc/src/sdpManager.js.map +1 -1
  350. package/lib/webrtc/src/secureTransportManager.d.ts +38 -25
  351. package/lib/webrtc/src/secureTransportManager.js +130 -34
  352. package/lib/webrtc/src/secureTransportManager.js.map +1 -1
  353. package/lib/webrtc/src/transceiverManager.d.ts +62 -18
  354. package/lib/webrtc/src/transceiverManager.js +266 -105
  355. package/lib/webrtc/src/transceiverManager.js.map +1 -1
  356. package/lib/webrtc/src/transport/dtls.d.ts +11 -2
  357. package/lib/webrtc/src/transport/dtls.js +37 -13
  358. package/lib/webrtc/src/transport/dtls.js.map +1 -1
  359. package/lib/webrtc/src/transport/ice.d.ts +254 -7
  360. package/lib/webrtc/src/transport/ice.js +608 -52
  361. package/lib/webrtc/src/transport/ice.js.map +1 -1
  362. package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +98 -0
  363. package/lib/webrtc/src/transport/iceCandidateAttribute.js +129 -0
  364. package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -0
  365. package/lib/webrtc/src/transport/sctp.d.ts +4 -1
  366. package/lib/webrtc/src/transport/sctp.js +83 -17
  367. package/lib/webrtc/src/transport/sctp.js.map +1 -1
  368. package/lib/webrtc/src/utils.d.ts +3 -3
  369. package/lib/webrtc/src/utils.js +1 -1
  370. package/lib/webrtc/src/utils.js.map +1 -1
  371. package/package.json +13 -14
@@ -0,0 +1,86 @@
1
+ import type { NegotiationTransaction } from "../negotiationTransaction";
2
+ import type { SessionDescription } from "../sdp";
3
+ import type { SDPManager } from "../sdpManager";
4
+ import type { SecureTransportManager } from "../secureTransportManager";
5
+ import type { RTCIceCandidate, RTCIceCandidateInit } from "../transport/ice";
6
+ import type { RTCSignalingState } from "../types/domain";
7
+ import type { BundleTopology } from "./bundleTopology";
8
+ /**
9
+ * The ICE generation of a candidate is its ufrag, given either as the
10
+ * `usernameFragment` property or as the `ufrag` token of the candidate
11
+ * string. Both forms route the same way; conflicting values are rejected.
12
+ */
13
+ export declare function normalizeCandidateUfrag(message: RTCIceCandidate | RTCIceCandidateInit | null): RTCIceCandidate | RTCIceCandidateInit | null;
14
+ /**
15
+ * Trickle ICE for remote candidates: routes each candidate or
16
+ * end-of-candidates to the ICE generation (current or pending) of the m-line
17
+ * it targets, records it in that SDP and hands it to the live, pending-only or
18
+ * provisional checklist. Candidates added before any remote description wait
19
+ * in a queue (werift convenience; the WPT runner keeps the strict rejection).
20
+ *
21
+ * - The generation is chosen by the ufrag of the m-line the candidate targets
22
+ * (`sdpMid`, else `sdpMLineIndex`): in a partial BUNDLE split one m-line can
23
+ * keep the current ufrag while another moves to a new one.
24
+ * - During a remote re-offer, a candidate for an m-line whose ufrag is
25
+ * unchanged belongs to both the pending proposal and the live generation:
26
+ * it is recorded in both SDPs and handed to the live checklist once, and a
27
+ * rollback keeps it.
28
+ * - End-of-candidates ends one generation (RFC 8838): every m-line sharing
29
+ * its transport and ufrag is marked complete, in the current or pending SDP,
30
+ * and a later candidate of it reaches neither an SDP nor a checklist. A
31
+ * pending restart ufrag on the same transport stays open; an m-line a
32
+ * proposal splits off stays open even with the same credentials (RFC 8839
33
+ * section 5.4).
34
+ * - Queued candidates are checked against an incoming remote description
35
+ * before any state change; one it cannot place rejects
36
+ * setRemoteDescription and stays queued for a retry.
37
+ * - Duplicates within a generation are idempotent; a callback of a retired
38
+ * generation cannot reach its replacement.
39
+ */
40
+ export declare class RemoteCandidates {
41
+ private readonly sdp;
42
+ private readonly secure;
43
+ private readonly negotiation;
44
+ private readonly topology;
45
+ private readonly host;
46
+ /** Candidates added before a remote description was applied. */
47
+ readonly queued: Array<RTCIceCandidate | RTCIceCandidateInit | null>;
48
+ constructor(sdp: SDPManager, secure: SecureTransportManager, negotiation: NegotiationTransaction, topology: BundleTopology, host: {
49
+ signalingState: () => RTCSignalingState;
50
+ hasRemoteDescription: () => boolean;
51
+ });
52
+ /** Route a trickled candidate or end-of-candidates to its ICE generation. */
53
+ apply(candidateMessage: RTCIceCandidate | RTCIceCandidateInit | null): Promise<void>;
54
+ /**
55
+ * A re-offer or pranswer that keeps the current transports may still carry
56
+ * new candidates or end-of-candidates for an m-line whose ufrag is
57
+ * unchanged. They belong to the live generation too, so they reach the live
58
+ * checklist and the current SDP (once, and not after its end-of-candidates),
59
+ * exactly like trickled ones. A pending-only transport receives its own.
60
+ */
61
+ deliverSameGenerationDescription(proposal: SessionDescription): Promise<void>;
62
+ /**
63
+ * End-of-candidates ends an ICE generation on its transport, not one
64
+ * m-line: every m-line of `sdp` on the same finished transport with the
65
+ * same ufrag as `completed` (the rest of its BUNDLE group) is marked
66
+ * complete, so the SDP never promises more candidates to it.
67
+ */
68
+ completeSharedTransportMedia(sdp: SessionDescription, completed: number[]): void;
69
+ /**
70
+ * A candidate trickled for a pending re-offer whose m-line keeps the current
71
+ * ufrag belongs to the live ICE generation as well. Besides the pending SDP,
72
+ * it is recorded in the current SDP and handed to the live checklist once,
73
+ * so the committed session can use it while the proposal is pending.
74
+ */
75
+ private deliverSameGenerationCandidate;
76
+ /**
77
+ * Candidates queued before any remote description are checked against the
78
+ * description during validation, so a bad one rejects setRemoteDescription
79
+ * before any state changes and before any application event fires. The rejected
80
+ * candidates leave the queue: their addIceCandidate already resolved, and a
81
+ * retry of the same description must not fail on them again.
82
+ */
83
+ validateQueued(sdp: SessionDescription): Promise<void>;
84
+ /** Apply the queued candidates once a remote description exists. */
85
+ flushQueued(): Promise<void>;
86
+ }
@@ -0,0 +1,344 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RemoteCandidates = void 0;
4
+ exports.normalizeCandidateUfrag = normalizeCandidateUfrag;
5
+ const errors_1 = require("../errors");
6
+ /**
7
+ * The ICE generation of a candidate is its ufrag, given either as the
8
+ * `usernameFragment` property or as the `ufrag` token of the candidate
9
+ * string. Both forms route the same way; conflicting values are rejected.
10
+ */
11
+ function normalizeCandidateUfrag(message) {
12
+ if (!message)
13
+ return message;
14
+ const fromString = message.candidate?.match(/\bufrag\s+(\S+)/)?.[1];
15
+ const fromProperty = message.usernameFragment ?? undefined;
16
+ if (fromString && fromProperty && fromString !== fromProperty) {
17
+ throw (0, errors_1.createWebRtcDomException)("OperationError", "Candidate ufrag does not match usernameFragment");
18
+ }
19
+ if (!fromString || fromProperty)
20
+ return message;
21
+ const init = "toJSON" in message ? message.toJSON() : { ...message };
22
+ return { ...init, usernameFragment: fromString };
23
+ }
24
+ /**
25
+ * Trickle ICE for remote candidates: routes each candidate or
26
+ * end-of-candidates to the ICE generation (current or pending) of the m-line
27
+ * it targets, records it in that SDP and hands it to the live, pending-only or
28
+ * provisional checklist. Candidates added before any remote description wait
29
+ * in a queue (werift convenience; the WPT runner keeps the strict rejection).
30
+ *
31
+ * - The generation is chosen by the ufrag of the m-line the candidate targets
32
+ * (`sdpMid`, else `sdpMLineIndex`): in a partial BUNDLE split one m-line can
33
+ * keep the current ufrag while another moves to a new one.
34
+ * - During a remote re-offer, a candidate for an m-line whose ufrag is
35
+ * unchanged belongs to both the pending proposal and the live generation:
36
+ * it is recorded in both SDPs and handed to the live checklist once, and a
37
+ * rollback keeps it.
38
+ * - End-of-candidates ends one generation (RFC 8838): every m-line sharing
39
+ * its transport and ufrag is marked complete, in the current or pending SDP,
40
+ * and a later candidate of it reaches neither an SDP nor a checklist. A
41
+ * pending restart ufrag on the same transport stays open; an m-line a
42
+ * proposal splits off stays open even with the same credentials (RFC 8839
43
+ * section 5.4).
44
+ * - Queued candidates are checked against an incoming remote description
45
+ * before any state change; one it cannot place rejects
46
+ * setRemoteDescription and stays queued for a retry.
47
+ * - Duplicates within a generation are idempotent; a callback of a retired
48
+ * generation cannot reach its replacement.
49
+ */
50
+ class RemoteCandidates {
51
+ constructor(sdp, secure, negotiation, topology, host) {
52
+ Object.defineProperty(this, "sdp", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: sdp
57
+ });
58
+ Object.defineProperty(this, "secure", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: secure
63
+ });
64
+ Object.defineProperty(this, "negotiation", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: negotiation
69
+ });
70
+ Object.defineProperty(this, "topology", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: topology
75
+ });
76
+ Object.defineProperty(this, "host", {
77
+ enumerable: true,
78
+ configurable: true,
79
+ writable: true,
80
+ value: host
81
+ });
82
+ /** Candidates added before a remote description was applied. */
83
+ Object.defineProperty(this, "queued", {
84
+ enumerable: true,
85
+ configurable: true,
86
+ writable: true,
87
+ value: []
88
+ });
89
+ }
90
+ /** Route a trickled candidate or end-of-candidates to its ICE generation. */
91
+ async apply(candidateMessage) {
92
+ const current = this.sdp.currentRemoteDescription;
93
+ const pending = this.sdp.pendingRemoteDescription;
94
+ const ufrag = candidateMessage?.usernameFragment;
95
+ // The generation is decided by the m-line the candidate targets: with a
96
+ // partial BUNDLE split one m-line may keep the current ufrag while another
97
+ // moves to a new one within the same pending description.
98
+ const sdpMid = candidateMessage?.sdpMid;
99
+ const sdpMLineIndex = candidateMessage?.sdpMLineIndex;
100
+ const targetMedia = (description) => typeof sdpMid === "string"
101
+ ? description.media.filter((media) => media.rtp.muxId === sdpMid)
102
+ : typeof sdpMLineIndex === "number"
103
+ ? description.media.slice(sdpMLineIndex, sdpMLineIndex + 1)
104
+ : description.media;
105
+ const matchesUfrag = (description) => targetMedia(description).some((media) => media.iceParams?.usernameFragment === ufrag);
106
+ const sdp = ufrag &&
107
+ current &&
108
+ matchesUfrag(current) &&
109
+ (!pending || !matchesUfrag(pending))
110
+ ? current
111
+ : (pending ?? current);
112
+ if (!sdp) {
113
+ return;
114
+ }
115
+ // A new remote generation is only a proposal during a re-offer. Keep its
116
+ // trickle data in the pending SDP until the final answer activates it.
117
+ const stageOnly = sdp === pending &&
118
+ !!current &&
119
+ (pending?.type === "offer" || pending?.type === "pranswer");
120
+ const appliedCandidate = await this.secure.addIceCandidate(sdp, candidateMessage, !stageOnly);
121
+ const remoteDescription = sdp;
122
+ if (!remoteDescription || !appliedCandidate) {
123
+ return;
124
+ }
125
+ if (stageOnly) {
126
+ const targets = new Set(appliedCandidate.mediaIndices
127
+ .map((index) => this.negotiation.transportByMid.get(remoteDescription.media[index]?.rtp.muxId ?? ""))
128
+ .filter((transport) => !!transport &&
129
+ this.negotiation.isPendingOnlyTransport(transport.iceTransport.id)));
130
+ for (const transport of targets) {
131
+ transport.iceTransport.deliverRemoteCandidate(appliedCandidate.kind === "end-of-candidates"
132
+ ? undefined
133
+ : appliedCandidate.candidate);
134
+ }
135
+ if (current) {
136
+ await this.deliverSameGenerationCandidate(remoteDescription, current, appliedCandidate);
137
+ }
138
+ if (this.host.signalingState() === "have-local-pranswer" ||
139
+ this.host.signalingState() === "have-remote-pranswer") {
140
+ const provisional = new Set(appliedCandidate.mediaIndices
141
+ .map((index) => this.topology.currentTransportForMid(remoteDescription.media[index]?.rtp.muxId ?? "")?.iceTransport)
142
+ .filter((transport) => !!transport?.hasStagedRestart &&
143
+ !this.negotiation.isPendingOnlyTransport(transport.id)));
144
+ for (const transport of provisional) {
145
+ transport.deliverProvisionalRemoteCandidate(appliedCandidate.kind === "end-of-candidates"
146
+ ? undefined
147
+ : appliedCandidate.candidate);
148
+ }
149
+ }
150
+ }
151
+ if (appliedCandidate.kind === "end-of-candidates") {
152
+ for (const mediaIndex of appliedCandidate.mediaIndices) {
153
+ const media = remoteDescription.media[mediaIndex];
154
+ if (media) {
155
+ media.iceCandidatesComplete = true;
156
+ }
157
+ }
158
+ // A pending SDP becomes current at the answer, so it is aligned too.
159
+ this.completeSharedTransportMedia(remoteDescription, appliedCandidate.mediaIndices);
160
+ return;
161
+ }
162
+ for (const mediaIndex of appliedCandidate.mediaIndices) {
163
+ const media = remoteDescription.media[mediaIndex];
164
+ if (!media) {
165
+ continue;
166
+ }
167
+ media.iceCandidates.push(appliedCandidate.candidate);
168
+ }
169
+ }
170
+ /**
171
+ * A re-offer or pranswer that keeps the current transports may still carry
172
+ * new candidates or end-of-candidates for an m-line whose ufrag is
173
+ * unchanged. They belong to the live generation too, so they reach the live
174
+ * checklist and the current SDP (once, and not after its end-of-candidates),
175
+ * exactly like trickled ones. A pending-only transport receives its own.
176
+ */
177
+ async deliverSameGenerationDescription(proposal) {
178
+ const current = this.sdp.currentRemoteDescription;
179
+ if (!current)
180
+ return;
181
+ const shared = [...proposal.media.entries()].filter(([, media]) => {
182
+ if (media.port === 0)
183
+ return false;
184
+ const prepared = this.negotiation.transportByMid.get(media.rtp.muxId ?? "");
185
+ return !(prepared &&
186
+ this.negotiation.isPendingOnlyTransport(prepared.iceTransport.id));
187
+ });
188
+ // Candidates first (a non-tag BUNDLE member carries none of its own),
189
+ // then end-of-candidates from any m-line, since it ends the shared
190
+ // generation for the whole group.
191
+ for (const [index, media] of shared) {
192
+ if (this.topology.isBundledNonTag(proposal, media.rtp.muxId))
193
+ continue;
194
+ for (const candidate of media.iceCandidates) {
195
+ await this.deliverSameGenerationCandidate(proposal, current, {
196
+ kind: "candidate",
197
+ candidate,
198
+ mediaIndices: [index],
199
+ });
200
+ }
201
+ }
202
+ for (const [index, media] of shared) {
203
+ if (!media.iceCandidatesComplete)
204
+ continue;
205
+ await this.deliverSameGenerationCandidate(proposal, current, {
206
+ kind: "end-of-candidates",
207
+ mediaIndices: [index],
208
+ });
209
+ }
210
+ }
211
+ /**
212
+ * End-of-candidates ends an ICE generation on its transport, not one
213
+ * m-line: every m-line of `sdp` on the same finished transport with the
214
+ * same ufrag as `completed` (the rest of its BUNDLE group) is marked
215
+ * complete, so the SDP never promises more candidates to it.
216
+ */
217
+ completeSharedTransportMedia(sdp, completed) {
218
+ const current = this.sdp.currentRemoteDescription;
219
+ if (sdp === current) {
220
+ // The current description is laid out on the committed transports:
221
+ // only the live generation that ended on a transport counts (a pending
222
+ // restart ufrag on the same transport is still open).
223
+ const transportFor = (mid) => this.topology.liveTransportForMid(mid)?.iceTransport;
224
+ const ended = completed.flatMap((index) => {
225
+ const media = sdp.media[index];
226
+ const transport = transportFor(media?.rtp.muxId ?? "");
227
+ const ufrag = media?.iceParams?.usernameFragment;
228
+ return transport?.connection.remoteCandidatesEnd &&
229
+ transport.connection.remoteUsername === ufrag
230
+ ? [{ transport, ufrag }]
231
+ : [];
232
+ });
233
+ for (const media of sdp.media) {
234
+ const transport = transportFor(media.rtp.muxId ?? "");
235
+ if (ended.some((generation) => generation.transport === transport &&
236
+ generation.ufrag === media.iceParams?.usernameFragment)) {
237
+ media.iceCandidatesComplete = true;
238
+ }
239
+ }
240
+ return;
241
+ }
242
+ // A pending proposal: a generation is identified by the proposal's own
243
+ // BUNDLE ownership (the group tag, or the m-line itself) and ufrag, so an
244
+ // m-line the proposal splits off stays open even with the same
245
+ // credentials (RFC 8839 section 5.4), before any transport is prepared.
246
+ const ownerIn = (description, mid) => this.topology.bundleTagOf(description, mid) ?? mid;
247
+ const keyOf = (media) => `${ownerIn(sdp, media.rtp.muxId ?? "")}\u0000${media.iceParams?.usernameFragment ?? ""}`;
248
+ const ended = new Set();
249
+ for (const index of completed) {
250
+ const media = sdp.media[index];
251
+ const mid = media?.rtp.muxId;
252
+ const ufrag = media?.iceParams?.usernameFragment;
253
+ if (!media || !mid || !ufrag)
254
+ continue;
255
+ // Its end-of-candidates arrived for this proposal, or the proposal
256
+ // repeats a live generation that already ended, on an m-line it keeps
257
+ // with the same owner.
258
+ const live = this.topology.liveTransportForMid(mid)?.iceTransport;
259
+ const repeatsEndedLive = !!current &&
260
+ ownerIn(current, mid) === ownerIn(sdp, mid) &&
261
+ !!live?.connection.remoteCandidatesEnd &&
262
+ live.connection.remoteUsername === ufrag;
263
+ if (media.iceCandidatesComplete || repeatsEndedLive) {
264
+ ended.add(keyOf(media));
265
+ }
266
+ }
267
+ for (const media of sdp.media) {
268
+ if (ended.has(keyOf(media)))
269
+ media.iceCandidatesComplete = true;
270
+ }
271
+ }
272
+ /**
273
+ * A candidate trickled for a pending re-offer whose m-line keeps the current
274
+ * ufrag belongs to the live ICE generation as well. Besides the pending SDP,
275
+ * it is recorded in the current SDP and handed to the live checklist once,
276
+ * so the committed session can use it while the proposal is pending.
277
+ */
278
+ async deliverSameGenerationCandidate(pending, current, applied) {
279
+ for (const index of applied.mediaIndices) {
280
+ const mid = pending.media[index]?.rtp.muxId;
281
+ const ufrag = pending.media[index]?.iceParams?.usernameFragment;
282
+ const currentMedia = current.media.find((media) => media.rtp.muxId === mid);
283
+ const iceTransport = mid
284
+ ? this.topology.currentTransportForMid(mid)?.iceTransport
285
+ : undefined;
286
+ if (!ufrag ||
287
+ !currentMedia ||
288
+ currentMedia.iceParams?.usernameFragment !== ufrag ||
289
+ !iceTransport ||
290
+ this.negotiation.isPendingOnlyTransport(iceTransport.id) ||
291
+ iceTransport.connection.remoteUsername !== ufrag ||
292
+ // RFC 8838: a generation that signalled end-of-candidates is complete,
293
+ // whichever BUNDLE m-line of the shared transport carried it.
294
+ currentMedia.iceCandidatesComplete ||
295
+ iceTransport.connection.remoteCandidatesEnd) {
296
+ continue;
297
+ }
298
+ if (applied.kind === "end-of-candidates") {
299
+ currentMedia.iceCandidatesComplete = true;
300
+ iceTransport.deliverRemoteCandidate(undefined);
301
+ this.completeSharedTransportMedia(current, [
302
+ current.media.indexOf(currentMedia),
303
+ ]);
304
+ continue;
305
+ }
306
+ const text = applied.candidate.toJSON().candidate;
307
+ if (currentMedia.iceCandidates.some((existing) => existing.toJSON().candidate === text)) {
308
+ continue;
309
+ }
310
+ currentMedia.iceCandidates.push(applied.candidate);
311
+ iceTransport.deliverRemoteCandidate(applied.candidate);
312
+ }
313
+ }
314
+ /**
315
+ * Candidates queued before any remote description are checked against the
316
+ * description during validation, so a bad one rejects setRemoteDescription
317
+ * before any state changes and before any application event fires. The rejected
318
+ * candidates leave the queue: their addIceCandidate already resolved, and a
319
+ * retry of the same description must not fail on them again.
320
+ */
321
+ async validateQueued(sdp) {
322
+ let firstError;
323
+ for (const candidate of [...this.queued]) {
324
+ try {
325
+ await this.secure.addIceCandidate(sdp, candidate ?? null, false);
326
+ }
327
+ catch (error) {
328
+ firstError ?? (firstError = error);
329
+ this.queued.splice(this.queued.indexOf(candidate), 1);
330
+ }
331
+ }
332
+ if (firstError)
333
+ throw firstError;
334
+ }
335
+ /** Apply the queued candidates once a remote description exists. */
336
+ async flushQueued() {
337
+ while (this.queued.length > 0 && this.host.hasRemoteDescription()) {
338
+ const candidate = this.queued.shift();
339
+ await this.apply(candidate ?? null);
340
+ }
341
+ }
342
+ }
343
+ exports.RemoteCandidates = RemoteCandidates;
344
+ //# sourceMappingURL=remoteCandidates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteCandidates.js","sourceRoot":"","sources":["../../../../src/negotiation/remoteCandidates.ts"],"names":[],"mappings":";;;AAmBA,0DAeC;AAlCD,sCAAqD;AAcrD;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,OAAqD;IAErD,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,IAAI,SAAS,CAAC;IAC3D,IAAI,UAAU,IAAI,YAAY,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;QAC9D,MAAM,IAAA,iCAAwB,EAC5B,gBAAgB,EAChB,iDAAiD,CAClD,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,UAAU,IAAI,YAAY;QAAE,OAAO,OAAO,CAAC;IAChD,MAAM,IAAI,GAAG,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IACrE,OAAO,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,gBAAgB;IAI3B,YACmB,GAAe,EACf,MAA8B,EAC9B,WAAmC,EACnC,QAAwB,EACxB,IAGhB;QAPD;;;;mBAAiB,GAAG;WAAY;QAChC;;;;mBAAiB,MAAM;WAAwB;QAC/C;;;;mBAAiB,WAAW;WAAwB;QACpD;;;;mBAAiB,QAAQ;WAAgB;QACzC;;;;mBAAiB,IAAI;WAGpB;QAXH,gEAAgE;QACvD;;;;mBAA8D,EAAE;WAAC;IAWvE,CAAC;IAEJ,6EAA6E;IAC7E,KAAK,CAAC,KAA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AI,CAAC;gBACH,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,SAAS,IAAI,IAAI,EAAE,KAAK,CAAC,CAAC;YACnE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,UAAU,KAAV,UAAU,GAAK,KAAK,EAAC;gBACrB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QACD,IAAI,UAAU;YAAE,MAAM,UAAU,CAAC;IACnC,CAAC;IAED,oEAAoE;IACpE,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAClE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtC,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF;AAjVD,4CAiVC","sourcesContent":["import { createWebRtcDomException } from \"../errors\";\nimport type { NegotiationTransaction } from \"../negotiationTransaction\";\nimport type { SessionDescription } from \"../sdp\";\nimport type { SDPManager } from \"../sdpManager\";\nimport type { SecureTransportManager } from \"../secureTransportManager\";\nimport type { RTCDtlsTransport } from \"../transport/dtls\";\nimport type {\n RTCIceCandidate,\n RTCIceCandidateInit,\n RTCIceTransport,\n} from \"../transport/ice\";\nimport type { RTCSignalingState } from \"../types/domain\";\nimport type { BundleTopology } from \"./bundleTopology\";\n\n/**\n * The ICE generation of a candidate is its ufrag, given either as the\n * `usernameFragment` property or as the `ufrag` token of the candidate\n * string. Both forms route the same way; conflicting values are rejected.\n */\nexport function normalizeCandidateUfrag(\n message: RTCIceCandidate | RTCIceCandidateInit | null,\n): RTCIceCandidate | RTCIceCandidateInit | null {\n if (!message) return message;\n const fromString = message.candidate?.match(/\\bufrag\\s+(\\S+)/)?.[1];\n const fromProperty = message.usernameFragment ?? undefined;\n if (fromString && fromProperty && fromString !== fromProperty) {\n throw createWebRtcDomException(\n \"OperationError\",\n \"Candidate ufrag does not match usernameFragment\",\n );\n }\n if (!fromString || fromProperty) return message;\n const init = \"toJSON\" in message ? message.toJSON() : { ...message };\n return { ...init, usernameFragment: fromString };\n}\n\n/**\n * Trickle ICE for remote candidates: routes each candidate or\n * end-of-candidates to the ICE generation (current or pending) of the m-line\n * it targets, records it in that SDP and hands it to the live, pending-only or\n * provisional checklist. Candidates added before any remote description wait\n * in a queue (werift convenience; the WPT runner keeps the strict rejection).\n *\n * - The generation is chosen by the ufrag of the m-line the candidate targets\n * (`sdpMid`, else `sdpMLineIndex`): in a partial BUNDLE split one m-line can\n * keep the current ufrag while another moves to a new one.\n * - During a remote re-offer, a candidate for an m-line whose ufrag is\n * unchanged belongs to both the pending proposal and the live generation:\n * it is recorded in both SDPs and handed to the live checklist once, and a\n * rollback keeps it.\n * - End-of-candidates ends one generation (RFC 8838): every m-line sharing\n * its transport and ufrag is marked complete, in the current or pending SDP,\n * and a later candidate of it reaches neither an SDP nor a checklist. A\n * pending restart ufrag on the same transport stays open; an m-line a\n * proposal splits off stays open even with the same credentials (RFC 8839\n * section 5.4).\n * - Queued candidates are checked against an incoming remote description\n * before any state change; one it cannot place rejects\n * setRemoteDescription and stays queued for a retry.\n * - Duplicates within a generation are idempotent; a callback of a retired\n * generation cannot reach its replacement.\n */\nexport class RemoteCandidates {\n /** Candidates added before a remote description was applied. */\n readonly queued: Array<RTCIceCandidate | RTCIceCandidateInit | null> = [];\n\n constructor(\n private readonly sdp: SDPManager,\n private readonly secure: SecureTransportManager,\n private readonly negotiation: NegotiationTransaction,\n private readonly topology: BundleTopology,\n private readonly host: {\n signalingState: () => RTCSignalingState;\n hasRemoteDescription: () => boolean;\n },\n ) {}\n\n /** Route a trickled candidate or end-of-candidates to its ICE generation. */\n async apply(candidateMessage: RTCIceCandidate | RTCIceCandidateInit | null) {\n const current = this.sdp.currentRemoteDescription;\n const pending = this.sdp.pendingRemoteDescription;\n const ufrag = candidateMessage?.usernameFragment;\n // The generation is decided by the m-line the candidate targets: with a\n // partial BUNDLE split one m-line may keep the current ufrag while another\n // moves to a new one within the same pending description.\n const sdpMid = candidateMessage?.sdpMid;\n const sdpMLineIndex = candidateMessage?.sdpMLineIndex;\n const targetMedia = (description: SessionDescription) =>\n typeof sdpMid === \"string\"\n ? description.media.filter((media) => media.rtp.muxId === sdpMid)\n : typeof sdpMLineIndex === \"number\"\n ? description.media.slice(sdpMLineIndex, sdpMLineIndex + 1)\n : description.media;\n const matchesUfrag = (description: SessionDescription) =>\n targetMedia(description).some(\n (media) => media.iceParams?.usernameFragment === ufrag,\n );\n const sdp =\n ufrag &&\n current &&\n matchesUfrag(current) &&\n (!pending || !matchesUfrag(pending))\n ? current\n : (pending ?? current);\n if (!sdp) {\n return;\n }\n // A new remote generation is only a proposal during a re-offer. Keep its\n // trickle data in the pending SDP until the final answer activates it.\n const stageOnly =\n sdp === pending &&\n !!current &&\n (pending?.type === \"offer\" || pending?.type === \"pranswer\");\n const appliedCandidate = await this.secure.addIceCandidate(\n sdp,\n candidateMessage,\n !stageOnly,\n );\n const remoteDescription = sdp;\n if (!remoteDescription || !appliedCandidate) {\n return;\n }\n if (stageOnly) {\n const targets = new Set(\n appliedCandidate.mediaIndices\n .map((index) =>\n this.negotiation.transportByMid.get(\n remoteDescription.media[index]?.rtp.muxId ?? \"\",\n ),\n )\n .filter(\n (transport): transport is RTCDtlsTransport =>\n !!transport &&\n this.negotiation.isPendingOnlyTransport(\n transport.iceTransport.id,\n ),\n ),\n );\n for (const transport of targets) {\n transport.iceTransport.deliverRemoteCandidate(\n appliedCandidate.kind === \"end-of-candidates\"\n ? undefined\n : appliedCandidate.candidate,\n );\n }\n if (current) {\n await this.deliverSameGenerationCandidate(\n remoteDescription,\n current,\n appliedCandidate,\n );\n }\n if (\n this.host.signalingState() === \"have-local-pranswer\" ||\n this.host.signalingState() === \"have-remote-pranswer\"\n ) {\n const provisional = new Set(\n appliedCandidate.mediaIndices\n .map(\n (index) =>\n this.topology.currentTransportForMid(\n remoteDescription.media[index]?.rtp.muxId ?? \"\",\n )?.iceTransport,\n )\n .filter(\n (transport): transport is RTCIceTransport =>\n !!transport?.hasStagedRestart &&\n !this.negotiation.isPendingOnlyTransport(transport.id),\n ),\n );\n for (const transport of provisional) {\n transport.deliverProvisionalRemoteCandidate(\n appliedCandidate.kind === \"end-of-candidates\"\n ? undefined\n : appliedCandidate.candidate,\n );\n }\n }\n }\n\n if (appliedCandidate.kind === \"end-of-candidates\") {\n for (const mediaIndex of appliedCandidate.mediaIndices) {\n const media = remoteDescription.media[mediaIndex];\n if (media) {\n media.iceCandidatesComplete = true;\n }\n }\n // A pending SDP becomes current at the answer, so it is aligned too.\n this.completeSharedTransportMedia(\n remoteDescription,\n appliedCandidate.mediaIndices,\n );\n return;\n }\n\n for (const mediaIndex of appliedCandidate.mediaIndices) {\n const media = remoteDescription.media[mediaIndex];\n if (!media) {\n continue;\n }\n media.iceCandidates.push(appliedCandidate.candidate);\n }\n }\n\n /**\n * A re-offer or pranswer that keeps the current transports may still carry\n * new candidates or end-of-candidates for an m-line whose ufrag is\n * unchanged. They belong to the live generation too, so they reach the live\n * checklist and the current SDP (once, and not after its end-of-candidates),\n * exactly like trickled ones. A pending-only transport receives its own.\n */\n async deliverSameGenerationDescription(proposal: SessionDescription) {\n const current = this.sdp.currentRemoteDescription;\n if (!current) return;\n const shared = [...proposal.media.entries()].filter(([, media]) => {\n if (media.port === 0) return false;\n const prepared = this.negotiation.transportByMid.get(\n media.rtp.muxId ?? \"\",\n );\n return !(\n prepared &&\n this.negotiation.isPendingOnlyTransport(prepared.iceTransport.id)\n );\n });\n // Candidates first (a non-tag BUNDLE member carries none of its own),\n // then end-of-candidates from any m-line, since it ends the shared\n // generation for the whole group.\n for (const [index, media] of shared) {\n if (this.topology.isBundledNonTag(proposal, media.rtp.muxId)) continue;\n for (const candidate of media.iceCandidates) {\n await this.deliverSameGenerationCandidate(proposal, current, {\n kind: \"candidate\",\n candidate,\n mediaIndices: [index],\n });\n }\n }\n for (const [index, media] of shared) {\n if (!media.iceCandidatesComplete) continue;\n await this.deliverSameGenerationCandidate(proposal, current, {\n kind: \"end-of-candidates\",\n mediaIndices: [index],\n });\n }\n }\n\n /**\n * End-of-candidates ends an ICE generation on its transport, not one\n * m-line: every m-line of `sdp` on the same finished transport with the\n * same ufrag as `completed` (the rest of its BUNDLE group) is marked\n * complete, so the SDP never promises more candidates to it.\n */\n completeSharedTransportMedia(sdp: SessionDescription, completed: number[]) {\n const current = this.sdp.currentRemoteDescription;\n if (sdp === current) {\n // The current description is laid out on the committed transports:\n // only the live generation that ended on a transport counts (a pending\n // restart ufrag on the same transport is still open).\n const transportFor = (mid: string) =>\n this.topology.liveTransportForMid(mid)?.iceTransport;\n const ended = completed.flatMap((index) => {\n const media = sdp.media[index];\n const transport = transportFor(media?.rtp.muxId ?? \"\");\n const ufrag = media?.iceParams?.usernameFragment;\n return transport?.connection.remoteCandidatesEnd &&\n transport.connection.remoteUsername === ufrag\n ? [{ transport, ufrag }]\n : [];\n });\n for (const media of sdp.media) {\n const transport = transportFor(media.rtp.muxId ?? \"\");\n if (\n ended.some(\n (generation) =>\n generation.transport === transport &&\n generation.ufrag === media.iceParams?.usernameFragment,\n )\n ) {\n media.iceCandidatesComplete = true;\n }\n }\n return;\n }\n // A pending proposal: a generation is identified by the proposal's own\n // BUNDLE ownership (the group tag, or the m-line itself) and ufrag, so an\n // m-line the proposal splits off stays open even with the same\n // credentials (RFC 8839 section 5.4), before any transport is prepared.\n const ownerIn = (description: SessionDescription, mid: string) =>\n this.topology.bundleTagOf(description, mid) ?? mid;\n const keyOf = (media: SessionDescription[\"media\"][number]) =>\n `${ownerIn(sdp, media.rtp.muxId ?? \"\")}\\u0000${media.iceParams?.usernameFragment ?? \"\"}`;\n const ended = new Set<string>();\n for (const index of completed) {\n const media = sdp.media[index];\n const mid = media?.rtp.muxId;\n const ufrag = media?.iceParams?.usernameFragment;\n if (!media || !mid || !ufrag) continue;\n // Its end-of-candidates arrived for this proposal, or the proposal\n // repeats a live generation that already ended, on an m-line it keeps\n // with the same owner.\n const live = this.topology.liveTransportForMid(mid)?.iceTransport;\n const repeatsEndedLive =\n !!current &&\n ownerIn(current, mid) === ownerIn(sdp, mid) &&\n !!live?.connection.remoteCandidatesEnd &&\n live.connection.remoteUsername === ufrag;\n if (media.iceCandidatesComplete || repeatsEndedLive) {\n ended.add(keyOf(media));\n }\n }\n for (const media of sdp.media) {\n if (ended.has(keyOf(media))) media.iceCandidatesComplete = true;\n }\n }\n\n /**\n * A candidate trickled for a pending re-offer whose m-line keeps the current\n * ufrag belongs to the live ICE generation as well. Besides the pending SDP,\n * it is recorded in the current SDP and handed to the live checklist once,\n * so the committed session can use it while the proposal is pending.\n */\n private async deliverSameGenerationCandidate(\n pending: SessionDescription,\n current: SessionDescription,\n applied: NonNullable<\n Awaited<ReturnType<SecureTransportManager[\"addIceCandidate\"]>>\n >,\n ) {\n for (const index of applied.mediaIndices) {\n const mid = pending.media[index]?.rtp.muxId;\n const ufrag = pending.media[index]?.iceParams?.usernameFragment;\n const currentMedia = current.media.find(\n (media) => media.rtp.muxId === mid,\n );\n const iceTransport = mid\n ? this.topology.currentTransportForMid(mid)?.iceTransport\n : undefined;\n if (\n !ufrag ||\n !currentMedia ||\n currentMedia.iceParams?.usernameFragment !== ufrag ||\n !iceTransport ||\n this.negotiation.isPendingOnlyTransport(iceTransport.id) ||\n iceTransport.connection.remoteUsername !== ufrag ||\n // RFC 8838: a generation that signalled end-of-candidates is complete,\n // whichever BUNDLE m-line of the shared transport carried it.\n currentMedia.iceCandidatesComplete ||\n iceTransport.connection.remoteCandidatesEnd\n ) {\n continue;\n }\n if (applied.kind === \"end-of-candidates\") {\n currentMedia.iceCandidatesComplete = true;\n iceTransport.deliverRemoteCandidate(undefined);\n this.completeSharedTransportMedia(current, [\n current.media.indexOf(currentMedia),\n ]);\n continue;\n }\n const text = applied.candidate.toJSON().candidate;\n if (\n currentMedia.iceCandidates.some(\n (existing) => existing.toJSON().candidate === text,\n )\n ) {\n continue;\n }\n currentMedia.iceCandidates.push(applied.candidate);\n iceTransport.deliverRemoteCandidate(applied.candidate);\n }\n }\n\n /**\n * Candidates queued before any remote description are checked against the\n * description during validation, so a bad one rejects setRemoteDescription\n * before any state changes and before any application event fires. The rejected\n * candidates leave the queue: their addIceCandidate already resolved, and a\n * retry of the same description must not fail on them again.\n */\n async validateQueued(sdp: SessionDescription) {\n let firstError: unknown;\n for (const candidate of [...this.queued]) {\n try {\n await this.secure.addIceCandidate(sdp, candidate ?? null, false);\n } catch (error) {\n firstError ??= error;\n this.queued.splice(this.queued.indexOf(candidate), 1);\n }\n }\n if (firstError) throw firstError;\n }\n\n /** Apply the queued candidates once a remote description exists. */\n async flushQueued() {\n while (this.queued.length > 0 && this.host.hasRemoteDescription()) {\n const candidate = this.queued.shift();\n await this.apply(candidate ?? null);\n }\n }\n}\n"]}
@@ -0,0 +1,71 @@
1
+ import type { RTCRtpCodecParameters, RTCRtpTransceiver, RtpRouter, TransceiverManager } from "../media";
2
+ import type { NegotiationTransaction } from "../negotiationTransaction";
3
+ import type { SctpTransportManager } from "../sctpManager";
4
+ import type { MediaDescription, SessionDescription } from "../sdp";
5
+ import type { SDPManager } from "../sdpManager";
6
+ import type { RTCDtlsTransport } from "../transport/dtls";
7
+ import type { RTCIceTransport } from "../transport/ice";
8
+ import type { RTCSctpTransport } from "../transport/sctp";
9
+ /** What applying the m-lines of a remote description left for the caller. */
10
+ export type RemoteMediaPlan = {
11
+ /** A re-offer or pranswer on a live session keeps the current transports. */
12
+ preserveCurrentTransport: boolean;
13
+ /**
14
+ * Live transport and media stop operations. They run only after every
15
+ * m-line applied without error, so a failure leaves the ICE generation,
16
+ * selected pair and DTLS/SCTP bindings untouched.
17
+ */
18
+ transportUpdates: (() => void)[];
19
+ /** Transports whose remote generation ended (run after every candidate). */
20
+ endOfCandidates: RTCIceTransport[];
21
+ /** Pranswer credentials for a transport with a staged ICE restart. */
22
+ provisionalIce: [RTCIceTransport, MediaDescription][];
23
+ /** Transceivers associated with an m-line of the description. */
24
+ associated: Set<RTCRtpTransceiver>;
25
+ };
26
+ /**
27
+ * Applies the m-lines of a remote description inside the negotiation
28
+ * transaction: associates each m-line with a transceiver or the SCTP
29
+ * transport, decides the BUNDLE transport ownership, applies RTP / SCTP
30
+ * parameters (accept or mark rejected), and plans the transport parameter
31
+ * updates the caller runs after every fallible step.
32
+ */
33
+ export declare class RemoteMediaApplication {
34
+ private readonly sdp;
35
+ private readonly transceivers;
36
+ private readonly sctp;
37
+ private readonly router;
38
+ private readonly negotiation;
39
+ private readonly host;
40
+ constructor(sdp: SDPManager, transceivers: TransceiverManager, sctp: SctpTransportManager, router: RtpRouter, negotiation: NegotiationTransaction, host: {
41
+ createSctpTransport: () => RTCSctpTransport;
42
+ /** The transport a new transceiver starts on. */
43
+ createTransport: () => RTCDtlsTransport;
44
+ /** An independent transport (own ICE credentials) for ownership. */
45
+ createOwnerTransport: () => RTCDtlsTransport;
46
+ onRemoteTransceiverAdded: (transceiver: RTCRtpTransceiver) => void;
47
+ });
48
+ /** Resolve all m-line codecs without mutating the current transaction. */
49
+ planCodecs(remoteSdp: SessionDescription): Map<number, RTCRtpCodecParameters[]>;
50
+ apply(remoteSdp: SessionDescription, codecPlan?: Map<number, RTCRtpCodecParameters[]>): RemoteMediaPlan;
51
+ private associate;
52
+ /** Whether a current description has an m-line with `mid`. */
53
+ private inCurrent;
54
+ /** Whether the current session rejected (port 0) the m-line `mid`. */
55
+ private rejectedInCurrent;
56
+ /**
57
+ * remote m-line に対応する transceiver を探す。MID の一致を優先し、
58
+ * 未関連付け transceiver は同じ offer 内で異なる m-line に割り当てる。
59
+ */
60
+ private findTransceiver;
61
+ /**
62
+ * Transport ownership. BUNDLE group ごとに 1 つの transport を共有する。remote offer
63
+ * の所有関係は bundlePolicy によらず offer の group だけで決まり (max-bundle は自分の
64
+ * offer にだけ効く)、異なる group や group 外の m-line とは共有しない。
65
+ */
66
+ private assignTransports;
67
+ /** Apply RTP / SCTP parameters: the entries accepted (not rejected). */
68
+ private accept;
69
+ /** Plan the ICE / DTLS parameters, candidates and role of every transport. */
70
+ private planTransportUpdates;
71
+ }