@eluvio/elv-client-js 4.0.86 → 4.0.88

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.
@@ -1711,7 +1711,7 @@ exports.FinalizeContentObject = /*#__PURE__*/function () {
1711
1711
  */
1712
1712
  exports.PublishContentVersion = /*#__PURE__*/function () {
1713
1713
  var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref37) {
1714
- var objectId, versionHash, _ref37$awaitCommitCon, awaitCommitConfirmation, commit, abi, fromBlock, objectHash, pendingHash, pollingInterval, events, confirmEvent;
1714
+ var objectId, versionHash, _ref37$awaitCommitCon, awaitCommitConfirmation, commit, abi, fromBlock, objectHash, pendingHash, pollingInterval, events, confirmEvent, _pollingInterval, tries, h;
1715
1715
  return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1716
1716
  while (1) switch (_context21.prev = _context21.next) {
1717
1717
  case 0:
@@ -1793,16 +1793,68 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
1793
1793
  break;
1794
1794
  }
1795
1795
  // Found confirmation
1796
- this.Log("Commit confirmed: ".concat(objectHash));
1796
+ this.Log("Commit confirmed on chain: ".concat(objectHash));
1797
1797
  return _context21.abrupt("break", 34);
1798
1798
  case 32:
1799
1799
  _context21.next = 22;
1800
1800
  break;
1801
1801
  case 34:
1802
+ if (!awaitCommitConfirmation) {
1803
+ _context21.next = 62;
1804
+ break;
1805
+ }
1806
+ _pollingInterval = 500; // ms
1807
+ tries = 20;
1808
+ case 37:
1809
+ if (!(tries > 0)) {
1810
+ _context21.next = 62;
1811
+ break;
1812
+ }
1813
+ h = void 0;
1814
+ _context21.prev = 39;
1815
+ _context21.next = 42;
1816
+ return this.LatestVersionHashV2({
1817
+ objectId: objectId
1818
+ });
1819
+ case 42:
1820
+ h = _context21.sent;
1821
+ if (!(h === versionHash)) {
1822
+ _context21.next = 48;
1823
+ break;
1824
+ }
1825
+ this.Log("Commit confirmed on fabric node: ".concat(versionHash));
1826
+ return _context21.abrupt("break", 62);
1827
+ case 48:
1828
+ tries--;
1829
+ _context21.next = 51;
1830
+ return new Promise(function (resolve) {
1831
+ return setTimeout(resolve, _pollingInterval);
1832
+ });
1833
+ case 51:
1834
+ _context21.next = 60;
1835
+ break;
1836
+ case 53:
1837
+ _context21.prev = 53;
1838
+ _context21.t0 = _context21["catch"](39);
1839
+ if (!(_context21.t0.status !== 404)) {
1840
+ _context21.next = 57;
1841
+ break;
1842
+ }
1843
+ throw _context21.t0;
1844
+ case 57:
1845
+ tries--;
1846
+ _context21.next = 60;
1847
+ return new Promise(function (resolve) {
1848
+ return setTimeout(resolve, _pollingInterval);
1849
+ });
1850
+ case 60:
1851
+ _context21.next = 37;
1852
+ break;
1853
+ case 62:
1802
1854
  case "end":
1803
1855
  return _context21.stop();
1804
1856
  }
1805
- }, _callee21, this);
1857
+ }, _callee21, this, [[39, 53]]);
1806
1858
  }));
1807
1859
  return function (_x20) {
1808
1860
  return _ref38.apply(this, arguments);
@@ -35,24 +35,27 @@ var _require = require("../Validation"),
35
35
  * @namedParams
36
36
  * @param {string=} libraryId - ID of the library
37
37
  * @param {string=} objectId - ID of the object
38
+ * @param {string=} path - ID of the object
38
39
  * @param {string=} versionHash - Hash of the object version - if not specified, most recent version will be used
40
+ * @param {string=} writeToken - Write token of a draft (incompatible with versionHash)
39
41
  */
40
42
  exports.ListFiles = /*#__PURE__*/function () {
41
43
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
42
- var libraryId, objectId, versionHash, path;
44
+ var libraryId, objectId, _ref$path, path, versionHash, writeToken, urlPath;
43
45
  return _regeneratorRuntime.wrap(function _callee$(_context) {
44
46
  while (1) switch (_context.prev = _context.next) {
45
47
  case 0:
46
- libraryId = _ref.libraryId, objectId = _ref.objectId, versionHash = _ref.versionHash;
48
+ libraryId = _ref.libraryId, objectId = _ref.objectId, _ref$path = _ref.path, path = _ref$path === void 0 ? "" : _ref$path, versionHash = _ref.versionHash, writeToken = _ref.writeToken;
47
49
  ValidateParameters({
48
50
  libraryId: libraryId,
49
51
  objectId: objectId,
50
- versionHash: versionHash
52
+ versionHash: versionHash,
53
+ writeToken: writeToken
51
54
  });
52
55
  if (versionHash) {
53
56
  objectId = this.utils.DecodeVersionHash(versionHash).objectId;
54
57
  }
55
- path = UrlJoin("q", versionHash || objectId, "meta", "files");
58
+ urlPath = UrlJoin("q", writeToken || versionHash || objectId, "files_list", path);
56
59
  _context.t0 = this.utils;
57
60
  _context.t1 = this.HttpClient;
58
61
  _context.next = 8;
@@ -63,7 +66,7 @@ exports.ListFiles = /*#__PURE__*/function () {
63
66
  });
64
67
  case 8:
65
68
  _context.t2 = _context.sent;
66
- _context.t3 = path;
69
+ _context.t3 = urlPath;
67
70
  _context.t4 = {
68
71
  headers: _context.t2,
69
72
  method: "GET",
@@ -882,7 +885,7 @@ exports.UploadFileData = /*#__PURE__*/function () {
882
885
  jobStatus = _context11.sent;
883
886
  // Find the status of this file
884
887
  fileStatus = jobStatus.files.find(function (item) {
885
- return item.path == filePath;
888
+ return item.path === filePath;
886
889
  });
887
890
  if (encryption && encryption !== "none") {
888
891
  fileStatus = fileStatus.encrypted;
@@ -1,5 +1,8 @@
1
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
1
2
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
2
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; }
3
6
  var LadderTemplate = {
4
7
  "2160": {
5
8
  bit_rate: 14000000,
@@ -17,6 +20,7 @@ var LadderTemplate = {
17
20
  media_type: 1,
18
21
  representation: "videovideo_1920x1080_h264@9500000",
19
22
  stream_name: "video",
23
+ stream_index: 0,
20
24
  width: 1920
21
25
  },
22
26
  "720": {
@@ -26,6 +30,7 @@ var LadderTemplate = {
26
30
  media_type: 1,
27
31
  representation: "videovideo_1280x720_h264@4500000",
28
32
  stream_name: "video",
33
+ stream_index: 0,
29
34
  width: 1280
30
35
  },
31
36
  "540": {
@@ -35,6 +40,7 @@ var LadderTemplate = {
35
40
  media_type: 1,
36
41
  representation: "videovideo_960x540_h264@2000000",
37
42
  stream_name: "video",
43
+ stream_index: 0,
38
44
  width: 960
39
45
  },
40
46
  "540_low": {
@@ -44,6 +50,7 @@ var LadderTemplate = {
44
50
  media_type: 1,
45
51
  representation: "videovideo_960x540_h264@900000",
46
52
  stream_name: "video",
53
+ stream_index: 0,
47
54
  width: 960
48
55
  }
49
56
  };
@@ -60,14 +67,7 @@ var LiveconfTemplate = {
60
67
  recording_config: {
61
68
  recording_params: {
62
69
  description: "",
63
- ladder_specs: [{
64
- bit_rate: 384000,
65
- channels: 2,
66
- codecs: "mp4a.40.2",
67
- media_type: 2,
68
- representation: "audioaudio_aac@384000",
69
- stream_name: "audio"
70
- }],
70
+ ladder_specs: [],
71
71
  listen: true,
72
72
  live_delay_nano: 2000000000,
73
73
  max_duration_sec: -1,
@@ -80,6 +80,7 @@ var LiveconfTemplate = {
80
80
  audio_bitrate: 384000,
81
81
  audio_index: [0, 0, 0, 0, 0, 0, 0, 0],
82
82
  audio_seg_duration_ts: null,
83
+ connection_timeout: 60,
83
84
  ecodec2: "aac",
84
85
  enc_height: null,
85
86
  enc_width: null,
@@ -98,12 +99,22 @@ var LiveconfTemplate = {
98
99
  video_bitrate: null,
99
100
  video_seg_duration_ts: null,
100
101
  video_time_base: null,
102
+ video_frame_duration_ts: null,
101
103
  xc_type: 3
102
104
  }
103
105
  }
104
106
  }
105
107
  }
106
108
  };
109
+ var LadderSpecAudio = {
110
+ bit_rate: 384000,
111
+ channels: 2,
112
+ codecs: "mp4a.40.2",
113
+ media_type: 2,
114
+ representation: "audioaudio_aac@384000",
115
+ stream_name: "audio",
116
+ stream_index: 0
117
+ };
107
118
  var LiveConf = /*#__PURE__*/function () {
108
119
  "use strict";
109
120
 
@@ -133,6 +144,24 @@ var LiveConf = /*#__PURE__*/function () {
133
144
  }
134
145
  return stream;
135
146
  }
147
+
148
+ // Return all audio streams found in the probe
149
+ // Used by generateAudioStreamsConfig()
150
+ }, {
151
+ key: "getAudioStreamsFromProbe",
152
+ value: function getAudioStreamsFromProbe() {
153
+ var audioStreams = {};
154
+ for (var index = 0; index < this.probeData.streams.length; index++) {
155
+ if (this.probeData.streams[index].codec_type == "audio") {
156
+ audioStreams[index] = {
157
+ recordingBitrate: Math.max(this.probeData.streams[index].bit_rate, 128000),
158
+ recordingChannels: this.probeData.streams[index].channels,
159
+ playoutLabel: "Audio ".concat(index)
160
+ };
161
+ }
162
+ }
163
+ return audioStreams;
164
+ }
136
165
  }, {
137
166
  key: "getFrameRate",
138
167
  value: function getFrameRate() {
@@ -216,13 +245,30 @@ var LiveConf = /*#__PURE__*/function () {
216
245
 
217
246
  return seg;
218
247
  }
248
+
249
+ /*
250
+ * Calculate output timebase from the encoder (codec) timebase. The videoTimeBase parameter
251
+ * represents the encoder timebase. The format muxer will change it so it is greater than 10000.
252
+ */
253
+ }, {
254
+ key: "calcOutputTimebase",
255
+ value: function calcOutputTimebase(codecTimebase) {
256
+ var outputTimebase = codecTimebase;
257
+ while (outputTimebase < 10000) outputTimebase = outputTimebase * 2;
258
+ return outputTimebase;
259
+ }
219
260
  }, {
220
261
  key: "calcSegDurationMpegts",
221
262
  value: function calcSegDurationMpegts(_ref2) {
222
263
  var sourceTimescale = _ref2.sourceTimescale;
223
264
  var videoStream = this.getStreamDataForCodecType("video");
224
265
  var frameRate = videoStream.frame_rate;
225
- var seg = {};
266
+
267
+ // PENDING(SS) - calculate frame duration here
268
+ // let frameRateNum = 0;
269
+ var seg = {
270
+ // videoFrameDurationTs: sourceTimescale / frameRateNum
271
+ };
226
272
  switch (frameRate) {
227
273
  case "24":
228
274
  seg.video = sourceTimescale * 30;
@@ -240,21 +286,25 @@ var LiveConf = /*#__PURE__*/function () {
240
286
  seg.duration = "30";
241
287
  break;
242
288
  case "30000/1001":
289
+ //seg.videoFrameDurationTs = 3003;
243
290
  seg.video = sourceTimescale * 30;
244
291
  seg.keyint = 60;
245
292
  seg.duration = "30.03";
246
293
  break;
247
294
  case "48":
295
+ //seg.videoFrameDurationTs = 1875;
248
296
  seg.video = sourceTimescale * 30;
249
297
  seg.keyint = 96;
250
298
  seg.duration = "30";
251
299
  break;
252
300
  case "50":
301
+ //seg.videoFrameDurationTs = 1800;
253
302
  seg.video = sourceTimescale * 30;
254
303
  seg.keyint = 100;
255
304
  seg.duration = "30";
256
305
  break;
257
306
  case "60":
307
+ //seg.videoFrameDurationTs = 1500;
258
308
  seg.video = sourceTimescale * 30;
259
309
  seg.keyint = 120;
260
310
  seg.duration = "30";
@@ -280,7 +330,9 @@ var LiveConf = /*#__PURE__*/function () {
280
330
  var seg = {};
281
331
  switch (frameRate) {
282
332
  case "24":
283
- seg.video = sourceTimescale * 30;
333
+ seg.videoTimeBase = 768; // Note 1536 produces low output bitrate
334
+ seg.videoFrameDurationTs = 512;
335
+ seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
284
336
  seg.keyint = 48;
285
337
  seg.duration = "30";
286
338
  break;
@@ -290,7 +342,9 @@ var LiveConf = /*#__PURE__*/function () {
290
342
  seg.duration = "30";
291
343
  break;
292
344
  case "30":
293
- seg.video = sourceTimescale * 30;
345
+ seg.videoTimeBase = 960; // Output timebase: 15360
346
+ seg.videoFrameDurationTs = 512;
347
+ seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
294
348
  seg.keyint = 60;
295
349
  seg.duration = "30";
296
350
  break;
@@ -300,7 +354,9 @@ var LiveConf = /*#__PURE__*/function () {
300
354
  seg.duration = "30.03";
301
355
  break;
302
356
  case "48":
303
- seg.video = sourceTimescale * 30;
357
+ seg.videoTimeBase = 1536; // Output timebase: 12288
358
+ seg.videoFrameDurationTs = 256;
359
+ seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
304
360
  seg.keyint = 96;
305
361
  seg.duration = "30";
306
362
  break;
@@ -310,7 +366,9 @@ var LiveConf = /*#__PURE__*/function () {
310
366
  seg.duration = "30";
311
367
  break;
312
368
  case "60":
313
- seg.video = sourceTimescale * 30;
369
+ seg.videoTimeBase = 960; // Output timebase: 15360
370
+ seg.videoFrameDurationTs = 256;
371
+ seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
314
372
  seg.keyint = 120;
315
373
  seg.duration = "30";
316
374
  break;
@@ -341,16 +399,52 @@ var LiveConf = /*#__PURE__*/function () {
341
399
  }
342
400
  return sync_id;
343
401
  }
402
+
403
+ /*
404
+ * Generate audio streams recording configuration based on the optional custom settings.
405
+ * If no custom "audio" section is present, record all the acceptable audio streams found in the probe
406
+ */
407
+ }, {
408
+ key: "generateAudioStreamsConfig",
409
+ value: function generateAudioStreamsConfig(_ref4) {
410
+ var customSettings = _ref4.customSettings;
411
+ var audioStreams = {};
412
+ if (customSettings && customSettings.audio) {
413
+ for (var i = 0; i < Object.keys(customSettings.audio).length; i++) {
414
+ var audioIdx = Object.keys(customSettings.audio)[i];
415
+ var audio = customSettings.audio[audioIdx];
416
+ audioStreams[audioIdx] = {
417
+ recordingBitrate: audio.recording_bitrate || 192000,
418
+ recordingChannels: audio.recording_channels || 2
419
+ };
420
+ if (audio.playout) {
421
+ audioStreams[audioIdx].playoutLabel = audio.playout_label || "Audio ".concat(audioIdx);
422
+ }
423
+ }
424
+ }
425
+
426
+ // If no audio streams specified in custom config, set up all the suitable audio streams in the probe
427
+ if (!customSettings.audio) {
428
+ audioStreams = this.getAudioStreamsFromProbe();
429
+ }
430
+ return audioStreams;
431
+ }
432
+
433
+ /*
434
+ * Generate the live recording config as required by QFAB, based on defaults and optional custom settings.
435
+ */
344
436
  }, {
345
437
  key: "generateLiveConf",
346
- value: function generateLiveConf(_ref4) {
347
- var audioBitrate = _ref4.audioBitrate,
348
- audioIndex = _ref4.audioIndex,
349
- partTtl = _ref4.partTtl,
350
- channelLayout = _ref4.channelLayout;
438
+ value: function generateLiveConf(_ref5) {
439
+ var customSettings = _ref5.customSettings;
351
440
  // gather required data
352
441
  var conf = JSON.parse(JSON.stringify(LiveconfTemplate));
353
442
  var fileName = this.overwriteOriginUrl || this.probeData.format.filename;
443
+ var audioStreams = this.generateAudioStreamsConfig({
444
+ customSettings: customSettings
445
+ });
446
+
447
+ // Retrieve one audio stream from the probe to read the sample rate and codec name
354
448
  var audioStream = this.getStreamDataForCodecType("audio");
355
449
  var sampleRate = parseInt(audioStream.sample_rate);
356
450
  var audioCodec = audioStream.codec_name;
@@ -358,22 +452,26 @@ var LiveConf = /*#__PURE__*/function () {
358
452
  var sourceTimescale;
359
453
 
360
454
  // Fill in liveconf all formats have in common
361
- conf.live_recording.probe_info = this.probeData;
362
455
  conf.live_recording.fabric_config.ingress_node_api = this.nodeUrl || null;
363
456
  conf.live_recording.fabric_config.ingress_node_id = this.nodeId || null;
364
457
  conf.live_recording.recording_config.recording_params.description;
365
458
  conf.live_recording.recording_config.recording_params.origin_url = fileName;
366
459
  conf.live_recording.recording_config.recording_params.description = "Ingest stream ".concat(fileName);
367
460
  conf.live_recording.recording_config.recording_params.name = "Ingest stream ".concat(fileName);
368
- conf.live_recording.recording_config.recording_params.xc_params.audio_index[0] = audioIndex === undefined ? audioStream.stream_index : audioIndex;
369
461
  conf.live_recording.recording_config.recording_params.xc_params.sample_rate = sampleRate;
370
462
  conf.live_recording.recording_config.recording_params.xc_params.enc_height = videoStream.height;
371
463
  conf.live_recording.recording_config.recording_params.xc_params.enc_width = videoStream.width;
464
+ for (var i = 0; i < Object.keys(audioStreams).length; i++) {
465
+ conf.live_recording.recording_config.recording_params.xc_params.audio_index[i] = parseInt(Object.keys(audioStreams)[i]);
466
+ }
372
467
  if (this.syncAudioToVideo) {
373
468
  conf.live_recording.recording_config.recording_params.xc_params.sync_audio_to_stream_id = this.syncAudioToStreamIdValue();
374
469
  }
375
- if (partTtl) {
376
- conf.live_recording.recording_config.recording_params.part_ttl = partTtl;
470
+ if (customSettings.edge_write_token) {
471
+ conf.live_recording.fabric_config.edge_write_token = customSettings.edge_write_token;
472
+ }
473
+ if (customSettings.part_ttl) {
474
+ conf.live_recording.recording_config.recording_params.part_ttl = customSettings.part_ttl;
377
475
  }
378
476
 
379
477
  // Fill in specifics for protocol
@@ -413,7 +511,9 @@ var LiveConf = /*#__PURE__*/function () {
413
511
  // Optional override output timebase and frame duration (ts)
414
512
  if (segDurations.videoTimeBase) {
415
513
  conf.live_recording.recording_config.recording_params.xc_params.video_time_base = segDurations.videoTimeBase;
416
- conf.live_recording.recording_config.recording_params.source_timescale = segDurations.videoTimeBase;
514
+
515
+ // Note 'source_timescale' needs to be set to the output timebase and is used by playout
516
+ conf.live_recording.recording_config.recording_params.source_timescale = this.calcOutputTimebase(segDurations.videoTimeBase);
417
517
  }
418
518
  if (segDurations.videoFrameDurationTs) {
419
519
  conf.live_recording.recording_config.recording_params.xc_params.video_frame_duration_ts = segDurations.videoFrameDurationTs;
@@ -446,20 +546,29 @@ var LiveConf = /*#__PURE__*/function () {
446
546
  default:
447
547
  throw new Error("ERROR: Probed stream does not conform to one of the following built in resolution ladders [4096, 2160], [1920, 1080] [1280, 720], [960, 540]");
448
548
  }
449
- if (audioBitrate || channelLayout) {
450
- var audioLadderSpec = conf.live_recording.recording_config.recording_params.ladder_specs.find(function (spec) {
451
- return spec.stream_name === "audio";
452
- });
453
- if (audioBitrate) {
454
- conf.live_recording.recording_config.recording_params.xc_params.audio_bitrate = audioBitrate;
455
- audioLadderSpec.bit_rate = audioBitrate;
456
- audioLadderSpec.representation = "audioaudio_aac@".concat(audioBitrate);
457
- }
458
- if (channelLayout) {
459
- audioLadderSpec.channels = channelLayout;
549
+ var globalAudioBitrate = 0;
550
+ var nAudio = 0;
551
+ for (var _i = 0; _i < Object.keys(audioStreams).length; _i++) {
552
+ var audioLadderSpec = _objectSpread({}, LadderSpecAudio);
553
+ var audioIndex = Object.keys(audioStreams)[_i];
554
+ var audio = audioStreams[audioIndex];
555
+ audioLadderSpec.bit_rate = audio.recordingBitrate;
556
+ audioLadderSpec.representation = "audioaudio_aac@".concat(audio.recordingBitrate);
557
+ audioLadderSpec.channels = audio.recordingChannels;
558
+ audioLadderSpec.stream_index = parseInt(audioIndex);
559
+ audioLadderSpec.stream_name = "audio_".concat(audioIndex);
560
+ audioLadderSpec.stream_label = audio.playoutLabel ? audio.playoutLabel : null;
561
+ conf.live_recording.recording_config.recording_params.ladder_specs.push(audioLadderSpec);
562
+ if (audio.recordingBitrate > globalAudioBitrate) {
563
+ globalAudioBitrate = audio.recordingBitrate;
460
564
  }
565
+ nAudio++;
461
566
  }
462
- return JSON.stringify(conf, null, 2);
567
+
568
+ // Global recording bitrate for all audio streams
569
+ conf.live_recording.recording_config.recording_params.xc_params.audio_bitrate = globalAudioBitrate;
570
+ conf.live_recording.recording_config.recording_params.xc_params.n_audio = nAudio;
571
+ return conf;
463
572
  }
464
573
  }]);
465
574
  return LiveConf;