werift 0.18.13 → 0.18.15

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 (252) hide show
  1. package/lib/common/src/binary.js.map +1 -1
  2. package/lib/common/src/index.d.ts +0 -1
  3. package/lib/common/src/index.js +0 -1
  4. package/lib/common/src/index.js.map +1 -1
  5. package/lib/dtls/src/client.js.map +1 -1
  6. package/lib/dtls/src/context/cipher.js +1 -1
  7. package/lib/dtls/src/context/cipher.js.map +1 -1
  8. package/lib/dtls/src/context/dtls.js.map +1 -1
  9. package/lib/dtls/src/context/transport.js.map +1 -1
  10. package/lib/dtls/src/flight/client/flight1.js.map +1 -1
  11. package/lib/dtls/src/flight/client/flight5.js.map +1 -1
  12. package/lib/dtls/src/flight/flight.js +1 -1
  13. package/lib/dtls/src/flight/flight.js.map +1 -1
  14. package/lib/dtls/src/flight/server/flight4.js.map +1 -1
  15. package/lib/dtls/src/flight/server/flight6.js.map +1 -1
  16. package/lib/dtls/src/handshake/extensions/ellipticCurves.js +1 -1
  17. package/lib/dtls/src/handshake/extensions/ellipticCurves.js.map +1 -1
  18. package/lib/dtls/src/handshake/extensions/extendedMasterSecret.js +1 -1
  19. package/lib/dtls/src/handshake/extensions/extendedMasterSecret.js.map +1 -1
  20. package/lib/dtls/src/handshake/extensions/renegotiationIndication.js +1 -1
  21. package/lib/dtls/src/handshake/extensions/renegotiationIndication.js.map +1 -1
  22. package/lib/dtls/src/handshake/extensions/signature.js +1 -1
  23. package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
  24. package/lib/dtls/src/handshake/extensions/useSrtp.js +1 -1
  25. package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
  26. package/lib/dtls/src/handshake/message/alert.js +1 -1
  27. package/lib/dtls/src/handshake/message/alert.js.map +1 -1
  28. package/lib/dtls/src/handshake/message/certificate.js +1 -1
  29. package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
  30. package/lib/dtls/src/handshake/message/changeCipherSpec.js +1 -1
  31. package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
  32. package/lib/dtls/src/handshake/message/client/certificateVerify.js +1 -1
  33. package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
  34. package/lib/dtls/src/handshake/message/client/hello.js +1 -1
  35. package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
  36. package/lib/dtls/src/handshake/message/client/keyExchange.js +1 -1
  37. package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
  38. package/lib/dtls/src/handshake/message/finished.js.map +1 -1
  39. package/lib/dtls/src/handshake/message/server/certificateRequest.js +1 -1
  40. package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
  41. package/lib/dtls/src/handshake/message/server/hello.js +1 -1
  42. package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
  43. package/lib/dtls/src/handshake/message/server/helloDone.js +1 -1
  44. package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
  45. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +1 -1
  46. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
  47. package/lib/dtls/src/handshake/message/server/keyExchange.js +1 -1
  48. package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
  49. package/lib/dtls/src/handshake/random.js +1 -1
  50. package/lib/dtls/src/handshake/random.js.map +1 -1
  51. package/lib/dtls/src/record/message/fragment.js +1 -1
  52. package/lib/dtls/src/record/message/fragment.js.map +1 -1
  53. package/lib/dtls/src/record/message/header.js +2 -2
  54. package/lib/dtls/src/record/message/header.js.map +1 -1
  55. package/lib/dtls/src/record/message/plaintext.js +1 -1
  56. package/lib/dtls/src/record/message/plaintext.js.map +1 -1
  57. package/lib/dtls/src/server.js.map +1 -1
  58. package/lib/dtls/src/socket.js.map +1 -1
  59. package/lib/dtls/src/transport.js.map +1 -1
  60. package/lib/ice/src/candidate.js.map +1 -1
  61. package/lib/ice/src/exceptions.js.map +1 -1
  62. package/lib/ice/src/helper.js.map +1 -1
  63. package/lib/ice/src/ice.js.map +1 -1
  64. package/lib/ice/src/stun/attributes.js.map +1 -1
  65. package/lib/ice/src/stun/message.js.map +1 -1
  66. package/lib/ice/src/stun/protocol.js.map +1 -1
  67. package/lib/ice/src/stun/transaction.js.map +1 -1
  68. package/lib/ice/src/transport.js.map +1 -1
  69. package/lib/ice/src/turn/protocol.js.map +1 -1
  70. package/lib/rtp/src/codec/av1.js +1 -1
  71. package/lib/rtp/src/codec/av1.js.map +1 -1
  72. package/lib/rtp/src/container/index.d.ts +2 -1
  73. package/lib/rtp/src/container/index.js +2 -1
  74. package/lib/rtp/src/container/index.js.map +1 -1
  75. package/lib/rtp/src/container/mp4/container.d.ts +66 -0
  76. package/lib/rtp/src/container/mp4/container.js +262 -0
  77. package/lib/rtp/src/container/mp4/container.js.map +1 -0
  78. package/lib/rtp/src/container/mp4/exp-golomb.d.ts +20 -0
  79. package/lib/rtp/src/container/mp4/exp-golomb.js +144 -0
  80. package/lib/rtp/src/container/mp4/exp-golomb.js.map +1 -0
  81. package/lib/rtp/src/container/mp4/h264.d.ts +42 -0
  82. package/lib/rtp/src/container/mp4/h264.js +240 -0
  83. package/lib/rtp/src/container/mp4/h264.js.map +1 -0
  84. package/lib/rtp/src/container/mp4/index.d.ts +2 -0
  85. package/lib/rtp/src/container/mp4/index.js +19 -0
  86. package/lib/rtp/src/container/mp4/index.js.map +1 -0
  87. package/lib/rtp/src/container/mp4/mp4box.d.ts +5 -0
  88. package/lib/rtp/src/container/mp4/mp4box.js +32 -0
  89. package/lib/rtp/src/container/mp4/mp4box.js.map +1 -0
  90. package/lib/rtp/src/container/mp4/sps-parser.d.ts +40 -0
  91. package/lib/rtp/src/container/mp4/sps-parser.js +291 -0
  92. package/lib/rtp/src/container/mp4/sps-parser.js.map +1 -0
  93. package/lib/rtp/src/container/ogg/index.d.ts +1 -0
  94. package/lib/rtp/src/container/ogg/index.js +18 -0
  95. package/lib/rtp/src/container/ogg/index.js.map +1 -0
  96. package/lib/rtp/src/container/ogg/parser.d.ts +12 -0
  97. package/lib/rtp/src/container/ogg/parser.js +100 -0
  98. package/lib/rtp/src/container/ogg/parser.js.map +1 -0
  99. package/lib/rtp/src/container/{webm.d.ts → webm/container.d.ts} +1 -1
  100. package/lib/rtp/src/container/{webm.js → webm/container.js} +6 -6
  101. package/lib/rtp/src/container/webm/container.js.map +1 -0
  102. package/lib/rtp/src/container/webm/ebml/ebml.js.map +1 -0
  103. package/lib/rtp/src/container/webm/ebml/id.js.map +1 -0
  104. package/lib/rtp/src/container/webm/ebml/index.js.map +1 -0
  105. package/lib/rtp/src/container/webm/ebml/typedArrayUtils.js.map +1 -0
  106. package/lib/rtp/src/container/webm/index.d.ts +2 -0
  107. package/lib/rtp/src/container/webm/index.js +19 -0
  108. package/lib/rtp/src/container/webm/index.js.map +1 -0
  109. package/lib/rtp/src/processor/depacketizer.js.map +1 -1
  110. package/lib/rtp/src/processor/dtx.d.ts +1 -1
  111. package/lib/rtp/src/processor/dtx.js.map +1 -1
  112. package/lib/rtp/src/processor/index.d.ts +2 -0
  113. package/lib/rtp/src/processor/index.js +2 -0
  114. package/lib/rtp/src/processor/index.js.map +1 -1
  115. package/lib/rtp/src/processor/jitterBuffer.js.map +1 -1
  116. package/lib/rtp/src/processor/jitterBufferTransformer.js.map +1 -1
  117. package/lib/rtp/src/processor/lipsync.js.map +1 -1
  118. package/lib/rtp/src/processor/lipsyncCallback.js.map +1 -1
  119. package/lib/rtp/src/processor/mp4.d.ts +50 -0
  120. package/lib/rtp/src/processor/mp4.js +162 -0
  121. package/lib/rtp/src/processor/mp4.js.map +1 -0
  122. package/lib/rtp/src/processor/mp4Callback.d.ts +12 -0
  123. package/lib/rtp/src/processor/mp4Callback.js +83 -0
  124. package/lib/rtp/src/processor/mp4Callback.js.map +1 -0
  125. package/lib/rtp/src/processor/mute.d.ts +1 -1
  126. package/lib/rtp/src/processor/mute.js +6 -3
  127. package/lib/rtp/src/processor/mute.js.map +1 -1
  128. package/lib/rtp/src/processor/muteCallback.js.map +1 -1
  129. package/lib/rtp/src/processor/nack.js +2 -3
  130. package/lib/rtp/src/processor/nack.js.map +1 -1
  131. package/lib/rtp/src/processor/ntpTime.d.ts +1 -1
  132. package/lib/rtp/src/processor/ntpTime.js.map +1 -1
  133. package/lib/rtp/src/processor/rtcpCallback.js.map +1 -1
  134. package/lib/rtp/src/processor/rtpCallback.js.map +1 -1
  135. package/lib/rtp/src/processor/rtpStream.js.map +1 -1
  136. package/lib/rtp/src/processor/rtpTime.js.map +1 -1
  137. package/lib/rtp/src/processor/webm.d.ts +1 -1
  138. package/lib/rtp/src/processor/webm.js +1 -1
  139. package/lib/rtp/src/processor/webm.js.map +1 -1
  140. package/lib/rtp/src/processor/webmCallback.d.ts +1 -1
  141. package/lib/rtp/src/processor/webmCallback.js.map +1 -1
  142. package/lib/rtp/src/processor/webmStream.d.ts +1 -1
  143. package/lib/rtp/src/processor/webmStream.js.map +1 -1
  144. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +1 -1
  145. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
  146. package/lib/rtp/src/rtcp/psfb/index.js +1 -1
  147. package/lib/rtp/src/rtcp/psfb/index.js.map +1 -1
  148. package/lib/rtp/src/rtcp/psfb/pictureLossIndication.js +1 -1
  149. package/lib/rtp/src/rtcp/psfb/pictureLossIndication.js.map +1 -1
  150. package/lib/rtp/src/rtcp/psfb/remb.js +1 -1
  151. package/lib/rtp/src/rtcp/psfb/remb.js.map +1 -1
  152. package/lib/rtp/src/rtcp/rr.js +3 -7
  153. package/lib/rtp/src/rtcp/rr.js.map +1 -1
  154. package/lib/rtp/src/rtcp/rtpfb/index.js +1 -1
  155. package/lib/rtp/src/rtcp/rtpfb/index.js.map +1 -1
  156. package/lib/rtp/src/rtcp/rtpfb/nack.js +6 -13
  157. package/lib/rtp/src/rtcp/rtpfb/nack.js.map +1 -1
  158. package/lib/rtp/src/rtcp/rtpfb/twcc.js +12 -8
  159. package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
  160. package/lib/rtp/src/rtcp/sdes.js +1 -1
  161. package/lib/rtp/src/rtcp/sdes.js.map +1 -1
  162. package/lib/rtp/src/rtcp/sr.js +2 -6
  163. package/lib/rtp/src/rtcp/sr.js.map +1 -1
  164. package/lib/rtp/src/rtp/headerExtension.d.ts +5 -0
  165. package/lib/rtp/src/rtp/headerExtension.js +35 -9
  166. package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
  167. package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
  168. package/lib/rtp/src/rtp/red/handler.js.map +1 -1
  169. package/lib/rtp/src/rtp/rtp.js.map +1 -1
  170. package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
  171. package/lib/rtp/src/srtp/cipher/gcm.js.map +1 -1
  172. package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
  173. package/lib/rtp/src/srtp/context/context.js.map +1 -1
  174. package/lib/rtp/src/srtp/session.js.map +1 -1
  175. package/lib/rtp/src/srtp/srtcp.js.map +1 -1
  176. package/lib/rtp/src/srtp/srtp.js.map +1 -1
  177. package/lib/rtp/src/util.js.map +1 -1
  178. package/lib/sctp/src/chunk.js +17 -17
  179. package/lib/sctp/src/chunk.js.map +1 -1
  180. package/lib/sctp/src/param.js +3 -3
  181. package/lib/sctp/src/param.js.map +1 -1
  182. package/lib/sctp/src/sctp.js.map +1 -1
  183. package/lib/sctp/src/transport.js.map +1 -1
  184. package/lib/webrtc/src/const.js.map +1 -1
  185. package/lib/webrtc/src/dataChannel.js.map +1 -1
  186. package/lib/webrtc/src/media/parameters.js.map +1 -1
  187. package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
  188. package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
  189. package/lib/webrtc/src/media/receiver/statistics.js.map +1 -1
  190. package/lib/webrtc/src/media/router.js.map +1 -1
  191. package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
  192. package/lib/webrtc/src/media/rtpSender.js.map +1 -1
  193. package/lib/webrtc/src/media/rtpTransceiver.d.ts +1 -1
  194. package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
  195. package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
  196. package/lib/webrtc/src/media/track.js.map +1 -1
  197. package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
  198. package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
  199. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
  200. package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
  201. package/lib/webrtc/src/peerConnection.js.map +1 -1
  202. package/lib/webrtc/src/sdp.js.map +1 -1
  203. package/lib/webrtc/src/transport/dtls.d.ts +1 -1
  204. package/lib/webrtc/src/transport/dtls.js.map +1 -1
  205. package/lib/webrtc/src/transport/ice.d.ts +2 -2
  206. package/lib/webrtc/src/transport/ice.js.map +1 -1
  207. package/lib/webrtc/src/transport/sctp.js.map +1 -1
  208. package/lib/webrtc/src/types/domain.d.ts +2 -2
  209. package/lib/webrtc/src/types/domain.js.map +1 -1
  210. package/lib/webrtc/src/utils.d.ts +1 -0
  211. package/lib/webrtc/src/utils.js +9 -1
  212. package/lib/webrtc/src/utils.js.map +1 -1
  213. package/package.json +5 -3
  214. package/src/const.ts +1 -1
  215. package/src/dataChannel.ts +3 -3
  216. package/src/media/parameters.ts +3 -3
  217. package/src/media/receiver/nack.ts +7 -4
  218. package/src/media/receiver/receiverTwcc.ts +5 -5
  219. package/src/media/receiver/statistics.ts +1 -1
  220. package/src/media/router.ts +5 -5
  221. package/src/media/rtpReceiver.ts +9 -9
  222. package/src/media/rtpSender.ts +8 -8
  223. package/src/media/rtpTransceiver.ts +3 -3
  224. package/src/media/sender/senderBWE.ts +2 -2
  225. package/src/media/track.ts +1 -1
  226. package/src/nonstandard/recorder/index.ts +1 -1
  227. package/src/nonstandard/recorder/writer/index.ts +1 -1
  228. package/src/nonstandard/recorder/writer/webm.ts +2 -2
  229. package/src/nonstandard/userMedia.ts +1 -1
  230. package/src/peerConnection.ts +52 -52
  231. package/src/sdp.ts +27 -21
  232. package/src/transport/dtls.ts +13 -10
  233. package/src/transport/ice.ts +6 -6
  234. package/src/transport/sctp.ts +4 -4
  235. package/src/types/domain.ts +2 -2
  236. package/src/utils.ts +11 -2
  237. package/lib/common/src/array.d.ts +0 -1
  238. package/lib/common/src/array.js +0 -15
  239. package/lib/common/src/array.js.map +0 -1
  240. package/lib/rtp/src/container/ebml/ebml.js.map +0 -1
  241. package/lib/rtp/src/container/ebml/id.js.map +0 -1
  242. package/lib/rtp/src/container/ebml/index.js.map +0 -1
  243. package/lib/rtp/src/container/ebml/typedArrayUtils.js.map +0 -1
  244. package/lib/rtp/src/container/webm.js.map +0 -1
  245. /package/lib/rtp/src/container/{ebml → webm/ebml}/ebml.d.ts +0 -0
  246. /package/lib/rtp/src/container/{ebml → webm/ebml}/ebml.js +0 -0
  247. /package/lib/rtp/src/container/{ebml → webm/ebml}/id.d.ts +0 -0
  248. /package/lib/rtp/src/container/{ebml → webm/ebml}/id.js +0 -0
  249. /package/lib/rtp/src/container/{ebml → webm/ebml}/index.d.ts +0 -0
  250. /package/lib/rtp/src/container/{ebml → webm/ebml}/index.js +0 -0
  251. /package/lib/rtp/src/container/{ebml → webm/ebml}/typedArrayUtils.d.ts +0 -0
  252. /package/lib/rtp/src/container/{ebml → webm/ebml}/typedArrayUtils.js +0 -0
@@ -196,7 +196,7 @@ export class RTCPeerConnection extends EventTarget {
196
196
  const { keys } = this.config.dtls;
197
197
  if (keys) {
198
198
  this.certificates.push(
199
- new RTCCertificate(keys.keyPem, keys.certPem, keys.signatureHash)
199
+ new RTCCertificate(keys.keyPem, keys.certPem, keys.signatureHash),
200
200
  );
201
201
  }
202
202
  }
@@ -237,7 +237,7 @@ export class RTCPeerConnection extends EventTarget {
237
237
 
238
238
  private getTransceiverByMLineIndex(index: number) {
239
239
  return this.transceivers.find(
240
- (transceiver) => transceiver.mLineIndex === index
240
+ (transceiver) => transceiver.mLineIndex === index,
241
241
  );
242
242
  }
243
243
 
@@ -307,7 +307,7 @@ export class RTCPeerConnection extends EventTarget {
307
307
  }
308
308
  this.sctpTransport.mLineIndex = i;
309
309
  description.media.push(
310
- createMediaDescriptionForSctp(this.sctpTransport)
310
+ createMediaDescriptionForSctp(this.sctpTransport),
311
311
  );
312
312
  } else {
313
313
  const transceiver = this.getTransceiverByMid(mid);
@@ -323,8 +323,8 @@ export class RTCPeerConnection extends EventTarget {
323
323
  createMediaDescriptionForTransceiver(
324
324
  transceiver,
325
325
  this.cname,
326
- transceiver.direction
327
- )
326
+ transceiver.direction,
327
+ ),
328
328
  );
329
329
  }
330
330
  });
@@ -336,13 +336,13 @@ export class RTCPeerConnection extends EventTarget {
336
336
  if (transceiver.mid == undefined) {
337
337
  transceiver.mid = allocateMid(
338
338
  this.seenMid,
339
- this.config.midSuffix ? "av" : ""
339
+ this.config.midSuffix ? "av" : "",
340
340
  );
341
341
  }
342
342
  const mediaDescription = createMediaDescriptionForTransceiver(
343
343
  transceiver,
344
344
  this.cname,
345
- transceiver.direction
345
+ transceiver.direction,
346
346
  );
347
347
  if (transceiver.mLineIndex === undefined) {
348
348
  transceiver.mLineIndex = description.media.length;
@@ -360,7 +360,7 @@ export class RTCPeerConnection extends EventTarget {
360
360
  if (this.sctpTransport.mid == undefined) {
361
361
  this.sctpTransport.mid = allocateMid(
362
362
  this.seenMid,
363
- this.config.midSuffix ? "dc" : ""
363
+ this.config.midSuffix ? "dc" : "",
364
364
  );
365
365
  }
366
366
  description.media.push(createMediaDescriptionForSctp(this.sctpTransport));
@@ -388,7 +388,7 @@ export class RTCPeerConnection extends EventTarget {
388
388
  ordered: boolean;
389
389
  negotiated: boolean;
390
390
  id?: number;
391
- }> = {}
391
+ }> = {},
392
392
  ): RTCDataChannel {
393
393
  const base: typeof options = {
394
394
  protocol: "",
@@ -427,7 +427,7 @@ export class RTCPeerConnection extends EventTarget {
427
427
  }
428
428
 
429
429
  const transceiver = this.transceivers.find(
430
- ({ sender: { ssrc } }) => sender.ssrc === ssrc
430
+ ({ sender: { ssrc } }) => sender.ssrc === ssrc,
431
431
  );
432
432
  if (!transceiver) throw new Error("unExist");
433
433
 
@@ -510,7 +510,7 @@ export class RTCPeerConnection extends EventTarget {
510
510
  }
511
511
  } else {
512
512
  const transceiver = this.transceivers.find(
513
- (t) => t.dtlsTransport.iceTransport.id === iceTransport.id
513
+ (t) => t.dtlsTransport.iceTransport.id === iceTransport.id,
514
514
  );
515
515
  if (transceiver) {
516
516
  candidate.sdpMLineIndex = transceiver.mLineIndex;
@@ -548,7 +548,7 @@ export class RTCPeerConnection extends EventTarget {
548
548
  iceTransport,
549
549
  this.router,
550
550
  this.certificates,
551
- srtpProfiles
551
+ srtpProfiles,
552
552
  );
553
553
 
554
554
  return dtlsTransport;
@@ -655,7 +655,7 @@ export class RTCPeerConnection extends EventTarget {
655
655
 
656
656
  // # gather candidates
657
657
  const connected = this.iceTransports.find(
658
- (transport) => transport.state === "connected"
658
+ (transport) => transport.state === "connected",
659
659
  );
660
660
  if (this.remoteIsBundled && connected) {
661
661
  // no need to gather ice candidates on an existing bundled connection
@@ -663,8 +663,8 @@ export class RTCPeerConnection extends EventTarget {
663
663
  } else {
664
664
  await Promise.allSettled(
665
665
  this.iceTransports.map((iceTransport) =>
666
- iceTransport.iceGather.gather()
667
- )
666
+ iceTransport.iceGather.gather(),
667
+ ),
668
668
  );
669
669
  }
670
670
 
@@ -775,7 +775,7 @@ export class RTCPeerConnection extends EventTarget {
775
775
  await this.sctpTransport.sctp.stateChanged.connected.asPromise();
776
776
  log("sctp connected");
777
777
  }
778
- })
778
+ }),
779
779
  );
780
780
 
781
781
  this.transportEstablished = true;
@@ -796,7 +796,7 @@ export class RTCPeerConnection extends EventTarget {
796
796
 
797
797
  private getRemoteRtpParams(
798
798
  media: MediaDescription,
799
- transceiver: RTCRtpTransceiver
799
+ transceiver: RTCRtpTransceiver,
800
800
  ): RTCRtpReceiveParameters {
801
801
  const receiveParameters: RTCRtpReceiveParameters = {
802
802
  muxId: media.rtp.muxId,
@@ -820,8 +820,8 @@ export class RTCPeerConnection extends EventTarget {
820
820
  });
821
821
  return acc;
822
822
  },
823
- {}
824
- )
823
+ {},
824
+ ),
825
825
  ),
826
826
  };
827
827
 
@@ -832,7 +832,7 @@ export class RTCPeerConnection extends EventTarget {
832
832
  const remoteSdp = this._remoteDescription;
833
833
  if (!remoteSdp) return;
834
834
  const bundle = remoteSdp.group.find(
835
- (g) => g.semantic === "BUNDLE" && this.config.bundlePolicy !== "disable"
835
+ (g) => g.semantic === "BUNDLE" && this.config.bundlePolicy !== "disable",
836
836
  );
837
837
  return bundle;
838
838
  }
@@ -865,7 +865,7 @@ export class RTCPeerConnection extends EventTarget {
865
865
 
866
866
  const matchTransceiverWithMedia = (
867
867
  transceiver: RTCRtpTransceiver,
868
- media: MediaDescription
868
+ media: MediaDescription,
869
869
  ) =>
870
870
  transceiver.kind === media.kind &&
871
871
  [undefined, media.rtp.muxId].includes(transceiver.mid);
@@ -875,7 +875,7 @@ export class RTCPeerConnection extends EventTarget {
875
875
 
876
876
  if (["audio", "video"].includes(remoteMedia.kind)) {
877
877
  let transceiver = this.transceivers.find((t) =>
878
- matchTransceiverWithMedia(t, remoteMedia)
878
+ matchTransceiverWithMedia(t, remoteMedia),
879
879
  );
880
880
  if (!transceiver) {
881
881
  // create remote transceiver
@@ -961,7 +961,7 @@ export class RTCPeerConnection extends EventTarget {
961
961
  const removedTransceivers = this.transceivers.filter(
962
962
  (t) =>
963
963
  remoteSdp.media.find((m) => matchTransceiverWithMedia(t, m)) ==
964
- undefined
964
+ undefined,
965
965
  );
966
966
 
967
967
  if (sessionDescription.type === "answer") {
@@ -989,14 +989,14 @@ export class RTCPeerConnection extends EventTarget {
989
989
  }
990
990
 
991
991
  const connected = this.iceTransports.find(
992
- (transport) => transport.state === "connected"
992
+ (transport) => transport.state === "connected",
993
993
  );
994
994
  if (this.remoteIsBundled && connected) {
995
995
  // no need to gather ice candidates on an existing bundled connection
996
996
  await connected.iceGather.gather();
997
997
  } else {
998
998
  await Promise.allSettled(
999
- transports.map((iceTransport) => iceTransport.iceGather.gather())
999
+ transports.map((iceTransport) => iceTransport.iceGather.gather()),
1000
1000
  );
1001
1001
  }
1002
1002
 
@@ -1010,7 +1010,7 @@ export class RTCPeerConnection extends EventTarget {
1010
1010
  transceiver: RTCRtpTransceiver,
1011
1011
  remoteMedia: MediaDescription,
1012
1012
  type: "offer" | "answer",
1013
- mLineIndex: number
1013
+ mLineIndex: number,
1014
1014
  ) {
1015
1015
  if (!transceiver.mid) {
1016
1016
  transceiver.mid = remoteMedia.rtp.muxId;
@@ -1042,8 +1042,8 @@ export class RTCPeerConnection extends EventTarget {
1042
1042
  transceiver.headerExtensions = remoteMedia.rtp.headerExtensions.filter(
1043
1043
  (extension) =>
1044
1044
  (this.config.headerExtensions[remoteMedia.kind as Media] || []).find(
1045
- (v) => v.uri === extension.uri
1046
- )
1045
+ (v) => v.uri === extension.uri,
1046
+ ),
1047
1047
  );
1048
1048
 
1049
1049
  // # configure direction
@@ -1082,7 +1082,7 @@ export class RTCPeerConnection extends EventTarget {
1082
1082
  new MediaStream({
1083
1083
  id: streamId,
1084
1084
  tracks: [transceiver.receiver.track],
1085
- })
1085
+ }),
1086
1086
  );
1087
1087
  }
1088
1088
  }
@@ -1095,7 +1095,7 @@ export class RTCPeerConnection extends EventTarget {
1095
1095
  private setRemoteSCTP(
1096
1096
  remoteMedia: MediaDescription,
1097
1097
  sctpTransport: RTCSctpTransport,
1098
- mLineIndex: number
1098
+ mLineIndex: number,
1099
1099
  ) {
1100
1100
  // # configure sctp
1101
1101
  this.sctpRemotePort = remoteMedia.sctpPort;
@@ -1112,7 +1112,7 @@ export class RTCPeerConnection extends EventTarget {
1112
1112
 
1113
1113
  private validateDescription(
1114
1114
  description: SessionDescription,
1115
- isLocal: boolean
1115
+ isLocal: boolean,
1116
1116
  ) {
1117
1117
  if (isLocal) {
1118
1118
  if (description.type === "offer") {
@@ -1121,7 +1121,7 @@ export class RTCPeerConnection extends EventTarget {
1121
1121
  } else if (description.type === "answer") {
1122
1122
  if (
1123
1123
  !["have-remote-offer", "have-local-pranswer"].includes(
1124
- this.signalingState
1124
+ this.signalingState,
1125
1125
  )
1126
1126
  ) {
1127
1127
  throw new Error("Cannot handle answer in signaling state");
@@ -1135,7 +1135,7 @@ export class RTCPeerConnection extends EventTarget {
1135
1135
  } else if (description.type === "answer") {
1136
1136
  if (
1137
1137
  !["have-local-offer", "have-remote-pranswer"].includes(
1138
- this.signalingState
1138
+ this.signalingState,
1139
1139
  )
1140
1140
  ) {
1141
1141
  throw new Error("Cannot handle answer in signaling state");
@@ -1168,7 +1168,7 @@ export class RTCPeerConnection extends EventTarget {
1168
1168
  private fireOnTrack(
1169
1169
  track: MediaStreamTrack,
1170
1170
  transceiver: RTCRtpTransceiver,
1171
- stream: MediaStream
1171
+ stream: MediaStream,
1172
1172
  ) {
1173
1173
  const event: RTCTrackEvent = {
1174
1174
  track,
@@ -1183,14 +1183,14 @@ export class RTCPeerConnection extends EventTarget {
1183
1183
 
1184
1184
  addTransceiver(
1185
1185
  trackOrKind: Kind | MediaStreamTrack,
1186
- options: Partial<TransceiverOptions> = {}
1186
+ options: Partial<TransceiverOptions> = {},
1187
1187
  ) {
1188
1188
  return this._addTransceiver(trackOrKind, options);
1189
1189
  }
1190
1190
 
1191
1191
  private _addTransceiver(
1192
1192
  trackOrKind: Kind | MediaStreamTrack,
1193
- options: Partial<TransceiverOptions> = {}
1193
+ options: Partial<TransceiverOptions> = {},
1194
1194
  ) {
1195
1195
  const kind =
1196
1196
  typeof trackOrKind === "string" ? trackOrKind : trackOrKind.kind;
@@ -1209,17 +1209,17 @@ export class RTCPeerConnection extends EventTarget {
1209
1209
  dtlsTransport,
1210
1210
  receiver,
1211
1211
  sender,
1212
- direction
1212
+ direction,
1213
1213
  );
1214
1214
  newTransceiver.options = options;
1215
1215
  this.router.registerRtpSender(newTransceiver.sender);
1216
1216
 
1217
1217
  // reuse inactive
1218
1218
  const inactiveTransceiverIndex = this.transceivers.findIndex(
1219
- (t) => t.currentDirection === "inactive"
1219
+ (t) => t.currentDirection === "inactive",
1220
1220
  );
1221
1221
  const inactiveTransceiver = this.transceivers.find(
1222
- (t) => t.currentDirection === "inactive"
1222
+ (t) => t.currentDirection === "inactive",
1223
1223
  );
1224
1224
  if (inactiveTransceiverIndex > -1 && inactiveTransceiver) {
1225
1225
  this.replaceTransceiver(newTransceiver, inactiveTransceiverIndex);
@@ -1252,7 +1252,7 @@ export class RTCPeerConnection extends EventTarget {
1252
1252
  addTrack(
1253
1253
  track: MediaStreamTrack,
1254
1254
  /**todo impl */
1255
- ms?: MediaStream
1255
+ ms?: MediaStream,
1256
1256
  ) {
1257
1257
  if (this.isClosed) throw new Error("is closed");
1258
1258
  if (this.getSenders().find((sender) => sender.track?.uuid === track.uuid)) {
@@ -1263,7 +1263,7 @@ export class RTCPeerConnection extends EventTarget {
1263
1263
  (t) =>
1264
1264
  t.sender.track == undefined &&
1265
1265
  t.kind === track.kind &&
1266
- SenderDirections.includes(t.direction) === true
1266
+ SenderDirections.includes(t.direction) === true,
1267
1267
  );
1268
1268
  if (emptyTrackSender) {
1269
1269
  const sender = emptyTrackSender.sender;
@@ -1277,7 +1277,7 @@ export class RTCPeerConnection extends EventTarget {
1277
1277
  t.sender.track == undefined &&
1278
1278
  t.kind === track.kind &&
1279
1279
  SenderDirections.includes(t.direction) === false &&
1280
- !t.usedForSender
1280
+ !t.usedForSender,
1281
1281
  );
1282
1282
  if (notSendTransceiver) {
1283
1283
  const sender = notSendTransceiver.sender;
@@ -1326,7 +1326,7 @@ export class RTCPeerConnection extends EventTarget {
1326
1326
  this.assertNotClosed();
1327
1327
  if (
1328
1328
  !["have-remote-offer", "have-local-pranswer"].includes(
1329
- this.signalingState
1329
+ this.signalingState,
1330
1330
  )
1331
1331
  ) {
1332
1332
  throw new Error("createAnswer failed");
@@ -1347,7 +1347,7 @@ export class RTCPeerConnection extends EventTarget {
1347
1347
  media = createMediaDescriptionForTransceiver(
1348
1348
  transceiver,
1349
1349
  this.cname,
1350
- andDirection(transceiver.direction, transceiver.offerDirection)
1350
+ andDirection(transceiver.direction, transceiver.offerDirection),
1351
1351
  );
1352
1352
  dtlsTransport = transceiver.dtlsTransport;
1353
1353
  } else if (remoteMedia.kind === "application") {
@@ -1525,13 +1525,13 @@ export class RTCPeerConnection extends EventTarget {
1525
1525
  export function createMediaDescriptionForTransceiver(
1526
1526
  transceiver: RTCRtpTransceiver,
1527
1527
  cname: string,
1528
- direction: Direction
1528
+ direction: Direction,
1529
1529
  ) {
1530
1530
  const media = new MediaDescription(
1531
1531
  transceiver.kind,
1532
1532
  9,
1533
1533
  "UDP/TLS/RTP/SAVPF",
1534
- transceiver.codecs.map((c) => c.payloadType)
1534
+ transceiver.codecs.map((c) => c.payloadType),
1535
1535
  );
1536
1536
  media.direction = direction;
1537
1537
  media.msid = transceiver.msid;
@@ -1547,13 +1547,13 @@ export function createMediaDescriptionForTransceiver(
1547
1547
 
1548
1548
  if (transceiver.options.simulcast) {
1549
1549
  media.simulcastParameters = transceiver.options.simulcast.map(
1550
- (o) => new RTCRtpSimulcastParameters(o)
1550
+ (o) => new RTCRtpSimulcastParameters(o),
1551
1551
  );
1552
1552
  }
1553
1553
 
1554
1554
  if (media.rtp.codecs.find((c) => c.name.toLowerCase() === "rtx")) {
1555
1555
  media.ssrc.push(
1556
- new SsrcDescription({ ssrc: transceiver.sender.rtxSsrc, cname })
1556
+ new SsrcDescription({ ssrc: transceiver.sender.rtxSsrc, cname }),
1557
1557
  );
1558
1558
  media.ssrcGroup = [
1559
1559
  new GroupDescription("FID", [
@@ -1572,7 +1572,7 @@ export function createMediaDescriptionForSctp(sctp: RTCSctpTransport) {
1572
1572
  "application",
1573
1573
  DISCARD_PORT,
1574
1574
  "UDP/DTLS/SCTP",
1575
- ["webrtc-datachannel"]
1575
+ ["webrtc-datachannel"],
1576
1576
  );
1577
1577
  media.sctpPort = sctp.port;
1578
1578
  media.rtp.muxId = sctp.mid;
@@ -1584,7 +1584,7 @@ export function createMediaDescriptionForSctp(sctp: RTCSctpTransport) {
1584
1584
 
1585
1585
  export function addTransportDescription(
1586
1586
  media: MediaDescription,
1587
- dtlsTransport: RTCDtlsTransport
1587
+ dtlsTransport: RTCDtlsTransport,
1588
1588
  ) {
1589
1589
  const iceTransport = dtlsTransport.iceTransport;
1590
1590
  const iceGatherer = iceTransport.iceGather;
@@ -1674,11 +1674,11 @@ export interface PeerConfig {
1674
1674
 
1675
1675
  export const findCodecByMimeType = (
1676
1676
  codecs: RTCRtpCodecParameters[],
1677
- target: RTCRtpCodecParameters
1677
+ target: RTCRtpCodecParameters,
1678
1678
  ) =>
1679
1679
  codecs.find(
1680
1680
  (localCodec) =>
1681
- localCodec.mimeType.toLowerCase() === target.mimeType.toLowerCase()
1681
+ localCodec.mimeType.toLowerCase() === target.mimeType.toLowerCase(),
1682
1682
  )
1683
1683
  ? target
1684
1684
  : undefined;
package/src/sdp.ts CHANGED
@@ -66,7 +66,7 @@ export class SessionDescription {
66
66
  case "fingerprint":
67
67
  const [algorithm, fingerprint] = value?.split(" ") || [];
68
68
  session.dtlsFingerprints.push(
69
- new RTCDtlsFingerprint(algorithm, fingerprint)
69
+ new RTCDtlsFingerprint(algorithm, fingerprint),
70
70
  );
71
71
  break;
72
72
  case "ice-lite":
@@ -117,11 +117,11 @@ export class SessionDescription {
117
117
  kind,
118
118
  parseInt(m[2]),
119
119
  m[3],
120
- fmtInt || fmt
120
+ fmtInt || fmt,
121
121
  );
122
122
  currentMedia.dtlsParams = new RTCDtlsParameters(
123
123
  [...session.dtlsFingerprints],
124
- session.dtlsRole
124
+ session.dtlsRole,
125
125
  );
126
126
 
127
127
  currentMedia.iceParams = new RTCIceParameters({
@@ -157,14 +157,14 @@ export class SessionDescription {
157
157
  new RTCRtpHeaderExtensionParameters({
158
158
  id: parseInt(extId),
159
159
  uri: extUri,
160
- })
160
+ }),
161
161
  );
162
162
  break;
163
163
  case "fingerprint":
164
164
  if (!value) throw new Error();
165
165
  const [algorithm, fingerprint] = value.split(" ");
166
166
  currentMedia.dtlsParams?.fingerprints.push(
167
- new RTCDtlsFingerprint(algorithm, fingerprint)
167
+ new RTCDtlsFingerprint(algorithm, fingerprint),
168
168
  );
169
169
  break;
170
170
  case "ice-options":
@@ -181,7 +181,7 @@ export class SessionDescription {
181
181
  break;
182
182
  case "max-message-size":
183
183
  currentMedia.sctpCapabilities = new RTCSctpCapabilities(
184
- parseInt(value, 10)
184
+ parseInt(value, 10),
185
185
  );
186
186
  break;
187
187
  case "mid":
@@ -258,7 +258,7 @@ export class SessionDescription {
258
258
  new RTCRtpSimulcastParameters({
259
259
  rid,
260
260
  direction: direction as any,
261
- })
261
+ }),
262
262
  );
263
263
  }
264
264
  break;
@@ -314,7 +314,7 @@ export class SessionDescription {
314
314
  new RTCRtcpFeedback({
315
315
  type: feedbackType,
316
316
  parameter: feedbackParam,
317
- })
317
+ }),
318
318
  );
319
319
  }
320
320
  });
@@ -352,7 +352,7 @@ export class SessionDescription {
352
352
  lines.push(`a=extmap-allow-mixed`);
353
353
  }
354
354
  this.msidSemantic.forEach((group) =>
355
- lines.push(`a=msid-semantic:${group.str}`)
355
+ lines.push(`a=msid-semantic:${group.str}`),
356
356
  );
357
357
  const media = this.media.map((m) => m.toString()).join("");
358
358
  const sdp = lines.join("\r\n") + "\r\n" + media;
@@ -403,7 +403,7 @@ export class MediaDescription {
403
403
  public kind: Kind,
404
404
  public port: number,
405
405
  public profile: string,
406
- public fmt: string[] | number[]
406
+ public fmt: string[] | number[],
407
407
  ) {}
408
408
 
409
409
  toString() {
@@ -411,7 +411,7 @@ export class MediaDescription {
411
411
  lines.push(
412
412
  `m=${this.kind} ${this.port} ${this.profile} ${(this.fmt as number[])
413
413
  .map((v) => v.toString())
414
- .join(" ")}`
414
+ .join(" ")}`,
415
415
  );
416
416
  if (this.host) {
417
417
  lines.push(`c=${ipAddressToSdp(this.host)}`);
@@ -440,7 +440,7 @@ export class MediaDescription {
440
440
  if (this.dtlsParams) {
441
441
  this.dtlsParams.fingerprints.forEach((fingerprint) => {
442
442
  lines.push(
443
- `a=fingerprint:${fingerprint.algorithm} ${fingerprint.value}`
443
+ `a=fingerprint:${fingerprint.algorithm} ${fingerprint.value}`,
444
444
  );
445
445
  });
446
446
  lines.push(`a=setup:${DTLS_ROLE_SETUP[this.dtlsParams.role]}`);
@@ -502,7 +502,7 @@ export class MediaDescription {
502
502
 
503
503
  // rtp extension
504
504
  this.rtp.headerExtensions.forEach((extension) =>
505
- lines.push(`a=extmap:${extension.id} ${extension.uri}`)
505
+ lines.push(`a=extmap:${extension.id} ${extension.uri}`),
506
506
  );
507
507
 
508
508
  // simulcast
@@ -512,13 +512,13 @@ export class MediaDescription {
512
512
  });
513
513
  let line = `a=simulcast:`;
514
514
  const recv = this.simulcastParameters.filter(
515
- (v) => v.direction === "recv"
515
+ (v) => v.direction === "recv",
516
516
  );
517
517
  if (recv.length) {
518
518
  line += `recv ${recv.map((v) => v.rid).join(";")} `;
519
519
  }
520
520
  const send = this.simulcastParameters.filter(
521
- (v) => v.direction === "send"
521
+ (v) => v.direction === "send",
522
522
  );
523
523
  if (send.length) {
524
524
  line += `send ${send.map((v) => v.rid).join(";")}`;
@@ -532,7 +532,10 @@ export class MediaDescription {
532
532
  }
533
533
 
534
534
  export class GroupDescription {
535
- constructor(public semantic: string, public items: string[]) {}
535
+ constructor(
536
+ public semantic: string,
537
+ public items: string[],
538
+ ) {}
536
539
 
537
540
  get str() {
538
541
  return `${this.semantic} ${this.items.join(" ")}`;
@@ -598,7 +601,7 @@ function parseAttr(line: string): [string, string] {
598
601
  export function parseGroup(
599
602
  dest: GroupDescription[],
600
603
  value: string,
601
- type: (v: string) => any = (v) => v.toString()
604
+ type: (v: string) => any = (v) => v.toString(),
602
605
  ) {
603
606
  const bits = value.split(" ");
604
607
  if (bits.length > 0) {
@@ -619,7 +622,7 @@ export function candidateFromSdp(sdp: string) {
619
622
  parseInt(bits[5], 10),
620
623
  parseInt(bits[3], 10),
621
624
  bits[2],
622
- bits[7]
625
+ bits[7],
623
626
  );
624
627
 
625
628
  range(8, bits.length - 1, 2).forEach((i) => {
@@ -640,7 +643,10 @@ export function candidateFromSdp(sdp: string) {
640
643
  }
641
644
 
642
645
  export class RTCSessionDescription {
643
- constructor(public sdp: string, public type: "offer" | "answer") {}
646
+ constructor(
647
+ public sdp: string,
648
+ public type: "offer" | "answer",
649
+ ) {}
644
650
  static isThis(o: any) {
645
651
  if (typeof o?.sdp === "string") return true;
646
652
  }
@@ -648,7 +654,7 @@ export class RTCSessionDescription {
648
654
 
649
655
  export function addSDPHeader(
650
656
  type: "offer" | "answer",
651
- description: SessionDescription
657
+ description: SessionDescription,
652
658
  ) {
653
659
  const username = "-";
654
660
  const sessionId = new Uint64BE(randomBytes(64)).toString().slice(0, 8);
@@ -683,7 +689,7 @@ export function codecParametersToString(
683
689
  parameters: {
684
690
  [key: string]: string | number;
685
691
  },
686
- joint: string = "="
692
+ joint: string = "=",
687
693
  ) {
688
694
  const params = Object.entries(parameters).map(([k, v]) => {
689
695
  if (v) return `${k}${joint}${v}`;
@@ -59,7 +59,7 @@ export class RTCDtlsTransport {
59
59
  readonly iceTransport: RTCIceTransport,
60
60
  readonly router: RtpRouter,
61
61
  readonly certificates: RTCCertificate[],
62
- private readonly srtpProfiles: Profile[] = []
62
+ private readonly srtpProfiles: Profile[] = [],
63
63
  ) {
64
64
  this.localCertificate = this.certificates[0];
65
65
  }
@@ -67,7 +67,7 @@ export class RTCDtlsTransport {
67
67
  get localParameters() {
68
68
  return new RTCDtlsParameters(
69
69
  this.localCertificate ? this.localCertificate.getFingerprints() : [],
70
- this.role
70
+ this.role,
71
71
  );
72
72
  }
73
73
 
@@ -79,12 +79,12 @@ export class RTCDtlsTransport {
79
79
  signature: SignatureAlgorithm.ecdsa_3,
80
80
  hash: HashAlgorithm.sha256_4,
81
81
  },
82
- NamedCurveAlgorithm.secp256r1_23
82
+ NamedCurveAlgorithm.secp256r1_23,
83
83
  );
84
84
  this.localCertificate = new RTCCertificate(
85
85
  keyPem,
86
86
  certPem,
87
- signatureHash
87
+ signatureHash,
88
88
  );
89
89
  }
90
90
  return this.localCertificate;
@@ -291,7 +291,7 @@ export const DtlsStates = [
291
291
  "closed",
292
292
  "failed",
293
293
  ] as const;
294
- export type DtlsState = typeof DtlsStates[number];
294
+ export type DtlsState = (typeof DtlsStates)[number];
295
295
 
296
296
  export type DtlsRole = "auto" | "server" | "client";
297
297
 
@@ -302,7 +302,7 @@ export class RTCCertificate {
302
302
  constructor(
303
303
  privateKeyPem: string,
304
304
  public certPem: string,
305
- public signatureHash: SignatureHash
305
+ public signatureHash: SignatureHash,
306
306
  ) {
307
307
  const cert = Certificate.fromPEM(Buffer.from(certPem));
308
308
  this.publicKey = cert.publicKey.toPEM();
@@ -315,8 +315,8 @@ export class RTCCertificate {
315
315
  "sha-256",
316
316
  fingerprint(
317
317
  Certificate.fromPEM(Buffer.from(this.certPem)).raw,
318
- "sha256"
319
- )
318
+ "sha256",
319
+ ),
320
320
  ),
321
321
  ];
322
322
  }
@@ -329,13 +329,16 @@ export type DtlsKeys = {
329
329
  };
330
330
 
331
331
  export class RTCDtlsFingerprint {
332
- constructor(public algorithm: string, public value: string) {}
332
+ constructor(
333
+ public algorithm: string,
334
+ public value: string,
335
+ ) {}
333
336
  }
334
337
 
335
338
  export class RTCDtlsParameters {
336
339
  constructor(
337
340
  public fingerprints: RTCDtlsFingerprint[] = [],
338
- public role: "auto" | "client" | "server"
341
+ public role: "auto" | "client" | "server",
339
342
  ) {}
340
343
  }
341
344