werift 0.18.0 → 0.18.2

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 (78) hide show
  1. package/lib/ice/src/ice.js +58 -37
  2. package/lib/ice/src/ice.js.map +1 -1
  3. package/lib/ice/src/index.d.ts +3 -3
  4. package/lib/ice/src/index.js +3 -5
  5. package/lib/ice/src/index.js.map +1 -1
  6. package/lib/ice/src/utils.d.ts +1 -1
  7. package/lib/ice/src/utils.js +3 -0
  8. package/lib/ice/src/utils.js.map +1 -1
  9. package/lib/rtp/src/index.d.ts +1 -0
  10. package/lib/rtp/src/index.js +1 -0
  11. package/lib/rtp/src/index.js.map +1 -1
  12. package/lib/rtp/src/processor/depacketizer.d.ts +8 -3
  13. package/lib/rtp/src/processor/depacketizer.js +18 -1
  14. package/lib/rtp/src/processor/depacketizer.js.map +1 -1
  15. package/lib/rtp/src/processor/depacketizerCallback.d.ts +2 -6
  16. package/lib/rtp/src/processor/depacketizerCallback.js.map +1 -1
  17. package/lib/rtp/src/processor/depacketizerTransformer.d.ts +2 -6
  18. package/lib/rtp/src/processor/depacketizerTransformer.js.map +1 -1
  19. package/lib/rtp/src/processor/index.d.ts +4 -0
  20. package/lib/rtp/src/processor/index.js +4 -0
  21. package/lib/rtp/src/processor/index.js.map +1 -1
  22. package/lib/rtp/src/processor/nack.d.ts +29 -0
  23. package/lib/rtp/src/processor/nack.js +183 -0
  24. package/lib/rtp/src/processor/nack.js.map +1 -0
  25. package/lib/rtp/src/processor/nackHandlerCallback.d.ts +8 -0
  26. package/lib/rtp/src/processor/nackHandlerCallback.js +36 -0
  27. package/lib/rtp/src/processor/nackHandlerCallback.js.map +1 -0
  28. package/lib/rtp/src/processor/ntpTime.js +2 -1
  29. package/lib/rtp/src/processor/ntpTime.js.map +1 -1
  30. package/lib/rtp/src/processor/rtpTime.d.ts +22 -0
  31. package/lib/rtp/src/processor/rtpTime.js +51 -0
  32. package/lib/rtp/src/processor/rtpTime.js.map +1 -0
  33. package/lib/rtp/src/processor/rtpTimeCallback.d.ts +7 -0
  34. package/lib/rtp/src/processor/rtpTimeCallback.js +36 -0
  35. package/lib/rtp/src/processor/rtpTimeCallback.js.map +1 -0
  36. package/lib/rtp/src/processor/source/rtcpCallback.d.ts +2 -1
  37. package/lib/rtp/src/processor/source/rtcpCallback.js +11 -0
  38. package/lib/rtp/src/processor/source/rtcpCallback.js.map +1 -1
  39. package/lib/rtp/src/processor/source/rtpCallback.d.ts +2 -0
  40. package/lib/rtp/src/processor/source/rtpCallback.js +11 -0
  41. package/lib/rtp/src/processor/source/rtpCallback.js.map +1 -1
  42. package/lib/rtp/src/processor/webm.d.ts +8 -3
  43. package/lib/rtp/src/processor/webm.js +67 -10
  44. package/lib/rtp/src/processor/webm.js.map +1 -1
  45. package/lib/rtp/src/processor/webmCallback.js +2 -0
  46. package/lib/rtp/src/processor/webmCallback.js.map +1 -1
  47. package/lib/rtp/src/rtcp/rtcp.d.ts +1 -0
  48. package/lib/rtp/src/rtcp/rtcp.js +5 -1
  49. package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
  50. package/lib/rtp/src/rtp/rtp.d.ts +2 -2
  51. package/lib/rtp/src/rtp/rtp.js +2 -2
  52. package/lib/rtp/src/rtp/rtp.js.map +1 -1
  53. package/lib/rtp/src/rtp/rtx.d.ts +3 -0
  54. package/lib/rtp/src/rtp/rtx.js +33 -0
  55. package/lib/rtp/src/rtp/rtx.js.map +1 -0
  56. package/lib/webrtc/src/media/receiver/nack.js +0 -1
  57. package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
  58. package/lib/webrtc/src/media/rtpReceiver.d.ts +0 -1
  59. package/lib/webrtc/src/media/rtpReceiver.js +2 -14
  60. package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
  61. package/lib/webrtc/src/media/rtpSender.d.ts +0 -1
  62. package/lib/webrtc/src/media/rtpSender.js +2 -18
  63. package/lib/webrtc/src/media/rtpSender.js.map +1 -1
  64. package/lib/webrtc/src/nonstandard/recorder/index.d.ts +2 -0
  65. package/lib/webrtc/src/nonstandard/recorder/index.js +15 -0
  66. package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
  67. package/lib/webrtc/src/transport/dtls.js +1 -1
  68. package/lib/webrtc/src/transport/dtls.js.map +1 -1
  69. package/lib/webrtc/src/utils.d.ts +0 -1
  70. package/lib/webrtc/src/utils.js +1 -5
  71. package/lib/webrtc/src/utils.js.map +1 -1
  72. package/package.json +1 -1
  73. package/src/media/receiver/nack.ts +1 -1
  74. package/src/media/rtpReceiver.ts +1 -16
  75. package/src/media/rtpSender.ts +1 -24
  76. package/src/nonstandard/recorder/index.ts +9 -0
  77. package/src/transport/dtls.ts +2 -1
  78. package/src/utils.ts +0 -4
@@ -121,7 +121,7 @@ export class NackHandler {
121
121
  mediaSourceSsrc: this.mediaSourceSsrc,
122
122
  lost: this.lostSeqNumbers,
123
123
  });
124
- // log("sendNack", nack.toJSON());
124
+
125
125
  const rtcp = new RtcpTransportLayerFeedback({
126
126
  feedback: nack,
127
127
  });
@@ -1,5 +1,4 @@
1
1
  import { debug } from "debug";
2
- import { jspack } from "jspack";
3
2
  import Event from "rx.mini";
4
3
  import { setTimeout } from "timers/promises";
5
4
  import { v4 as uuid } from "uuid";
@@ -14,8 +13,8 @@ import {
14
13
  RtcpReceiverInfo,
15
14
  RtcpRrPacket,
16
15
  RtcpSrPacket,
17
- RtpHeader,
18
16
  RtpPacket,
17
+ unwrapRtx,
19
18
  } from "../../../rtp/src";
20
19
  import { codecParametersFromString, PeerConfig, usePLI, useTWCC } from "..";
21
20
  import { RTCDtlsTransport } from "../transport/dtls";
@@ -345,17 +344,3 @@ export class RTCRtpReceiver {
345
344
  this.runRtcp();
346
345
  }
347
346
  }
348
-
349
- export function unwrapRtx(rtx: RtpPacket, payloadType: number, ssrc: number) {
350
- const packet = new RtpPacket(
351
- new RtpHeader({
352
- payloadType,
353
- marker: rtx.header.marker,
354
- sequenceNumber: jspack.Unpack("!H", rtx.payload.subarray(0, 2))[0],
355
- timestamp: rtx.header.timestamp,
356
- ssrc,
357
- }),
358
- rtx.payload.subarray(2)
359
- );
360
- return packet;
361
- }
@@ -51,6 +51,7 @@ import {
51
51
  SourceDescriptionChunk,
52
52
  SourceDescriptionItem,
53
53
  TransportWideCC,
54
+ wrapRtx,
54
55
  } from "../../../rtp/src";
55
56
  import { codecParametersFromString } from "..";
56
57
  import { RTCDtlsTransport } from "../transport/dtls";
@@ -491,27 +492,3 @@ export class RTCRtpSender {
491
492
  this.onRtcp.execute(rtcpPacket);
492
493
  }
493
494
  }
494
-
495
- export function wrapRtx(
496
- packet: RtpPacket,
497
- payloadType: number,
498
- sequenceNumber: number,
499
- ssrc: number
500
- ) {
501
- const rtx = new RtpPacket(
502
- new RtpHeader({
503
- payloadType,
504
- marker: packet.header.marker,
505
- sequenceNumber,
506
- timestamp: packet.header.timestamp,
507
- ssrc,
508
- csrc: packet.header.csrc,
509
- extensions: packet.header.extensions,
510
- }),
511
- Buffer.concat([
512
- Buffer.from(jspack.Pack("!H", [packet.header.sequenceNumber])),
513
- packet.payload,
514
- ])
515
- );
516
- return rtx;
517
- }
@@ -1,3 +1,5 @@
1
+ import Event from "rx.mini";
2
+
1
3
  import { MediaStreamTrack } from "../../media/track";
2
4
  import { MediaWriter } from "./writer";
3
5
  import { WebmFactory } from "./writer/webm";
@@ -7,6 +9,7 @@ export class MediaRecorder {
7
9
  ext: string;
8
10
  tracks: MediaStreamTrack[] = [];
9
11
  started = false;
12
+ onError = new Event<[Error]>();
10
13
 
11
14
  constructor(
12
15
  public path: string,
@@ -22,7 +25,13 @@ export class MediaRecorder {
22
25
  throw new Error();
23
26
  }
24
27
  })();
28
+
25
29
  this.tracks = options.tracks ?? this.tracks;
30
+ if (this.tracks.length === numOfTracks) {
31
+ this.start().catch((error) => {
32
+ this.onError.execute(error);
33
+ });
34
+ }
26
35
  }
27
36
 
28
37
  async addTrack(track: MediaStreamTrack) {
@@ -20,6 +20,7 @@ import { CipherContext } from "../../../dtls/src/context/cipher";
20
20
  import { Profile } from "../../../dtls/src/context/srtp";
21
21
  import { Connection } from "../../../ice/src";
22
22
  import {
23
+ isRtcp,
23
24
  RtcpPacket,
24
25
  RtcpPacketConverter,
25
26
  RtpHeader,
@@ -30,7 +31,7 @@ import {
30
31
  import { keyLength, saltLength } from "../../../rtp/src/srtp/const";
31
32
  import { RtpRouter } from "../media/router";
32
33
  import { PeerConfig } from "../peerConnection";
33
- import { fingerprint, isDtls, isMedia, isRtcp } from "../utils";
34
+ import { fingerprint, isDtls, isMedia } from "../utils";
34
35
  import { RTCIceTransport } from "./ice";
35
36
 
36
37
  const log = debug("werift:packages/webrtc/src/transport/dtls.ts");
package/src/utils.ts CHANGED
@@ -39,10 +39,6 @@ export function isMedia(buf: Buffer) {
39
39
  return firstByte > 127 && firstByte < 192;
40
40
  }
41
41
 
42
- export function isRtcp(buf: Buffer) {
43
- return buf.length >= 2 && buf[1] >= 192 && buf[1] <= 208;
44
- }
45
-
46
42
  export function reverseSimulcastDirection(dir: "recv" | "send") {
47
43
  if (dir === "recv") return "send";
48
44
  return "recv";