werift 0.17.6 → 0.18.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 (338) hide show
  1. package/lib/common/src/binary.d.ts +1 -0
  2. package/lib/common/src/binary.js +74 -21
  3. package/lib/common/src/binary.js.map +1 -1
  4. package/lib/common/src/log.js +18 -0
  5. package/lib/common/src/log.js.map +1 -1
  6. package/lib/common/src/network.d.ts +1 -1
  7. package/lib/common/src/network.js +1 -0
  8. package/lib/common/src/network.js.map +1 -1
  9. package/lib/common/src/promise.js +22 -7
  10. package/lib/common/src/promise.js.map +1 -1
  11. package/lib/common/src/type.d.ts +1 -1
  12. package/lib/dtls/src/cipher/const.d.ts +7 -7
  13. package/lib/dtls/src/cipher/key-exchange.js +24 -1
  14. package/lib/dtls/src/cipher/key-exchange.js.map +1 -1
  15. package/lib/dtls/src/cipher/suites/abstract.d.ts +2 -2
  16. package/lib/dtls/src/cipher/suites/abstract.js +36 -2
  17. package/lib/dtls/src/cipher/suites/abstract.js.map +1 -1
  18. package/lib/dtls/src/cipher/suites/aead.js +60 -6
  19. package/lib/dtls/src/cipher/suites/aead.js.map +1 -1
  20. package/lib/dtls/src/client.js +62 -51
  21. package/lib/dtls/src/client.js.map +1 -1
  22. package/lib/dtls/src/context/cipher.js +151 -59
  23. package/lib/dtls/src/context/cipher.js.map +1 -1
  24. package/lib/dtls/src/context/dtls.js +90 -14
  25. package/lib/dtls/src/context/dtls.js.map +1 -1
  26. package/lib/dtls/src/context/srtp.d.ts +1 -1
  27. package/lib/dtls/src/context/srtp.js +8 -0
  28. package/lib/dtls/src/context/srtp.js.map +1 -1
  29. package/lib/dtls/src/context/transport.js +14 -2
  30. package/lib/dtls/src/context/transport.js.map +1 -1
  31. package/lib/dtls/src/flight/client/flight1.js +6 -1
  32. package/lib/dtls/src/flight/client/flight1.js.map +1 -1
  33. package/lib/dtls/src/flight/client/flight5.js +12 -2
  34. package/lib/dtls/src/flight/client/flight5.js.map +1 -1
  35. package/lib/dtls/src/flight/flight.d.ts +1 -1
  36. package/lib/dtls/src/flight/flight.js +42 -7
  37. package/lib/dtls/src/flight/flight.js.map +1 -1
  38. package/lib/dtls/src/flight/server/flight2.js +4 -2
  39. package/lib/dtls/src/flight/server/flight2.js.map +1 -1
  40. package/lib/dtls/src/flight/server/flight4.js +12 -2
  41. package/lib/dtls/src/flight/server/flight4.js.map +1 -1
  42. package/lib/dtls/src/flight/server/flight6.js +6 -1
  43. package/lib/dtls/src/flight/server/flight6.js.map +1 -1
  44. package/lib/dtls/src/handshake/extensions/ellipticCurves.js +27 -7
  45. package/lib/dtls/src/handshake/extensions/ellipticCurves.js.map +1 -1
  46. package/lib/dtls/src/handshake/extensions/extendedMasterSecret.js +6 -1
  47. package/lib/dtls/src/handshake/extensions/extendedMasterSecret.js.map +1 -1
  48. package/lib/dtls/src/handshake/extensions/renegotiationIndication.js +27 -7
  49. package/lib/dtls/src/handshake/extensions/renegotiationIndication.js.map +1 -1
  50. package/lib/dtls/src/handshake/extensions/signature.js +27 -7
  51. package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
  52. package/lib/dtls/src/handshake/extensions/useSrtp.js +39 -9
  53. package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
  54. package/lib/dtls/src/handshake/message/alert.js +21 -6
  55. package/lib/dtls/src/handshake/message/alert.js.map +1 -1
  56. package/lib/dtls/src/handshake/message/certificate.js +26 -5
  57. package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
  58. package/lib/dtls/src/handshake/message/changeCipherSpec.js +14 -4
  59. package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
  60. package/lib/dtls/src/handshake/message/client/certificateVerify.js +33 -7
  61. package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
  62. package/lib/dtls/src/handshake/message/client/hello.js +68 -18
  63. package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
  64. package/lib/dtls/src/handshake/message/client/keyExchange.js +26 -5
  65. package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
  66. package/lib/dtls/src/handshake/message/finished.js +18 -2
  67. package/lib/dtls/src/handshake/message/finished.js.map +1 -1
  68. package/lib/dtls/src/handshake/message/server/certificateRequest.js +40 -9
  69. package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
  70. package/lib/dtls/src/handshake/message/server/hello.js +60 -14
  71. package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
  72. package/lib/dtls/src/handshake/message/server/helloDone.js +18 -2
  73. package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
  74. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +33 -7
  75. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
  76. package/lib/dtls/src/handshake/message/server/keyExchange.js +75 -19
  77. package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
  78. package/lib/dtls/src/handshake/random.js +21 -6
  79. package/lib/dtls/src/handshake/random.js.map +1 -1
  80. package/lib/dtls/src/record/builder.d.ts +1 -1
  81. package/lib/dtls/src/record/message/fragment.js +49 -14
  82. package/lib/dtls/src/record/message/fragment.js.map +1 -1
  83. package/lib/dtls/src/record/message/header.js +84 -24
  84. package/lib/dtls/src/record/message/header.js.map +1 -1
  85. package/lib/dtls/src/record/message/plaintext.js +21 -6
  86. package/lib/dtls/src/record/message/plaintext.js.map +1 -1
  87. package/lib/dtls/src/server.js +59 -42
  88. package/lib/dtls/src/server.js.map +1 -1
  89. package/lib/dtls/src/socket.js +153 -64
  90. package/lib/dtls/src/socket.js.map +1 -1
  91. package/lib/dtls/src/transport.js +38 -11
  92. package/lib/dtls/src/transport.js.map +1 -1
  93. package/lib/dtls/src/typings/domain.d.ts +4 -4
  94. package/lib/ice/src/candidate.js +66 -11
  95. package/lib/ice/src/candidate.js.map +1 -1
  96. package/lib/ice/src/dns/lookup.js +12 -1
  97. package/lib/ice/src/dns/lookup.js.map +1 -1
  98. package/lib/ice/src/exceptions.js +27 -2
  99. package/lib/ice/src/exceptions.js.map +1 -1
  100. package/lib/ice/src/helper.d.ts +1 -1
  101. package/lib/ice/src/helper.js +12 -2
  102. package/lib/ice/src/helper.js.map +1 -1
  103. package/lib/ice/src/ice.d.ts +9 -3
  104. package/lib/ice/src/ice.js +407 -155
  105. package/lib/ice/src/ice.js.map +1 -1
  106. package/lib/ice/src/stun/attributes.d.ts +3 -3
  107. package/lib/ice/src/stun/attributes.js +6 -1
  108. package/lib/ice/src/stun/attributes.js.map +1 -1
  109. package/lib/ice/src/stun/message.d.ts +4 -0
  110. package/lib/ice/src/stun/message.js +24 -3
  111. package/lib/ice/src/stun/message.js.map +1 -1
  112. package/lib/ice/src/stun/protocol.js +64 -15
  113. package/lib/ice/src/stun/protocol.js.map +1 -1
  114. package/lib/ice/src/stun/transaction.js +99 -36
  115. package/lib/ice/src/stun/transaction.js.map +1 -1
  116. package/lib/ice/src/transport.js +57 -21
  117. package/lib/ice/src/transport.js.map +1 -1
  118. package/lib/ice/src/turn/protocol.js +176 -40
  119. package/lib/ice/src/turn/protocol.js.map +1 -1
  120. package/lib/ice/src/types/model.d.ts +1 -1
  121. package/lib/rtp/src/codec/av1.d.ts +1 -1
  122. package/lib/rtp/src/codec/av1.js +118 -30
  123. package/lib/rtp/src/codec/av1.js.map +1 -1
  124. package/lib/rtp/src/codec/base.js +8 -0
  125. package/lib/rtp/src/codec/base.js.map +1 -1
  126. package/lib/rtp/src/codec/h264.js +55 -0
  127. package/lib/rtp/src/codec/h264.js.map +1 -1
  128. package/lib/rtp/src/codec/index.d.ts +2 -0
  129. package/lib/rtp/src/codec/index.js +12 -2
  130. package/lib/rtp/src/codec/index.js.map +1 -1
  131. package/lib/rtp/src/codec/opus.js +8 -0
  132. package/lib/rtp/src/codec/opus.js.map +1 -1
  133. package/lib/rtp/src/codec/vp8.js +102 -3
  134. package/lib/rtp/src/codec/vp8.js.map +1 -1
  135. package/lib/rtp/src/codec/vp9.js +164 -7
  136. package/lib/rtp/src/codec/vp9.js.map +1 -1
  137. package/lib/rtp/src/container/ebml/ebml.js +30 -3
  138. package/lib/rtp/src/container/ebml/ebml.js.map +1 -1
  139. package/lib/rtp/src/container/webm.d.ts +1 -1
  140. package/lib/rtp/src/container/webm.js +44 -13
  141. package/lib/rtp/src/container/webm.js.map +1 -1
  142. package/lib/rtp/src/processor/depacketizer.d.ts +16 -8
  143. package/lib/rtp/src/processor/depacketizer.js +59 -22
  144. package/lib/rtp/src/processor/depacketizer.js.map +1 -1
  145. package/lib/rtp/src/processor/depacketizerCallback.js +24 -8
  146. package/lib/rtp/src/processor/depacketizerCallback.js.map +1 -1
  147. package/lib/rtp/src/processor/depacketizerTransformer.d.ts +2 -2
  148. package/lib/rtp/src/processor/depacketizerTransformer.js +6 -0
  149. package/lib/rtp/src/processor/depacketizerTransformer.js.map +1 -1
  150. package/lib/rtp/src/processor/index.d.ts +4 -2
  151. package/lib/rtp/src/processor/index.js +4 -2
  152. package/lib/rtp/src/processor/index.js.map +1 -1
  153. package/lib/rtp/src/processor/interface.d.ts +4 -0
  154. package/lib/rtp/src/processor/interface.js.map +1 -1
  155. package/lib/rtp/src/processor/jitterBuffer.d.ts +2 -1
  156. package/lib/rtp/src/processor/jitterBuffer.js +40 -8
  157. package/lib/rtp/src/processor/jitterBuffer.js.map +1 -1
  158. package/lib/rtp/src/processor/jitterBufferCallback.js +30 -9
  159. package/lib/rtp/src/processor/jitterBufferCallback.js.map +1 -1
  160. package/lib/rtp/src/processor/jitterBufferTransformer.js +12 -1
  161. package/lib/rtp/src/processor/jitterBufferTransformer.js.map +1 -1
  162. package/lib/rtp/src/processor/lipsync.d.ts +42 -0
  163. package/lib/rtp/src/processor/lipsync.js +178 -0
  164. package/lib/rtp/src/processor/lipsync.js.map +1 -0
  165. package/lib/rtp/src/processor/lipsyncCallback.d.ts +10 -0
  166. package/lib/rtp/src/processor/lipsyncCallback.js +59 -0
  167. package/lib/rtp/src/processor/lipsyncCallback.js.map +1 -0
  168. package/lib/rtp/src/processor/ntpTime.d.ts +24 -0
  169. package/lib/rtp/src/processor/ntpTime.js +91 -0
  170. package/lib/rtp/src/processor/ntpTime.js.map +1 -0
  171. package/lib/rtp/src/processor/ntpTimeCallback.d.ts +7 -0
  172. package/lib/rtp/src/processor/ntpTimeCallback.js +36 -0
  173. package/lib/rtp/src/processor/ntpTimeCallback.js.map +1 -0
  174. package/lib/rtp/src/processor/source/index.d.ts +1 -0
  175. package/lib/rtp/src/processor/source/index.js +1 -0
  176. package/lib/rtp/src/processor/source/index.js.map +1 -1
  177. package/lib/rtp/src/processor/source/rtcpCallback.d.ts +12 -0
  178. package/lib/rtp/src/processor/source/rtcpCallback.js +33 -0
  179. package/lib/rtp/src/processor/source/rtcpCallback.js.map +1 -0
  180. package/lib/rtp/src/processor/source/rtpCallback.js +28 -12
  181. package/lib/rtp/src/processor/source/rtpCallback.js.map +1 -1
  182. package/lib/rtp/src/processor/source/rtpStream.js +38 -10
  183. package/lib/rtp/src/processor/source/rtpStream.js.map +1 -1
  184. package/lib/rtp/src/processor/webm.d.ts +11 -4
  185. package/lib/rtp/src/processor/webm.js +169 -46
  186. package/lib/rtp/src/processor/webm.js.map +1 -1
  187. package/lib/rtp/src/processor/webmCallback.d.ts +5 -3
  188. package/lib/rtp/src/processor/webmCallback.js +52 -8
  189. package/lib/rtp/src/processor/webmCallback.js.map +1 -1
  190. package/lib/rtp/src/processor/webmStream.d.ts +2 -2
  191. package/lib/rtp/src/processor/webmStream.js +24 -0
  192. package/lib/rtp/src/processor/webmStream.js.map +1 -1
  193. package/lib/rtp/src/processor_old/base.d.ts +18 -0
  194. package/lib/rtp/src/processor_old/base.js +51 -0
  195. package/lib/rtp/src/processor_old/base.js.map +1 -0
  196. package/lib/rtp/src/processor_old/lipsync.d.ts +30 -0
  197. package/lib/rtp/src/processor_old/lipsync.js +119 -0
  198. package/lib/rtp/src/processor_old/lipsync.js.map +1 -0
  199. package/lib/rtp/src/rtcp/header.js +30 -5
  200. package/lib/rtp/src/rtcp/header.js.map +1 -1
  201. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +1 -1
  202. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +30 -3
  203. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
  204. package/lib/rtp/src/rtcp/psfb/index.d.ts +1 -1
  205. package/lib/rtp/src/rtcp/psfb/index.js +18 -2
  206. package/lib/rtp/src/rtcp/psfb/index.js.map +1 -1
  207. package/lib/rtp/src/rtcp/psfb/pictureLossIndication.js +30 -3
  208. package/lib/rtp/src/rtcp/psfb/pictureLossIndication.js.map +1 -1
  209. package/lib/rtp/src/rtcp/psfb/remb.js +66 -5
  210. package/lib/rtp/src/rtcp/psfb/remb.js.map +1 -1
  211. package/lib/rtp/src/rtcp/rr.js +68 -4
  212. package/lib/rtp/src/rtcp/rr.js.map +1 -1
  213. package/lib/rtp/src/rtcp/rtcp.d.ts +1 -1
  214. package/lib/rtp/src/rtcp/rtpfb/index.d.ts +1 -1
  215. package/lib/rtp/src/rtcp/rtpfb/index.js +24 -2
  216. package/lib/rtp/src/rtcp/rtpfb/index.js.map +1 -1
  217. package/lib/rtp/src/rtcp/rtpfb/nack.d.ts +5 -0
  218. package/lib/rtp/src/rtcp/rtpfb/nack.js +43 -3
  219. package/lib/rtp/src/rtcp/rtpfb/nack.js.map +1 -1
  220. package/lib/rtp/src/rtcp/rtpfb/twcc.js +154 -11
  221. package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
  222. package/lib/rtp/src/rtcp/sdes.js +42 -4
  223. package/lib/rtp/src/rtcp/sdes.js.map +1 -1
  224. package/lib/rtp/src/rtcp/sr.js +56 -5
  225. package/lib/rtp/src/rtcp/sr.js.map +1 -1
  226. package/lib/rtp/src/rtp/red/encoder.js +18 -3
  227. package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
  228. package/lib/rtp/src/rtp/red/handler.js +12 -2
  229. package/lib/rtp/src/rtp/red/handler.js.map +1 -1
  230. package/lib/rtp/src/rtp/red/packet.js +18 -2
  231. package/lib/rtp/src/rtp/red/packet.js.map +1 -1
  232. package/lib/rtp/src/rtp/rtp.d.ts +3 -3
  233. package/lib/rtp/src/rtp/rtp.js +104 -17
  234. package/lib/rtp/src/rtp/rtp.js.map +1 -1
  235. package/lib/rtp/src/srtp/cipher/ctr.js +26 -10
  236. package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
  237. package/lib/rtp/src/srtp/cipher/gcm.d.ts +3 -0
  238. package/lib/rtp/src/srtp/cipher/gcm.js +40 -20
  239. package/lib/rtp/src/srtp/cipher/gcm.js.map +1 -1
  240. package/lib/rtp/src/srtp/cipher/index.js +24 -4
  241. package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
  242. package/lib/rtp/src/srtp/const.d.ts +1 -1
  243. package/lib/rtp/src/srtp/context/context.d.ts +1 -1
  244. package/lib/rtp/src/srtp/context/context.js +84 -5
  245. package/lib/rtp/src/srtp/context/context.js.map +1 -1
  246. package/lib/rtp/src/srtp/session.d.ts +2 -2
  247. package/lib/rtp/src/srtp/session.js +24 -1
  248. package/lib/rtp/src/srtp/session.js.map +1 -1
  249. package/lib/rtp/src/srtp/srtcp.js +15 -5
  250. package/lib/rtp/src/srtp/srtcp.js.map +1 -1
  251. package/lib/rtp/src/srtp/srtp.js +15 -5
  252. package/lib/rtp/src/srtp/srtp.js.map +1 -1
  253. package/lib/sctp/src/chunk.js +349 -69
  254. package/lib/sctp/src/chunk.js.map +1 -1
  255. package/lib/sctp/src/helper.d.ts +1 -1
  256. package/lib/sctp/src/param.d.ts +3 -3
  257. package/lib/sctp/src/param.js +66 -11
  258. package/lib/sctp/src/param.js.map +1 -1
  259. package/lib/sctp/src/sctp.d.ts +1 -1
  260. package/lib/sctp/src/sctp.js +479 -138
  261. package/lib/sctp/src/sctp.js.map +1 -1
  262. package/lib/sctp/src/transport.js +31 -10
  263. package/lib/sctp/src/transport.js.map +1 -1
  264. package/lib/webrtc/src/dataChannel.d.ts +1 -1
  265. package/lib/webrtc/src/dataChannel.js +145 -15
  266. package/lib/webrtc/src/dataChannel.js.map +1 -1
  267. package/lib/webrtc/src/helper.js +37 -12
  268. package/lib/webrtc/src/helper.js.map +1 -1
  269. package/lib/webrtc/src/media/parameters.d.ts +1 -1
  270. package/lib/webrtc/src/media/parameters.js +124 -3
  271. package/lib/webrtc/src/media/parameters.js.map +1 -1
  272. package/lib/webrtc/src/media/receiver/nack.d.ts +4 -4
  273. package/lib/webrtc/src/media/receiver/nack.js +85 -33
  274. package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
  275. package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +1 -1
  276. package/lib/webrtc/src/media/receiver/receiverTwcc.js +42 -6
  277. package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
  278. package/lib/webrtc/src/media/receiver/statistics.js +61 -5
  279. package/lib/webrtc/src/media/receiver/statistics.js.map +1 -1
  280. package/lib/webrtc/src/media/router.d.ts +1 -1
  281. package/lib/webrtc/src/media/router.js +108 -83
  282. package/lib/webrtc/src/media/router.js.map +1 -1
  283. package/lib/webrtc/src/media/rtpReceiver.js +188 -33
  284. package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
  285. package/lib/webrtc/src/media/rtpSender.js +279 -42
  286. package/lib/webrtc/src/media/rtpSender.js.map +1 -1
  287. package/lib/webrtc/src/media/rtpTransceiver.d.ts +2 -2
  288. package/lib/webrtc/src/media/rtpTransceiver.js +102 -18
  289. package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
  290. package/lib/webrtc/src/media/sender/cumulativeResult.js +36 -6
  291. package/lib/webrtc/src/media/sender/cumulativeResult.js.map +1 -1
  292. package/lib/webrtc/src/media/sender/senderBWE.js +57 -12
  293. package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
  294. package/lib/webrtc/src/media/track.js +135 -24
  295. package/lib/webrtc/src/media/track.js.map +1 -1
  296. package/lib/webrtc/src/nonstandard/recorder/index.d.ts +7 -4
  297. package/lib/webrtc/src/nonstandard/recorder/index.js +50 -6
  298. package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
  299. package/lib/webrtc/src/nonstandard/recorder/writer/index.js +12 -2
  300. package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
  301. package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +2 -2
  302. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +39 -35
  303. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
  304. package/lib/webrtc/src/nonstandard/userMedia.js +158 -56
  305. package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
  306. package/lib/webrtc/src/peerConnection.d.ts +2 -2
  307. package/lib/webrtc/src/peerConnection.js +260 -58
  308. package/lib/webrtc/src/peerConnection.js.map +1 -1
  309. package/lib/webrtc/src/sdp.js +287 -24
  310. package/lib/webrtc/src/sdp.js.map +1 -1
  311. package/lib/webrtc/src/transport/dtls.d.ts +3 -3
  312. package/lib/webrtc/src/transport/dtls.js +185 -30
  313. package/lib/webrtc/src/transport/dtls.js.map +1 -1
  314. package/lib/webrtc/src/transport/ice.d.ts +2 -2
  315. package/lib/webrtc/src/transport/ice.js +193 -25
  316. package/lib/webrtc/src/transport/ice.js.map +1 -1
  317. package/lib/webrtc/src/transport/sctp.js +193 -101
  318. package/lib/webrtc/src/transport/sctp.js.map +1 -1
  319. package/lib/webrtc/src/types/domain.d.ts +3 -3
  320. package/lib/webrtc/src/types/util.d.ts +2 -2
  321. package/lib/webrtc/src/utils.js +12 -2
  322. package/lib/webrtc/src/utils.js.map +1 -1
  323. package/package.json +15 -15
  324. package/src/dataChannel.ts +3 -1
  325. package/src/media/receiver/nack.ts +23 -19
  326. package/src/media/rtpReceiver.ts +5 -0
  327. package/src/media/rtpSender.ts +22 -19
  328. package/src/nonstandard/recorder/index.ts +12 -4
  329. package/src/nonstandard/recorder/writer/webm.ts +42 -50
  330. package/src/transport/dtls.ts +7 -3
  331. package/src/transport/ice.ts +6 -3
  332. package/src/transport/sctp.ts +3 -1
  333. package/lib/rtp/src/processor/avBuffer.d.ts +0 -36
  334. package/lib/rtp/src/processor/avBuffer.js +0 -107
  335. package/lib/rtp/src/processor/avBuffer.js.map +0 -1
  336. package/lib/rtp/src/processor/avBufferCallback.d.ts +0 -10
  337. package/lib/rtp/src/processor/avBufferCallback.js +0 -27
  338. package/lib/rtp/src/processor/avBufferCallback.js.map +0 -1
@@ -48,160 +48,353 @@ const protocol_2 = require("./turn/protocol");
48
48
  const utils_1 = require("./utils");
49
49
  const log = (0, debug_1.default)("werift-ice : packages/ice/src/ice.ts : log");
50
50
  class Connection {
51
+ get nominatedKeys() {
52
+ return Object.keys(this.nominated).map((v) => v.toString());
53
+ }
51
54
  constructor(iceControlling, options) {
52
- this.iceControlling = iceControlling;
53
- this.localUserName = (0, helper_1.randomString)(4);
54
- this.localPassword = (0, helper_1.randomString)(22);
55
- this.remotePassword = "";
56
- this.remoteUsername = "";
57
- this.remoteIsLite = false;
58
- this.checkList = [];
59
- this.localCandidates = [];
60
- this.remoteCandidatesEnd = false;
61
- this._localCandidatesEnd = false;
62
- this._tieBreaker = BigInt(new int64_buffer_1.Uint64BE((0, crypto_1.randomBytes)(64)).toString());
63
- this.state = "new";
64
- this.onData = new rx_mini_1.Event();
65
- this.stateChanged = new rx_mini_1.Event();
66
- this._remoteCandidates = [];
55
+ Object.defineProperty(this, "iceControlling", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: iceControlling
60
+ });
61
+ Object.defineProperty(this, "localUserName", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: (0, helper_1.randomString)(4)
66
+ });
67
+ Object.defineProperty(this, "localPassword", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: (0, helper_1.randomString)(22)
72
+ });
73
+ Object.defineProperty(this, "remotePassword", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: ""
78
+ });
79
+ Object.defineProperty(this, "remoteUsername", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: ""
84
+ });
85
+ Object.defineProperty(this, "remoteIsLite", {
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true,
89
+ value: false
90
+ });
91
+ Object.defineProperty(this, "checkList", {
92
+ enumerable: true,
93
+ configurable: true,
94
+ writable: true,
95
+ value: []
96
+ });
97
+ Object.defineProperty(this, "localCandidates", {
98
+ enumerable: true,
99
+ configurable: true,
100
+ writable: true,
101
+ value: []
102
+ });
103
+ Object.defineProperty(this, "stunServer", {
104
+ enumerable: true,
105
+ configurable: true,
106
+ writable: true,
107
+ value: void 0
108
+ });
109
+ Object.defineProperty(this, "turnServer", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: void 0
114
+ });
115
+ Object.defineProperty(this, "useIpv4", {
116
+ enumerable: true,
117
+ configurable: true,
118
+ writable: true,
119
+ value: void 0
120
+ });
121
+ Object.defineProperty(this, "useIpv6", {
122
+ enumerable: true,
123
+ configurable: true,
124
+ writable: true,
125
+ value: void 0
126
+ });
127
+ Object.defineProperty(this, "options", {
128
+ enumerable: true,
129
+ configurable: true,
130
+ writable: true,
131
+ value: void 0
132
+ });
133
+ Object.defineProperty(this, "remoteCandidatesEnd", {
134
+ enumerable: true,
135
+ configurable: true,
136
+ writable: true,
137
+ value: false
138
+ });
139
+ /**コンポーネントはデータストリームの一部です. データストリームには複数のコンポーネントが必要な場合があり、
140
+ * データストリーム全体が機能するには、それぞれが機能する必要があります.
141
+ * RTP / RTCPデータストリームの場合、RTPとRTCPが同じポートで多重化されていない限り、データストリームごとに2つのコンポーネントがあります.
142
+ * 1つはRTP用、もう1つはRTCP用です. コンポーネントには候補ペアがあり、他のコンポーネントでは使用できません. */
143
+ Object.defineProperty(this, "_components", {
144
+ enumerable: true,
145
+ configurable: true,
146
+ writable: true,
147
+ value: void 0
148
+ });
149
+ Object.defineProperty(this, "_localCandidatesEnd", {
150
+ enumerable: true,
151
+ configurable: true,
152
+ writable: true,
153
+ value: false
154
+ });
155
+ Object.defineProperty(this, "_tieBreaker", {
156
+ enumerable: true,
157
+ configurable: true,
158
+ writable: true,
159
+ value: BigInt(new int64_buffer_1.Uint64BE((0, crypto_1.randomBytes)(64)).toString())
160
+ });
161
+ Object.defineProperty(this, "state", {
162
+ enumerable: true,
163
+ configurable: true,
164
+ writable: true,
165
+ value: "new"
166
+ });
167
+ Object.defineProperty(this, "dnsLookup", {
168
+ enumerable: true,
169
+ configurable: true,
170
+ writable: true,
171
+ value: void 0
172
+ });
173
+ Object.defineProperty(this, "onData", {
174
+ enumerable: true,
175
+ configurable: true,
176
+ writable: true,
177
+ value: new rx_mini_1.Event()
178
+ });
179
+ Object.defineProperty(this, "stateChanged", {
180
+ enumerable: true,
181
+ configurable: true,
182
+ writable: true,
183
+ value: new rx_mini_1.Event()
184
+ });
185
+ Object.defineProperty(this, "_remoteCandidates", {
186
+ enumerable: true,
187
+ configurable: true,
188
+ writable: true,
189
+ value: []
190
+ });
67
191
  // P2P接続完了したソケット
68
- this.nominated = {};
69
- this.nominating = new Set();
70
- this.checkListDone = false;
71
- this.checkListState = new helper_1.PQueue();
72
- this.earlyChecks = [];
73
- this.localCandidatesStart = false;
74
- this.protocols = [];
192
+ Object.defineProperty(this, "nominated", {
193
+ enumerable: true,
194
+ configurable: true,
195
+ writable: true,
196
+ value: {}
197
+ });
198
+ Object.defineProperty(this, "nominating", {
199
+ enumerable: true,
200
+ configurable: true,
201
+ writable: true,
202
+ value: new Set()
203
+ });
204
+ Object.defineProperty(this, "checkListDone", {
205
+ enumerable: true,
206
+ configurable: true,
207
+ writable: true,
208
+ value: false
209
+ });
210
+ Object.defineProperty(this, "checkListState", {
211
+ enumerable: true,
212
+ configurable: true,
213
+ writable: true,
214
+ value: new helper_1.PQueue()
215
+ });
216
+ Object.defineProperty(this, "earlyChecks", {
217
+ enumerable: true,
218
+ configurable: true,
219
+ writable: true,
220
+ value: []
221
+ });
222
+ Object.defineProperty(this, "localCandidatesStart", {
223
+ enumerable: true,
224
+ configurable: true,
225
+ writable: true,
226
+ value: false
227
+ });
228
+ Object.defineProperty(this, "protocols", {
229
+ enumerable: true,
230
+ configurable: true,
231
+ writable: true,
232
+ value: []
233
+ });
234
+ Object.defineProperty(this, "queryConsentHandle", {
235
+ enumerable: true,
236
+ configurable: true,
237
+ writable: true,
238
+ value: void 0
239
+ });
240
+ Object.defineProperty(this, "promiseGatherCandidates", {
241
+ enumerable: true,
242
+ configurable: true,
243
+ writable: true,
244
+ value: void 0
245
+ });
75
246
  // 4.1.1.4 ? 生存確認 life check
76
- this.queryConsent = () => new p_cancelable_1.default(async (r, f, onCancel) => {
77
- let failures = 0;
78
- const cancelEvent = new AbortController();
79
- onCancel(() => {
80
- failures += CONSENT_FAILURES;
81
- cancelEvent.abort();
82
- f("cancel");
83
- });
84
- // """
85
- // Periodically check consent (RFC 7675).
86
- // """
87
- try {
88
- while (!this.remoteIsLite && this.state !== "closed") {
89
- // # randomize between 0.8 and 1.2 times CONSENT_INTERVAL
90
- await promises_1.default.setTimeout(CONSENT_INTERVAL * (0.8 + 0.4 * Math.random()) * 1000, undefined, { signal: cancelEvent.signal });
91
- for (const key of this.nominatedKeys) {
92
- const pair = this.nominated[Number(key)];
93
- const request = this.buildRequest(pair, false);
94
- try {
95
- const [msg, addr] = await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"), 0);
96
- failures = 0;
97
- if (this.state === "disconnected") {
98
- this.setState("connected");
247
+ Object.defineProperty(this, "queryConsent", {
248
+ enumerable: true,
249
+ configurable: true,
250
+ writable: true,
251
+ value: () => new p_cancelable_1.default(async (r, f, onCancel) => {
252
+ let failures = 0;
253
+ const cancelEvent = new AbortController();
254
+ onCancel(() => {
255
+ failures += CONSENT_FAILURES;
256
+ cancelEvent.abort();
257
+ f("cancel");
258
+ });
259
+ // """
260
+ // Periodically check consent (RFC 7675).
261
+ // """
262
+ try {
263
+ while (!this.remoteIsLite && this.state !== "closed") {
264
+ // # randomize between 0.8 and 1.2 times CONSENT_INTERVAL
265
+ await promises_1.default.setTimeout(CONSENT_INTERVAL * (0.8 + 0.4 * Math.random()) * 1000, undefined, { signal: cancelEvent.signal });
266
+ for (const key of this.nominatedKeys) {
267
+ const pair = this.nominated[Number(key)];
268
+ const request = this.buildRequest(pair, false);
269
+ try {
270
+ const [msg, addr] = await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"), 0);
271
+ failures = 0;
272
+ if (this.state === "disconnected") {
273
+ this.setState("connected");
274
+ }
275
+ }
276
+ catch (error) {
277
+ log("no stun response");
278
+ failures++;
279
+ this.setState("disconnected");
280
+ }
281
+ if (failures >= CONSENT_FAILURES) {
282
+ log("Consent to send expired");
283
+ this.queryConsentHandle = undefined;
284
+ // 切断検知
285
+ r(await this.close());
286
+ return;
99
287
  }
100
- }
101
- catch (error) {
102
- log("no stun response");
103
- failures++;
104
- this.setState("disconnected");
105
- }
106
- if (failures >= CONSENT_FAILURES) {
107
- log("Consent to send expired");
108
- this.queryConsentHandle = undefined;
109
- // 切断検知
110
- r(await this.close());
111
- return;
112
288
  }
113
289
  }
114
290
  }
291
+ catch (error) { }
292
+ })
293
+ });
294
+ Object.defineProperty(this, "send", {
295
+ enumerable: true,
296
+ configurable: true,
297
+ writable: true,
298
+ value: async (data) => {
299
+ // """
300
+ // Send a datagram on the first component.
301
+ // If the connection is not established, a `ConnectionError` is raised.
302
+ // :param data: The data to be sent.
303
+ // """
304
+ await this.sendTo(data, 1);
115
305
  }
116
- catch (error) { }
117
306
  });
118
- this.send = async (data) => {
119
- // """
120
- // Send a datagram on the first component.
121
- // If the connection is not established, a `ConnectionError` is raised.
122
- // :param data: The data to be sent.
123
- // """
124
- await this.sendTo(data, 1);
125
- };
126
307
  // 3. Terminology : Check
127
- this.checkStart = (pair) => new p_cancelable_1.default(async (r, f, onCancel) => {
128
- onCancel(() => f("cancel"));
129
- // """
130
- // Starts a check.
131
- // """
132
- log("check start", pair.remoteCandidate);
133
- this.checkState(pair, CandidatePairState.IN_PROGRESS);
134
- const nominate = this.iceControlling && !this.remoteIsLite;
135
- const request = this.buildRequest(pair, nominate);
136
- const result = {};
137
- try {
138
- const [response, addr] = await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"), 4);
139
- log("response", response, addr);
140
- result.response = response;
141
- result.addr = addr;
142
- }
143
- catch (error) {
144
- const exc = error;
145
- // 7.1.3.1. Failure Cases
146
- log("failure case", exc.response);
147
- if (exc.response?.getAttributeValue("ERROR-CODE")[0] === 487) {
148
- if (request.attributesKeys.includes("ICE-CONTROLLED")) {
149
- this.switchRole(true);
308
+ Object.defineProperty(this, "checkStart", {
309
+ enumerable: true,
310
+ configurable: true,
311
+ writable: true,
312
+ value: (pair) => new p_cancelable_1.default(async (r, f, onCancel) => {
313
+ onCancel(() => f("cancel"));
314
+ // """
315
+ // Starts a check.
316
+ // """
317
+ log("check start", pair.toJSON());
318
+ this.setPairState(pair, CandidatePairState.IN_PROGRESS);
319
+ const nominate = this.iceControlling && !this.remoteIsLite;
320
+ const request = this.buildRequest(pair, nominate);
321
+ const result = {};
322
+ try {
323
+ const [response, addr] = await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"), 4);
324
+ log("response", response, addr);
325
+ result.response = response;
326
+ result.addr = addr;
327
+ }
328
+ catch (error) {
329
+ const exc = error;
330
+ // 7.1.3.1. Failure Cases
331
+ log("failure case", exc.response);
332
+ if (exc.response?.getAttributeValue("ERROR-CODE")[0] === 487) {
333
+ if (request.attributesKeys.includes("ICE-CONTROLLED")) {
334
+ this.switchRole(true);
335
+ }
336
+ else if (request.attributesKeys.includes("ICE-CONTROLLING")) {
337
+ this.switchRole(false);
338
+ }
339
+ await this.checkStart(pair);
340
+ r();
341
+ return;
150
342
  }
151
- else if (request.attributesKeys.includes("ICE-CONTROLLING")) {
152
- this.switchRole(false);
343
+ else {
344
+ // timeout
345
+ log("CandidatePairState.FAILED", pair.toJSON());
346
+ this.setPairState(pair, CandidatePairState.FAILED);
347
+ this.checkComplete(pair);
348
+ r();
349
+ return;
153
350
  }
154
- await this.checkStart(pair);
155
- r();
156
- return;
157
351
  }
158
- else {
159
- log("CandidatePairState.FAILED");
160
- this.checkState(pair, CandidatePairState.FAILED);
352
+ // # check remote address matches
353
+ if (!(0, isEqual_1.default)(result.addr, pair.remoteAddr)) {
354
+ this.setPairState(pair, CandidatePairState.FAILED);
161
355
  this.checkComplete(pair);
162
356
  r();
163
357
  return;
164
358
  }
165
- }
166
- // # check remote address matches
167
- if (!(0, isEqual_1.default)(result.addr, pair.remoteAddr)) {
168
- this.checkState(pair, CandidatePairState.FAILED);
169
- this.checkComplete(pair);
170
- r();
171
- return;
172
- }
173
- // # success
174
- if (nominate || pair.remoteNominated) {
175
- // # nominated by agressive nomination or the remote party
176
- pair.nominated = true;
177
- }
178
- else if (this.iceControlling && !this.nominating.has(pair.component)) {
179
- // # perform regular nomination
180
- this.nominating.add(pair.component);
181
- const request = this.buildRequest(pair, true);
182
- try {
183
- await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"));
359
+ // # success
360
+ if (nominate || pair.remoteNominated) {
361
+ // # nominated by agressive nomination or the remote party
362
+ pair.nominated = true;
184
363
  }
185
- catch (error) {
186
- this.checkState(pair, CandidatePairState.FAILED);
187
- this.checkComplete(pair);
188
- return;
364
+ else if (this.iceControlling && !this.nominating.has(pair.component)) {
365
+ // # perform regular nomination
366
+ this.nominating.add(pair.component);
367
+ const request = this.buildRequest(pair, true);
368
+ try {
369
+ await pair.protocol.request(request, pair.remoteAddr, Buffer.from(this.remotePassword, "utf8"));
370
+ }
371
+ catch (error) {
372
+ this.setPairState(pair, CandidatePairState.FAILED);
373
+ this.checkComplete(pair);
374
+ return;
375
+ }
376
+ pair.nominated = true;
189
377
  }
190
- pair.nominated = true;
191
- }
192
- this.checkState(pair, CandidatePairState.SUCCEEDED);
193
- this.checkComplete(pair);
194
- r();
378
+ this.setPairState(pair, CandidatePairState.SUCCEEDED);
379
+ this.checkComplete(pair);
380
+ r();
381
+ })
195
382
  });
196
- this.pairRemoteCandidate = (remoteCandidate) => {
197
- for (const protocol of this.protocols) {
198
- if (protocol.localCandidate?.canPairWith(remoteCandidate) &&
199
- !this.findPair(protocol, remoteCandidate)) {
200
- const pair = new CandidatePair(protocol, remoteCandidate);
201
- this.checkList.push(pair);
383
+ Object.defineProperty(this, "pairRemoteCandidate", {
384
+ enumerable: true,
385
+ configurable: true,
386
+ writable: true,
387
+ value: (remoteCandidate) => {
388
+ for (const protocol of this.protocols) {
389
+ if (protocol.localCandidate?.canPairWith(remoteCandidate) &&
390
+ !this.findPair(protocol, remoteCandidate)) {
391
+ const pair = new CandidatePair(protocol, remoteCandidate);
392
+ this.checkList.push(pair);
393
+ this.setPairState(pair, CandidatePairState.WAITING);
394
+ }
202
395
  }
203
396
  }
204
- };
397
+ });
205
398
  this.options = {
206
399
  ...defaultOptions,
207
400
  ...options,
@@ -213,10 +406,8 @@ class Connection {
213
406
  this.useIpv6 = useIpv6;
214
407
  this._components = new Set((0, range_1.default)(1, components + 1));
215
408
  }
216
- get nominatedKeys() {
217
- return Object.keys(this.nominated).map((v) => v.toString());
218
- }
219
409
  setRemoteParams({ iceLite, usernameFragment, password, }) {
410
+ log("setRemoteParams", { iceLite, usernameFragment, password });
220
411
  this.remoteIsLite = iceLite;
221
412
  this.remoteUsername = usernameFragment;
222
413
  this.remotePassword = password;
@@ -353,7 +544,7 @@ class Connection {
353
544
  if (!firstPair)
354
545
  return;
355
546
  if (firstPair.state === CandidatePairState.FROZEN) {
356
- this.checkState(firstPair, CandidatePairState.WAITING);
547
+ this.setPairState(firstPair, CandidatePairState.WAITING);
357
548
  }
358
549
  // # unfreeze pairs with same component but different foundations
359
550
  const seenFoundations = new Set(firstPair.localCandidate.foundation);
@@ -361,7 +552,7 @@ class Connection {
361
552
  if (pair.component === firstPair.component &&
362
553
  !seenFoundations.has(pair.localCandidate.foundation) &&
363
554
  pair.state === CandidatePairState.FROZEN) {
364
- this.checkState(pair, CandidatePairState.WAITING);
555
+ this.setPairState(pair, CandidatePairState.WAITING);
365
556
  seenFoundations.add(pair.localCandidate.foundation);
366
557
  }
367
558
  }
@@ -438,8 +629,6 @@ class Connection {
438
629
  // To signal end-of-candidates, pass `None`.
439
630
  // :param remote_candidate: A :class:`Candidate` instance or `None`.
440
631
  // """
441
- if (this.remoteCandidatesEnd)
442
- throw new Error("Cannot add remote candidate after end-of-candidates.");
443
632
  if (!remoteCandidate) {
444
633
  this.pruneComponents();
445
634
  this.remoteCandidatesEnd = true;
@@ -501,8 +690,9 @@ class Connection {
501
690
  (0, message_1.parseMessage)(rawData, Buffer.from(this.localPassword, "utf8"));
502
691
  if (!this.remoteUsername) {
503
692
  const rxUsername = `${this.localUserName}:${this.remoteUsername}`;
504
- if (message.getAttributeValue("USERNAME") != rxUsername)
693
+ if (message.getAttributeValue("USERNAME") != rxUsername) {
505
694
  throw new Error("Wrong username");
695
+ }
506
696
  }
507
697
  }
508
698
  catch (error) {
@@ -549,7 +739,12 @@ class Connection {
549
739
  // }
550
740
  }
551
741
  dataReceived(data, component) {
552
- this.onData.execute(data, component);
742
+ try {
743
+ this.onData.execute(data, component);
744
+ }
745
+ catch (error) {
746
+ log("dataReceived", error);
747
+ }
553
748
  }
554
749
  // for test only
555
750
  set remoteCandidates(value) {
@@ -586,8 +781,9 @@ class Connection {
586
781
  (0, isEqual_1.default)(pair.remoteCandidate, remoteCandidate));
587
782
  return pair;
588
783
  }
589
- checkState(pair, state) {
590
- pair.state = state;
784
+ setPairState(pair, state) {
785
+ log("setPairState", pair.toJSON(), CandidatePairState[state]);
786
+ pair.updateState(state);
591
787
  }
592
788
  switchRole(iceControlling) {
593
789
  log("switch role", iceControlling);
@@ -595,6 +791,7 @@ class Connection {
595
791
  this.sortCheckList();
596
792
  }
597
793
  resetNominatedPair() {
794
+ log("resetNominatedPair");
598
795
  this.nominated = {};
599
796
  this.nominating.clear();
600
797
  }
@@ -607,6 +804,7 @@ class Connection {
607
804
  // concludes the ICE processing for that component. See Section 8.
608
805
  // So disallow overwriting of the pair nominated for that component
609
806
  if (pair.nominated && this.nominated[pair.component] == undefined) {
807
+ log("nominated", pair.toJSON());
610
808
  this.nominated[pair.component] = pair;
611
809
  this.nominating.delete(pair.component);
612
810
  // 8.1.2. Updating States
@@ -616,7 +814,7 @@ class Connection {
616
814
  for (const p of this.checkList) {
617
815
  if (p.component === pair.component &&
618
816
  [CandidatePairState.WAITING, CandidatePairState.FROZEN].includes(p.state)) {
619
- this.checkState(p, CandidatePairState.FAILED);
817
+ this.setPairState(p, CandidatePairState.FAILED);
620
818
  }
621
819
  }
622
820
  }
@@ -635,7 +833,7 @@ class Connection {
635
833
  for (const p of this.checkList) {
636
834
  if (p.localCandidate.foundation === pair.localCandidate.foundation &&
637
835
  p.state === CandidatePairState.FROZEN) {
638
- this.checkState(p, CandidatePairState.WAITING);
836
+ this.setPairState(p, CandidatePairState.WAITING);
639
837
  }
640
838
  }
641
839
  }
@@ -661,20 +859,23 @@ class Connection {
661
859
  // 7.2. STUN Server Procedures
662
860
  // 7.2.1.3、7.2.1.4、および7.2.1.5
663
861
  checkIncoming(message, addr, protocol) {
862
+ // log("checkIncoming", message.toJSON(), addr);
664
863
  // """
665
864
  // Handle a successful incoming check.
666
865
  // """
667
866
  const component = protocol.localCandidate?.component;
668
- if (component == undefined)
669
- throw new Error();
867
+ if (component == undefined) {
868
+ throw new Error("component not exist");
869
+ }
670
870
  // find remote candidate
671
871
  let remoteCandidate;
672
872
  const [host, port] = addr;
673
873
  for (const c of this.remoteCandidates) {
674
874
  if (c.host === host && c.port === port) {
675
875
  remoteCandidate = c;
676
- if (remoteCandidate.component !== component)
876
+ if (remoteCandidate.component !== component) {
677
877
  throw new Error("checkIncoming");
878
+ }
678
879
  break;
679
880
  }
680
881
  }
@@ -687,7 +888,7 @@ class Connection {
687
888
  let pair = this.findPair(protocol, remoteCandidate);
688
889
  if (!pair) {
689
890
  pair = new CandidatePair(protocol, remoteCandidate);
690
- pair.state = CandidatePairState.WAITING;
891
+ this.setPairState(pair, CandidatePairState.WAITING);
691
892
  this.checkList.push(pair);
692
893
  this.sortCheckList();
693
894
  }
@@ -695,6 +896,9 @@ class Connection {
695
896
  if ([CandidatePairState.WAITING, CandidatePairState.FAILED].includes(pair.state)) {
696
897
  pair.handle = (0, helper_1.future)(this.checkStart(pair));
697
898
  }
899
+ else {
900
+ pair;
901
+ }
698
902
  // 7.2.1.5. Updating the Nominated Flag
699
903
  if (message.attributesKeys.includes("USE-CANDIDATE") &&
700
904
  !this.iceControlling) {
@@ -733,13 +937,56 @@ class Connection {
733
937
  }
734
938
  exports.Connection = Connection;
735
939
  class CandidatePair {
940
+ get state() {
941
+ return this._state;
942
+ }
943
+ toJSON() {
944
+ return {
945
+ protocol: this.protocol.type,
946
+ remoteAddr: this.remoteAddr,
947
+ };
948
+ }
736
949
  constructor(protocol, remoteCandidate) {
737
- this.protocol = protocol;
738
- this.remoteCandidate = remoteCandidate;
739
- this.nominated = false;
740
- this.remoteNominated = false;
950
+ Object.defineProperty(this, "protocol", {
951
+ enumerable: true,
952
+ configurable: true,
953
+ writable: true,
954
+ value: protocol
955
+ });
956
+ Object.defineProperty(this, "remoteCandidate", {
957
+ enumerable: true,
958
+ configurable: true,
959
+ writable: true,
960
+ value: remoteCandidate
961
+ });
962
+ Object.defineProperty(this, "handle", {
963
+ enumerable: true,
964
+ configurable: true,
965
+ writable: true,
966
+ value: void 0
967
+ });
968
+ Object.defineProperty(this, "nominated", {
969
+ enumerable: true,
970
+ configurable: true,
971
+ writable: true,
972
+ value: false
973
+ });
974
+ Object.defineProperty(this, "remoteNominated", {
975
+ enumerable: true,
976
+ configurable: true,
977
+ writable: true,
978
+ value: false
979
+ });
741
980
  // 5.7.4. Computing States
742
- this.state = CandidatePairState.FROZEN;
981
+ Object.defineProperty(this, "_state", {
982
+ enumerable: true,
983
+ configurable: true,
984
+ writable: true,
985
+ value: CandidatePairState.FROZEN
986
+ });
987
+ }
988
+ updateState(state) {
989
+ this._state = state;
743
990
  }
744
991
  get localCandidate() {
745
992
  if (!this.protocol.localCandidate)
@@ -793,6 +1040,10 @@ function candidatePairPriority(local, remote, iceControlling) {
793
1040
  return (1 << 32) * Math.min(G, D) + 2 * Math.max(G, D) + (G > D ? 1 : 0);
794
1041
  }
795
1042
  exports.candidatePairPriority = candidatePairPriority;
1043
+ function isAutoconfigurationAddress(info) {
1044
+ return ((0, utils_1.normalizeFamilyNodeV18)(info.family) === 4 &&
1045
+ info.address?.startsWith("169.254."));
1046
+ }
796
1047
  function nodeIpAddress(family) {
797
1048
  // https://chromium.googlesource.com/external/webrtc/+/master/rtc_base/network.cc#236
798
1049
  const costlyNetworks = ["ipsec", "tun", "utun", "tap"];
@@ -809,7 +1060,8 @@ function nodeIpAddress(family) {
809
1060
  }
810
1061
  }
811
1062
  const addresses = interfaces[nic].filter((details) => (0, utils_1.normalizeFamilyNodeV18)(details.family) === family &&
812
- !nodeIp.isLoopback(details.address));
1063
+ !nodeIp.isLoopback(details.address) &&
1064
+ !isAutoconfigurationAddress(details));
813
1065
  return {
814
1066
  nic,
815
1067
  addresses: addresses.map((address) => address.address),