@eluvio/elv-client-js 4.2.22 → 4.2.23

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.
@@ -1064,47 +1064,34 @@ exports.CopyContentObject = /*#__PURE__*/function () {
1064
1064
  // User CAP
1065
1065
  userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1066
1066
  if (!metadata[userCapKey]) {
1067
- _context13.next = 40;
1067
+ _context13.next = 33;
1068
1068
  break;
1069
1069
  }
1070
- if (!this.signer.remoteSigner) {
1071
- _context13.next = 24;
1072
- break;
1073
- }
1074
- _context13.next = 21;
1075
- return this.signer.DecryptCap(metadata[userCapKey]);
1076
- case 21:
1077
- _context13.t0 = _context13.sent;
1078
- _context13.next = 27;
1079
- break;
1080
- case 24:
1081
- _context13.next = 26;
1070
+ _context13.next = 20;
1082
1071
  return this.Crypto.DecryptCap(metadata[userCapKey], this.signer._signingKey().privateKey);
1083
- case 26:
1084
- _context13.t0 = _context13.sent;
1085
- case 27:
1086
- userConkKey = _context13.t0;
1072
+ case 20:
1073
+ userConkKey = _context13.sent;
1087
1074
  userConkKey.qid = objectId;
1088
- _context13.t1 = this;
1089
- _context13.t2 = libraryId;
1090
- _context13.t3 = objectId;
1091
- _context13.t4 = writeToken;
1092
- _context13.t5 = userCapKey;
1093
- _context13.next = 36;
1075
+ _context13.t0 = this;
1076
+ _context13.t1 = libraryId;
1077
+ _context13.t2 = objectId;
1078
+ _context13.t3 = writeToken;
1079
+ _context13.t4 = userCapKey;
1080
+ _context13.next = 29;
1094
1081
  return this.Crypto.EncryptConk(userConkKey, this.signer._signingKey().publicKey);
1095
- case 36:
1096
- _context13.t6 = _context13.sent;
1097
- _context13.t7 = {
1098
- libraryId: _context13.t2,
1099
- objectId: _context13.t3,
1100
- writeToken: _context13.t4,
1101
- metadataSubtree: _context13.t5,
1102
- metadata: _context13.t6
1082
+ case 29:
1083
+ _context13.t5 = _context13.sent;
1084
+ _context13.t6 = {
1085
+ libraryId: _context13.t1,
1086
+ objectId: _context13.t2,
1087
+ writeToken: _context13.t3,
1088
+ metadataSubtree: _context13.t4,
1089
+ metadata: _context13.t5
1103
1090
  };
1104
- _context13.next = 40;
1105
- return _context13.t1.ReplaceMetadata.call(_context13.t1, _context13.t7);
1106
- case 40:
1107
- _context13.next = 42;
1091
+ _context13.next = 33;
1092
+ return _context13.t0.ReplaceMetadata.call(_context13.t0, _context13.t6);
1093
+ case 33:
1094
+ _context13.next = 35;
1108
1095
  return Promise.all(Object.keys(metadata).filter(function (key) {
1109
1096
  return key.startsWith("eluv.caps.ikms");
1110
1097
  }).map( /*#__PURE__*/function () {
@@ -1131,28 +1118,28 @@ exports.CopyContentObject = /*#__PURE__*/function () {
1131
1118
  return _ref24.apply(this, arguments);
1132
1119
  };
1133
1120
  }()));
1134
- case 42:
1121
+ case 35:
1135
1122
  if (!(permission !== "owner")) {
1136
- _context13.next = 45;
1123
+ _context13.next = 38;
1137
1124
  break;
1138
1125
  }
1139
- _context13.next = 45;
1126
+ _context13.next = 38;
1140
1127
  return this.CreateEncryptionConk({
1141
1128
  libraryId: libraryId,
1142
1129
  objectId: objectId,
1143
1130
  writeToken: writeToken,
1144
1131
  createKMSConk: true
1145
1132
  });
1146
- case 45:
1147
- _context13.next = 47;
1133
+ case 38:
1134
+ _context13.next = 40;
1148
1135
  return this.FinalizeContentObject({
1149
1136
  libraryId: libraryId,
1150
1137
  objectId: objectId,
1151
1138
  writeToken: writeToken
1152
1139
  });
1153
- case 47:
1140
+ case 40:
1154
1141
  return _context13.abrupt("return", _context13.sent);
1155
- case 48:
1142
+ case 41:
1156
1143
  case "end":
1157
1144
  return _context13.stop();
1158
1145
  }
@@ -1197,42 +1184,29 @@ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
1197
1184
  }
1198
1185
  throw Error("No user cap found for current user");
1199
1186
  case 7:
1200
- if (!this.signer.remoteSigner) {
1201
- _context14.next = 13;
1202
- break;
1203
- }
1204
- _context14.next = 10;
1205
- return this.signer.DecryptCap(userCapValue);
1206
- case 10:
1207
- _context14.t0 = _context14.sent;
1208
- _context14.next = 16;
1209
- break;
1210
- case 13:
1211
- _context14.next = 15;
1187
+ _context14.next = 9;
1212
1188
  return this.Crypto.DecryptCap(userCapValue, this.signer._signingKey().privateKey);
1213
- case 15:
1214
- _context14.t0 = _context14.sent;
1215
- case 16:
1216
- userConk = _context14.t0;
1189
+ case 9:
1190
+ userConk = _context14.sent;
1217
1191
  publicAddress = this.utils.PublicKeyToAddress(publicKey);
1218
1192
  targetUserCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(publicAddress));
1219
- _context14.next = 21;
1193
+ _context14.next = 14;
1220
1194
  return this.Crypto.EncryptConk(userConk, publicKey);
1221
- case 21:
1195
+ case 14:
1222
1196
  targetUserCapValue = _context14.sent;
1223
1197
  finalize = !writeToken;
1224
1198
  if (writeToken) {
1225
- _context14.next = 27;
1199
+ _context14.next = 20;
1226
1200
  break;
1227
1201
  }
1228
- _context14.next = 26;
1202
+ _context14.next = 19;
1229
1203
  return this.EditContentObject({
1230
1204
  libraryId: libraryId,
1231
1205
  objectId: objectId
1232
1206
  }).writeToken;
1233
- case 26:
1207
+ case 19:
1234
1208
  writeToken = _context14.sent;
1235
- case 27:
1209
+ case 20:
1236
1210
  this.ReplaceMetadata({
1237
1211
  libraryId: libraryId,
1238
1212
  objectId: objectId,
@@ -1241,17 +1215,17 @@ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
1241
1215
  metadata: targetUserCapValue
1242
1216
  });
1243
1217
  if (!finalize) {
1244
- _context14.next = 31;
1218
+ _context14.next = 24;
1245
1219
  break;
1246
1220
  }
1247
- _context14.next = 31;
1221
+ _context14.next = 24;
1248
1222
  return this.FinalizeContentObject({
1249
1223
  libraryId: libraryId,
1250
1224
  objectId: objectId,
1251
1225
  writeToken: writeToken,
1252
1226
  commitMessage: "Create non-owner cap"
1253
1227
  });
1254
- case 31:
1228
+ case 24:
1255
1229
  case "end":
1256
1230
  return _context14.stop();
1257
1231
  }
@@ -1,13 +1,11 @@
1
+ var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
1
2
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
- var _objectWithoutProperties = require("@babel/runtime/helpers/objectWithoutProperties");
3
- var _typeof = require("@babel/runtime/helpers/typeof");
4
3
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
5
4
  var _createClass = require("@babel/runtime/helpers/createClass");
6
- var _excluded = ["recording_config", "recording_params"];
7
5
  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; }
8
6
  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; }
9
7
  /* eslint no-console: 0 */
10
- var R = require("ramda");
8
+
11
9
  var DefaultABRLadder = {
12
10
  "video": [{
13
11
  bit_rate: 14000000,
@@ -53,9 +51,8 @@ var LiveconfTemplate = {
53
51
  },
54
52
  playout_config: {
55
53
  dvr_enabled: true,
56
- dvr_max_duration: 14400,
54
+ dvr_max_duration: 0,
57
55
  rebroadcast_start_time_sec_epoch: 0,
58
- playout_sharding_level: 2,
59
56
  vod_enabled: false
60
57
  },
61
58
  recording_config: {
@@ -63,11 +60,11 @@ var LiveconfTemplate = {
63
60
  description: "",
64
61
  ladder_specs: [],
65
62
  listen: true,
66
- live_delay_nano: 6000000000,
63
+ live_delay_nano: 2000000000,
67
64
  max_duration_sec: -1,
68
65
  name: "",
69
66
  origin_url: "",
70
- part_ttl: 86400,
67
+ part_ttl: 3600,
71
68
  playout_type: "live",
72
69
  source_timescale: null,
73
70
  reconnect_timeout: 600,
@@ -104,52 +101,20 @@ var LiveconfTemplate = {
104
101
  var LiveConf = /*#__PURE__*/function () {
105
102
  "use strict";
106
103
 
107
- function LiveConf(_ref) {
108
- var url = _ref.url,
109
- probeData = _ref.probeData,
110
- nodeId = _ref.nodeId,
111
- nodeUrl = _ref.nodeUrl,
112
- includeAVSegDurations = _ref.includeAVSegDurations,
113
- overwriteOriginUrl = _ref.overwriteOriginUrl,
114
- syncAudioToVideo = _ref.syncAudioToVideo,
115
- liveRecordingMeta = _ref.liveRecordingMeta;
104
+ function LiveConf(probeData, nodeId, nodeUrl, includeAVSegDurations, overwriteOriginUrl, syncAudioToVideo) {
116
105
  _classCallCheck(this, LiveConf);
117
- this.url = url;
118
106
  this.probeData = probeData;
119
107
  this.nodeId = nodeId;
120
108
  this.nodeUrl = nodeUrl;
121
109
  this.includeAVSegDurations = includeAVSegDurations;
122
110
  this.overwriteOriginUrl = overwriteOriginUrl;
123
111
  this.syncAudioToVideo = syncAudioToVideo;
124
- this.currentLiveRecordingMeta = liveRecordingMeta;
125
112
  }
126
113
  _createClass(LiveConf, [{
127
- key: "getFormat",
128
- value: function getFormat() {
129
- var _this$probeData$forma;
130
- if (this.probeData.format.format_name) {
131
- return this.probeData.format.format_name;
132
- }
133
- var fileNameSplit = (_this$probeData$forma = this.probeData.format) === null || _this$probeData$forma === void 0 || (_this$probeData$forma = _this$probeData$forma.filename) === null || _this$probeData$forma === void 0 ? void 0 : _this$probeData$forma.split(":");
134
- if (fileNameSplit.length > 1) {
135
- var protoScheme = fileNameSplit[0];
136
- switch (protoScheme) {
137
- case "rtmp":
138
- return "flv";
139
- case "udp":
140
- case "rtp":
141
- case "srt":
142
- return "mpegts";
143
- default:
144
- return "format_unknown";
145
- }
146
- }
147
- }
148
- }, {
149
- key: "getProtocol",
150
- value: function getProtocol() {
151
- var protoScheme = this.url.split(":")[0];
152
- return protoScheme;
114
+ key: "probeKind",
115
+ value: function probeKind() {
116
+ var fileNameSplit = this.probeData.format.filename.split(":");
117
+ return fileNameSplit[0];
153
118
  }
154
119
  }, {
155
120
  key: "getStreamDataForCodecType",
@@ -167,27 +132,19 @@ var LiveConf = /*#__PURE__*/function () {
167
132
  // Used by generateAudioStreamsConfig()
168
133
  }, {
169
134
  key: "getAudioStreamsFromProbe",
170
- value: function getAudioStreamsFromProbe(_ref2) {
171
- var ladderProfile = _ref2.ladderProfile;
135
+ value: function getAudioStreamsFromProbe() {
172
136
  var audioStreams = {};
173
137
  var audioStreamData = this.probeData.streams.filter(function (value) {
174
138
  return value.codec_type === "audio";
175
139
  });
176
- var _loop = function _loop() {
177
- var _ladderProfile$audio, _profileAudioForType$, _currentStreamData$bi;
140
+ for (var index = 0; index < audioStreamData.length; index++) {
178
141
  var currentStreamIndex = audioStreamData[index].stream_index;
179
142
  var currentStreamData = audioStreamData[index];
180
- var profileAudioForType = ladderProfile === null || ladderProfile === void 0 || (_ladderProfile$audio = ladderProfile.audio) === null || _ladderProfile$audio === void 0 ? void 0 : _ladderProfile$audio.find(function (a) {
181
- return a.channels === currentStreamData.channels;
182
- });
183
143
  audioStreams[currentStreamIndex] = {
184
- recordingBitrate: (_profileAudioForType$ = profileAudioForType === null || profileAudioForType === void 0 ? void 0 : profileAudioForType.bit_rate) !== null && _profileAudioForType$ !== void 0 ? _profileAudioForType$ : Math.max((_currentStreamData$bi = currentStreamData.bit_rate) !== null && _currentStreamData$bi !== void 0 ? _currentStreamData$bi : 0, 12800),
144
+ recordingBitrate: Math.max(currentStreamData.bit_rate, 128000),
185
145
  recordingChannels: currentStreamData.channels,
186
146
  playoutLabel: "Audio ".concat(index + 1)
187
147
  };
188
- };
189
- for (var index = 0; index < audioStreamData.length; index++) {
190
- _loop();
191
148
  }
192
149
  return audioStreams;
193
150
  }
@@ -242,20 +199,21 @@ var LiveConf = /*#__PURE__*/function () {
242
199
  */
243
200
  }, {
244
201
  key: "calcSegDuration",
245
- value: function calcSegDuration(_ref3) {
246
- var sourceTimescale = _ref3.sourceTimescale,
247
- sampleRate = _ref3.sampleRate,
248
- audioCodec = _ref3.audioCodec;
202
+ value: function calcSegDuration(_ref) {
203
+ var sourceTimescale = _ref.sourceTimescale,
204
+ sampleRate = _ref.sampleRate,
205
+ audioCodec = _ref.audioCodec;
249
206
  var seg = {};
250
- switch (this.getFormat()) {
251
- case "flv":
207
+ switch (this.probeKind()) {
208
+ case "rtmp":
252
209
  seg = this.calcSegDurationRtmp({
253
210
  sourceTimescale: sourceTimescale,
254
211
  sampleRate: sampleRate,
255
212
  audioCodec: audioCodec
256
213
  });
257
214
  break;
258
- case "mpegts":
215
+ case "udp":
216
+ case "srt":
259
217
  seg = this.calcSegDurationMpegts({
260
218
  sourceTimescale: sourceTimescale,
261
219
  sampleRate: sampleRate,
@@ -263,7 +221,7 @@ var LiveConf = /*#__PURE__*/function () {
263
221
  });
264
222
  break;
265
223
  default:
266
- throw "protocol not supported - " + this.getFormat();
224
+ throw "protocol not supported - " + this.probeKind();
267
225
  }
268
226
  if (audioCodec == "aac") {
269
227
  seg.audio = 29.76 * sampleRate;
@@ -287,8 +245,8 @@ var LiveConf = /*#__PURE__*/function () {
287
245
  }
288
246
  }, {
289
247
  key: "calcSegDurationMpegts",
290
- value: function calcSegDurationMpegts(_ref4) {
291
- var sourceTimescale = _ref4.sourceTimescale;
248
+ value: function calcSegDurationMpegts(_ref2) {
249
+ var sourceTimescale = _ref2.sourceTimescale;
292
250
  var videoStream = this.getStreamDataForCodecType("video");
293
251
  var frameRate = videoStream.frame_rate;
294
252
 
@@ -350,8 +308,8 @@ var LiveConf = /*#__PURE__*/function () {
350
308
  }
351
309
  }, {
352
310
  key: "calcSegDurationRtmp",
353
- value: function calcSegDurationRtmp(_ref5) {
354
- var sourceTimescale = _ref5.sourceTimescale;
311
+ value: function calcSegDurationRtmp(_ref3) {
312
+ var sourceTimescale = _ref3.sourceTimescale;
355
313
  var videoStream = this.getStreamDataForCodecType("video");
356
314
  var frameRate = videoStream.frame_rate;
357
315
  var seg = {};
@@ -414,123 +372,60 @@ var LiveConf = /*#__PURE__*/function () {
414
372
  value: function syncAudioToStreamIdValue() {
415
373
  var sync_id = -1;
416
374
  var videoStream = this.getStreamDataForCodecType("video");
417
- switch (this.getFormat()) {
418
- case "mpegts":
375
+ switch (this.probeKind()) {
376
+ case "udp":
377
+ case "srt":
419
378
  sync_id = videoStream.stream_id;
420
379
  break;
421
- case "flv":
380
+ case "rtmp":
422
381
  sync_id = videoStream.stream_index;
423
382
  break;
424
383
  }
425
384
  return sync_id;
426
385
  }
427
386
 
428
- /**
429
- * Map custom live recording profile to the expected config structure
430
- * @param {Object} customProfile - User's custom recording profile
431
- * @return {Object} - Mapped config in live_recording format
432
- */
433
- }, {
434
- key: "MapCustomProfileToLiveConfig",
435
- value: function MapCustomProfileToLiveConfig(_ref6) {
436
- var customProfile = _ref6.customProfile;
437
- if (!customProfile) return {};
438
- var CompactDeep = function CompactDeep(obj) {
439
- if (obj === null || _typeof(obj) !== "object" || Array.isArray(obj)) {
440
- return obj;
441
- }
442
- return R.pipe(R.reject(R.isNil), R.map(function (val) {
443
- return _typeof(val) === "object" ? CompactDeep(val) : val;
444
- }))(obj);
445
- };
446
- var recording_config = customProfile.recording_config,
447
- recording_params = customProfile.recording_params,
448
- rest = _objectWithoutProperties(customProfile, _excluded);
449
- return CompactDeep({
450
- live_recording: _objectSpread(_objectSpread({}, rest), {}, {
451
- recording_config: {
452
- recording_params: _objectSpread(_objectSpread({}, recording_params), {}, {
453
- part_ttl: recording_config === null || recording_config === void 0 ? void 0 : recording_config.part_ttl,
454
- reconnect_timeout: recording_config === null || recording_config === void 0 ? void 0 : recording_config.reconnect_timeout,
455
- xc_params: _objectSpread(_objectSpread({}, (recording_params === null || recording_params === void 0 ? void 0 : recording_params.xc_params) || {}), {}, {
456
- connection_timeout: recording_config === null || recording_config === void 0 ? void 0 : recording_config.connection_timeout,
457
- copy_mpegts: recording_config === null || recording_config === void 0 ? void 0 : recording_config.copy_mpegts,
458
- input_cfg: recording_config === null || recording_config === void 0 ? void 0 : recording_config.input_cfg
459
- })
460
- })
461
- }
462
- })
463
- });
464
- }
465
-
466
387
  /*
467
388
  * Generate audio streams recording configuration based on the optional custom settings.
468
389
  * If no custom "audio" section is present, record all the acceptable audio streams found in the probe
469
390
  */
470
391
  }, {
471
392
  key: "generateAudioStreamsConfig",
472
- value: function generateAudioStreamsConfig(_ref7) {
473
- var _liveRecordingConfigP, _liveRecordingConfigP2;
474
- var liveRecordingConfigProfile = _ref7.liveRecordingConfigProfile;
475
- var ladderProfile = (liveRecordingConfigProfile === null || liveRecordingConfigProfile === void 0 || (_liveRecordingConfigP = liveRecordingConfigProfile.playout_config) === null || _liveRecordingConfigP === void 0 ? void 0 : _liveRecordingConfigP.ladder_specs) || DefaultABRLadder;
476
- var audioSettings = liveRecordingConfigProfile === null || liveRecordingConfigProfile === void 0 || (_liveRecordingConfigP2 = liveRecordingConfigProfile.recording_stream_config) === null || _liveRecordingConfigP2 === void 0 ? void 0 : _liveRecordingConfigP2.audio;
393
+ value: function generateAudioStreamsConfig(_ref4) {
394
+ var customSettings = _ref4.customSettings;
477
395
  var audioStreams = {};
478
- if (audioSettings && Object.keys(audioSettings).length > 0) {
479
- var _loop2 = function _loop2() {
480
- var _audio$recording_bitr;
481
- var audioIdx = Object.keys(audioSettings)[i];
482
- var audio = audioSettings[audioIdx];
483
- var profileAudioForType = ladderProfile === null || ladderProfile === void 0 ? void 0 : ladderProfile.audio.find(function (a) {
484
- var _audio$channels;
485
- return a.channels === ((_audio$channels = audio.channels) !== null && _audio$channels !== void 0 ? _audio$channels : 2);
486
- });
396
+ if (customSettings && customSettings.audio && Object.keys(customSettings.audio).length > 0) {
397
+ for (var i = 0; i < Object.keys(customSettings.audio).length; i++) {
398
+ var audioIdx = Object.keys(customSettings.audio)[i];
399
+ var audio = customSettings.audio[audioIdx];
487
400
  audioStreams[audioIdx] = {
488
- recordingBitrate: ladderProfile !== null && ladderProfile !== void 0 && ladderProfile.audio ? profileAudioForType.bit_rate : (_audio$recording_bitr = audio.recording_bitrate) !== null && _audio$recording_bitr !== void 0 ? _audio$recording_bitr : 192000,
489
- recordingChannels: audio.recording_channels || 2,
490
- lang: audio.lang,
491
- isDefault: audio["default"]
401
+ recordingBitrate: audio.recording_bitrate || 192000,
402
+ recordingChannels: audio.recording_channels || 2
492
403
  };
493
404
  if (audio.playout) {
494
405
  audioStreams[audioIdx].playoutLabel = audio.playout_label || "Audio ".concat(i + 1);
495
406
  }
496
- };
497
- for (var i = 0; i < Object.keys(audioSettings).length; i++) {
498
- _loop2();
499
407
  }
500
408
  }
501
409
 
502
410
  // If no audio streams specified in custom config, set up all the suitable audio streams in the probe
503
- if (!audioSettings || Object.keys(audioSettings).length === 0) {
504
- audioStreams = this.getAudioStreamsFromProbe({
505
- ladderProfile: ladderProfile
506
- });
411
+ if (!customSettings.audio || Object.keys(customSettings.audio).length == 0) {
412
+ audioStreams = this.getAudioStreamsFromProbe();
507
413
  }
508
414
  return audioStreams;
509
415
  }
510
416
 
511
417
  /*
512
- * Generate the live recording config as required by QFAB, based on defaults, existing settings and optional custom settings.
418
+ * Generate the live recording config as required by QFAB, based on defaults and optional custom settings.
513
419
  */
514
420
  }, {
515
421
  key: "generateLiveConf",
516
- value: function generateLiveConf(_ref8) {
517
- var _customSettings$liveR, _customSettings$liveR2, _ladder_specs$video;
518
- var customSettings = _ref8.customSettings;
519
- // Saved config overrides defaults and is preserved on reconfiguration
520
- var conf = R.clone(LiveconfTemplate);
521
- if (this.currentLiveRecordingMeta) {
522
- conf = R.mergeDeepRight(conf, {
523
- live_recording: this.currentLiveRecordingMeta
524
- });
525
- }
526
- if (customSettings.liveRecordingConfigProfile) {
527
- conf = R.mergeDeepRight(conf, this.MapCustomProfileToLiveConfig({
528
- customProfile: customSettings.liveRecordingConfigProfile
529
- }));
530
- }
531
- var fileName = this.url;
422
+ value: function generateLiveConf(_ref5) {
423
+ var customSettings = _ref5.customSettings;
424
+ // gather required data
425
+ var conf = JSON.parse(JSON.stringify(LiveconfTemplate));
426
+ var fileName = this.overwriteOriginUrl || this.probeData.format.filename;
532
427
  var audioStreams = this.generateAudioStreamsConfig({
533
- liveRecordingConfigProfile: customSettings.liveRecordingConfigProfile
428
+ customSettings: customSettings
534
429
  });
535
430
 
536
431
  // Retrieve one audio stream from the probe to read the sample rate and codec name
@@ -558,13 +453,17 @@ var LiveConf = /*#__PURE__*/function () {
558
453
  }
559
454
 
560
455
  // Fill in specifics for protocol
561
- switch (this.getFormat()) {
562
- case "mpegts":
456
+ switch (this.probeKind()) {
457
+ case "udp":
563
458
  sourceTimescale = 90000;
564
459
  conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
565
460
  break;
461
+ case "srt":
462
+ sourceTimescale = 90000;
463
+ conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
464
+ conf.live_recording.recording_config.recording_params.live_delay_nano = 4000000000;
465
+ break;
566
466
  case "rtmp":
567
- case "flv":
568
467
  sourceTimescale = 16000;
569
468
  conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
570
469
  break;
@@ -572,14 +471,7 @@ var LiveConf = /*#__PURE__*/function () {
572
471
  console.log("HLS detected. Not yet implemented");
573
472
  break;
574
473
  default:
575
- console.log("Unsupported media", this.getFormat());
576
- break;
577
- }
578
- switch (this.getProtocol()) {
579
- case "srt":
580
- if (!((_customSettings$liveR = customSettings.liveRecordingConfigProfile) !== null && _customSettings$liveR !== void 0 && (_customSettings$liveR = _customSettings$liveR.recording_params) !== null && _customSettings$liveR !== void 0 && _customSettings$liveR.live_delay_nano)) {
581
- conf.live_recording.recording_config.recording_params.live_delay_nano = 6000000000;
582
- }
474
+ console.log("Unsupported media", this.probeKind());
583
475
  break;
584
476
  }
585
477
  var segDurations = this.calcSegDuration({
@@ -604,14 +496,10 @@ var LiveConf = /*#__PURE__*/function () {
604
496
  if (segDurations.videoFrameDurationTs) {
605
497
  conf.live_recording.recording_config.recording_params.xc_params.video_frame_duration_ts = segDurations.videoFrameDurationTs;
606
498
  }
607
- var ladder_specs = (_customSettings$liveR2 = customSettings.liveRecordingConfigProfile) === null || _customSettings$liveR2 === void 0 || (_customSettings$liveR2 = _customSettings$liveR2.playout_config) === null || _customSettings$liveR2 === void 0 ? void 0 : _customSettings$liveR2.ladder_specs;
608
- var ladderProfile = (ladder_specs === null || ladder_specs === void 0 || (_ladder_specs$video = ladder_specs.video) === null || _ladder_specs$video === void 0 ? void 0 : _ladder_specs$video.length) > 0 ? ladder_specs : DefaultABRLadder;
499
+ var ladderProfile = customSettings.ladder_profile || DefaultABRLadder;
609
500
  conf.live_recording.recording_config.recording_params.xc_params.enc_height = videoStream.height;
610
501
  conf.live_recording.recording_config.recording_params.xc_params.enc_width = videoStream.width;
611
502
 
612
- // Reset ladder specs (updating existing stream will carry over old specs
613
- conf.live_recording.recording_config.recording_params.ladder_specs = [];
614
-
615
503
  // Determine video recording bitrate and ABR ladder
616
504
  var topLadderRate = 0;
617
505
  for (var _i = 0; _i < ladderProfile.video.length; _i++) {
@@ -633,7 +521,6 @@ var LiveConf = /*#__PURE__*/function () {
633
521
  var globalAudioBitrate = 0;
634
522
  var nAudio = 0;
635
523
  for (var _i2 = 0; _i2 < Object.keys(audioStreams).length; _i2++) {
636
- var _audio$lang;
637
524
  var audioLadderSpec = {};
638
525
  var audioIndex = Object.keys(audioStreams)[_i2];
639
526
  var audio = audioStreams[audioIndex];
@@ -656,8 +543,7 @@ var LiveConf = /*#__PURE__*/function () {
656
543
  audioLadderSpec.stream_name = "audio_".concat(audioIndex);
657
544
  audioLadderSpec.stream_label = audio.playoutLabel ? audio.playoutLabel : null;
658
545
  audioLadderSpec.media_type = 2;
659
- audioLadderSpec.lang = (_audio$lang = audio.lang) !== null && _audio$lang !== void 0 ? _audio$lang : "";
660
- if (Object.keys(audioStreams).length === 1 || audio.isDefault) {
546
+ if (Object.keys(audioStreams).length === 1) {
661
547
  audioLadderSpec["default"] = true;
662
548
  }
663
549
  conf.live_recording.recording_config.recording_params.ladder_specs.push(audioLadderSpec);
@@ -670,6 +556,33 @@ var LiveConf = /*#__PURE__*/function () {
670
556
  // Global recording bitrate for all audio streams
671
557
  conf.live_recording.recording_config.recording_params.xc_params.audio_bitrate = globalAudioBitrate;
672
558
  conf.live_recording.recording_config.recording_params.xc_params.n_audio = nAudio;
559
+
560
+ // Iterate through custom settings (which will override any existing setting)
561
+ function SetByPath(_ref6) {
562
+ var obj = _ref6.obj,
563
+ path = _ref6.path,
564
+ value = _ref6.value;
565
+ var keys = path.split(".");
566
+ var temp = obj;
567
+ for (var _i3 = 0; _i3 < keys.length - 1; _i3++) {
568
+ if (!temp[keys[_i3]]) {
569
+ temp[keys[_i3]] = {};
570
+ }
571
+ temp = temp[keys[_i3]];
572
+ }
573
+ temp[keys[keys.length - 1]] = value;
574
+ }
575
+ var metaPathValues = customSettings.metaPathValues;
576
+ for (var _i4 = 0, _Object$entries = Object.entries(metaPathValues || {}); _i4 < _Object$entries.length; _i4++) {
577
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i4], 2),
578
+ path = _Object$entries$_i[0],
579
+ value = _Object$entries$_i[1];
580
+ SetByPath({
581
+ obj: conf,
582
+ path: path,
583
+ value: value
584
+ });
585
+ }
673
586
  return conf;
674
587
  }
675
588
  }]);