werift 0.18.3 → 0.18.4

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 (97) hide show
  1. package/lib/dtls/src/flight/server/flight2.js +1 -1
  2. package/lib/dtls/src/flight/server/flight2.js.map +1 -1
  3. package/lib/rtp/src/container/ebml/ebml.d.ts +5 -6
  4. package/lib/rtp/src/container/ebml/ebml.js +14 -13
  5. package/lib/rtp/src/container/ebml/ebml.js.map +1 -1
  6. package/lib/rtp/src/container/ebml/typedArrayUtils.d.ts +3 -4
  7. package/lib/rtp/src/container/ebml/typedArrayUtils.js +9 -10
  8. package/lib/rtp/src/container/ebml/typedArrayUtils.js.map +1 -1
  9. package/lib/rtp/src/container/index.d.ts +2 -0
  10. package/lib/rtp/src/{processor/source → container}/index.js +2 -3
  11. package/lib/rtp/src/container/index.js.map +1 -0
  12. package/lib/rtp/src/helper.d.ts +4 -0
  13. package/lib/rtp/src/helper.js +14 -1
  14. package/lib/rtp/src/helper.js.map +1 -1
  15. package/lib/rtp/src/index.d.ts +2 -0
  16. package/lib/rtp/src/index.js +2 -0
  17. package/lib/rtp/src/index.js.map +1 -1
  18. package/lib/rtp/src/processor/depacketizer.d.ts +1 -1
  19. package/lib/rtp/src/processor/depacketizer.js +16 -9
  20. package/lib/rtp/src/processor/depacketizer.js.map +1 -1
  21. package/lib/rtp/src/processor/depacketizerCallback.d.ts +14 -6
  22. package/lib/rtp/src/processor/depacketizerCallback.js +2 -35
  23. package/lib/rtp/src/processor/depacketizerCallback.js.map +1 -1
  24. package/lib/rtp/src/processor/dtx.d.ts +1 -0
  25. package/lib/rtp/src/processor/dtx.js +10 -1
  26. package/lib/rtp/src/processor/dtx.js.map +1 -1
  27. package/lib/rtp/src/processor/dtxCallback.d.ts +14 -5
  28. package/lib/rtp/src/processor/dtxCallback.js +2 -35
  29. package/lib/rtp/src/processor/dtxCallback.js.map +1 -1
  30. package/lib/rtp/src/processor/index.d.ts +3 -1
  31. package/lib/rtp/src/processor/index.js +3 -1
  32. package/lib/rtp/src/processor/index.js.map +1 -1
  33. package/lib/rtp/src/processor/interface.d.ts +17 -0
  34. package/lib/rtp/src/processor/interface.js +57 -0
  35. package/lib/rtp/src/processor/interface.js.map +1 -1
  36. package/lib/rtp/src/processor/jitterBuffer.d.ts +1 -2
  37. package/lib/rtp/src/processor/jitterBuffer.js +3 -1
  38. package/lib/rtp/src/processor/jitterBuffer.js.map +1 -1
  39. package/lib/rtp/src/processor/jitterBufferCallback.d.ts +14 -5
  40. package/lib/rtp/src/processor/jitterBufferCallback.js +2 -35
  41. package/lib/rtp/src/processor/jitterBufferCallback.js.map +1 -1
  42. package/lib/rtp/src/processor/jitterBufferTransformer.d.ts +1 -1
  43. package/lib/rtp/src/processor/lipsync.d.ts +19 -8
  44. package/lib/rtp/src/processor/lipsync.js +131 -83
  45. package/lib/rtp/src/processor/lipsync.js.map +1 -1
  46. package/lib/rtp/src/processor/lipsyncCallback.d.ts +8 -5
  47. package/lib/rtp/src/processor/lipsyncCallback.js +39 -4
  48. package/lib/rtp/src/processor/lipsyncCallback.js.map +1 -1
  49. package/lib/rtp/src/processor/mute.d.ts +17 -4
  50. package/lib/rtp/src/processor/mute.js +121 -40
  51. package/lib/rtp/src/processor/mute.js.map +1 -1
  52. package/lib/rtp/src/processor/muteCallback.d.ts +5 -2
  53. package/lib/rtp/src/processor/muteCallback.js +23 -7
  54. package/lib/rtp/src/processor/muteCallback.js.map +1 -1
  55. package/lib/rtp/src/processor/nack.d.ts +6 -6
  56. package/lib/rtp/src/processor/nack.js +23 -17
  57. package/lib/rtp/src/processor/nack.js.map +1 -1
  58. package/lib/rtp/src/processor/nackHandlerCallback.d.ts +14 -7
  59. package/lib/rtp/src/processor/nackHandlerCallback.js +2 -29
  60. package/lib/rtp/src/processor/nackHandlerCallback.js.map +1 -1
  61. package/lib/rtp/src/processor/ntpTime.d.ts +7 -7
  62. package/lib/rtp/src/processor/ntpTime.js +27 -29
  63. package/lib/rtp/src/processor/ntpTime.js.map +1 -1
  64. package/lib/rtp/src/processor/ntpTimeCallback.d.ts +13 -4
  65. package/lib/rtp/src/processor/ntpTimeCallback.js +2 -29
  66. package/lib/rtp/src/processor/ntpTimeCallback.js.map +1 -1
  67. package/lib/rtp/src/processor/rtcpCallback.d.ts +18 -0
  68. package/lib/rtp/src/processor/{source/rtcpCallback.js → rtcpCallback.js} +25 -3
  69. package/lib/rtp/src/processor/rtcpCallback.js.map +1 -0
  70. package/lib/rtp/src/processor/rtpCallback.d.ts +28 -0
  71. package/lib/rtp/src/processor/rtpCallback.js +125 -0
  72. package/lib/rtp/src/processor/rtpCallback.js.map +1 -0
  73. package/lib/rtp/src/processor/{source/rtpStream.d.ts → rtpStream.d.ts} +1 -1
  74. package/lib/rtp/src/processor/{source/rtpStream.js → rtpStream.js} +1 -1
  75. package/lib/rtp/src/processor/rtpStream.js.map +1 -0
  76. package/lib/rtp/src/processor/rtpTimeCallback.d.ts +13 -5
  77. package/lib/rtp/src/processor/rtpTimeCallback.js +2 -29
  78. package/lib/rtp/src/processor/rtpTimeCallback.js.map +1 -1
  79. package/lib/rtp/src/processor/webm.d.ts +8 -4
  80. package/lib/rtp/src/processor/webm.js +41 -8
  81. package/lib/rtp/src/processor/webm.js.map +1 -1
  82. package/lib/rtp/src/processor/webmCallback.d.ts +6 -5
  83. package/lib/rtp/src/processor/webmCallback.js +21 -7
  84. package/lib/rtp/src/processor/webmCallback.js.map +1 -1
  85. package/lib/webrtc/src/nonstandard/userMedia.d.ts +32 -23
  86. package/lib/webrtc/src/nonstandard/userMedia.js +49 -131
  87. package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
  88. package/package.json +1 -1
  89. package/src/nonstandard/userMedia.ts +69 -75
  90. package/lib/rtp/src/processor/source/index.d.ts +0 -3
  91. package/lib/rtp/src/processor/source/index.js.map +0 -1
  92. package/lib/rtp/src/processor/source/rtcpCallback.d.ts +0 -13
  93. package/lib/rtp/src/processor/source/rtcpCallback.js.map +0 -1
  94. package/lib/rtp/src/processor/source/rtpCallback.d.ts +0 -19
  95. package/lib/rtp/src/processor/source/rtpCallback.js +0 -62
  96. package/lib/rtp/src/processor/source/rtpCallback.js.map +0 -1
  97. package/lib/rtp/src/processor/source/rtpStream.js.map +0 -1
@@ -11,6 +11,12 @@ class NtpTimeBase {
11
11
  writable: true,
12
12
  value: clockRate
13
13
  });
14
+ Object.defineProperty(this, "id", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: (0, crypto_1.randomUUID)()
19
+ });
14
20
  Object.defineProperty(this, "baseNtpTimestamp", {
15
21
  enumerable: true,
16
22
  configurable: true,
@@ -53,30 +59,24 @@ class NtpTimeBase {
53
59
  writable: true,
54
60
  value: {}
55
61
  });
56
- Object.defineProperty(this, "id", {
57
- enumerable: true,
58
- configurable: true,
59
- writable: true,
60
- value: (0, crypto_1.randomUUID)()
61
- });
62
- Object.defineProperty(this, "payloadType", {
62
+ Object.defineProperty(this, "started", {
63
63
  enumerable: true,
64
64
  configurable: true,
65
65
  writable: true,
66
- value: 0
66
+ value: false
67
67
  });
68
68
  }
69
69
  toJSON() {
70
70
  return {
71
+ ...this.internalStats,
72
+ id: this.id,
71
73
  baseRtpTimestamp: this.baseRtpTimestamp,
72
74
  latestRtpTimestamp: this.latestRtpTimestamp,
73
75
  baseNtpTimestamp: this.baseNtpTimestamp && (0, __1.ntpTime2Sec)(this.baseNtpTimestamp),
74
76
  latestNtpTimestamp: this.latestNtpTimestamp && (0, __1.ntpTime2Sec)(this.latestNtpTimestamp),
75
77
  bufferLength: this.buffer.length,
76
78
  currentElapsed: this.currentElapsed,
77
- id: this.id,
78
79
  clockRate: this.clockRate,
79
- ...this.internalStats,
80
80
  };
81
81
  }
82
82
  stop() {
@@ -96,22 +96,28 @@ class NtpTimeBase {
96
96
  this.baseNtpTimestamp = ntpTimestamp;
97
97
  this.baseRtpTimestamp = rtpTimestamp;
98
98
  }
99
+ this.internalStats["ntpReceived"] = new Date().toISOString();
100
+ this.started = true;
99
101
  }
100
102
  if (rtp) {
101
103
  this.buffer.push(rtp);
102
- this.payloadType = rtp.header.payloadType;
104
+ this.internalStats["payloadType"] = rtp.header.payloadType;
103
105
  const res = [];
104
- this.buffer = this.buffer
105
- .map((rtp) => {
106
+ if (this.baseRtpTimestamp == undefined ||
107
+ this.baseNtpTimestamp == undefined ||
108
+ this.latestNtpTimestamp == undefined ||
109
+ this.latestRtpTimestamp == undefined) {
110
+ return [];
111
+ }
112
+ for (const rtp of this.buffer) {
106
113
  const ntp = this.updateNtp(rtp.header.timestamp);
107
- if (ntp != undefined) {
108
- const ms = ntp * 1000;
109
- res.push({ rtp, time: Math.round(ms) });
110
- return undefined;
111
- }
112
- return rtp;
113
- })
114
- .filter((r) => r != undefined);
114
+ const ms = ntp * 1000;
115
+ const time = Math.round(ms);
116
+ res.push({ rtp, time });
117
+ this.internalStats["timeSource"] =
118
+ new Date().toISOString() + " time:" + time;
119
+ }
120
+ this.buffer = [];
115
121
  return res;
116
122
  }
117
123
  return [];
@@ -127,19 +133,11 @@ class NtpTimeBase {
127
133
  ? rtpTimestamp + __1.Max32Uint - baseRtpTimestamp
128
134
  : rtpTimestamp - baseRtpTimestamp;
129
135
  const elapsedSec = elapsed / this.clockRate;
130
- this.internalStats["totalElapsed"] =
131
- (this.internalStats["totalElapsed"] ?? 0) + elapsedSec;
132
136
  // sec
133
137
  const ntp = (0, __1.ntpTime2Sec)(baseNtpTimestamp) + elapsedOffset + elapsedSec;
134
138
  return { ntp, elapsedSec };
135
139
  }
136
140
  updateNtp(rtpTimestamp) {
137
- if (this.baseRtpTimestamp == undefined ||
138
- this.baseNtpTimestamp == undefined ||
139
- this.latestNtpTimestamp == undefined ||
140
- this.latestRtpTimestamp == undefined) {
141
- return;
142
- }
143
141
  this.internalStats["inputRtp"] = rtpTimestamp;
144
142
  const base = this.calcNtp({
145
143
  rtpTimestamp,
@@ -1 +1 @@
1
- {"version":3,"file":"ntpTime.js","sourceRo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Aa,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;QAC7C,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;QAEjD,IAAI,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE;YACzB,iBAAiB;YACjB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC;YAChD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC;YAChD,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;YACxB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;YAC3C,OAAO,MAAM,CAAC,GAAG,CAAC;SACnB;aAAM;YACL,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC;YACvC,IAAI,CAAC,gBAAgB,GAAG,YAAY,CAAC;YACrC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;YACzC,OAAO,IAAI,CAAC,GAAG,CAAC;SACjB;IACH,CAAC;CACF;AAnJD,kCAmJC","sourcesContent":["import { randomUUID } from \"crypto\";\n\nimport {\n Max32Uint,\n ntpTime2Sec,\n Processor,\n RtcpPacket,\n RtcpSrPacket,\n RtpPacket,\n} from \"..\";\n\nexport type NtpTimeInput = {\n rtp?: RtpPacket;\n eol?: boolean;\n rtcp?: RtcpPacket;\n};\n\nexport interface NtpTimeOutput {\n rtp?: RtpPacket;\n /**ms */\n time?: number;\n eol?: boolean;\n}\n\nexport class NtpTimeBase implements Processor<NtpTimeInput, NtpTimeOutput> {\n baseNtpTimestamp?: bigint;\n baseRtpTimestamp?: number;\n latestNtpTimestamp?: bigint;\n latestRtpTimestamp?: number;\n private currentElapsed = 0;\n buffer: RtpPacket[] = [];\n private internalStats = {};\n id = randomUUID();\n payloadType = 0;\n\n constructor(public clockRate: number) {}\n\n toJSON(): Record<string, any> {\n return {\n baseRtpTimestamp: this.baseRtpTimestamp,\n latestRtpTimestamp: this.latestRtpTimestamp,\n baseNtpTimestamp:\n this.baseNtpTimestamp && ntpTime2Sec(this.baseNtpTimestamp),\n latestNtpTimestamp:\n this.latestNtpTimestamp && ntpTime2Sec(this.latestNtpTimestamp),\n bufferLength: this.buffer.length,\n currentElapsed: this.currentElapsed,\n id: this.id,\n clockRate: this.clockRate,\n ...this.internalStats,\n };\n }\n\n private stop() {\n this.buffer = [];\n this.internalStats = {};\n }\n\n processInput({ rtcp, rtp, eol }: NtpTimeInput): NtpTimeOutput[] {\n if (eol) {\n this.stop();\n return [{ eol: true }];\n }\n\n if (rtcp && rtcp instanceof RtcpSrPacket) {\n const { ntpTimestamp, rtpTimestamp } = rtcp.senderInfo;\n this.latestNtpTimestamp = ntpTimestamp;\n this.latestRtpTimestamp = rtpTimestamp;\n\n if (this.baseNtpTimestamp == undefined) {\n this.baseNtpTimestamp = ntpTimestamp;\n this.baseRtpTimestamp = rtpTimestamp;\n }\n }\n\n if (rtp) {\n this.buffer.push(rtp);\n this.payloadType = rtp.header.payloadType;\n\n const res: NtpTimeOutput[] = [];\n\n this.buffer = this.buffer\n .map((rtp) => {\n const ntp = this.updateNtp(rtp.header.timestamp);\n if (ntp != undefined) {\n const ms = ntp * 1000;\n res.push({ rtp, time: Math.round(ms) });\n return undefined;\n }\n return rtp;\n })\n .filter((r): r is NonNullable<typeof r> => r != undefined);\n return res;\n }\n\n return [];\n }\n\n /**\n *\n * @param rtpTimestamp\n * @returns sec\n */\n private calcNtp({\n rtpTimestamp,\n baseNtpTimestamp,\n baseRtpTimestamp,\n elapsedOffset,\n }: {\n rtpTimestamp: number;\n baseRtpTimestamp: number;\n baseNtpTimestamp: bigint;\n elapsedOffset: number;\n }) {\n const rotate =\n Math.abs(rtpTimestamp - baseRtpTimestamp) > (Max32Uint / 4) * 3;\n\n const elapsed = rotate\n ? rtpTimestamp + Max32Uint - baseRtpTimestamp\n : rtpTimestamp - baseRtpTimestamp;\n const elapsedSec = elapsed / this.clockRate;\n this.internalStats[\"totalElapsed\"] =\n (this.internalStats[\"totalElapsed\"] ?? 0) + elapsedSec;\n\n // sec\n const ntp = ntpTime2Sec(baseNtpTimestamp) + elapsedOffset + elapsedSec;\n return { ntp, elapsedSec };\n }\n\n private updateNtp(rtpTimestamp: number) {\n if (\n this.baseRtpTimestamp == undefined ||\n this.baseNtpTimestamp == undefined ||\n this.latestNtpTimestamp == undefined ||\n this.latestRtpTimestamp == undefined\n ) {\n return;\n }\n\n this.internalStats[\"inputRtp\"] = rtpTimestamp;\n\n const base = this.calcNtp({\n rtpTimestamp,\n baseNtpTimestamp: this.baseNtpTimestamp,\n baseRtpTimestamp: this.baseRtpTimestamp,\n elapsedOffset: this.currentElapsed,\n });\n const latest = this.calcNtp({\n rtpTimestamp,\n baseNtpTimestamp: this.latestNtpTimestamp,\n baseRtpTimestamp: this.latestRtpTimestamp,\n elapsedOffset: 0,\n });\n\n this.internalStats[\"calcBaseNtp\"] = base.ntp;\n this.internalStats[\"calcLatestNtp\"] = latest.ntp;\n\n if (base.ntp < latest.ntp) {\n // update baseNtp\n this.baseNtpTimestamp = this.latestNtpTimestamp;\n this.baseRtpTimestamp = this.latestRtpTimestamp;\n this.currentElapsed = 0;\n this.internalStats[\"calcNtp\"] = latest.ntp;\n return latest.ntp;\n } else {\n this.currentElapsed += base.elapsedSec;\n this.baseRtpTimestamp = rtpTimestamp;\n this.internalStats[\"calcNtp\"] = base.ntp;\n return base.ntp;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ntpTime.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/ntpTime.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,0BAOY;AAeZ,MAAa,WAAW;IAWtB,YAAmB,SAAiB;;;;;mBAAjB;;QAVnB;;;;mBAAc,IAAA,mBAAU,GAAE;WAAC;QAC3B;;;;;WAAkC;QAClC;;;;;WAAkC;QAClC;;;;;WAAoC;QACpC;;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AI,CAAC,kBAAkB,CAAC;YAChD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC;YAChD,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;YACxB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;YAC3C,OAAO,MAAM,CAAC,GAAG,CAAC;SACnB;aAAM;YACL,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC;YACvC,IAAI,CAAC,gBAAgB,GAAG,YAAY,CAAC;YACrC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;YACzC,OAAO,IAAI,CAAC,GAAG,CAAC;SACjB;IACH,CAAC;CACF;AAnJD,kCAmJC","sourcesContent":["import { randomUUID } from \"crypto\";\n\nimport {\n Max32Uint,\n ntpTime2Sec,\n Processor,\n RtcpPacket,\n RtcpSrPacket,\n RtpPacket,\n} from \"..\";\n\nexport type NtpTimeInput = {\n rtp?: RtpPacket;\n eol?: boolean;\n rtcp?: RtcpPacket;\n};\n\nexport interface NtpTimeOutput {\n rtp?: RtpPacket;\n /**ms */\n time?: number;\n eol?: boolean;\n}\n\nexport class NtpTimeBase implements Processor<NtpTimeInput, NtpTimeOutput> {\n readonly id = randomUUID();\n private baseNtpTimestamp?: bigint;\n private baseRtpTimestamp?: number;\n private latestNtpTimestamp?: bigint;\n private latestRtpTimestamp?: number;\n private currentElapsed = 0;\n private buffer: RtpPacket[] = [];\n private internalStats = {};\n started = false;\n\n constructor(public clockRate: number) {}\n\n toJSON(): Record<string, any> {\n return {\n ...this.internalStats,\n id: this.id,\n baseRtpTimestamp: this.baseRtpTimestamp,\n latestRtpTimestamp: this.latestRtpTimestamp,\n baseNtpTimestamp:\n this.baseNtpTimestamp && ntpTime2Sec(this.baseNtpTimestamp),\n latestNtpTimestamp:\n this.latestNtpTimestamp && ntpTime2Sec(this.latestNtpTimestamp),\n bufferLength: this.buffer.length,\n currentElapsed: this.currentElapsed,\n clockRate: this.clockRate,\n };\n }\n\n private stop() {\n this.buffer = [];\n this.internalStats = {};\n }\n\n processInput({ rtcp, rtp, eol }: NtpTimeInput): NtpTimeOutput[] {\n if (eol) {\n this.stop();\n return [{ eol: true }];\n }\n\n if (rtcp && rtcp instanceof RtcpSrPacket) {\n const { ntpTimestamp, rtpTimestamp } = rtcp.senderInfo;\n this.latestNtpTimestamp = ntpTimestamp;\n this.latestRtpTimestamp = rtpTimestamp;\n\n if (this.baseNtpTimestamp == undefined) {\n this.baseNtpTimestamp = ntpTimestamp;\n this.baseRtpTimestamp = rtpTimestamp;\n }\n\n this.internalStats[\"ntpReceived\"] = new Date().toISOString();\n this.started = true;\n }\n\n if (rtp) {\n this.buffer.push(rtp);\n this.internalStats[\"payloadType\"] = rtp.header.payloadType;\n\n const res: NtpTimeOutput[] = [];\n\n if (\n this.baseRtpTimestamp == undefined ||\n this.baseNtpTimestamp == undefined ||\n this.latestNtpTimestamp == undefined ||\n this.latestRtpTimestamp == undefined\n ) {\n return [];\n }\n\n for (const rtp of this.buffer) {\n const ntp = this.updateNtp(rtp.header.timestamp);\n const ms = ntp * 1000;\n const time = Math.round(ms);\n res.push({ rtp, time });\n\n this.internalStats[\"timeSource\"] =\n new Date().toISOString() + \" time:\" + time;\n }\n this.buffer = [];\n return res;\n }\n\n return [];\n }\n\n /**\n *\n * @param rtpTimestamp\n * @returns sec\n */\n private calcNtp({\n rtpTimestamp,\n baseNtpTimestamp,\n baseRtpTimestamp,\n elapsedOffset,\n }: {\n rtpTimestamp: number;\n baseRtpTimestamp: number;\n baseNtpTimestamp: bigint;\n elapsedOffset: number;\n }) {\n const rotate =\n Math.abs(rtpTimestamp - baseRtpTimestamp) > (Max32Uint / 4) * 3;\n\n const elapsed = rotate\n ? rtpTimestamp + Max32Uint - baseRtpTimestamp\n : rtpTimestamp - baseRtpTimestamp;\n const elapsedSec = elapsed / this.clockRate;\n\n // sec\n const ntp = ntpTime2Sec(baseNtpTimestamp) + elapsedOffset + elapsedSec;\n return { ntp, elapsedSec };\n }\n\n private updateNtp(rtpTimestamp: number) {\n this.internalStats[\"inputRtp\"] = rtpTimestamp;\n\n const base = this.calcNtp({\n rtpTimestamp,\n baseNtpTimestamp: this.baseNtpTimestamp!,\n baseRtpTimestamp: this.baseRtpTimestamp!,\n elapsedOffset: this.currentElapsed,\n });\n const latest = this.calcNtp({\n rtpTimestamp,\n baseNtpTimestamp: this.latestNtpTimestamp!,\n baseRtpTimestamp: this.latestRtpTimestamp!,\n elapsedOffset: 0,\n });\n\n this.internalStats[\"calcBaseNtp\"] = base.ntp;\n this.internalStats[\"calcLatestNtp\"] = latest.ntp;\n\n if (base.ntp < latest.ntp) {\n // update baseNtp\n this.baseNtpTimestamp = this.latestNtpTimestamp;\n this.baseRtpTimestamp = this.latestRtpTimestamp;\n this.currentElapsed = 0;\n this.internalStats[\"calcNtp\"] = latest.ntp;\n return latest.ntp;\n } else {\n this.currentElapsed += base.elapsedSec;\n this.baseRtpTimestamp = rtpTimestamp;\n this.internalStats[\"calcNtp\"] = base.ntp;\n return base.ntp;\n }\n }\n}\n"]}
@@ -1,6 +1,15 @@
1
1
  import { NtpTimeBase, NtpTimeInput, NtpTimeOutput } from "./ntpTime";
2
- export declare class NtpTimeCallback extends NtpTimeBase {
3
- private cb;
4
- pipe: (cb: (input: NtpTimeOutput) => void) => this;
5
- input: (input: NtpTimeInput) => void;
2
+ declare const NtpTimeCallback_base: {
3
+ new (...args: any[]): {
4
+ cb?: ((o: NtpTimeOutput) => void) | undefined;
5
+ destructor?: (() => void) | undefined;
6
+ pipe: (cb: (o: NtpTimeOutput) => void, destructor?: (() => void) | undefined) => any;
7
+ input: (input: NtpTimeInput) => void;
8
+ destroy: () => void;
9
+ processInput: (input: NtpTimeInput) => NtpTimeOutput[];
10
+ toJSON(): Record<string, any>;
11
+ };
12
+ } & typeof NtpTimeBase;
13
+ export declare class NtpTimeCallback extends NtpTimeCallback_base {
6
14
  }
15
+ export {};
@@ -1,36 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NtpTimeCallback = void 0;
4
+ const interface_1 = require("./interface");
4
5
  const ntpTime_1 = require("./ntpTime");
5
- class NtpTimeCallback extends ntpTime_1.NtpTimeBase {
6
- constructor() {
7
- super(...arguments);
8
- Object.defineProperty(this, "cb", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: void 0
13
- });
14
- Object.defineProperty(this, "pipe", {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value: (cb) => {
19
- this.cb = cb;
20
- return this;
21
- }
22
- });
23
- Object.defineProperty(this, "input", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: (input) => {
28
- for (const output of this.processInput(input)) {
29
- this.cb(output);
30
- }
31
- }
32
- });
33
- }
6
+ class NtpTimeCallback extends (0, interface_1.SimpleProcessorCallbackBase)(ntpTime_1.NtpTimeBase) {
34
7
  }
35
8
  exports.NtpTimeCallback = NtpTimeCallback;
36
9
  //# sourceMappingURL=ntpTimeCallback.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ntpTimeCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/ntpTimeCallback.ts"],"names":[],"mappings":";;;AAAA,uCAAqE;AAErE,MAAa,eAAgB,SAAQ,qBAAW;IAAhD;;QACE;;;;;WAA4C;QAE5C;;;;mBAAO,CAAC,EAAkC,EAAE,EAAE;gBAC5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;gBACb,OAAO,IAAI,CAAC;YACd,CAAC;WAAC;QAEF;;;;mBAAQ,CAAC,KAAmB,EAAE,EAAE;gBAC9B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;oBAC7C,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;iBACjB;YACH,CAAC;WAAC;IACJ,CAAC;CAAA;AAbD,0CAaC","sourcesContent":["import { NtpTimeBase, NtpTimeInput, NtpTimeOutput } from \"./ntpTime\";\n\nexport class NtpTimeCallback extends NtpTimeBase {\n private cb!: (input: NtpTimeOutput) => void;\n\n pipe = (cb: (input: NtpTimeOutput) => void) => {\n this.cb = cb;\n return this;\n };\n\n input = (input: NtpTimeInput) => {\n for (const output of this.processInput(input)) {\n this.cb(output);\n }\n };\n}\n"]}
1
+ {"version":3,"file":"ntpTimeCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/ntpTimeCallback.ts"],"names":[],"mappings":";;;AAAA,2CAA0D;AAC1D,uCAAqE;AAErE,MAAa,eAAgB,SAAQ,IAAA,uCAA2B,EAI9D,qBAAW,CAAC;CAAG;AAJjB,0CAIiB","sourcesContent":["import { SimpleProcessorCallbackBase } from \"./interface\";\nimport { NtpTimeBase, NtpTimeInput, NtpTimeOutput } from \"./ntpTime\";\n\nexport class NtpTimeCallback extends SimpleProcessorCallbackBase<\n NtpTimeInput,\n NtpTimeOutput,\n typeof NtpTimeBase\n>(NtpTimeBase) {}\n"]}
@@ -0,0 +1,18 @@
1
+ import Event from "rx.mini";
2
+ import { RtcpPacket } from "..";
3
+ import { SimpleProcessorCallback } from "./interface";
4
+ export type RtcpInput = RtcpPacket;
5
+ export interface RtcpOutput {
6
+ rtcp?: RtcpPacket;
7
+ eol?: boolean;
8
+ }
9
+ export declare class RtcpSourceCallback implements SimpleProcessorCallback<RtcpInput, RtcpOutput> {
10
+ private cb?;
11
+ private destructor?;
12
+ onStopped: Event<any[]>;
13
+ toJSON(): {};
14
+ pipe(cb: (chunk: RtcpOutput) => void, destructor?: () => void): this;
15
+ input: (rtcp: RtcpInput) => void;
16
+ stop(): void;
17
+ destroy: () => void;
18
+ }
@@ -13,6 +13,12 @@ class RtcpSourceCallback {
13
13
  writable: true,
14
14
  value: void 0
15
15
  });
16
+ Object.defineProperty(this, "destructor", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
16
22
  Object.defineProperty(this, "onStopped", {
17
23
  enumerable: true,
18
24
  configurable: true,
@@ -29,17 +35,33 @@ class RtcpSourceCallback {
29
35
  }
30
36
  }
31
37
  });
38
+ Object.defineProperty(this, "destroy", {
39
+ enumerable: true,
40
+ configurable: true,
41
+ writable: true,
42
+ value: () => {
43
+ if (this.destructor) {
44
+ this.destructor();
45
+ this.destructor = undefined;
46
+ }
47
+ this.cb = undefined;
48
+ this.onStopped.allUnsubscribe();
49
+ }
50
+ });
51
+ }
52
+ toJSON() {
53
+ return {};
32
54
  }
33
- pipe(cb) {
55
+ pipe(cb, destructor) {
34
56
  this.cb = cb;
57
+ this.destructor = destructor;
58
+ return this;
35
59
  }
36
60
  stop() {
37
61
  if (this.cb) {
38
62
  this.cb({ eol: true });
39
63
  }
40
64
  this.onStopped.execute();
41
- this.cb = undefined;
42
- this.onStopped.allUnsubscribe();
43
65
  }
44
66
  }
45
67
  exports.RtcpSourceCallback = RtcpSourceCallback;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtcpCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/rtcpCallback.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAY5B,MAAa,kBAAkB;IAA/B;QAGE;;;;;WAAyC;QACzC;;;;;WAAgC;QAChC;;;;mBAAY,IAAI,iBAAK,EAAE;WAAC;QAYxB;;;;mBAAQ,CAAC,IAAe,EAAE,EAAE;gBAC1B,IAAI,IAAI,CAAC,EAAE,EAAE;oBACX,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;iBACnB;YACH,CAAC;WAAC;QASF;;;;mBAAU,GAAG,EAAE;gBACb,IAAI,IAAI,CAAC,UAAU,EAAE;oBACnB,IAAI,CAAC,UAAU,EAAE,CAAC;oBAClB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;iBAC7B;gBACD,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;gBACpB,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;YAClC,CAAC;WAAC;IACJ,CAAC;IA/BC,MAAM;QACJ,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC,EAA+B,EAAE,UAAuB;QAC3D,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAQD,IAAI;QACF,IAAI,IAAI,CAAC,EAAE,EAAE;YACX,IAAI,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;SACxB;QACD,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CAUF;AAtCD,gDAsCC","sourcesContent":["import Event from \"rx.mini\";\n\nimport { RtcpPacket } from \"..\";\nimport { SimpleProcessorCallback } from \"./interface\";\n\nexport type RtcpInput = RtcpPacket;\n\nexport interface RtcpOutput {\n rtcp?: RtcpPacket;\n eol?: boolean;\n}\n\nexport class RtcpSourceCallback\n implements SimpleProcessorCallback<RtcpInput, RtcpOutput>\n{\n private cb?: (chunk: RtcpOutput) => void;\n private destructor?: () => void;\n onStopped = new Event();\n\n toJSON() {\n return {};\n }\n\n pipe(cb: (chunk: RtcpOutput) => void, destructor?: () => void) {\n this.cb = cb;\n this.destructor = destructor;\n return this;\n }\n\n input = (rtcp: RtcpInput) => {\n if (this.cb) {\n this.cb({ rtcp });\n }\n };\n\n stop() {\n if (this.cb) {\n this.cb({ eol: true });\n }\n this.onStopped.execute();\n }\n\n destroy = () => {\n if (this.destructor) {\n this.destructor();\n this.destructor = undefined;\n }\n this.cb = undefined;\n this.onStopped.allUnsubscribe();\n };\n}\n"]}
@@ -0,0 +1,28 @@
1
+ /// <reference types="node" />
2
+ import Event from "rx.mini";
3
+ import { RtpPacket } from "..";
4
+ import { SimpleProcessorCallback } from "./interface";
5
+ export type RtpInput = Buffer | RtpPacket;
6
+ export interface RtpOutput {
7
+ rtp?: RtpPacket;
8
+ eol?: boolean;
9
+ }
10
+ export declare class RtpSourceCallback implements SimpleProcessorCallback<RtpInput, RtpOutput> {
11
+ private options;
12
+ private cb?;
13
+ private destructor?;
14
+ onStopped: Event<any[]>;
15
+ stats: {};
16
+ buffer: RtpPacket[];
17
+ bufferFulfilled: boolean;
18
+ constructor(options?: {
19
+ payloadType?: number;
20
+ clearInvalidPTPacket?: boolean;
21
+ initialBufferLength?: number;
22
+ });
23
+ toJSON(): {};
24
+ pipe(cb: (chunk: RtpOutput) => void, destructor?: () => void): this;
25
+ input: (packet: Buffer | RtpPacket) => void;
26
+ stop(): void;
27
+ destroy: () => void;
28
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RtpSourceCallback = void 0;
7
+ const rx_mini_1 = __importDefault(require("rx.mini"));
8
+ const __1 = require("..");
9
+ class RtpSourceCallback {
10
+ constructor(options = {}) {
11
+ Object.defineProperty(this, "options", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: options
16
+ });
17
+ Object.defineProperty(this, "cb", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "destructor", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ Object.defineProperty(this, "onStopped", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: new rx_mini_1.default()
34
+ });
35
+ Object.defineProperty(this, "stats", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: {}
40
+ });
41
+ Object.defineProperty(this, "buffer", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: []
46
+ });
47
+ Object.defineProperty(this, "bufferFulfilled", {
48
+ enumerable: true,
49
+ configurable: true,
50
+ writable: true,
51
+ value: false
52
+ });
53
+ Object.defineProperty(this, "input", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: (packet) => {
58
+ const rtp = packet instanceof __1.RtpPacket ? packet : __1.RtpPacket.deSerialize(packet);
59
+ if (this.options.payloadType != undefined &&
60
+ this.options.payloadType !== rtp.header.payloadType) {
61
+ if (this.options.clearInvalidPTPacket) {
62
+ rtp.clear();
63
+ }
64
+ return;
65
+ }
66
+ this.stats["rtpSource"] =
67
+ new Date().toISOString() +
68
+ " timestamp:" +
69
+ rtp?.header.timestamp +
70
+ " seq:" +
71
+ rtp?.header.sequenceNumber;
72
+ const cb = this.cb;
73
+ if (cb) {
74
+ if (this.options.initialBufferLength) {
75
+ if (this.bufferFulfilled) {
76
+ cb({ rtp });
77
+ return;
78
+ }
79
+ this.buffer.push(rtp);
80
+ if (this.buffer.length > this.options.initialBufferLength) {
81
+ this.buffer.forEach((rtp) => {
82
+ cb({ rtp });
83
+ });
84
+ this.buffer = [];
85
+ this.bufferFulfilled = true;
86
+ }
87
+ }
88
+ else {
89
+ cb({ rtp });
90
+ }
91
+ }
92
+ }
93
+ });
94
+ Object.defineProperty(this, "destroy", {
95
+ enumerable: true,
96
+ configurable: true,
97
+ writable: true,
98
+ value: () => {
99
+ if (this.destructor) {
100
+ this.destructor();
101
+ this.destructor = undefined;
102
+ }
103
+ this.cb = undefined;
104
+ this.onStopped.allUnsubscribe();
105
+ }
106
+ });
107
+ options.clearInvalidPTPacket = options.clearInvalidPTPacket ?? true;
108
+ }
109
+ toJSON() {
110
+ return { ...this.stats };
111
+ }
112
+ pipe(cb, destructor) {
113
+ this.cb = cb;
114
+ this.destructor = destructor;
115
+ return this;
116
+ }
117
+ stop() {
118
+ if (this.cb) {
119
+ this.cb({ eol: true });
120
+ }
121
+ this.onStopped.execute();
122
+ }
123
+ }
124
+ exports.RtpSourceCallback = RtpSourceCallback;
125
+ //# sourceMappingURL=rtpCallback.js.map
@@ -0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ourcesContent":["import Event from \"rx.mini\";\n\nimport { RtpPacket } from \"..\";\nimport { SimpleProcessorCallback } from \"./interface\";\n\nexport type RtpInput = Buffer | RtpPacket;\n\nexport interface RtpOutput {\n rtp?: RtpPacket;\n eol?: boolean;\n}\n\nexport class RtpSourceCallback\n implements SimpleProcessorCallback<RtpInput, RtpOutput>\n{\n private cb?: (chunk: RtpOutput) => void;\n private destructor?: () => void;\n onStopped = new Event();\n stats = {};\n buffer: RtpPacket[] = [];\n bufferFulfilled = false;\n\n constructor(\n private options: {\n payloadType?: number;\n clearInvalidPTPacket?: boolean;\n initialBufferLength?: number;\n } = {}\n ) {\n options.clearInvalidPTPacket = options.clearInvalidPTPacket ?? true;\n }\n\n toJSON() {\n return { ...this.stats };\n }\n\n pipe(cb: (chunk: RtpOutput) => void, destructor?: () => void) {\n this.cb = cb;\n this.destructor = destructor;\n return this;\n }\n\n input = (packet: Buffer | RtpPacket) => {\n const rtp =\n packet instanceof RtpPacket ? packet : RtpPacket.deSerialize(packet);\n\n if (\n this.options.payloadType != undefined &&\n this.options.payloadType !== rtp.header.payloadType\n ) {\n if (this.options.clearInvalidPTPacket) {\n rtp.clear();\n }\n return;\n }\n\n this.stats[\"rtpSource\"] =\n new Date().toISOString() +\n \" timestamp:\" +\n rtp?.header.timestamp +\n \" seq:\" +\n rtp?.header.sequenceNumber;\n\n const cb = this.cb;\n if (cb) {\n if (this.options.initialBufferLength) {\n if (this.bufferFulfilled) {\n cb({ rtp });\n return;\n }\n this.buffer.push(rtp);\n if (this.buffer.length > this.options.initialBufferLength) {\n this.buffer.forEach((rtp) => {\n cb({ rtp });\n });\n this.buffer = [];\n this.bufferFulfilled = true;\n }\n } else {\n cb({ rtp });\n }\n }\n };\n\n stop() {\n if (this.cb) {\n this.cb({ eol: true });\n }\n this.onStopped.execute();\n }\n\n destroy = () => {\n if (this.destructor) {\n this.destructor();\n this.destructor = undefined;\n }\n this.cb = undefined;\n this.onStopped.allUnsubscribe();\n };\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import { ReadableStream, ReadableStreamController } from "stream/web";
4
- import { RtpPacket } from "../../rtp/rtp";
4
+ import { RtpPacket } from "../rtp/rtp";
5
5
  import { RtpOutput } from "./rtpCallback";
6
6
  export declare class RtpSourceStream {
7
7
  private options;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RtpSourceStream = void 0;
4
4
  const web_1 = require("stream/web");
5
- const rtp_1 = require("../../rtp/rtp");
5
+ const rtp_1 = require("../rtp/rtp");
6
6
  class RtpSourceStream {
7
7
  constructor(options = {}) {
8
8
  Object.defineProperty(this, "options", {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtpStream.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/rtpStream.ts"],"names":[],"mappings":";;;AAAA,oCAAsE;AAEtE,oCAAuC;AAGvC,MAAa,eAAe;IAK1B,YACU,UAGJ,EAAE;;;;;mBAHE;;QALV;;;;;WAAoC;QACpC;;;;;WAAmC;QACnC;;;;;WAA2D;QAkB3D;;;;mBAAO,CAAC,MAA0B,EAAE,EAAE;gBACpC,MAAM,GAAG,GACP,MAAM,YAAY,eAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,eAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBAEvE,IACE,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,SAAS;oBACrC,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,GAAG,CAAC,MAAM,CAAC,WAAW,EACnD;oBACA,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;wBACrC,GAAG,CAAC,KAAK,EAAE,CAAC;qBACb;oBACD,OAAO;iBACR;gBAED,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;YACtB,CAAC;WAAC;QAzBA,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,IAAI,IAAI,CAAC;QAEpE,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAc,CAAC;YACjC,KAAK,EAAE,CAAC,UAAU,EAAE,EAAE;gBACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;gBAC7B,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAmBD,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAzCD,0CAyCC","sourcesContent":["import { ReadableStream, ReadableStreamController } from \"stream/web\";\n\nimport { RtpPacket } from \"../rtp/rtp\";\nimport { RtpOutput } from \"./rtpCallback\";\n\nexport class RtpSourceStream {\n readable: ReadableStream<RtpOutput>;\n write!: (chunk: RtpOutput) => void;\n protected controller!: ReadableStreamController<RtpOutput>;\n\n constructor(\n private options: {\n payloadType?: number;\n clearInvalidPTPacket?: boolean;\n } = {}\n ) {\n options.clearInvalidPTPacket = options.clearInvalidPTPacket ?? true;\n\n this.readable = new ReadableStream({\n start: (controller) => {\n this.controller = controller;\n this.write = (chunk) => controller.enqueue(chunk);\n },\n });\n }\n\n push = (packet: Buffer | RtpPacket) => {\n const rtp =\n packet instanceof RtpPacket ? packet : RtpPacket.deSerialize(packet);\n\n if (\n this.options.payloadType != undefined &&\n this.options.payloadType !== rtp.header.payloadType\n ) {\n if (this.options.clearInvalidPTPacket) {\n rtp.clear();\n }\n return;\n }\n\n this.write({ rtp });\n };\n\n stop() {\n this.controller.enqueue({ eol: true });\n }\n}\n"]}
@@ -1,7 +1,15 @@
1
1
  import { RtpTimeBase, RtpTimeInput, RtpTimeOutput } from "./rtpTime";
2
- export declare class RtpTimeCallback extends RtpTimeBase {
3
- private cb;
4
- constructor(clockRate: number);
5
- pipe: (cb: (input: RtpTimeOutput) => void) => this;
6
- input: (input: RtpTimeInput) => void;
2
+ declare const RtpTimeCallback_base: {
3
+ new (...args: any[]): {
4
+ cb?: ((o: RtpTimeOutput) => void) | undefined;
5
+ destructor?: (() => void) | undefined;
6
+ pipe: (cb: (o: RtpTimeOutput) => void, destructor?: (() => void) | undefined) => any;
7
+ input: (input: RtpTimeInput) => void;
8
+ destroy: () => void;
9
+ processInput: (input: RtpTimeInput) => RtpTimeOutput[];
10
+ toJSON(): Record<string, any>;
11
+ };
12
+ } & typeof RtpTimeBase;
13
+ export declare class RtpTimeCallback extends RtpTimeCallback_base {
7
14
  }
15
+ export {};
@@ -1,36 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RtpTimeCallback = void 0;
4
+ const interface_1 = require("./interface");
4
5
  const rtpTime_1 = require("./rtpTime");
5
- class RtpTimeCallback extends rtpTime_1.RtpTimeBase {
6
- constructor(clockRate) {
7
- super(clockRate);
8
- Object.defineProperty(this, "cb", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: void 0
13
- });
14
- Object.defineProperty(this, "pipe", {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value: (cb) => {
19
- this.cb = cb;
20
- return this;
21
- }
22
- });
23
- Object.defineProperty(this, "input", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: (input) => {
28
- for (const output of this.processInput(input)) {
29
- this.cb(output);
30
- }
31
- }
32
- });
33
- }
6
+ class RtpTimeCallback extends (0, interface_1.SimpleProcessorCallbackBase)(rtpTime_1.RtpTimeBase) {
34
7
  }
35
8
  exports.RtpTimeCallback = RtpTimeCallback;
36
9
  //# sourceMappingURL=rtpTimeCallback.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rtpTimeCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/rtpTimeCallback.ts"],"names":[],"mappings":";;;AAAA,uCAAqE;AAErE,MAAa,eAAgB,SAAQ,qBAAW;IAG9C,YAAY,SAAiB;QAC3B,KAAK,CAAC,SAAS,CAAC,CAAC;QAHnB;;;;;WAA4C;QAM5C;;;;mBAAO,CAAC,EAAkC,EAAE,EAAE;gBAC5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;gBACb,OAAO,IAAI,CAAC;YACd,CAAC;WAAC;QAEF;;;;mBAAQ,CAAC,KAAmB,EAAE,EAAE;gBAC9B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;oBAC7C,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;iBACjB;YACH,CAAC;WAAC;IAXF,CAAC;CAYF;AAjBD,0CAiBC","sourcesContent":["import { RtpTimeBase, RtpTimeInput, RtpTimeOutput } from \"./rtpTime\";\n\nexport class RtpTimeCallback extends RtpTimeBase {\n private cb!: (input: RtpTimeOutput) => void;\n\n constructor(clockRate: number) {\n super(clockRate);\n }\n\n pipe = (cb: (input: RtpTimeOutput) => void) => {\n this.cb = cb;\n return this;\n };\n\n input = (input: RtpTimeInput) => {\n for (const output of this.processInput(input)) {\n this.cb(output);\n }\n };\n}\n"]}
1
+ {"version":3,"file":"rtpTimeCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/rtpTimeCallback.ts"],"names":[],"mappings":";;;AAAA,2CAA0D;AAC1D,uCAAqE;AAErE,MAAa,eAAgB,SAAQ,IAAA,uCAA2B,EAI9D,qBAAW,CAAC;CAAG;AAJjB,0CAIiB","sourcesContent":["import { SimpleProcessorCallbackBase } from \"./interface\";\nimport { RtpTimeBase, RtpTimeInput, RtpTimeOutput } from \"./rtpTime\";\n\nexport class RtpTimeCallback extends SimpleProcessorCallbackBase<\n RtpTimeInput,\n RtpTimeOutput,\n typeof RtpTimeBase\n>(RtpTimeBase) {}\n"]}
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { SupportedCodec } from "../container/webm";
2
+ import Event from "rx.mini";
3
+ import { SupportedCodec } from "..";
3
4
  import { AVProcessor } from "./interface";
4
5
  export type WebmInput = {
5
6
  frame?: {
@@ -32,7 +33,7 @@ export declare class WebmBase implements AVProcessor<WebmInput> {
32
33
  tracks: {
33
34
  width?: number;
34
35
  height?: number;
35
- kind: "audio" | "video";
36
+ kind: MediaKind;
36
37
  codec: SupportedCodec;
37
38
  clockRate: number;
38
39
  trackNumber: number;
@@ -45,16 +46,18 @@ export declare class WebmBase implements AVProcessor<WebmInput> {
45
46
  private cuePoints;
46
47
  private position;
47
48
  private clusterCounts;
49
+ /**ms */
48
50
  elapsed?: number;
49
51
  audioStopped: boolean;
50
52
  videoStopped: boolean;
51
53
  stopped: boolean;
52
54
  videoKeyframeReceived: boolean;
53
55
  internalStats: {};
56
+ onStopped: Event<any[]>;
54
57
  constructor(tracks: {
55
58
  width?: number;
56
59
  height?: number;
57
- kind: "audio" | "video";
60
+ kind: MediaKind;
58
61
  codec: SupportedCodec;
59
62
  clockRate: number;
60
63
  trackNumber: number;
@@ -67,7 +70,7 @@ export declare class WebmBase implements AVProcessor<WebmInput> {
67
70
  private onFrameReceived;
68
71
  private createCluster;
69
72
  private createSimpleBlock;
70
- private stop;
73
+ stop(): void;
71
74
  }
72
75
  /**4294967295 */
73
76
  export declare const Max32Uint: number;
@@ -76,3 +79,4 @@ export declare const MaxSinged16Int: number;
76
79
  export declare const DurationPosition = 83;
77
80
  export declare const SegmentSizePosition = 40;
78
81
  export declare function replaceSegmentSize(totalFileSize: number): Buffer;
82
+ export type MediaKind = "video" | "audio";