@eluvio/elv-client-js 4.0.83 → 4.0.85

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.
@@ -1967,8 +1967,8 @@ exports.LatestVersionHashV2 = /*#__PURE__*/function () {
1967
1967
  case 19:
1968
1968
  _context28.prev = 19;
1969
1969
  _context28.t6 = _context28["catch"](3);
1970
- console.log("ERROR", _context28.t6);
1971
- throw Error("Unable to determine latest version hash for ".concat(versionHash || objectId));
1970
+ _context28.t6.message = "Unable to determine latest version hash for ".concat(versionHash || objectId);
1971
+ throw _context28.t6;
1972
1972
  case 23:
1973
1973
  return _context28.abrupt("return", latestHash);
1974
1974
  case 24:
@@ -1800,41 +1800,62 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
1800
1800
  break;
1801
1801
  case 34:
1802
1802
  if (!awaitCommitConfirmation) {
1803
- _context21.next = 48;
1803
+ _context21.next = 63;
1804
1804
  break;
1805
1805
  }
1806
1806
  _pollingInterval = 500; // ms
1807
1807
  tries = 20;
1808
1808
  case 37:
1809
1809
  if (!(tries > 0)) {
1810
- _context21.next = 48;
1810
+ _context21.next = 63;
1811
1811
  break;
1812
1812
  }
1813
- _context21.next = 40;
1813
+ h = void 0;
1814
+ _context21.prev = 39;
1815
+ _context21.next = 42;
1814
1816
  return this.LatestVersionHashV2({
1815
1817
  objectId: objectId
1816
1818
  });
1817
- case 40:
1819
+ case 42:
1818
1820
  h = _context21.sent;
1819
- if (!(h == versionHash)) {
1820
- _context21.next = 44;
1821
+ if (!(h === versionHash)) {
1822
+ _context21.next = 48;
1821
1823
  break;
1822
1824
  }
1823
1825
  this.Log("Commit confirmed on fabric node: ".concat(versionHash));
1824
- return _context21.abrupt("break", 48);
1825
- case 44:
1826
- _context21.next = 46;
1826
+ return _context21.abrupt("break", 63);
1827
+ case 48:
1828
+ tries--;
1829
+ _context21.next = 51;
1827
1830
  return new Promise(function (resolve) {
1828
1831
  return setTimeout(resolve, _pollingInterval);
1829
1832
  });
1830
- case 46:
1833
+ case 51:
1834
+ _context21.next = 61;
1835
+ break;
1836
+ case 53:
1837
+ _context21.prev = 53;
1838
+ _context21.t0 = _context21["catch"](39);
1839
+ console.error(_context21.t0);
1840
+ if (!(_context21.t0.status !== 404)) {
1841
+ _context21.next = 58;
1842
+ break;
1843
+ }
1844
+ throw _context21.t0;
1845
+ case 58:
1846
+ tries--;
1847
+ _context21.next = 61;
1848
+ return new Promise(function (resolve) {
1849
+ return setTimeout(resolve, _pollingInterval);
1850
+ });
1851
+ case 61:
1831
1852
  _context21.next = 37;
1832
1853
  break;
1833
- case 48:
1854
+ case 63:
1834
1855
  case "end":
1835
1856
  return _context21.stop();
1836
1857
  }
1837
- }, _callee21, this);
1858
+ }, _callee21, this, [[39, 53]]);
1838
1859
  }));
1839
1860
  return function (_x20) {
1840
1861
  return _ref38.apply(this, arguments);
@@ -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(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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() {
@@ -234,7 +263,12 @@ var LiveConf = /*#__PURE__*/function () {
234
263
  var sourceTimescale = _ref2.sourceTimescale;
235
264
  var videoStream = this.getStreamDataForCodecType("video");
236
265
  var frameRate = videoStream.frame_rate;
237
- var seg = {};
266
+
267
+ // PENDING(SS) - calculate frame duration here
268
+ // let frameRateNum = 0;
269
+ var seg = {
270
+ // videoFrameDurationTs: sourceTimescale / frameRateNum
271
+ };
238
272
  switch (frameRate) {
239
273
  case "24":
240
274
  seg.video = sourceTimescale * 30;
@@ -252,21 +286,25 @@ var LiveConf = /*#__PURE__*/function () {
252
286
  seg.duration = "30";
253
287
  break;
254
288
  case "30000/1001":
289
+ //seg.videoFrameDurationTs = 3003;
255
290
  seg.video = sourceTimescale * 30;
256
291
  seg.keyint = 60;
257
292
  seg.duration = "30.03";
258
293
  break;
259
294
  case "48":
295
+ //seg.videoFrameDurationTs = 1875;
260
296
  seg.video = sourceTimescale * 30;
261
297
  seg.keyint = 96;
262
298
  seg.duration = "30";
263
299
  break;
264
300
  case "50":
301
+ //seg.videoFrameDurationTs = 1800;
265
302
  seg.video = sourceTimescale * 30;
266
303
  seg.keyint = 100;
267
304
  seg.duration = "30";
268
305
  break;
269
306
  case "60":
307
+ //seg.videoFrameDurationTs = 1500;
270
308
  seg.video = sourceTimescale * 30;
271
309
  seg.keyint = 120;
272
310
  seg.duration = "30";
@@ -292,7 +330,7 @@ var LiveConf = /*#__PURE__*/function () {
292
330
  var seg = {};
293
331
  switch (frameRate) {
294
332
  case "24":
295
- seg.videoTimeBase = 1536; // Output timebase: 12288
333
+ seg.videoTimeBase = 768; // Note 1536 produces low output bitrate
296
334
  seg.videoFrameDurationTs = 512;
297
335
  seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
298
336
  seg.keyint = 48;
@@ -361,16 +399,52 @@ var LiveConf = /*#__PURE__*/function () {
361
399
  }
362
400
  return sync_id;
363
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
+ */
364
436
  }, {
365
437
  key: "generateLiveConf",
366
- value: function generateLiveConf(_ref4) {
367
- var audioBitrate = _ref4.audioBitrate,
368
- audioIndex = _ref4.audioIndex,
369
- partTtl = _ref4.partTtl,
370
- channelLayout = _ref4.channelLayout;
438
+ value: function generateLiveConf(_ref5) {
439
+ var customSettings = _ref5.customSettings;
371
440
  // gather required data
372
441
  var conf = JSON.parse(JSON.stringify(LiveconfTemplate));
373
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
374
448
  var audioStream = this.getStreamDataForCodecType("audio");
375
449
  var sampleRate = parseInt(audioStream.sample_rate);
376
450
  var audioCodec = audioStream.codec_name;
@@ -378,22 +452,26 @@ var LiveConf = /*#__PURE__*/function () {
378
452
  var sourceTimescale;
379
453
 
380
454
  // Fill in liveconf all formats have in common
381
- conf.live_recording.probe_info = this.probeData;
382
455
  conf.live_recording.fabric_config.ingress_node_api = this.nodeUrl || null;
383
456
  conf.live_recording.fabric_config.ingress_node_id = this.nodeId || null;
384
457
  conf.live_recording.recording_config.recording_params.description;
385
458
  conf.live_recording.recording_config.recording_params.origin_url = fileName;
386
459
  conf.live_recording.recording_config.recording_params.description = "Ingest stream ".concat(fileName);
387
460
  conf.live_recording.recording_config.recording_params.name = "Ingest stream ".concat(fileName);
388
- conf.live_recording.recording_config.recording_params.xc_params.audio_index[0] = audioIndex === undefined ? audioStream.stream_index : audioIndex;
389
461
  conf.live_recording.recording_config.recording_params.xc_params.sample_rate = sampleRate;
390
462
  conf.live_recording.recording_config.recording_params.xc_params.enc_height = videoStream.height;
391
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
+ }
392
467
  if (this.syncAudioToVideo) {
393
468
  conf.live_recording.recording_config.recording_params.xc_params.sync_audio_to_stream_id = this.syncAudioToStreamIdValue();
394
469
  }
395
- if (partTtl) {
396
- 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;
397
475
  }
398
476
 
399
477
  // Fill in specifics for protocol
@@ -468,20 +546,29 @@ var LiveConf = /*#__PURE__*/function () {
468
546
  default:
469
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]");
470
548
  }
471
- if (audioBitrate || channelLayout) {
472
- var audioLadderSpec = conf.live_recording.recording_config.recording_params.ladder_specs.find(function (spec) {
473
- return spec.stream_name === "audio";
474
- });
475
- if (audioBitrate) {
476
- conf.live_recording.recording_config.recording_params.xc_params.audio_bitrate = audioBitrate;
477
- audioLadderSpec.bit_rate = audioBitrate;
478
- audioLadderSpec.representation = "audioaudio_aac@".concat(audioBitrate);
479
- }
480
- if (channelLayout) {
481
- 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;
482
564
  }
565
+ nAudio++;
483
566
  }
484
- 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;
485
572
  }
486
573
  }]);
487
574
  return LiveConf;