@eluvio/elv-client-js 4.0.113 → 4.0.115

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 (129) hide show
  1. package/dist/ElvClient-min.js +67 -0
  2. package/dist/ElvClient-node-min.js +66 -0
  3. package/dist/ElvFrameClient-min.js +60 -0
  4. package/dist/ElvPermissionsClient-min.js +60 -0
  5. package/dist/ElvWalletClient-min.js +67 -0
  6. package/dist/ElvWalletClient-node-min.js +66 -0
  7. package/dist/src/AuthorizationClient.js +2169 -0
  8. package/dist/src/ContentObjectAudit.js +175 -0
  9. package/dist/src/ContentObjectVerification.js +281 -0
  10. package/dist/src/Crypto.js +412 -0
  11. package/dist/src/ElvClient.js +2044 -0
  12. package/dist/src/ElvWallet.js +245 -0
  13. package/dist/src/EthClient.js +1154 -0
  14. package/dist/src/FrameClient.js +485 -0
  15. package/dist/src/HttpClient.js +315 -0
  16. package/dist/src/Id.js +21 -0
  17. package/dist/src/LogMessage.js +25 -0
  18. package/dist/src/PermissionsClient.js +1544 -0
  19. package/dist/src/RemoteSigner.js +385 -0
  20. package/dist/src/UserProfileClient.js +1450 -0
  21. package/dist/src/Utils.js +894 -0
  22. package/dist/src/Validation.js +121 -0
  23. package/dist/src/abr_profiles/abr_profile_live_drm.js +1661 -0
  24. package/dist/src/abr_profiles/abr_profile_live_to_vod.js +1606 -0
  25. package/dist/src/client/ABRPublishing.js +1018 -0
  26. package/dist/src/client/AccessGroups.js +1503 -0
  27. package/dist/src/client/ContentAccess.js +5195 -0
  28. package/dist/src/client/ContentManagement.js +2680 -0
  29. package/dist/src/client/Contracts.js +1520 -0
  30. package/dist/src/client/Files.js +2181 -0
  31. package/dist/src/client/LiveConf.js +569 -0
  32. package/dist/src/client/LiveStream.js +2640 -0
  33. package/dist/src/client/NFT.js +162 -0
  34. package/dist/src/client/NTP.js +581 -0
  35. package/dist/src/contracts/v2/AccessIndexor.js +831 -0
  36. package/dist/src/contracts/v2/Accessible.js +31 -0
  37. package/dist/src/contracts/v2/BaseAccessControlGroup.js +1263 -0
  38. package/dist/src/contracts/v2/BaseAccessWallet.js +1609 -0
  39. package/dist/src/contracts/v2/BaseAccessWalletFactory.js +93 -0
  40. package/dist/src/contracts/v2/BaseContent.js +1076 -0
  41. package/dist/src/contracts/v2/BaseContentFactory.js +219 -0
  42. package/dist/src/contracts/v2/BaseContentSpace.js +1352 -0
  43. package/dist/src/contracts/v2/BaseContentType.js +364 -0
  44. package/dist/src/contracts/v2/BaseFactory.js +107 -0
  45. package/dist/src/contracts/v2/BaseGroupFactory.js +93 -0
  46. package/dist/src/contracts/v2/BaseLibrary.js +1041 -0
  47. package/dist/src/contracts/v2/BaseLibraryFactory.js +96 -0
  48. package/dist/src/contracts/v2/Certifyer.js +86 -0
  49. package/dist/src/contracts/v2/Container.js +540 -0
  50. package/dist/src/contracts/v2/Content.js +443 -0
  51. package/dist/src/contracts/v2/Editable.js +306 -0
  52. package/dist/src/contracts/v2/ExternalUserWallet.js +379 -0
  53. package/dist/src/contracts/v2/IFactorySpace.js +57 -0
  54. package/dist/src/contracts/v2/IKmsSpace.js +52 -0
  55. package/dist/src/contracts/v2/INodeSpace.js +18 -0
  56. package/dist/src/contracts/v2/IUserSpace.js +18 -0
  57. package/dist/src/contracts/v2/LvRecordableStream.js +1037 -0
  58. package/dist/src/contracts/v2/LvRecording.js +627 -0
  59. package/dist/src/contracts/v2/LvStreamRightsHolder.js +562 -0
  60. package/dist/src/contracts/v2/MetaObject.js +119 -0
  61. package/dist/src/contracts/v2/Node.js +167 -0
  62. package/dist/src/contracts/v2/NodeSpace.js +273 -0
  63. package/dist/src/contracts/v2/Ownable.js +87 -0
  64. package/dist/src/contracts/v2/PaymentService.js +627 -0
  65. package/dist/src/contracts/v2/Precompile.js +15 -0
  66. package/dist/src/contracts/v2/Transactable.js +82 -0
  67. package/dist/src/contracts/v2/UserSpace.js +29 -0
  68. package/dist/src/contracts/v2/Utils.js +18 -0
  69. package/dist/src/contracts/v2/Verifier.js +53 -0
  70. package/dist/src/contracts/v2/strings.js +4 -0
  71. package/dist/src/contracts/v3/AccessIndexor.js +774 -0
  72. package/dist/src/contracts/v3/Accessible.js +232 -0
  73. package/dist/src/contracts/v3/Adminable.js +107 -0
  74. package/dist/src/contracts/v3/AvailsDelivery.js +586 -0
  75. package/dist/src/contracts/v3/BaseAccessControlGroup.js +1603 -0
  76. package/dist/src/contracts/v3/BaseAccessWallet.js +1628 -0
  77. package/dist/src/contracts/v3/BaseAccessWalletFactory.js +112 -0
  78. package/dist/src/contracts/v3/BaseContent.js +1312 -0
  79. package/dist/src/contracts/v3/BaseContentFactory.js +183 -0
  80. package/dist/src/contracts/v3/BaseContentFactoryExt.js +175 -0
  81. package/dist/src/contracts/v3/BaseContentSpace.js +1515 -0
  82. package/dist/src/contracts/v3/BaseContentType.js +527 -0
  83. package/dist/src/contracts/v3/BaseFactory.js +126 -0
  84. package/dist/src/contracts/v3/BaseGroupFactory.js +112 -0
  85. package/dist/src/contracts/v3/BaseLibrary.js +1204 -0
  86. package/dist/src/contracts/v3/BaseLibraryFactory.js +115 -0
  87. package/dist/src/contracts/v3/BaseTenantSpace.js +1587 -0
  88. package/dist/src/contracts/v3/Certifyer.js +86 -0
  89. package/dist/src/contracts/v3/Container.js +739 -0
  90. package/dist/src/contracts/v3/Content.js +438 -0
  91. package/dist/src/contracts/v3/CounterObject.js +243 -0
  92. package/dist/src/contracts/v3/Editable.js +519 -0
  93. package/dist/src/contracts/v3/EncToken.js +4 -0
  94. package/dist/src/contracts/v3/ExternalUserWallet.js +587 -0
  95. package/dist/src/contracts/v3/IAdmin.js +18 -0
  96. package/dist/src/contracts/v3/IFactorySpace.js +57 -0
  97. package/dist/src/contracts/v3/IKmsSpace.js +52 -0
  98. package/dist/src/contracts/v3/INodeSpace.js +18 -0
  99. package/dist/src/contracts/v3/IUserSpace.js +32 -0
  100. package/dist/src/contracts/v3/LvRecordableStream.js +1032 -0
  101. package/dist/src/contracts/v3/LvRecording.js +650 -0
  102. package/dist/src/contracts/v3/LvStreamRightsHolder.js +557 -0
  103. package/dist/src/contracts/v3/MetaObject.js +144 -0
  104. package/dist/src/contracts/v3/Node.js +178 -0
  105. package/dist/src/contracts/v3/NodeSpace.js +284 -0
  106. package/dist/src/contracts/v3/Ownable.js +98 -0
  107. package/dist/src/contracts/v3/PaymentService.js +622 -0
  108. package/dist/src/contracts/v3/Precompile.js +26 -0
  109. package/dist/src/contracts/v3/TenantFuncsBase.js +351 -0
  110. package/dist/src/contracts/v3/Transactable.js +82 -0
  111. package/dist/src/contracts/v3/UserSpace.js +43 -0
  112. package/dist/src/contracts/v3/Utils.js +18 -0
  113. package/dist/src/contracts/v3/Verifier.js +53 -0
  114. package/dist/src/contracts/v3/strings.js +4 -0
  115. package/dist/src/contracts/v3b/BaseAccessControlGroup.js +1704 -0
  116. package/dist/src/events/Topics.js +1793 -0
  117. package/dist/src/index.js +8 -0
  118. package/dist/src/walletClient/ClientMethods.js +3102 -0
  119. package/dist/src/walletClient/Configuration.js +38 -0
  120. package/dist/src/walletClient/Notifications.js +168 -0
  121. package/dist/src/walletClient/Profile.js +332 -0
  122. package/dist/src/walletClient/Utils.js +281 -0
  123. package/dist/src/walletClient/index.js +2106 -0
  124. package/package.json +1 -1
  125. package/src/AuthorizationClient.js +25 -18
  126. package/src/ElvClient.js +19 -0
  127. package/src/client/ContentAccess.js +10 -1
  128. package/src/client/LiveConf.js +10 -8
  129. package/src/client/LiveStream.js +6 -4
@@ -0,0 +1,569 @@
1
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
+ var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
3
+ var _createClass = require("@babel/runtime/helpers/createClass");
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ /* eslint no-console: 0 */
7
+
8
+ var DefaultABRLadder = {
9
+ "video": [{
10
+ bit_rate: 14000000,
11
+ codecs: "avc1.640028,mp4a.40.2",
12
+ height: 2160,
13
+ width: 3840
14
+ }, {
15
+ bit_rate: 9500000,
16
+ codecs: "avc1.640028,mp4a.40.2",
17
+ height: 1080,
18
+ width: 1920
19
+ }, {
20
+ bit_rate: 4500000,
21
+ codecs: "avc1.640028,mp4a.40.2",
22
+ height: 720,
23
+ width: 1280
24
+ }, {
25
+ bit_rate: 2000000,
26
+ codecs: "avc1.640028,mp4a.40.2",
27
+ height: 540,
28
+ width: 960
29
+ }, {
30
+ bit_rate: 900000,
31
+ codecs: "avc1.640028,mp4a.40.2",
32
+ height: 540,
33
+ width: 960
34
+ }],
35
+ "audio": [{
36
+ bit_rate: 192000,
37
+ channels: 2,
38
+ codecs: "mp4a.40.2"
39
+ }, {
40
+ bit_rate: 384000,
41
+ channels: 6,
42
+ codecs: "mp4a.40.2"
43
+ }]
44
+ };
45
+ var LiveconfTemplate = {
46
+ live_recording: {
47
+ fabric_config: {
48
+ ingress_node_api: "",
49
+ ingress_node_id: ""
50
+ },
51
+ playout_config: {
52
+ dvr_enabled: true,
53
+ dvr_max_duration: 0,
54
+ rebroadcast_start_time_sec_epoch: 0,
55
+ vod_enabled: false
56
+ },
57
+ recording_config: {
58
+ recording_params: {
59
+ description: "",
60
+ ladder_specs: [],
61
+ listen: true,
62
+ live_delay_nano: 2000000000,
63
+ max_duration_sec: -1,
64
+ name: "",
65
+ origin_url: "",
66
+ part_ttl: 3600,
67
+ playout_type: "live",
68
+ source_timescale: null,
69
+ reconnect_timeout: 600,
70
+ xc_params: {
71
+ audio_bitrate: 384000,
72
+ audio_index: [0, 0, 0, 0, 0, 0, 0, 0],
73
+ audio_seg_duration_ts: null,
74
+ connection_timeout: 600,
75
+ ecodec2: "aac",
76
+ enc_height: null,
77
+ enc_width: null,
78
+ filter_descriptor: "",
79
+ force_keyint: null,
80
+ format: "fmp4-segment",
81
+ listen: true,
82
+ n_audio: 1,
83
+ preset: "faster",
84
+ sample_rate: 48000,
85
+ seg_duration: null,
86
+ skip_decoding: false,
87
+ start_segment_str: "1",
88
+ stream_id: -1,
89
+ sync_audio_to_stream_id: -1,
90
+ video_bitrate: null,
91
+ video_seg_duration_ts: null,
92
+ video_time_base: null,
93
+ video_frame_duration_ts: null,
94
+ xc_type: 3
95
+ }
96
+ }
97
+ }
98
+ }
99
+ };
100
+ var LiveConf = /*#__PURE__*/function () {
101
+ "use strict";
102
+
103
+ function LiveConf(probeData, nodeId, nodeUrl, includeAVSegDurations, overwriteOriginUrl, syncAudioToVideo) {
104
+ _classCallCheck(this, LiveConf);
105
+ this.probeData = probeData;
106
+ this.nodeId = nodeId;
107
+ this.nodeUrl = nodeUrl;
108
+ this.includeAVSegDurations = includeAVSegDurations;
109
+ this.overwriteOriginUrl = overwriteOriginUrl;
110
+ this.syncAudioToVideo = syncAudioToVideo;
111
+ }
112
+ _createClass(LiveConf, [{
113
+ key: "probeKind",
114
+ value: function probeKind() {
115
+ var fileNameSplit = this.probeData.format.filename.split(":");
116
+ return fileNameSplit[0];
117
+ }
118
+ }, {
119
+ key: "getStreamDataForCodecType",
120
+ value: function getStreamDataForCodecType(codecType) {
121
+ var stream = null;
122
+ for (var index = 0; index < this.probeData.streams.length; index++) {
123
+ if (this.probeData.streams[index].codec_type == codecType) {
124
+ stream = this.probeData.streams[index];
125
+ }
126
+ }
127
+ return stream;
128
+ }
129
+
130
+ // Return all audio streams found in the probe
131
+ // Used by generateAudioStreamsConfig()
132
+ }, {
133
+ key: "getAudioStreamsFromProbe",
134
+ value: function getAudioStreamsFromProbe() {
135
+ var audioStreams = {};
136
+ for (var index = 0; index < this.probeData.streams.length; index++) {
137
+ if (this.probeData.streams[index].codec_type == "audio") {
138
+ audioStreams[index] = {
139
+ recordingBitrate: Math.max(this.probeData.streams[index].bit_rate, 128000),
140
+ recordingChannels: this.probeData.streams[index].channels,
141
+ playoutLabel: "Audio ".concat(index)
142
+ };
143
+ }
144
+ }
145
+ return audioStreams;
146
+ }
147
+ }, {
148
+ key: "getFrameRate",
149
+ value: function getFrameRate() {
150
+ var videoStream = this.getStreamDataForCodecType("video");
151
+ var frameRate = videoStream.r_frame_rate || videoStream.frame_rate;
152
+ return frameRate.split("/");
153
+ }
154
+ }, {
155
+ key: "isFrameRateWhole",
156
+ value: function isFrameRateWhole() {
157
+ var frameRate = this.getFrameRate();
158
+ return frameRate[1] == "1";
159
+ }
160
+ }, {
161
+ key: "getForceKeyint",
162
+ value: function getForceKeyint() {
163
+ var frameRate = this.getFrameRate();
164
+ var roundedFrameRate = Math.round(frameRate[0] / frameRate[1]);
165
+ if (roundedFrameRate > 30) {
166
+ return roundedFrameRate;
167
+ } else {
168
+ return roundedFrameRate * 2;
169
+ }
170
+ }
171
+
172
+ /*
173
+ * Calculates mez segment durations based on input stream parameters
174
+ *
175
+ * Live input formats have fixed timebase:
176
+ * - MPEG-TS/SRT input stream timebase is 90000
177
+ * - RTMP input stream timebase is 1000 and gets translated to 16000 if not otherwise specified
178
+ *
179
+ * This causes frame duration irregularities for certain frame rates.
180
+ * For example RTMP 60fps has frames of durations 16 and 17. MPEG-TS 59.94fps has frames of
181
+ * durations 1001 and 1002.
182
+ *
183
+ * Live mez segmentation requires that the segment be cut at the specific number of frames, and when
184
+ * the frame durations are irregular we adjust both the video timebase and the video frame duration
185
+ * to make the math possible. This adjustment is also required for live-to-vod conversion.
186
+ *
187
+ * For example for MPEG-TS 59.94fps, the mez segment timebase needs to be 60000
188
+ * (and resulting frame duration is 1001) and for RTMP 60fps the timebase needs to be 15360 (resulting frame
189
+ * duration is 256).
190
+ *
191
+ * @sourceTimescale - adjusted source video stream timescale (eg. MPEGTS 90000, RTMP 16000 )
192
+ * @sampleRate - audio sample rate (commonly 48000 but can be different)
193
+ * @audioCodec - audio codec as a string (eg. "aac")
194
+ * @return - segment encoding parameters
195
+ */
196
+ }, {
197
+ key: "calcSegDuration",
198
+ value: function calcSegDuration(_ref) {
199
+ var sourceTimescale = _ref.sourceTimescale,
200
+ sampleRate = _ref.sampleRate,
201
+ audioCodec = _ref.audioCodec;
202
+ var seg = {};
203
+ switch (this.probeKind()) {
204
+ case "rtmp":
205
+ seg = this.calcSegDurationRtmp({
206
+ sourceTimescale: sourceTimescale,
207
+ sampleRate: sampleRate,
208
+ audioCodec: audioCodec
209
+ });
210
+ break;
211
+ case "udp":
212
+ case "srt":
213
+ seg = this.calcSegDurationMpegts({
214
+ sourceTimescale: sourceTimescale,
215
+ sampleRate: sampleRate,
216
+ audioCodec: audioCodec
217
+ });
218
+ break;
219
+ default:
220
+ throw "protocol not supported - " + this.probeKind();
221
+ }
222
+ if (audioCodec == "aac") {
223
+ seg.audio = 29.76 * sampleRate;
224
+ } else {
225
+ seg.audio = 29.76 * 48000; // Other codecs are resampled @48000
226
+ }
227
+
228
+ return seg;
229
+ }
230
+
231
+ /*
232
+ * Calculate output timebase from the encoder (codec) timebase. The videoTimeBase parameter
233
+ * represents the encoder timebase. The format muxer will change it so it is greater than 10000.
234
+ */
235
+ }, {
236
+ key: "calcOutputTimebase",
237
+ value: function calcOutputTimebase(codecTimebase) {
238
+ var outputTimebase = codecTimebase;
239
+ while (outputTimebase < 10000) outputTimebase = outputTimebase * 2;
240
+ return outputTimebase;
241
+ }
242
+ }, {
243
+ key: "calcSegDurationMpegts",
244
+ value: function calcSegDurationMpegts(_ref2) {
245
+ var sourceTimescale = _ref2.sourceTimescale;
246
+ var videoStream = this.getStreamDataForCodecType("video");
247
+ var frameRate = videoStream.frame_rate;
248
+
249
+ // PENDING(SS) - calculate frame duration here
250
+ // let frameRateNum = 0;
251
+ var seg = {
252
+ // videoFrameDurationTs: sourceTimescale / frameRateNum
253
+ };
254
+ switch (frameRate) {
255
+ case "24":
256
+ seg.video = sourceTimescale * 30;
257
+ seg.keyint = 48;
258
+ seg.duration = "30";
259
+ break;
260
+ case "25":
261
+ seg.video = sourceTimescale * 30;
262
+ seg.keyint = 50;
263
+ seg.duration = "30";
264
+ break;
265
+ case "30":
266
+ seg.video = sourceTimescale * 30;
267
+ seg.keyint = 60;
268
+ seg.duration = "30";
269
+ break;
270
+ case "30000/1001":
271
+ //seg.videoFrameDurationTs = 3003;
272
+ seg.video = sourceTimescale * 30;
273
+ seg.keyint = 60;
274
+ seg.duration = "30.03";
275
+ break;
276
+ case "48":
277
+ //seg.videoFrameDurationTs = 1875;
278
+ seg.video = sourceTimescale * 30;
279
+ seg.keyint = 96;
280
+ seg.duration = "30";
281
+ break;
282
+ case "50":
283
+ //seg.videoFrameDurationTs = 1800;
284
+ seg.video = sourceTimescale * 30;
285
+ seg.keyint = 100;
286
+ seg.duration = "30";
287
+ break;
288
+ case "60":
289
+ //seg.videoFrameDurationTs = 1500;
290
+ seg.video = sourceTimescale * 30;
291
+ seg.keyint = 120;
292
+ seg.duration = "30";
293
+ break;
294
+ case "60000/1001":
295
+ seg.videoTimeBase = 60000;
296
+ seg.video = seg.videoTimeBase * 30.03;
297
+ seg.keyint = 120;
298
+ seg.duration = "30.03";
299
+ break;
300
+ default:
301
+ throw "unsupported frame rate for MPEGTS - " + frameRate;
302
+ }
303
+ return seg;
304
+ }
305
+ }, {
306
+ key: "calcSegDurationRtmp",
307
+ value: function calcSegDurationRtmp(_ref3) {
308
+ var sourceTimescale = _ref3.sourceTimescale;
309
+ var videoStream = this.getStreamDataForCodecType("video");
310
+ var frameRate = videoStream.frame_rate;
311
+ var seg = {};
312
+ switch (frameRate) {
313
+ case "24":
314
+ seg.videoTimeBase = 768; // Note 1536 produces low output bitrate
315
+ seg.videoFrameDurationTs = 512;
316
+ seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
317
+ seg.keyint = 48;
318
+ seg.duration = "30";
319
+ break;
320
+ case "25":
321
+ seg.video = sourceTimescale * 30;
322
+ seg.keyint = 50;
323
+ seg.duration = "30";
324
+ break;
325
+ case "30":
326
+ seg.videoTimeBase = 960; // Output timebase: 15360
327
+ seg.videoFrameDurationTs = 512;
328
+ seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
329
+ seg.keyint = 60;
330
+ seg.duration = "30";
331
+ break;
332
+ case "30000/1001":
333
+ seg.video = sourceTimescale * 30.03;
334
+ seg.keyint = 60;
335
+ seg.duration = "30.03";
336
+ break;
337
+ case "48":
338
+ seg.videoTimeBase = 1536; // Output timebase: 12288
339
+ seg.videoFrameDurationTs = 256;
340
+ seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
341
+ seg.keyint = 96;
342
+ seg.duration = "30";
343
+ break;
344
+ case "50":
345
+ seg.video = sourceTimescale * 30;
346
+ seg.keyint = 100;
347
+ seg.duration = "30";
348
+ break;
349
+ case "60":
350
+ seg.videoTimeBase = 960; // Output timebase: 15360
351
+ seg.videoFrameDurationTs = 256;
352
+ seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
353
+ seg.keyint = 120;
354
+ seg.duration = "30";
355
+ break;
356
+ case "60000/1001":
357
+ seg.video = sourceTimescale * 30.03;
358
+ seg.keyint = 120;
359
+ seg.duration = "30.03";
360
+ break;
361
+ default:
362
+ throw "unsupported frame rate for RTMP - " + frameRate;
363
+ }
364
+ return seg;
365
+ }
366
+ }, {
367
+ key: "syncAudioToStreamIdValue",
368
+ value: function syncAudioToStreamIdValue() {
369
+ var sync_id = -1;
370
+ var videoStream = this.getStreamDataForCodecType("video");
371
+ switch (this.probeKind()) {
372
+ case "udp":
373
+ case "srt":
374
+ sync_id = videoStream.stream_id;
375
+ break;
376
+ case "rtmp":
377
+ sync_id = videoStream.stream_index;
378
+ break;
379
+ }
380
+ return sync_id;
381
+ }
382
+
383
+ /*
384
+ * Generate audio streams recording configuration based on the optional custom settings.
385
+ * If no custom "audio" section is present, record all the acceptable audio streams found in the probe
386
+ */
387
+ }, {
388
+ key: "generateAudioStreamsConfig",
389
+ value: function generateAudioStreamsConfig(_ref4) {
390
+ var customSettings = _ref4.customSettings;
391
+ var audioStreams = {};
392
+ if (customSettings && customSettings.audio && Object.keys(customSettings.audio).length > 0) {
393
+ for (var i = 0; i < Object.keys(customSettings.audio).length; i++) {
394
+ var audioIdx = Object.keys(customSettings.audio)[i];
395
+ var audio = customSettings.audio[audioIdx];
396
+ audioStreams[audioIdx] = {
397
+ recordingBitrate: audio.recording_bitrate || 192000,
398
+ recordingChannels: audio.recording_channels || 2
399
+ };
400
+ if (audio.playout) {
401
+ audioStreams[audioIdx].playoutLabel = audio.playout_label || "Audio ".concat(audioIdx);
402
+ }
403
+ }
404
+ }
405
+
406
+ // If no audio streams specified in custom config, set up all the suitable audio streams in the probe
407
+ if (!customSettings.audio || Object.keys(customSettings.audio).length == 0) {
408
+ audioStreams = this.getAudioStreamsFromProbe();
409
+ }
410
+ return audioStreams;
411
+ }
412
+
413
+ /*
414
+ * Generate the live recording config as required by QFAB, based on defaults and optional custom settings.
415
+ */
416
+ }, {
417
+ key: "generateLiveConf",
418
+ value: function generateLiveConf(_ref5) {
419
+ var customSettings = _ref5.customSettings;
420
+ // gather required data
421
+ var conf = JSON.parse(JSON.stringify(LiveconfTemplate));
422
+ var fileName = this.overwriteOriginUrl || this.probeData.format.filename;
423
+ var audioStreams = this.generateAudioStreamsConfig({
424
+ customSettings: customSettings
425
+ });
426
+
427
+ // Retrieve one audio stream from the probe to read the sample rate and codec name
428
+ var audioStream = this.getStreamDataForCodecType("audio");
429
+ var sampleRate = parseInt(audioStream.sample_rate);
430
+ var audioCodec = audioStream.codec_name;
431
+ var videoStream = this.getStreamDataForCodecType("video");
432
+ var sourceTimescale;
433
+
434
+ // Fill in liveconf all formats have in common
435
+ conf.live_recording.fabric_config.ingress_node_api = this.nodeUrl || null;
436
+ conf.live_recording.fabric_config.ingress_node_id = this.nodeId || null;
437
+ conf.live_recording.recording_config.recording_params.description;
438
+ conf.live_recording.recording_config.recording_params.origin_url = fileName;
439
+ conf.live_recording.recording_config.recording_params.description = "Ingest stream ".concat(fileName);
440
+ conf.live_recording.recording_config.recording_params.name = "Ingest stream ".concat(fileName);
441
+ conf.live_recording.recording_config.recording_params.xc_params.sample_rate = sampleRate;
442
+ conf.live_recording.recording_config.recording_params.xc_params.enc_height = videoStream.height;
443
+ conf.live_recording.recording_config.recording_params.xc_params.enc_width = videoStream.width;
444
+ for (var i = 0; i < Object.keys(audioStreams).length; i++) {
445
+ conf.live_recording.recording_config.recording_params.xc_params.audio_index[i] = parseInt(Object.keys(audioStreams)[i]);
446
+ }
447
+ if (this.syncAudioToVideo) {
448
+ conf.live_recording.recording_config.recording_params.xc_params.sync_audio_to_stream_id = this.syncAudioToStreamIdValue();
449
+ }
450
+ if (customSettings.edge_write_token) {
451
+ conf.live_recording.fabric_config.edge_write_token = customSettings.edge_write_token;
452
+ }
453
+ if (customSettings.part_ttl) {
454
+ conf.live_recording.recording_config.recording_params.part_ttl = customSettings.part_ttl;
455
+ }
456
+ if (customSettings.connection_timeout) {
457
+ conf.live_recording.recording_config.recording_params.xc_params.connection_timeout = customSettings.connection_timeout;
458
+ }
459
+ if (customSettings.reconnect_timeout) {
460
+ conf.live_recording.recording_config.recording_params.reconnect_timeout = customSettings.reconnect_timeout;
461
+ }
462
+
463
+ // Fill in specifics for protocol
464
+ switch (this.probeKind()) {
465
+ case "udp":
466
+ sourceTimescale = 90000;
467
+ conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
468
+ break;
469
+ case "srt":
470
+ sourceTimescale = 90000;
471
+ conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
472
+ conf.live_recording.recording_config.recording_params.live_delay_nano = 4000000000;
473
+ break;
474
+ case "rtmp":
475
+ sourceTimescale = 16000;
476
+ conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
477
+ break;
478
+ case "hls":
479
+ console.log("HLS detected. Not yet implemented");
480
+ break;
481
+ default:
482
+ console.log("Unsupported media", this.probeKind());
483
+ break;
484
+ }
485
+ var segDurations = this.calcSegDuration({
486
+ sourceTimescale: sourceTimescale,
487
+ sampleRate: sampleRate,
488
+ audioCodec: audioCodec
489
+ });
490
+
491
+ // Segment conditioning parameters
492
+ conf.live_recording.recording_config.recording_params.xc_params.seg_duration = segDurations.duration;
493
+ conf.live_recording.recording_config.recording_params.xc_params.audio_seg_duration_ts = segDurations.audio;
494
+ conf.live_recording.recording_config.recording_params.xc_params.video_seg_duration_ts = segDurations.video;
495
+ conf.live_recording.recording_config.recording_params.xc_params.force_keyint = segDurations.keyint;
496
+
497
+ // Optional override output timebase and frame duration (ts)
498
+ if (segDurations.videoTimeBase) {
499
+ conf.live_recording.recording_config.recording_params.xc_params.video_time_base = segDurations.videoTimeBase;
500
+
501
+ // Note 'source_timescale' needs to be set to the output timebase and is used by playout
502
+ conf.live_recording.recording_config.recording_params.source_timescale = this.calcOutputTimebase(segDurations.videoTimeBase);
503
+ }
504
+ if (segDurations.videoFrameDurationTs) {
505
+ conf.live_recording.recording_config.recording_params.xc_params.video_frame_duration_ts = segDurations.videoFrameDurationTs;
506
+ }
507
+ var ladderProfile = customSettings.ladder_profile || DefaultABRLadder;
508
+ conf.live_recording.recording_config.recording_params.xc_params.enc_height = videoStream.height;
509
+ conf.live_recording.recording_config.recording_params.xc_params.enc_width = videoStream.width;
510
+
511
+ // Determine video recording bitrate and ABR ladder
512
+ var topLadderRate = 0;
513
+ for (var _i = 0; _i < ladderProfile.video.length; _i++) {
514
+ var elem = ladderProfile.video[_i];
515
+ if (elem.height > videoStream.height) continue;
516
+ if (elem.bit_rate > topLadderRate) {
517
+ topLadderRate = elem.bit_rate;
518
+ }
519
+ elem.media_type = 1;
520
+ elem.stream_name = "video";
521
+ elem.stream_index = 0;
522
+ elem.representation = "videovideo_" + elem.width + "x" + elem.height + "_h264@" + elem.bit_rate;
523
+ conf.live_recording.recording_config.recording_params.ladder_specs.push(elem);
524
+ }
525
+ // Currently the recording bitrate is the top bitrate of the ladder (it will be configurable separately in the future)
526
+ conf.live_recording.recording_config.recording_params.xc_params.video_bitrate = topLadderRate;
527
+
528
+ // Determine audio recording bitrate and ABR ladder
529
+ var globalAudioBitrate = 0;
530
+ var nAudio = 0;
531
+ for (var _i2 = 0; _i2 < Object.keys(audioStreams).length; _i2++) {
532
+ var audioLadderSpec = {};
533
+ var audioIndex = Object.keys(audioStreams)[_i2];
534
+ var audio = audioStreams[audioIndex];
535
+
536
+ // Find ladder rung for the specific channel layout (2 or 6 channels)
537
+ for (var j = 0; j < ladderProfile.audio.length; j++) {
538
+ var _elem = ladderProfile.audio[j];
539
+ if (_elem.channels == audio.recordingChannels) {
540
+ audioLadderSpec = _objectSpread({}, _elem);
541
+ break;
542
+ }
543
+ }
544
+ if (Object.keys(audioLadderSpec).length === 0) {
545
+ // If no channels layout match, just use the first element in the ladder
546
+ audioLadderSpec = _objectSpread({}, ladderProfile.audio[0]);
547
+ }
548
+ audioLadderSpec.representation = "audioaudio_aac@".concat(audioLadderSpec.bit_rate);
549
+ audioLadderSpec.channels = audio.recordingChannels;
550
+ audioLadderSpec.stream_index = parseInt(audioIndex);
551
+ audioLadderSpec.stream_name = "audio_".concat(audioIndex);
552
+ audioLadderSpec.stream_label = audio.playoutLabel ? audio.playoutLabel : null;
553
+ audioLadderSpec.media_type = 2;
554
+ conf.live_recording.recording_config.recording_params.ladder_specs.push(audioLadderSpec);
555
+ if (audio.recordingBitrate > globalAudioBitrate) {
556
+ globalAudioBitrate = audio.recordingBitrate;
557
+ }
558
+ nAudio++;
559
+ }
560
+
561
+ // Global recording bitrate for all audio streams
562
+ conf.live_recording.recording_config.recording_params.xc_params.audio_bitrate = globalAudioBitrate;
563
+ conf.live_recording.recording_config.recording_params.xc_params.n_audio = nAudio;
564
+ return conf;
565
+ }
566
+ }]);
567
+ return LiveConf;
568
+ }();
569
+ exports.LiveConf = LiveConf;