@eluvio/elv-client-js 4.0.85 → 4.0.87

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 (39) hide show
  1. package/dist/ElvClient-min.js +12 -13
  2. package/dist/ElvClient-node-min.js +13 -14
  3. package/dist/ElvFrameClient-min.js +9 -9
  4. package/dist/ElvPermissionsClient-min.js +10 -10
  5. package/dist/ElvWalletClient-min.js +13 -14
  6. package/dist/ElvWalletClient-node-min.js +13 -14
  7. package/dist/src/AuthorizationClient.js +5 -4
  8. package/dist/src/Crypto.js +2 -2
  9. package/dist/src/ElvClient.js +2 -2
  10. package/dist/src/EthClient.js +2 -2
  11. package/dist/src/FrameClient.js +3 -3
  12. package/dist/src/PermissionsClient.js +2 -2
  13. package/dist/src/Utils.js +2 -2
  14. package/dist/src/abr_profiles/abr_profile_live_to_vod.js +0 -7
  15. package/dist/src/client/ABRPublishing.js +2 -2
  16. package/dist/src/client/AccessGroups.js +2 -2
  17. package/dist/src/client/ContentAccess.js +757 -821
  18. package/dist/src/client/ContentManagement.js +6 -59
  19. package/dist/src/client/Contracts.js +2 -2
  20. package/dist/src/client/Files.js +2 -2
  21. package/dist/src/client/LiveConf.js +35 -144
  22. package/dist/src/client/LiveStream.js +529 -1054
  23. package/dist/src/client/NFT.js +2 -2
  24. package/dist/src/walletClient/ClientMethods.js +2 -2
  25. package/dist/src/walletClient/Profile.js +2 -2
  26. package/dist/src/walletClient/Utils.js +2 -2
  27. package/dist/src/walletClient/index.js +2 -2
  28. package/package.json +1 -1
  29. package/src/ContentObjectAudit.js +98 -0
  30. package/src/ElvClient.js +86 -83
  31. package/src/FrameClient.js +2 -1
  32. package/src/HttpClient.js +36 -4
  33. package/src/RemoteSigner.js +54 -0
  34. package/src/client/ContentAccess.js +17 -14
  35. package/src/client/ContentManagement.js +0 -1
  36. package/src/client/LiveConf.js +13 -13
  37. package/src/client/LiveStream.js +40 -12
  38. package/src/walletClient/index.js +40 -13
  39. package/src/ContentObjectVerification.js +0 -210
@@ -2,7 +2,6 @@ var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
2
2
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
3
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
4
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
5
- var _this = this;
6
5
  /**
7
6
  * Methods for Live Stream creation and management
8
7
  *
@@ -15,9 +14,6 @@ var path = require("path");
15
14
  var fs = require("fs");
16
15
  var HttpClient = require("../HttpClient");
17
16
  var Fraction = require("fraction.js");
18
- var _require2 = require("../Validation"),
19
- ValidateObject = _require2.ValidateObject,
20
- ValidatePresence = _require2.ValidatePresence;
21
17
  var MakeTxLessToken = /*#__PURE__*/function () {
22
18
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
23
19
  var client, libraryId, objectId, versionHash, tok;
@@ -52,87 +48,6 @@ var Sleep = function Sleep(ms) {
52
48
  return setTimeout(resolve, ms);
53
49
  });
54
50
  };
55
- var CueInfo = /*#__PURE__*/function () {
56
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
57
- var eventId, status, cues, lroStatusResponse, eventStart, eventEnd, _i, _Object$values, value, _i2, _Object$values2, event;
58
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
59
- while (1) switch (_context2.prev = _context2.next) {
60
- case 0:
61
- eventId = _ref3.eventId, status = _ref3.status;
62
- _context2.prev = 1;
63
- _context2.t0 = _this.utils;
64
- _context2.next = 5;
65
- return HttpClient.Fetch(status.lro_status_url);
66
- case 5:
67
- _context2.t1 = _context2.sent;
68
- _context2.next = 8;
69
- return _context2.t0.ResponseToJson.call(_context2.t0, _context2.t1);
70
- case 8:
71
- lroStatusResponse = _context2.sent;
72
- console.log("lroStatusResponse", lroStatusResponse);
73
- cues = lroStatusResponse.custom.cues;
74
- _context2.next = 17;
75
- break;
76
- case 13:
77
- _context2.prev = 13;
78
- _context2.t2 = _context2["catch"](1);
79
- console.log("LRO status failed", _context2.t2);
80
- return _context2.abrupt("return", {
81
- error: "failed to retrieve status",
82
- eventId: eventId
83
- });
84
- case 17:
85
- _i = 0, _Object$values = Object.values(cues);
86
- case 18:
87
- if (!(_i < _Object$values.length)) {
88
- _context2.next = 37;
89
- break;
90
- }
91
- value = _Object$values[_i];
92
- _i2 = 0, _Object$values2 = Object.values(value.descriptors);
93
- case 21:
94
- if (!(_i2 < _Object$values2.length)) {
95
- _context2.next = 34;
96
- break;
97
- }
98
- event = _Object$values2[_i2];
99
- if (!(event.id == eventId)) {
100
- _context2.next = 31;
101
- break;
102
- }
103
- _context2.t3 = event.type_id;
104
- _context2.next = _context2.t3 === 32 ? 27 : _context2.t3 === 16 ? 27 : _context2.t3 === 33 ? 29 : _context2.t3 === 17 ? 29 : 31;
105
- break;
106
- case 27:
107
- eventStart = value.insertion_time;
108
- return _context2.abrupt("break", 31);
109
- case 29:
110
- eventEnd = value.insertion_time;
111
- return _context2.abrupt("break", 31);
112
- case 31:
113
- _i2++;
114
- _context2.next = 21;
115
- break;
116
- case 34:
117
- _i++;
118
- _context2.next = 18;
119
- break;
120
- case 37:
121
- return _context2.abrupt("return", {
122
- eventStart: eventStart,
123
- eventEnd: eventEnd,
124
- eventId: eventId
125
- });
126
- case 38:
127
- case "end":
128
- return _context2.stop();
129
- }
130
- }, _callee2, null, [[1, 13]]);
131
- }));
132
- return function CueInfo(_x2) {
133
- return _ref4.apply(this, arguments);
134
- };
135
- }();
136
51
 
137
52
  /**
138
53
  * Set the offering for the live stream
@@ -163,12 +78,12 @@ var CueInfo = /*#__PURE__*/function () {
163
78
  * @return {Promise<string>} - Final hash of the live stream object
164
79
  */
165
80
  var StreamGenerateOffering = /*#__PURE__*/function () {
166
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
81
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
167
82
  var client, libraryId, objectId, typeAbrMaster, typeLiveStream, streamUrl, abrProfile, aBitRate, aChannels, aSampleRate, aStreamIndex, aTimeBase, aChannelLayout, vBitRate, vHeight, vStreamIndex, vWidth, vDisplayAspectRatio, vFrameRate, vTimeBase, DUMMY_DURATION, aDurationTs, vDurationTs, sourceAudioStream, sourceVideoStream, DUMMY_STREAM, sourceStreams, maxStreamIndex, i, sources, variants, production_master, metadata, editResponse, writeToken, finalizeResponse, masterVersionHash, createResponse, versionHash, finalHash;
168
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
169
- while (1) switch (_context3.prev = _context3.next) {
83
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
84
+ while (1) switch (_context2.prev = _context2.next) {
170
85
  case 0:
171
- client = _ref5.client, libraryId = _ref5.libraryId, objectId = _ref5.objectId, typeAbrMaster = _ref5.typeAbrMaster, typeLiveStream = _ref5.typeLiveStream, streamUrl = _ref5.streamUrl, abrProfile = _ref5.abrProfile, aBitRate = _ref5.aBitRate, aChannels = _ref5.aChannels, aSampleRate = _ref5.aSampleRate, aStreamIndex = _ref5.aStreamIndex, aTimeBase = _ref5.aTimeBase, aChannelLayout = _ref5.aChannelLayout, vBitRate = _ref5.vBitRate, vHeight = _ref5.vHeight, vStreamIndex = _ref5.vStreamIndex, vWidth = _ref5.vWidth, vDisplayAspectRatio = _ref5.vDisplayAspectRatio, vFrameRate = _ref5.vFrameRate, vTimeBase = _ref5.vTimeBase;
86
+ client = _ref3.client, libraryId = _ref3.libraryId, objectId = _ref3.objectId, typeAbrMaster = _ref3.typeAbrMaster, typeLiveStream = _ref3.typeLiveStream, streamUrl = _ref3.streamUrl, abrProfile = _ref3.abrProfile, aBitRate = _ref3.aBitRate, aChannels = _ref3.aChannels, aSampleRate = _ref3.aSampleRate, aStreamIndex = _ref3.aStreamIndex, aTimeBase = _ref3.aTimeBase, aChannelLayout = _ref3.aChannelLayout, vBitRate = _ref3.vBitRate, vHeight = _ref3.vHeight, vStreamIndex = _ref3.vStreamIndex, vWidth = _ref3.vWidth, vDisplayAspectRatio = _ref3.vDisplayAspectRatio, vFrameRate = _ref3.vFrameRate, vTimeBase = _ref3.vTimeBase;
172
87
  // compute duration_ts
173
88
  DUMMY_DURATION = 1001; // should result in integer duration_ts values for both audio and video
174
89
  aDurationTs = Fraction(aTimeBase).inverse().mul(DUMMY_DURATION).valueOf();
@@ -275,19 +190,19 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
275
190
  variants: variants
276
191
  }; // get existing metadata
277
192
  console.log("Retrieving current metadata...");
278
- _context3.next = 16;
193
+ _context2.next = 16;
279
194
  return client.ContentObjectMetadata({
280
195
  libraryId: libraryId,
281
196
  objectId: objectId
282
197
  });
283
198
  case 16:
284
- metadata = _context3.sent;
199
+ metadata = _context2.sent;
285
200
  // add /production_master to metadata
286
201
  metadata.production_master = production_master;
287
202
 
288
203
  // write back to object
289
204
  console.log("Getting write token...");
290
- _context3.next = 21;
205
+ _context2.next = 21;
291
206
  return client.EditContentObject({
292
207
  libraryId: libraryId,
293
208
  objectId: objectId,
@@ -296,11 +211,11 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
296
211
  }
297
212
  });
298
213
  case 21:
299
- editResponse = _context3.sent;
214
+ editResponse = _context2.sent;
300
215
  writeToken = editResponse.write_token;
301
216
  console.log("New write token: ".concat(writeToken));
302
217
  console.log("Writing back metadata with /production_master added...");
303
- _context3.next = 27;
218
+ _context2.next = 27;
304
219
  return client.ReplaceMetadata({
305
220
  libraryId: libraryId,
306
221
  metadata: metadata,
@@ -309,19 +224,19 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
309
224
  });
310
225
  case 27:
311
226
  console.log("Finalizing...");
312
- _context3.next = 30;
227
+ _context2.next = 30;
313
228
  return client.FinalizeContentObject({
314
229
  libraryId: libraryId,
315
230
  objectId: objectId,
316
231
  writeToken: writeToken
317
232
  });
318
233
  case 30:
319
- finalizeResponse = _context3.sent;
234
+ finalizeResponse = _context2.sent;
320
235
  masterVersionHash = finalizeResponse.hash;
321
236
  console.log("Finalized, new version hash: ".concat(masterVersionHash));
322
237
 
323
238
  // Generate offering
324
- _context3.next = 35;
239
+ _context2.next = 35;
325
240
  return client.CreateABRMezzanine({
326
241
  libraryId: libraryId,
327
242
  objectId: objectId,
@@ -331,7 +246,7 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
331
246
  abrProfile: abrProfile
332
247
  });
333
248
  case 35:
334
- createResponse = _context3.sent;
249
+ createResponse = _context2.sent;
335
250
  if (createResponse.warnings.length > 0) {
336
251
  console.log("WARNINGS:");
337
252
  console.log(JSON.stringify(createResponse.warnings, null, 2));
@@ -345,13 +260,13 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
345
260
 
346
261
  // get new metadata
347
262
  console.log("Retrieving revised metadata with offering...");
348
- _context3.next = 43;
263
+ _context2.next = 43;
349
264
  return client.ContentObjectMetadata({
350
265
  libraryId: libraryId,
351
266
  versionHash: versionHash
352
267
  });
353
268
  case 43:
354
- metadata = _context3.sent;
269
+ metadata = _context2.sent;
355
270
  console.log("Moving /abr_mezzanine/offerings to /offerings and removing /abr_mezzanine...");
356
271
  metadata.offerings = metadata.abr_mezzanine.offerings;
357
272
  delete metadata.abr_mezzanine;
@@ -361,7 +276,7 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
361
276
 
362
277
  // write back to object
363
278
  console.log("Getting write token...");
364
- _context3.next = 51;
279
+ _context2.next = 51;
365
280
  return client.EditContentObject({
366
281
  libraryId: libraryId,
367
282
  objectId: objectId,
@@ -370,11 +285,11 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
370
285
  }
371
286
  });
372
287
  case 51:
373
- editResponse = _context3.sent;
288
+ editResponse = _context2.sent;
374
289
  writeToken = editResponse.write_token;
375
290
  console.log("New write token: ".concat(writeToken));
376
291
  console.log("Writing back metadata with /offerings...");
377
- _context3.next = 57;
292
+ _context2.next = 57;
378
293
  return client.ReplaceMetadata({
379
294
  libraryId: libraryId,
380
295
  metadata: metadata,
@@ -383,25 +298,25 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
383
298
  });
384
299
  case 57:
385
300
  console.log("Finalizing...");
386
- _context3.next = 60;
301
+ _context2.next = 60;
387
302
  return client.FinalizeContentObject({
388
303
  libraryId: libraryId,
389
304
  objectId: objectId,
390
305
  writeToken: writeToken
391
306
  });
392
307
  case 60:
393
- finalizeResponse = _context3.sent;
308
+ finalizeResponse = _context2.sent;
394
309
  finalHash = finalizeResponse.hash;
395
310
  console.log("Finalized, new version hash: ".concat(finalHash));
396
- return _context3.abrupt("return", finalHash);
311
+ return _context2.abrupt("return", finalHash);
397
312
  case 64:
398
313
  case "end":
399
- return _context3.stop();
314
+ return _context2.stop();
400
315
  }
401
- }, _callee3);
316
+ }, _callee2);
402
317
  }));
403
- return function StreamGenerateOffering(_x3) {
404
- return _ref6.apply(this, arguments);
318
+ return function StreamGenerateOffering(_x2) {
319
+ return _ref4.apply(this, arguments);
405
320
  };
406
321
  }();
407
322
 
@@ -425,57 +340,62 @@ var StreamGenerateOffering = /*#__PURE__*/function () {
425
340
  * @return {Promise<Object>} - The status response for the object, as well as logs, warnings and errors from the master initialization
426
341
  */
427
342
  exports.StreamStatus = /*#__PURE__*/function () {
428
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
429
- var name, _ref7$stopLro, stopLro, _ref7$showParams, showParams, objectId, status, libraryId, mainMeta, fabURI, edgeWriteToken, edgeMeta, recordings, sequence, period, tlro, videoLastFinalizationTimeEpochSec, videoFinalizedParts, sinceLastFinalize, recording_period, insertions, i, insertionTimeSinceEpoch, state, lroStatus, playout_urls, playout_options, hls_clear_enabled, hls_aes128_enabled, hls_sample_aes_enabled, networkInfo, token, embed_net, embed_url;
430
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
431
- while (1) switch (_context4.prev = _context4.next) {
343
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
344
+ var name, _ref5$stopLro, stopLro, _ref5$showParams, showParams, conf, status, libraryId, mainMeta, fabURI, _edgeWriteToken, edgeMeta, recordings, sequence, period, tlro, sinceLastFinalize, recording_period, insertions, i, insertionTimeSinceEpoch, state, lroStatus, playout_urls, objectId, playout_options, hls_clear_enabled, hls_aes128_enabled, hls_sample_aes_enabled, networkInfo, token, embed_net, embed_url;
345
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
346
+ while (1) switch (_context3.prev = _context3.next) {
432
347
  case 0:
433
- name = _ref7.name, _ref7$stopLro = _ref7.stopLro, stopLro = _ref7$stopLro === void 0 ? false : _ref7$stopLro, _ref7$showParams = _ref7.showParams, showParams = _ref7$showParams === void 0 ? false : _ref7$showParams;
434
- objectId = name;
348
+ name = _ref5.name, _ref5$stopLro = _ref5.stopLro, stopLro = _ref5$stopLro === void 0 ? false : _ref5$stopLro, _ref5$showParams = _ref5.showParams, showParams = _ref5$showParams === void 0 ? false : _ref5$showParams;
349
+ _context3.next = 3;
350
+ return this.LoadConf({
351
+ name: name
352
+ });
353
+ case 3:
354
+ conf = _context3.sent;
435
355
  status = {
436
356
  name: name
437
357
  };
438
- _context4.prev = 3;
439
- _context4.next = 6;
358
+ _context3.prev = 5;
359
+ _context3.next = 8;
440
360
  return this.ContentObjectLibraryId({
441
- objectId: objectId
361
+ objectId: conf.objectId
442
362
  });
443
- case 6:
444
- libraryId = _context4.sent;
363
+ case 8:
364
+ libraryId = _context3.sent;
445
365
  status.library_id = libraryId;
446
- status.object_id = objectId;
447
- _context4.next = 11;
366
+ status.object_id = conf.objectId;
367
+ _context3.next = 13;
448
368
  return this.ContentObjectMetadata({
449
369
  libraryId: libraryId,
450
- objectId: objectId,
370
+ objectId: conf.objectId,
451
371
  select: ["live_recording_config", "live_recording"]
452
372
  });
453
- case 11:
454
- mainMeta = _context4.sent;
373
+ case 13:
374
+ mainMeta = _context3.sent;
455
375
  status.reference_url = mainMeta.live_recording_config.reference_url;
456
376
  if (!(mainMeta.live_recording_config == undefined || mainMeta.live_recording_config.url == undefined)) {
457
- _context4.next = 16;
377
+ _context3.next = 18;
458
378
  break;
459
379
  }
460
380
  status.state = "unconfigured";
461
- return _context4.abrupt("return", status);
462
- case 16:
381
+ return _context3.abrupt("return", status);
382
+ case 18:
463
383
  if (!(mainMeta.live_recording == undefined || mainMeta.live_recording.fabric_config == undefined || mainMeta.live_recording.playout_config == undefined || mainMeta.live_recording.recording_config == undefined)) {
464
- _context4.next = 19;
384
+ _context3.next = 21;
465
385
  break;
466
386
  }
467
387
  status.state = "uninitialized";
468
- return _context4.abrupt("return", status);
469
- case 19:
388
+ return _context3.abrupt("return", status);
389
+ case 21:
470
390
  fabURI = mainMeta.live_recording.fabric_config.ingress_node_api;
471
391
  if (!(fabURI === undefined)) {
472
- _context4.next = 24;
392
+ _context3.next = 26;
473
393
  break;
474
394
  }
475
395
  console.log("bad fabric config - missing ingress node API");
476
396
  status.state = "uninitialized";
477
- return _context4.abrupt("return", status);
478
- case 24:
397
+ return _context3.abrupt("return", status);
398
+ case 26:
479
399
  // Support both hostname and URL ingress_node_api
480
400
  if (!fabURI.startsWith("http")) {
481
401
  // Assume https
@@ -483,73 +403,66 @@ exports.StreamStatus = /*#__PURE__*/function () {
483
403
  }
484
404
  status.fabric_api = fabURI;
485
405
  status.url = mainMeta.live_recording.recording_config.recording_params.origin_url;
486
- edgeWriteToken = mainMeta.live_recording.fabric_config.edge_write_token;
487
- if (edgeWriteToken) {
488
- _context4.next = 31;
406
+ _edgeWriteToken = mainMeta.live_recording.fabric_config.edge_write_token;
407
+ if (_edgeWriteToken) {
408
+ _context3.next = 33;
489
409
  break;
490
410
  }
491
411
  status.state = "inactive";
492
- return _context4.abrupt("return", status);
493
- case 31:
412
+ return _context3.abrupt("return", status);
413
+ case 33:
494
414
  this.RecordWriteToken({
495
- writeToken: edgeWriteToken,
415
+ writeToken: _edgeWriteToken,
496
416
  fabricNodeUrl: fabURI
497
417
  });
498
- status.edge_write_token = edgeWriteToken;
499
- status.stream_id = edgeWriteToken; // By convention the stream ID is its write token
500
- _context4.next = 36;
418
+ status.edge_write_token = _edgeWriteToken;
419
+ status.stream_id = _edgeWriteToken; // By convention the stream ID is its write token
420
+ _context3.next = 38;
501
421
  return this.ContentObjectMetadata({
502
422
  libraryId: libraryId,
503
- objectId: objectId,
504
- writeToken: edgeWriteToken,
423
+ objectId: conf.objectId,
424
+ writeToken: _edgeWriteToken,
505
425
  select: ["live_recording"]
506
426
  });
507
- case 36:
508
- edgeMeta = _context4.sent;
427
+ case 38:
428
+ edgeMeta = _context3.sent;
509
429
  status.edge_meta_size = JSON.stringify(edgeMeta).length;
510
430
 
511
431
  // If a stream has never been started return state 'inactive'
512
432
  if (!(edgeMeta.live_recording === undefined || edgeMeta.live_recording.recordings === undefined || edgeMeta.live_recording.recordings.recording_sequence === undefined)) {
513
- _context4.next = 41;
433
+ _context3.next = 43;
514
434
  break;
515
435
  }
516
436
  status.state = "stopped";
517
- return _context4.abrupt("return", status);
518
- case 41:
437
+ return _context3.abrupt("return", status);
438
+ case 43:
519
439
  recordings = edgeMeta.live_recording.recordings;
520
440
  status.recording_period_sequence = recordings.recording_sequence;
521
441
  sequence = recordings.recording_sequence;
522
442
  period = recordings.live_offering[sequence - 1];
523
443
  tlro = period.live_recording_handle;
524
444
  status.tlro = tlro;
525
- videoLastFinalizationTimeEpochSec = -1;
526
- videoFinalizedParts = 0;
527
- sinceLastFinalize = -1;
528
- if (period.finalized_parts_info && period.finalized_parts_info.video && period.finalized_parts_info.video.last_finalization_time) {
529
- videoLastFinalizationTimeEpochSec = period.finalized_parts_info.video.last_finalization_time / 1000000;
530
- videoFinalizedParts = period.finalized_parts_info.video.n_parts;
531
- sinceLastFinalize = Math.floor(new Date().getTime() / 1000) - videoLastFinalizationTimeEpochSec;
532
- }
445
+ sinceLastFinalize = Math.floor(new Date().getTime() / 1000) - period.video_finalized_parts_info.last_finalization_time / 1000000;
533
446
  recording_period = {
534
447
  activation_time_epoch_sec: period.recording_start_time_epoch_sec,
535
448
  start_time_epoch_sec: period.start_time_epoch_sec,
536
449
  start_time_text: new Date(period.start_time_epoch_sec * 1000).toLocaleString(),
537
450
  end_time_epoch_sec: period.end_time_epoch_sec,
538
451
  end_time_text: period.end_time_epoch_sec === 0 ? null : new Date(period.end_time_epoch_sec * 1000).toLocaleString(),
539
- video_parts: videoFinalizedParts,
540
- video_last_part_finalized_epoch_sec: videoLastFinalizationTimeEpochSec,
452
+ video_parts: period.video_finalized_parts_info.n_parts,
453
+ video_last_part_finalized_epoch_sec: period.video_finalized_parts_info.last_finalization_time / 1000000,
541
454
  video_since_last_finalize_sec: sinceLastFinalize
542
455
  };
543
456
  status.recording_period = recording_period;
544
- _context4.next = 55;
457
+ _context3.next = 54;
545
458
  return this.FabricUrl({
546
459
  libraryId: libraryId,
547
- objectId: objectId,
548
- writeToken: edgeWriteToken,
460
+ objectId: conf.objectId,
461
+ writeToken: _edgeWriteToken,
549
462
  call: "live/status/" + tlro
550
463
  });
551
- case 55:
552
- status.lro_status_url = _context4.sent;
464
+ case 54:
465
+ status.lro_status_url = _context3.sent;
553
466
  status.insertions = [];
554
467
  if (edgeMeta.live_recording.playout_config.interleaves != undefined && edgeMeta.live_recording.playout_config.interleaves[sequence] != undefined) {
555
468
  insertions = edgeMeta.live_recording.playout_config.interleaves[sequence];
@@ -568,31 +481,29 @@ exports.StreamStatus = /*#__PURE__*/function () {
568
481
  }
569
482
  state = "stopped";
570
483
  lroStatus = "";
571
- _context4.prev = 61;
572
- _context4.t0 = this.utils;
573
- _context4.next = 65;
484
+ _context3.prev = 60;
485
+ _context3.t0 = this.utils;
486
+ _context3.next = 64;
574
487
  return HttpClient.Fetch(status.lro_status_url);
575
- case 65:
576
- _context4.t1 = _context4.sent;
577
- _context4.next = 68;
578
- return _context4.t0.ResponseToJson.call(_context4.t0, _context4.t1);
579
- case 68:
580
- lroStatus = _context4.sent;
488
+ case 64:
489
+ _context3.t1 = _context3.sent;
490
+ _context3.next = 67;
491
+ return _context3.t0.ResponseToJson.call(_context3.t0, _context3.t1);
492
+ case 67:
493
+ lroStatus = _context3.sent;
581
494
  state = lroStatus.state;
582
- status.warnings = lroStatus.custom && lroStatus.custom.warnings;
583
- status.quality = lroStatus.custom && lroStatus.custom.quality;
584
- _context4.next = 80;
495
+ _context3.next = 77;
585
496
  break;
586
- case 74:
587
- _context4.prev = 74;
588
- _context4.t2 = _context4["catch"](61);
589
- console.log("LRO Status (failed): ", _context4.t2.response.statusCode);
497
+ case 71:
498
+ _context3.prev = 71;
499
+ _context3.t2 = _context3["catch"](60);
500
+ console.log("LRO Status (failed): ", _context3.t2.response.statusCode);
590
501
  status.state = "stopped";
591
- status.error = _context4.t2.response;
592
- return _context4.abrupt("return", status);
593
- case 80:
502
+ status.error = _context3.t2.response;
503
+ return _context3.abrupt("return", status);
504
+ case 77:
594
505
  // Convert LRO 'state' to desired 'state'
595
- if (state === "running" && videoLastFinalizationTimeEpochSec <= 0) {
506
+ if (state === "running" && period.video_finalized_parts_info.last_finalization_time === 0) {
596
507
  state = "starting";
597
508
  } else if (state === "running" && sinceLastFinalize > 32.9) {
598
509
  state = "stalled";
@@ -601,97 +512,98 @@ exports.StreamStatus = /*#__PURE__*/function () {
601
512
  }
602
513
  status.state = state;
603
514
  if (!((state === "running" || state === "stalled" || state === "starting") && stopLro)) {
604
- _context4.next = 101;
515
+ _context3.next = 98;
605
516
  break;
606
517
  }
607
- _context4.next = 85;
518
+ _context3.next = 82;
608
519
  return this.FabricUrl({
609
520
  libraryId: libraryId,
610
- objectId: objectId,
611
- writeToken: edgeWriteToken,
521
+ objectId: conf.objectId,
522
+ writeToken: _edgeWriteToken,
612
523
  call: "live/stop/" + tlro
613
524
  });
614
- case 85:
615
- lroStopUrl = _context4.sent;
616
- _context4.prev = 86;
617
- _context4.t3 = this.utils;
618
- _context4.next = 90;
525
+ case 82:
526
+ lroStopUrl = _context3.sent;
527
+ _context3.prev = 83;
528
+ _context3.t3 = this.utils;
529
+ _context3.next = 87;
619
530
  return HttpClient.Fetch(lroStopUrl);
531
+ case 87:
532
+ _context3.t4 = _context3.sent;
533
+ _context3.next = 90;
534
+ return _context3.t3.ResponseToJson.call(_context3.t3, _context3.t4);
620
535
  case 90:
621
- _context4.t4 = _context4.sent;
622
- _context4.next = 93;
623
- return _context4.t3.ResponseToJson.call(_context4.t3, _context4.t4);
624
- case 93:
625
536
  console.log("LRO Stop: ", lroStatus.body);
626
- _context4.next = 99;
537
+ _context3.next = 96;
627
538
  break;
539
+ case 93:
540
+ _context3.prev = 93;
541
+ _context3.t5 = _context3["catch"](83);
542
+ console.log("LRO Stop (failed): ", _context3.t5.response.statusCode);
628
543
  case 96:
629
- _context4.prev = 96;
630
- _context4.t5 = _context4["catch"](86);
631
- console.log("LRO Stop (failed): ", _context4.t5.response.statusCode);
632
- case 99:
633
544
  state = "stopped";
634
545
  status.state = state;
635
- case 101:
546
+ case 98:
636
547
  if (!(state === "running")) {
637
- _context4.next = 132;
548
+ _context3.next = 130;
638
549
  break;
639
550
  }
640
551
  playout_urls = {};
641
- _context4.next = 105;
552
+ objectId = conf.objectId;
553
+ _context3.next = 103;
642
554
  return this.PlayoutOptions({
643
555
  objectId: objectId,
644
556
  linkPath: "public/asset_metadata/sources/default"
645
557
  });
646
- case 105:
647
- playout_options = _context4.sent;
558
+ case 103:
559
+ playout_options = _context3.sent;
648
560
  hls_clear_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods.clear !== undefined;
649
561
  if (!hls_clear_enabled) {
650
- _context4.next = 111;
562
+ _context3.next = 109;
651
563
  break;
652
564
  }
653
- _context4.next = 110;
565
+ _context3.next = 108;
654
566
  return this.FabricUrl({
655
567
  libraryId: libraryId,
656
568
  objectId: objectId,
657
569
  rep: "playout/default/hls-clear/playlist.m3u8"
658
570
  });
659
- case 110:
660
- playout_urls.hls_clear = _context4.sent;
661
- case 111:
571
+ case 108:
572
+ playout_urls.hls_clear = _context3.sent;
573
+ case 109:
662
574
  hls_aes128_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods["aes-128"] !== undefined;
663
575
  if (!hls_aes128_enabled) {
664
- _context4.next = 116;
576
+ _context3.next = 114;
665
577
  break;
666
578
  }
667
- _context4.next = 115;
579
+ _context3.next = 113;
668
580
  return this.FabricUrl({
669
581
  libraryId: libraryId,
670
582
  objectId: objectId,
671
583
  rep: "playout/default/hls-aes128/playlist.m3u8"
672
584
  });
673
- case 115:
674
- playout_urls.hls_aes128 = _context4.sent;
675
- case 116:
585
+ case 113:
586
+ playout_urls.hls_aes128 = _context3.sent;
587
+ case 114:
676
588
  hls_sample_aes_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods["sample-aes"] !== undefined;
677
589
  if (!hls_sample_aes_enabled) {
678
- _context4.next = 121;
590
+ _context3.next = 119;
679
591
  break;
680
592
  }
681
- _context4.next = 120;
593
+ _context3.next = 118;
682
594
  return this.FabricUrl({
683
595
  libraryId: libraryId,
684
596
  objectId: objectId,
685
597
  rep: "playout/default/hls-sample-aes/playlist.m3u8"
686
598
  });
687
- case 120:
688
- playout_urls.hls_sample_aes = _context4.sent;
689
- case 121:
690
- _context4.next = 123;
599
+ case 118:
600
+ playout_urls.hls_sample_aes = _context3.sent;
601
+ case 119:
602
+ _context3.next = 121;
691
603
  return this.NetworkInfo();
692
- case 123:
693
- networkInfo = _context4.sent;
694
- _context4.next = 126;
604
+ case 121:
605
+ networkInfo = _context3.sent;
606
+ _context3.next = 124;
695
607
  return this.authClient.AuthorizationToken({
696
608
  libraryId: libraryId,
697
609
  objectId: objectId,
@@ -699,32 +611,32 @@ exports.StreamStatus = /*#__PURE__*/function () {
699
611
  noCache: true,
700
612
  noAuth: true
701
613
  });
702
- case 126:
703
- token = _context4.sent;
614
+ case 124:
615
+ token = _context3.sent;
704
616
  embed_net = "main";
705
617
  if (networkInfo.name.includes("demo")) {
706
618
  embed_net = "demo";
707
619
  }
708
- embed_url = "https://embed.v3.contentfabric.io/?net=".concat(embed_net, "&p&ct=h&oid=").concat(objectId, "&mt=lv&ath=").concat(token);
620
+ embed_url = "https://embed.v3.contentfabric.io/?net=".concat(embed_net, "&p&ct=h&oid=").concat(conf.objectId, "&mt=lv&ath=").concat(token);
709
621
  playout_urls.embed_url = embed_url;
710
622
  status.playout_urls = playout_urls;
711
- case 132:
712
- _context4.next = 137;
623
+ case 130:
624
+ _context3.next = 135;
713
625
  break;
714
- case 134:
715
- _context4.prev = 134;
716
- _context4.t6 = _context4["catch"](3);
717
- console.error(_context4.t6);
718
- case 137:
719
- return _context4.abrupt("return", status);
720
- case 138:
626
+ case 132:
627
+ _context3.prev = 132;
628
+ _context3.t6 = _context3["catch"](5);
629
+ console.error(_context3.t6);
630
+ case 135:
631
+ return _context3.abrupt("return", status);
632
+ case 136:
721
633
  case "end":
722
- return _context4.stop();
634
+ return _context3.stop();
723
635
  }
724
- }, _callee4, this, [[3, 134], [61, 74], [86, 96]]);
636
+ }, _callee3, this, [[5, 132], [60, 71], [83, 93]]);
725
637
  }));
726
- return function (_x4) {
727
- return _ref8.apply(this, arguments);
638
+ return function (_x3) {
639
+ return _ref6.apply(this, arguments);
728
640
  };
729
641
  }();
730
642
 
@@ -740,43 +652,43 @@ exports.StreamStatus = /*#__PURE__*/function () {
740
652
  *
741
653
  */
742
654
  exports.StreamCreate = /*#__PURE__*/function () {
743
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
744
- var name, _ref9$start, start, status, objectId, libraryId, liveRecording, fabURI, response, edgeToken, writeToken, objectHash;
745
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
746
- while (1) switch (_context5.prev = _context5.next) {
655
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
656
+ var name, _ref7$start, start, status, objectId, libraryId, liveRecording, fabURI, response, edgeToken, writeToken, objectHash;
657
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
658
+ while (1) switch (_context4.prev = _context4.next) {
747
659
  case 0:
748
- name = _ref9.name, _ref9$start = _ref9.start, start = _ref9$start === void 0 ? false : _ref9$start;
749
- _context5.next = 3;
660
+ name = _ref7.name, _ref7$start = _ref7.start, start = _ref7$start === void 0 ? false : _ref7$start;
661
+ _context4.next = 3;
750
662
  return this.StreamStatus({
751
663
  name: name
752
664
  });
753
665
  case 3:
754
- status = _context5.sent;
755
- if (!(status.state != "uninitialized" && status.state !== "inactive" && status.state !== "terminated" && status.state !== "stopped")) {
756
- _context5.next = 6;
666
+ status = _context4.sent;
667
+ if (!(status.state !== "inactive" && status.state !== "terminated" && status.state !== "stopped")) {
668
+ _context4.next = 6;
757
669
  break;
758
670
  }
759
- return _context5.abrupt("return", {
671
+ return _context4.abrupt("return", {
760
672
  state: status.state,
761
673
  error: "stream still active - must terminate first"
762
674
  });
763
675
  case 6:
764
676
  objectId = status.object_id;
765
677
  console.log("START: ", name, "start", start);
766
- _context5.next = 10;
678
+ _context4.next = 10;
767
679
  return this.ContentObjectLibraryId({
768
680
  objectId: objectId
769
681
  });
770
682
  case 10:
771
- libraryId = _context5.sent;
772
- _context5.next = 13;
683
+ libraryId = _context4.sent;
684
+ _context4.next = 13;
773
685
  return this.ContentObjectMetadata({
774
686
  libraryId: libraryId,
775
687
  objectId: objectId,
776
688
  metadataSubtree: "/live_recording"
777
689
  });
778
690
  case 13:
779
- liveRecording = _context5.sent;
691
+ liveRecording = _context4.sent;
780
692
  fabURI = liveRecording.fabric_config.ingress_node_api; // Support both hostname and URL ingress_node_api
781
693
  if (!fabURI.startsWith("http")) {
782
694
  // Assume https
@@ -786,29 +698,29 @@ exports.StreamCreate = /*#__PURE__*/function () {
786
698
  fabricURIs: [fabURI]
787
699
  });
788
700
  console.log("Node URI", fabURI, "ID", liveRecording.fabric_config.ingress_node_id);
789
- _context5.next = 20;
701
+ _context4.next = 20;
790
702
  return this.EditContentObject({
791
703
  libraryId: libraryId,
792
704
  objectId: objectId
793
705
  });
794
706
  case 20:
795
- response = _context5.sent;
707
+ response = _context4.sent;
796
708
  edgeToken = response.write_token;
797
709
  console.log("Edge token:", edgeToken);
798
710
 
799
711
  /*
800
712
  * Set the metadata, including the edge token.
801
713
  */
802
- _context5.next = 25;
714
+ _context4.next = 25;
803
715
  return this.EditContentObject({
804
716
  libraryId: libraryId,
805
717
  objectId: objectId
806
718
  });
807
719
  case 25:
808
- response = _context5.sent;
720
+ response = _context4.sent;
809
721
  writeToken = response.write_token;
810
722
  this.Log("Merging metadata: ", libraryId, objectId, writeToken);
811
- _context5.next = 30;
723
+ _context4.next = 30;
812
724
  return this.MergeMetadata({
813
725
  libraryId: libraryId,
814
726
  objectId: objectId,
@@ -828,7 +740,7 @@ exports.StreamCreate = /*#__PURE__*/function () {
828
740
  });
829
741
  case 30:
830
742
  this.Log("Finalizing content draft: ", libraryId, objectId, writeToken);
831
- _context5.next = 33;
743
+ _context4.next = 33;
832
744
  return this.FinalizeContentObject({
833
745
  libraryId: libraryId,
834
746
  objectId: objectId,
@@ -836,7 +748,7 @@ exports.StreamCreate = /*#__PURE__*/function () {
836
748
  commitMessage: "Create stream edge write token " + edgeToken
837
749
  });
838
750
  case 33:
839
- response = _context5.sent;
751
+ response = _context4.sent;
840
752
  objectHash = response.hash;
841
753
  this.Log("Finalized object: ", objectHash);
842
754
  status = {
@@ -854,15 +766,15 @@ exports.StreamCreate = /*#__PURE__*/function () {
854
766
  op: start
855
767
  });
856
768
  }
857
- return _context5.abrupt("return", status);
769
+ return _context4.abrupt("return", status);
858
770
  case 39:
859
771
  case "end":
860
- return _context5.stop();
772
+ return _context4.stop();
861
773
  }
862
- }, _callee5, this);
774
+ }, _callee4, this);
863
775
  }));
864
- return function (_x5) {
865
- return _ref10.apply(this, arguments);
776
+ return function (_x4) {
777
+ return _ref8.apply(this, arguments);
866
778
  };
867
779
  }();
868
780
 
@@ -883,36 +795,36 @@ exports.StreamCreate = /*#__PURE__*/function () {
883
795
  *
884
796
  */
885
797
  exports.StreamStartOrStopOrReset = /*#__PURE__*/function () {
886
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref11) {
798
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
887
799
  var name, op, status, _tries, tries;
888
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
889
- while (1) switch (_context6.prev = _context6.next) {
800
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
801
+ while (1) switch (_context5.prev = _context5.next) {
890
802
  case 0:
891
- name = _ref11.name, op = _ref11.op;
892
- _context6.prev = 1;
893
- _context6.next = 4;
803
+ name = _ref9.name, op = _ref9.op;
804
+ _context5.prev = 1;
805
+ _context5.next = 4;
894
806
  return this.StreamStatus({
895
807
  name: name
896
808
  });
897
809
  case 4:
898
- status = _context6.sent;
810
+ status = _context5.sent;
899
811
  if (!(status.state != "stopped")) {
900
- _context6.next = 9;
812
+ _context5.next = 9;
901
813
  break;
902
814
  }
903
815
  if (!(op === "start")) {
904
- _context6.next = 9;
816
+ _context5.next = 9;
905
817
  break;
906
818
  }
907
819
  status.error = "Unable to start stream - state: " + status.state;
908
- return _context6.abrupt("return", status);
820
+ return _context5.abrupt("return", status);
909
821
  case 9:
910
822
  if (!(status.state == "running" || status.state == "starting" || status.state == "stalled")) {
911
- _context6.next = 31;
823
+ _context5.next = 31;
912
824
  break;
913
825
  }
914
- _context6.prev = 10;
915
- _context6.next = 13;
826
+ _context5.prev = 10;
827
+ _context5.next = 13;
916
828
  return this.CallBitcodeMethod({
917
829
  libraryId: status.library_id,
918
830
  objectId: status.object_id,
@@ -921,49 +833,49 @@ exports.StreamStartOrStopOrReset = /*#__PURE__*/function () {
921
833
  constant: false
922
834
  });
923
835
  case 13:
924
- _context6.next = 17;
836
+ _context5.next = 17;
925
837
  break;
926
838
  case 15:
927
- _context6.prev = 15;
928
- _context6.t0 = _context6["catch"](10);
839
+ _context5.prev = 15;
840
+ _context5.t0 = _context5["catch"](10);
929
841
  case 17:
930
842
  // Wait until LRO is terminated
931
843
  _tries = 10;
932
844
  case 18:
933
845
  if (!(status.state != "stopped" && _tries-- > 0)) {
934
- _context6.next = 27;
846
+ _context5.next = 27;
935
847
  break;
936
848
  }
937
849
  console.log("Wait to terminate - ", status.state);
938
- _context6.next = 22;
850
+ _context5.next = 22;
939
851
  return Sleep(1000);
940
852
  case 22:
941
- _context6.next = 24;
853
+ _context5.next = 24;
942
854
  return this.StreamStatus({
943
855
  name: name
944
856
  });
945
857
  case 24:
946
- status = _context6.sent;
947
- _context6.next = 18;
858
+ status = _context5.sent;
859
+ _context5.next = 18;
948
860
  break;
949
861
  case 27:
950
862
  console.log("Status after stop - ", status.state);
951
863
  if (!(_tries <= 0)) {
952
- _context6.next = 31;
864
+ _context5.next = 31;
953
865
  break;
954
866
  }
955
867
  console.log("Failed to stop");
956
- return _context6.abrupt("return", status);
868
+ return _context5.abrupt("return", status);
957
869
  case 31:
958
870
  if (!(op === "stop")) {
959
- _context6.next = 33;
871
+ _context5.next = 33;
960
872
  break;
961
873
  }
962
- return _context6.abrupt("return", status);
874
+ return _context5.abrupt("return", status);
963
875
  case 33:
964
876
  console.log("STARTING", "edge_write_token", status.edge_write_token);
965
- _context6.prev = 34;
966
- _context6.next = 37;
877
+ _context5.prev = 34;
878
+ _context5.next = 37;
967
879
  return this.CallBitcodeMethod({
968
880
  libraryId: status.library_id,
969
881
  objectId: status.object_id,
@@ -972,13 +884,13 @@ exports.StreamStartOrStopOrReset = /*#__PURE__*/function () {
972
884
  constant: false
973
885
  });
974
886
  case 37:
975
- _context6.next = 43;
887
+ _context5.next = 43;
976
888
  break;
977
889
  case 39:
978
- _context6.prev = 39;
979
- _context6.t1 = _context6["catch"](34);
980
- console.log("LRO Start (failed): ", _context6.t1);
981
- return _context6.abrupt("return", {
890
+ _context5.prev = 39;
891
+ _context5.t1 = _context5["catch"](34);
892
+ console.log("LRO Start (failed): ", _context5.t1);
893
+ return _context5.abrupt("return", {
982
894
  state: status.state,
983
895
  error: "LRO start failed - must create a stream first"
984
896
  });
@@ -987,36 +899,36 @@ exports.StreamStartOrStopOrReset = /*#__PURE__*/function () {
987
899
  tries = 10;
988
900
  case 44:
989
901
  if (!(status.state != "starting" && tries-- > 0)) {
990
- _context6.next = 53;
902
+ _context5.next = 53;
991
903
  break;
992
904
  }
993
905
  console.log("Wait to start - ", status.state);
994
- _context6.next = 48;
906
+ _context5.next = 48;
995
907
  return Sleep(1000);
996
908
  case 48:
997
- _context6.next = 50;
909
+ _context5.next = 50;
998
910
  return this.StreamStatus({
999
911
  name: name
1000
912
  });
1001
913
  case 50:
1002
- status = _context6.sent;
1003
- _context6.next = 44;
914
+ status = _context5.sent;
915
+ _context5.next = 44;
1004
916
  break;
1005
917
  case 53:
1006
918
  console.log("Status after restart - ", status.state);
1007
- return _context6.abrupt("return", status);
919
+ return _context5.abrupt("return", status);
1008
920
  case 57:
1009
- _context6.prev = 57;
1010
- _context6.t2 = _context6["catch"](1);
1011
- console.error(_context6.t2);
921
+ _context5.prev = 57;
922
+ _context5.t2 = _context5["catch"](1);
923
+ console.error(_context5.t2);
1012
924
  case 60:
1013
925
  case "end":
1014
- return _context6.stop();
926
+ return _context5.stop();
1015
927
  }
1016
- }, _callee6, this, [[1, 57], [10, 15], [34, 39]]);
928
+ }, _callee5, this, [[1, 57], [10, 15], [34, 39]]);
1017
929
  }));
1018
- return function (_x6) {
1019
- return _ref12.apply(this, arguments);
930
+ return function (_x5) {
931
+ return _ref10.apply(this, arguments);
1020
932
  };
1021
933
  }();
1022
934
 
@@ -1030,28 +942,34 @@ exports.StreamStartOrStopOrReset = /*#__PURE__*/function () {
1030
942
  * @return {Promise<Object>} - The finalize response for the stream object
1031
943
  */
1032
944
  exports.StreamStopSession = /*#__PURE__*/function () {
1033
- var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref13) {
1034
- var name, objectId, libraryId, mainMeta, fabURI, metaEdgeWriteToken, streamMetadata, status, _yield$this$EditConte, writeToken, newState, stopTime, finalizeMetadata, fin;
1035
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
1036
- while (1) switch (_context7.prev = _context7.next) {
945
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref11) {
946
+ var name, conf, objectId, libraryId, mainMeta, fabURI, metaEdgeWriteToken, streamMetadata, status, _yield$this$EditConte, writeToken, newState, stopTime, finalizeMetadata, fin;
947
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
948
+ while (1) switch (_context6.prev = _context6.next) {
1037
949
  case 0:
1038
- name = _ref13.name;
1039
- _context7.prev = 1;
950
+ name = _ref11.name;
951
+ _context6.prev = 1;
1040
952
  this.Log("Terminating stream session for: ".concat(name));
1041
- objectId = name;
1042
- _context7.next = 6;
953
+ _context6.next = 5;
954
+ return this.LoadConf({
955
+ name: name
956
+ });
957
+ case 5:
958
+ conf = _context6.sent;
959
+ objectId = conf.objectId;
960
+ _context6.next = 9;
1043
961
  return this.ContentObjectLibraryId({
1044
962
  objectId: objectId
1045
963
  });
1046
- case 6:
1047
- libraryId = _context7.sent;
1048
- _context7.next = 9;
964
+ case 9:
965
+ libraryId = _context6.sent;
966
+ _context6.next = 12;
1049
967
  return this.ContentObjectMetadata({
1050
968
  libraryId: libraryId,
1051
969
  objectId: objectId
1052
970
  });
1053
- case 9:
1054
- mainMeta = _context7.sent;
971
+ case 12:
972
+ mainMeta = _context6.sent;
1055
973
  fabURI = mainMeta.live_recording.fabric_config.ingress_node_api; // Support both hostname and URL ingress_node_api
1056
974
  if (!fabURI.startsWith("http")) {
1057
975
  // Assume https
@@ -1062,58 +980,58 @@ exports.StreamStopSession = /*#__PURE__*/function () {
1062
980
  });
1063
981
  metaEdgeWriteToken = mainMeta.live_recording.fabric_config.edge_write_token;
1064
982
  if (metaEdgeWriteToken) {
1065
- _context7.next = 16;
983
+ _context6.next = 19;
1066
984
  break;
1067
985
  }
1068
- return _context7.abrupt("return", {
986
+ return _context6.abrupt("return", {
1069
987
  state: "inactive",
1070
988
  error: "The stream is not active"
1071
989
  });
1072
- case 16:
1073
- _context7.prev = 16;
1074
- _context7.next = 19;
990
+ case 19:
991
+ _context6.prev = 19;
992
+ _context6.next = 22;
1075
993
  return this.ContentObjectMetadata({
1076
994
  libraryId: libraryId,
1077
995
  objectId: objectId,
1078
996
  writeToken: metaEdgeWriteToken
1079
997
  });
1080
- case 19:
1081
- streamMetadata = _context7.sent;
1082
- _context7.next = 22;
998
+ case 22:
999
+ streamMetadata = _context6.sent;
1000
+ _context6.next = 25;
1083
1001
  return this.StreamStatus({
1084
1002
  name: name
1085
1003
  });
1086
- case 22:
1087
- status = _context7.sent;
1004
+ case 25:
1005
+ status = _context6.sent;
1088
1006
  if (!(status.state !== "stopped")) {
1089
- _context7.next = 25;
1007
+ _context6.next = 28;
1090
1008
  break;
1091
1009
  }
1092
- return _context7.abrupt("return", {
1010
+ return _context6.abrupt("return", {
1093
1011
  state: status.state,
1094
1012
  error: "The stream must be stopped before terminating"
1095
1013
  });
1096
- case 25:
1097
- _context7.next = 27;
1014
+ case 28:
1015
+ _context6.next = 30;
1098
1016
  return this.DeleteWriteToken({
1099
1017
  libraryId: libraryId,
1100
1018
  writeToken: metaEdgeWriteToken
1101
1019
  });
1102
- case 27:
1103
- _context7.next = 32;
1020
+ case 30:
1021
+ _context6.next = 35;
1104
1022
  break;
1105
- case 29:
1106
- _context7.prev = 29;
1107
- _context7.t0 = _context7["catch"](16);
1108
- this.Log("Unable to retrieve metadata for edge write token");
1109
1023
  case 32:
1110
- _context7.next = 34;
1024
+ _context6.prev = 32;
1025
+ _context6.t0 = _context6["catch"](19);
1026
+ this.Log("Unable to retrieve metadata for edge write token ".concat(edgeWriteToken));
1027
+ case 35:
1028
+ _context6.next = 37;
1111
1029
  return this.EditContentObject({
1112
1030
  libraryId: libraryId,
1113
1031
  objectId: objectId
1114
1032
  });
1115
- case 34:
1116
- _yield$this$EditConte = _context7.sent;
1033
+ case 37:
1034
+ _yield$this$EditConte = _context6.sent;
1117
1035
  writeToken = _yield$this$EditConte.writeToken;
1118
1036
  // Set stop time and inactive state
1119
1037
  newState = "inactive";
@@ -1128,42 +1046,43 @@ exports.StreamStopSession = /*#__PURE__*/function () {
1128
1046
  fabric_config: {
1129
1047
  edge_write_token: ""
1130
1048
  }
1131
- }
1049
+ },
1050
+ recording_stop_time: stopTime
1132
1051
  };
1133
- _context7.next = 41;
1052
+ _context6.next = 44;
1134
1053
  return this.MergeMetadata({
1135
1054
  libraryId: libraryId,
1136
1055
  objectId: objectId,
1137
1056
  writeToken: writeToken,
1138
1057
  metadata: finalizeMetadata
1139
1058
  });
1140
- case 41:
1141
- _context7.next = 43;
1059
+ case 44:
1060
+ _context6.next = 46;
1142
1061
  return this.FinalizeContentObject({
1143
1062
  libraryId: libraryId,
1144
1063
  objectId: objectId,
1145
1064
  writeToken: writeToken,
1146
1065
  commitMessage: "Deactivate live stream - stop time ".concat(stopTime)
1147
1066
  });
1148
- case 43:
1149
- fin = _context7.sent;
1150
- return _context7.abrupt("return", {
1067
+ case 46:
1068
+ fin = _context6.sent;
1069
+ return _context6.abrupt("return", {
1151
1070
  fin: fin,
1152
1071
  name: name,
1153
1072
  state: newState
1154
1073
  });
1155
- case 47:
1156
- _context7.prev = 47;
1157
- _context7.t1 = _context7["catch"](1);
1158
- console.error(_context7.t1);
1159
1074
  case 50:
1075
+ _context6.prev = 50;
1076
+ _context6.t1 = _context6["catch"](1);
1077
+ console.error(_context6.t1);
1078
+ case 53:
1160
1079
  case "end":
1161
- return _context7.stop();
1080
+ return _context6.stop();
1162
1081
  }
1163
- }, _callee7, this, [[1, 47], [16, 29]]);
1082
+ }, _callee6, this, [[1, 50], [19, 32]]);
1164
1083
  }));
1165
- return function (_x7) {
1166
- return _ref14.apply(this, arguments);
1084
+ return function (_x6) {
1085
+ return _ref12.apply(this, arguments);
1167
1086
  };
1168
1087
  }();
1169
1088
 
@@ -1181,41 +1100,33 @@ exports.StreamStopSession = /*#__PURE__*/function () {
1181
1100
  * @return {Promise<Object>} - The name, object ID, and state of the stream
1182
1101
  */
1183
1102
  exports.StreamInitialize = /*#__PURE__*/function () {
1184
- var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref15) {
1185
- var name, _ref15$drm, drm, format, typeAbrMaster, typeLiveStream, tenantContractId, _yield$this$ContentOb, live_stream, title, res;
1186
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
1187
- while (1) switch (_context8.prev = _context8.next) {
1103
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref13) {
1104
+ var name, _ref13$drm, drm, format, contentTypes, typeAbrMaster, typeLiveStream, i, key, res;
1105
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
1106
+ while (1) switch (_context7.prev = _context7.next) {
1188
1107
  case 0:
1189
- name = _ref15.name, _ref15$drm = _ref15.drm, drm = _ref15$drm === void 0 ? false : _ref15$drm, format = _ref15.format;
1190
- _context8.next = 3;
1191
- return this.userProfileClient.TenantContractId();
1108
+ name = _ref13.name, _ref13$drm = _ref13.drm, drm = _ref13$drm === void 0 ? false : _ref13$drm, format = _ref13.format;
1109
+ _context7.next = 3;
1110
+ return this.ContentTypes();
1192
1111
  case 3:
1193
- tenantContractId = _context8.sent;
1194
- _context8.next = 6;
1195
- return this.ContentObjectMetadata({
1196
- libraryId: tenantContractId.replace("iten", "ilib"),
1197
- objectId: tenantContractId.replace("iten", "iq__"),
1198
- metadataSubtree: "public/content_types",
1199
- select: ["live_stream", "title"]
1200
- });
1201
- case 6:
1202
- _yield$this$ContentOb = _context8.sent;
1203
- live_stream = _yield$this$ContentOb.live_stream;
1204
- title = _yield$this$ContentOb.title;
1205
- if (live_stream) {
1206
- typeLiveStream = live_stream;
1207
- }
1208
- if (title) {
1209
- typeAbrMaster = title;
1112
+ contentTypes = _context7.sent;
1113
+ for (i = 0; i < Object.keys(contentTypes).length; i++) {
1114
+ key = Object.keys(contentTypes)[i];
1115
+ if (contentTypes[key].name.includes("ABR Master") || contentTypes[key].name.includes("Title")) {
1116
+ typeAbrMaster = contentTypes[key].hash;
1117
+ }
1118
+ if (contentTypes[key].name.includes("Live Stream")) {
1119
+ typeLiveStream = contentTypes[key].hash;
1120
+ }
1210
1121
  }
1211
1122
  if (!(typeAbrMaster === undefined || typeLiveStream === undefined)) {
1212
- _context8.next = 14;
1123
+ _context7.next = 8;
1213
1124
  break;
1214
1125
  }
1215
1126
  console.log("ERROR - unable to find content types", "ABR Master", typeAbrMaster, "Live Stream", typeLiveStream);
1216
- return _context8.abrupt("return", {});
1217
- case 14:
1218
- _context8.next = 16;
1127
+ return _context7.abrupt("return", {});
1128
+ case 8:
1129
+ _context7.next = 10;
1219
1130
  return this.StreamSetOfferingAndDRM({
1220
1131
  name: name,
1221
1132
  typeAbrMaster: typeAbrMaster,
@@ -1223,22 +1134,22 @@ exports.StreamInitialize = /*#__PURE__*/function () {
1223
1134
  drm: drm,
1224
1135
  format: format
1225
1136
  });
1226
- case 16:
1227
- res = _context8.sent;
1228
- return _context8.abrupt("return", res);
1229
- case 18:
1137
+ case 10:
1138
+ res = _context7.sent;
1139
+ return _context7.abrupt("return", res);
1140
+ case 12:
1230
1141
  case "end":
1231
- return _context8.stop();
1142
+ return _context7.stop();
1232
1143
  }
1233
- }, _callee8, this);
1144
+ }, _callee7, this);
1234
1145
  }));
1235
- return function (_x8) {
1236
- return _ref16.apply(this, arguments);
1146
+ return function (_x7) {
1147
+ return _ref14.apply(this, arguments);
1237
1148
  };
1238
1149
  }();
1239
1150
 
1240
1151
  /**
1241
- * Create a dummy VoD offering and initialize DRM keys.
1152
+ * Set the Live Stream offering
1242
1153
  *
1243
1154
  * @methodGroup Live Stream
1244
1155
  * @namedParams
@@ -1253,23 +1164,23 @@ exports.StreamInitialize = /*#__PURE__*/function () {
1253
1164
  * @return {Promise<Object>} - The name, object ID, and state of the stream
1254
1165
  */
1255
1166
  exports.StreamSetOfferingAndDRM = /*#__PURE__*/function () {
1256
- var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref17) {
1257
- var name, typeAbrMaster, typeLiveStream, _ref17$drm, drm, format, status, objectId, aBitRate, aChannels, aSampleRate, aStreamIndex, aTimeBase, aChannelLayout, vBitRate, vHeight, vStreamIndex, vWidth, vDisplayAspectRatio, vFrameRate, vTimeBase, abrProfileDefault, playoutFormats, abrProfile, formats, i, libraryId, mainMeta, fabURI, streamUrl;
1258
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
1259
- while (1) switch (_context9.prev = _context9.next) {
1167
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref15) {
1168
+ var name, typeAbrMaster, typeLiveStream, _ref15$drm, drm, format, status, objectId, aBitRate, aChannels, aSampleRate, aStreamIndex, aTimeBase, aChannelLayout, vBitRate, vHeight, vStreamIndex, vWidth, vDisplayAspectRatio, vFrameRate, vTimeBase, abrProfile, playoutFormats, formats, i, libraryId, mainMeta, fabURI, streamUrl;
1169
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
1170
+ while (1) switch (_context8.prev = _context8.next) {
1260
1171
  case 0:
1261
- name = _ref17.name, typeAbrMaster = _ref17.typeAbrMaster, typeLiveStream = _ref17.typeLiveStream, _ref17$drm = _ref17.drm, drm = _ref17$drm === void 0 ? false : _ref17$drm, format = _ref17.format;
1262
- _context9.next = 3;
1172
+ name = _ref15.name, typeAbrMaster = _ref15.typeAbrMaster, typeLiveStream = _ref15.typeLiveStream, _ref15$drm = _ref15.drm, drm = _ref15$drm === void 0 ? false : _ref15$drm, format = _ref15.format;
1173
+ _context8.next = 3;
1263
1174
  return this.StreamStatus({
1264
1175
  name: name
1265
1176
  });
1266
1177
  case 3:
1267
- status = _context9.sent;
1268
- if (!(status.state != "uninitialized" && status.state != "inactive" && status.state != "stopped")) {
1269
- _context9.next = 6;
1178
+ status = _context8.sent;
1179
+ if (!(status.state != "inactive" && status.state != "stopped")) {
1180
+ _context8.next = 6;
1270
1181
  break;
1271
1182
  }
1272
- return _context9.abrupt("return", {
1183
+ return _context8.abrupt("return", {
1273
1184
  state: status.state,
1274
1185
  error: "stream still active - must terminate first"
1275
1186
  });
@@ -1289,10 +1200,10 @@ exports.StreamSetOfferingAndDRM = /*#__PURE__*/function () {
1289
1200
  vDisplayAspectRatio = "16/9";
1290
1201
  vFrameRate = "30000/1001";
1291
1202
  vTimeBase = "1/30000"; // "1/16000";
1292
- abrProfileDefault = require("../abr_profiles/abr_profile_live_drm.js");
1293
- abrProfile = JSON.parse(JSON.stringify(abrProfileDefault));
1203
+ abrProfile = require("../abr_profiles/abr_profile_live_drm.js");
1204
+ playoutFormats = abrProfile.playout_formats;
1294
1205
  if (!format) {
1295
- _context9.next = 39;
1206
+ _context8.next = 39;
1296
1207
  break;
1297
1208
  }
1298
1209
  drm = true; // Override DRM parameter
@@ -1301,11 +1212,11 @@ exports.StreamSetOfferingAndDRM = /*#__PURE__*/function () {
1301
1212
  i = 0;
1302
1213
  case 28:
1303
1214
  if (!(i < formats.length)) {
1304
- _context9.next = 37;
1215
+ _context8.next = 37;
1305
1216
  break;
1306
1217
  }
1307
1218
  if (!(formats[i] === "hls-clear")) {
1308
- _context9.next = 33;
1219
+ _context8.next = 33;
1309
1220
  break;
1310
1221
  }
1311
1222
  abrProfile.drm_optional = true;
@@ -1315,15 +1226,15 @@ exports.StreamSetOfferingAndDRM = /*#__PURE__*/function () {
1315
1226
  "type": "ProtoHls"
1316
1227
  }
1317
1228
  };
1318
- return _context9.abrupt("continue", 34);
1229
+ return _context8.abrupt("continue", 34);
1319
1230
  case 33:
1320
1231
  playoutFormats[formats[i]] = abrProfile.playout_formats[formats[i]];
1321
1232
  case 34:
1322
1233
  i++;
1323
- _context9.next = 28;
1234
+ _context8.next = 28;
1324
1235
  break;
1325
1236
  case 37:
1326
- _context9.next = 40;
1237
+ _context8.next = 40;
1327
1238
  break;
1328
1239
  case 39:
1329
1240
  if (!drm) {
@@ -1336,25 +1247,23 @@ exports.StreamSetOfferingAndDRM = /*#__PURE__*/function () {
1336
1247
  }
1337
1248
  }
1338
1249
  };
1339
- } else {
1340
- playoutFormats = Object.assign({}, abrProfile.playout_formats);
1341
1250
  }
1342
1251
  case 40:
1343
1252
  abrProfile.playout_formats = playoutFormats;
1344
- _context9.next = 43;
1253
+ _context8.next = 43;
1345
1254
  return this.ContentObjectLibraryId({
1346
1255
  objectId: objectId
1347
1256
  });
1348
1257
  case 43:
1349
- libraryId = _context9.sent;
1350
- _context9.prev = 44;
1351
- _context9.next = 47;
1258
+ libraryId = _context8.sent;
1259
+ _context8.prev = 44;
1260
+ _context8.next = 47;
1352
1261
  return this.ContentObjectMetadata({
1353
1262
  libraryId: libraryId,
1354
1263
  objectId: objectId
1355
1264
  });
1356
1265
  case 47:
1357
- mainMeta = _context9.sent;
1266
+ mainMeta = _context8.sent;
1358
1267
  fabURI = mainMeta.live_recording.fabric_config.ingress_node_api; // Support both hostname and URL ingress_node_api
1359
1268
  if (!fabURI.startsWith("http")) {
1360
1269
  // Assume https
@@ -1364,7 +1273,7 @@ exports.StreamSetOfferingAndDRM = /*#__PURE__*/function () {
1364
1273
  fabricURIs: [fabURI]
1365
1274
  });
1366
1275
  streamUrl = mainMeta.live_recording.recording_config.recording_params.origin_url;
1367
- _context9.next = 54;
1276
+ _context8.next = 54;
1368
1277
  return StreamGenerateOffering({
1369
1278
  client: this,
1370
1279
  libraryId: libraryId,
@@ -1389,23 +1298,23 @@ exports.StreamSetOfferingAndDRM = /*#__PURE__*/function () {
1389
1298
  });
1390
1299
  case 54:
1391
1300
  console.log("Finished generating offering");
1392
- return _context9.abrupt("return", {
1301
+ return _context8.abrupt("return", {
1393
1302
  name: name,
1394
1303
  object_id: objectId,
1395
1304
  state: "initialized"
1396
1305
  });
1397
1306
  case 58:
1398
- _context9.prev = 58;
1399
- _context9.t0 = _context9["catch"](44);
1400
- console.error(_context9.t0);
1307
+ _context8.prev = 58;
1308
+ _context8.t0 = _context8["catch"](44);
1309
+ console.error(_context8.t0);
1401
1310
  case 61:
1402
1311
  case "end":
1403
- return _context9.stop();
1312
+ return _context8.stop();
1404
1313
  }
1405
- }, _callee9, this, [[44, 58]]);
1314
+ }, _callee8, this, [[44, 58]]);
1406
1315
  }));
1407
- return function (_x9) {
1408
- return _ref18.apply(this, arguments);
1316
+ return function (_x8) {
1317
+ return _ref16.apply(this, arguments);
1409
1318
  };
1410
1319
  }();
1411
1320
 
@@ -1425,19 +1334,19 @@ exports.StreamSetOfferingAndDRM = /*#__PURE__*/function () {
1425
1334
  * @return {Promise<Object>} - Insertions, as well as any errors from bad insertions
1426
1335
  */
1427
1336
  exports.StreamInsertion = /*#__PURE__*/function () {
1428
- var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref19) {
1429
- var name, insertionTime, _ref19$sinceStart, sinceStart, duration, targetHash, _ref19$remove, remove, offeringMeta, insertionInfo, audioAbrDuration, videoAbrDuration, objectId, libraryId, mainMeta, fabURI, edgeWriteToken, edgeMeta, recordings, sequence, streamStartTime, period, playoutConfig, insertions, res, errs, currentTime, insertionDone, newInsertion, i;
1430
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
1431
- while (1) switch (_context10.prev = _context10.next) {
1337
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref17) {
1338
+ var name, insertionTime, _ref17$sinceStart, sinceStart, duration, targetHash, _ref17$remove, remove, offeringMeta, insertionInfo, audioAbrDuration, videoAbrDuration, conf, libraryId, objectId, mainMeta, fabURI, edgeWriteToken, edgeMeta, recordings, sequence, streamStartTime, period, playoutConfig, insertions, res, errs, currentTime, insertionDone, newInsertion, i;
1339
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
1340
+ while (1) switch (_context9.prev = _context9.next) {
1432
1341
  case 0:
1433
- name = _ref19.name, insertionTime = _ref19.insertionTime, _ref19$sinceStart = _ref19.sinceStart, sinceStart = _ref19$sinceStart === void 0 ? false : _ref19$sinceStart, duration = _ref19.duration, targetHash = _ref19.targetHash, _ref19$remove = _ref19.remove, remove = _ref19$remove === void 0 ? false : _ref19$remove;
1434
- _context10.next = 3;
1342
+ name = _ref17.name, insertionTime = _ref17.insertionTime, _ref17$sinceStart = _ref17.sinceStart, sinceStart = _ref17$sinceStart === void 0 ? false : _ref17$sinceStart, duration = _ref17.duration, targetHash = _ref17.targetHash, _ref17$remove = _ref17.remove, remove = _ref17$remove === void 0 ? false : _ref17$remove;
1343
+ _context9.next = 3;
1435
1344
  return this.ContentObjectMetadata({
1436
1345
  versionHash: targetHash,
1437
1346
  metadataSubtree: "/offerings/default"
1438
1347
  });
1439
1348
  case 3:
1440
- offeringMeta = _context10.sent;
1349
+ offeringMeta = _context9.sent;
1441
1350
  insertionInfo = {
1442
1351
  duration_sec: 0 // Minimum of video and audio duration
1443
1352
  };
@@ -1456,39 +1365,45 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1456
1365
  audioAbrDuration = insertionInfo.audio.seg_duration_sec;
1457
1366
  videoAbrDuration = insertionInfo.video.seg_duration_sec;
1458
1367
  if (!(audioAbrDuration === 0 || videoAbrDuration === 0)) {
1459
- _context10.next = 10;
1368
+ _context9.next = 10;
1460
1369
  break;
1461
1370
  }
1462
1371
  throw new Error("Bad segment duration hash:", targetHash);
1463
1372
  case 10:
1464
1373
  if (!(duration === undefined)) {
1465
- _context10.next = 14;
1374
+ _context9.next = 14;
1466
1375
  break;
1467
1376
  }
1468
1377
  duration = insertionInfo.duration_sec; // Use full duration of the insertion
1469
- _context10.next = 16;
1378
+ _context9.next = 16;
1470
1379
  break;
1471
1380
  case 14:
1472
1381
  if (!(duration > insertionInfo.duration_sec)) {
1473
- _context10.next = 16;
1382
+ _context9.next = 16;
1474
1383
  break;
1475
1384
  }
1476
1385
  throw new Error("Bad duration - larger than insertion object duration", insertionInfo.duration_sec);
1477
1386
  case 16:
1478
- objectId = name;
1479
- _context10.next = 19;
1387
+ _context9.next = 18;
1388
+ return this.LoadConf({
1389
+ name: name
1390
+ });
1391
+ case 18:
1392
+ conf = _context9.sent;
1393
+ _context9.next = 21;
1480
1394
  return this.ContentObjectLibraryId({
1481
- objectId: objectId
1395
+ objectId: conf.objectId
1482
1396
  });
1483
- case 19:
1484
- libraryId = _context10.sent;
1485
- _context10.next = 22;
1397
+ case 21:
1398
+ libraryId = _context9.sent;
1399
+ objectId = conf.objectId;
1400
+ _context9.next = 25;
1486
1401
  return this.ContentObjectMetadata({
1487
1402
  libraryId: libraryId,
1488
- objectId: objectId
1403
+ objectId: conf.objectId
1489
1404
  });
1490
- case 22:
1491
- mainMeta = _context10.sent;
1405
+ case 25:
1406
+ mainMeta = _context9.sent;
1492
1407
  fabURI = mainMeta.live_recording.fabric_config.ingress_node_api; // Support both hostname and URL ingress_node_api
1493
1408
  if (!fabURI.startsWith("http")) {
1494
1409
  // Assume https
@@ -1498,14 +1413,14 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1498
1413
  fabricURIs: [fabURI]
1499
1414
  });
1500
1415
  edgeWriteToken = mainMeta.live_recording.fabric_config.edge_write_token;
1501
- _context10.next = 29;
1416
+ _context9.next = 32;
1502
1417
  return this.ContentObjectMetadata({
1503
1418
  libraryId: libraryId,
1504
- objectId: objectId,
1419
+ objectId: conf.objectId,
1505
1420
  writeToken: edgeWriteToken
1506
1421
  });
1507
- case 29:
1508
- edgeMeta = _context10.sent;
1422
+ case 32:
1423
+ edgeMeta = _context9.sent;
1509
1424
  // Find stream start time (from the most recent recording section)
1510
1425
  recordings = edgeMeta.live_recording.recordings;
1511
1426
  sequence = 1;
@@ -1523,15 +1438,15 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1523
1438
  }
1524
1439
  }
1525
1440
  if (!(streamStartTime === 0)) {
1526
- _context10.next = 37;
1441
+ _context9.next = 40;
1527
1442
  break;
1528
1443
  }
1529
1444
  if (!(sinceStart === false)) {
1530
- _context10.next = 37;
1445
+ _context9.next = 40;
1531
1446
  break;
1532
1447
  }
1533
1448
  throw new Error("Stream not running - must use 'time since start'");
1534
- case 37:
1449
+ case 40:
1535
1450
  // Find the current period playout configuration
1536
1451
  if (edgeMeta.live_recording.playout_config.interleaves === undefined) {
1537
1452
  edgeMeta.live_recording.playout_config.interleaves = {};
@@ -1558,9 +1473,9 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1558
1473
  playout: "/qfab/" + targetHash + "/rep/playout" // TO FIX - should be a link
1559
1474
  };
1560
1475
  i = 0;
1561
- case 48:
1476
+ case 51:
1562
1477
  if (!(i < insertions.length)) {
1563
- _context10.next = 63;
1478
+ _context9.next = 66;
1564
1479
  break;
1565
1480
  }
1566
1481
  if (insertions[i].insertion_time <= currentTime) {
@@ -1568,21 +1483,21 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1568
1483
  append(errs, "Bad insertion - time:", insertions[i].insertion_time);
1569
1484
  }
1570
1485
  if (!remove) {
1571
- _context10.next = 56;
1486
+ _context9.next = 59;
1572
1487
  break;
1573
1488
  }
1574
1489
  if (!(insertions[i].insertion_time === insertionTime)) {
1575
- _context10.next = 54;
1490
+ _context9.next = 57;
1576
1491
  break;
1577
1492
  }
1578
1493
  insertions.splice(i, 1);
1579
- return _context10.abrupt("break", 63);
1580
- case 54:
1581
- _context10.next = 60;
1494
+ return _context9.abrupt("break", 66);
1495
+ case 57:
1496
+ _context9.next = 63;
1582
1497
  break;
1583
- case 56:
1498
+ case 59:
1584
1499
  if (!(insertions[i].insertion_time > insertionTime)) {
1585
- _context10.next = 60;
1500
+ _context9.next = 63;
1586
1501
  break;
1587
1502
  }
1588
1503
  if (i > 0) {
@@ -1591,12 +1506,12 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1591
1506
  insertions = [newInsertion].concat(_toConsumableArray(insertions.splice(i)));
1592
1507
  }
1593
1508
  insertionDone = true;
1594
- return _context10.abrupt("break", 63);
1595
- case 60:
1509
+ return _context9.abrupt("break", 66);
1510
+ case 63:
1596
1511
  i++;
1597
- _context10.next = 48;
1512
+ _context9.next = 51;
1598
1513
  break;
1599
- case 63:
1514
+ case 66:
1600
1515
  if (!remove && !insertionDone) {
1601
1516
  // Add to the end of the insertions list
1602
1517
  console.log("Add insertion at the end");
@@ -1605,7 +1520,7 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1605
1520
  playoutConfig.interleaves[sequence] = insertions;
1606
1521
 
1607
1522
  // Store the new insertions in the write token
1608
- _context10.next = 67;
1523
+ _context9.next = 70;
1609
1524
  return this.ReplaceMetadata({
1610
1525
  libraryId: libraryId,
1611
1526
  objectId: objectId,
@@ -1613,15 +1528,71 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1613
1528
  metadataSubtree: "/live_recording/playout_config",
1614
1529
  metadata: edgeMeta.live_recording.playout_config
1615
1530
  });
1616
- case 67:
1531
+ case 70:
1617
1532
  res.errors = errs;
1618
1533
  res.insertions = insertions;
1619
- return _context10.abrupt("return", res);
1620
- case 70:
1534
+ return _context9.abrupt("return", res);
1535
+ case 73:
1536
+ case "end":
1537
+ return _context9.stop();
1538
+ }
1539
+ }, _callee9, this);
1540
+ }));
1541
+ return function (_x9) {
1542
+ return _ref18.apply(this, arguments);
1543
+ };
1544
+ }();
1545
+
1546
+ /**
1547
+ * Load cached stream configuration
1548
+ *
1549
+ * @methodGroup Live Stream
1550
+ * @namedParams
1551
+ * @param {string} name - Object ID or name of the live stream object
1552
+ *
1553
+ * @return {Promise<Object>} - The configuration of the stream
1554
+ */
1555
+ exports.LoadConf = /*#__PURE__*/function () {
1556
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref19) {
1557
+ var name, streamsBuf, streams, conf;
1558
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
1559
+ while (1) switch (_context10.prev = _context10.next) {
1560
+ case 0:
1561
+ name = _ref19.name;
1562
+ if (!name.startsWith("iq__")) {
1563
+ _context10.next = 3;
1564
+ break;
1565
+ }
1566
+ return _context10.abrupt("return", {
1567
+ name: name,
1568
+ objectId: name
1569
+ });
1570
+ case 3:
1571
+ _context10.prev = 3;
1572
+ streamsBuf = fs.readFileSync(path.resolve(__dirname, "../liveconf.json"));
1573
+ _context10.next = 11;
1574
+ break;
1575
+ case 7:
1576
+ _context10.prev = 7;
1577
+ _context10.t0 = _context10["catch"](3);
1578
+ console.log("Stream name must be a QID or a label in liveconf.json");
1579
+ return _context10.abrupt("return", {});
1580
+ case 11:
1581
+ streams = JSON.parse(streamsBuf);
1582
+ conf = streams[name];
1583
+ if (!(conf === null)) {
1584
+ _context10.next = 16;
1585
+ break;
1586
+ }
1587
+ console.log("Bad name: ", name);
1588
+ return _context10.abrupt("return", {});
1589
+ case 16:
1590
+ return _context10.abrupt("return", conf);
1591
+ case 17:
1621
1592
  case "end":
1622
1593
  return _context10.stop();
1623
1594
  }
1624
- }, _callee10, this);
1595
+ }, _callee10, null, [[3, 7]]);
1625
1596
  }));
1626
1597
  return function (_x10) {
1627
1598
  return _ref20.apply(this, arguments);
@@ -1629,89 +1600,75 @@ exports.StreamInsertion = /*#__PURE__*/function () {
1629
1600
  }();
1630
1601
 
1631
1602
  /**
1632
- * Configure the stream based on built-in logic and optional custom settings.
1633
- *
1634
- * Custom settings format:
1635
- * {
1636
- * "audio" {
1637
- * "1" : { // This is the stream index
1638
- * "tags" : "language: english",
1639
- * "codec" : "aac",
1640
- * "bitrate": 204000,
1641
- * "record": true,
1642
- * "recording_bitrate" : 192000,
1643
- * "recording_channels" : 2,
1644
- * "playout": bool
1645
- * "playout_label": "English (Stereo)"
1646
- * },
1647
- * "3": {
1648
- * ...
1649
- * }
1650
- * }
1651
- * }
1603
+ * Configure the stream
1652
1604
  *
1653
1605
  * @methodGroup Live Stream
1654
1606
  * @namedParams
1655
1607
  * @param {string} name - Object ID or name of the live stream object
1656
1608
  * @param {Object=} customSettings - Additional options to customize configuration settings
1657
- * @param {Object=} probeMetadata - Metadata for the probe. If not specified, a new probe will be configured
1609
+ * - audioBitrate
1610
+ * - audioIndex
1611
+ * - partTtl
1612
+ * - channelLayout
1613
+ *
1658
1614
  * @return {Promise<Object>} - The status response for the stream
1659
1615
  *
1660
1616
  */
1661
1617
  exports.StreamConfig = /*#__PURE__*/function () {
1662
1618
  var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref21) {
1663
- var name, _ref21$customSettings, customSettings, probeMetadata, objectId, status, libraryId, probe, mainMeta, userConfig, hostName, streamUrl, nodes, node, endpoint, controller, timeoutId, probeUrl, lc, liveRecordingConfig, e, writeToken;
1619
+ var name, _ref21$customSettings, customSettings, conf, status, libraryId, mainMeta, userConfig, hostName, streamUrl, nodes, node, endpoint, probe, controller, timeoutId, probeUrl, lc, liveRecordingConfigStr, liveRecordingConfig, e, writeToken;
1664
1620
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
1665
1621
  while (1) switch (_context11.prev = _context11.next) {
1666
1622
  case 0:
1667
- name = _ref21.name, _ref21$customSettings = _ref21.customSettings, customSettings = _ref21$customSettings === void 0 ? {} : _ref21$customSettings, probeMetadata = _ref21.probeMetadata;
1668
- objectId = name;
1623
+ name = _ref21.name, _ref21$customSettings = _ref21.customSettings, customSettings = _ref21$customSettings === void 0 ? {} : _ref21$customSettings;
1624
+ _context11.next = 3;
1625
+ return this.LoadConf({
1626
+ name: name
1627
+ });
1628
+ case 3:
1629
+ conf = _context11.sent;
1669
1630
  status = {
1670
1631
  name: name
1671
1632
  };
1672
- _context11.next = 5;
1633
+ _context11.next = 7;
1673
1634
  return this.ContentObjectLibraryId({
1674
- objectId: objectId
1635
+ objectId: conf.objectId
1675
1636
  });
1676
- case 5:
1637
+ case 7:
1677
1638
  libraryId = _context11.sent;
1678
1639
  status.library_id = libraryId;
1679
- status.object_id = objectId;
1680
- probe = probeMetadata;
1681
- _context11.next = 11;
1640
+ status.object_id = conf.objectId;
1641
+ _context11.next = 12;
1682
1642
  return this.ContentObjectMetadata({
1683
1643
  libraryId: libraryId,
1684
- objectId: objectId
1644
+ objectId: conf.objectId
1685
1645
  });
1686
- case 11:
1646
+ case 12:
1687
1647
  mainMeta = _context11.sent;
1688
1648
  userConfig = mainMeta.live_recording_config;
1689
1649
  status.user_config = userConfig;
1650
+ console.log("userConfig", userConfig);
1690
1651
 
1691
1652
  // Get node URI from user config
1692
1653
  hostName = userConfig.url.replace("udp://", "").replace("rtmp://", "").replace("srt://", "").split(":")[0];
1693
1654
  streamUrl = new URL(userConfig.url);
1694
- console.log("Retrieving nodes - matching", hostName);
1695
- _context11.next = 19;
1655
+ console.log("Retrieving nodes...");
1656
+ _context11.next = 21;
1696
1657
  return this.SpaceNodes({
1697
1658
  matchEndpoint: hostName
1698
1659
  });
1699
- case 19:
1660
+ case 21:
1700
1661
  nodes = _context11.sent;
1701
1662
  if (!(nodes.length < 1)) {
1702
- _context11.next = 23;
1663
+ _context11.next = 25;
1703
1664
  break;
1704
1665
  }
1705
1666
  status.error = "No node matching stream URL " + streamUrl.href;
1706
1667
  return _context11.abrupt("return", status);
1707
- case 23:
1668
+ case 25:
1708
1669
  node = nodes[0];
1709
1670
  status.node = node;
1710
1671
  endpoint = node.endpoints[0];
1711
- if (probe) {
1712
- _context11.next = 55;
1713
- break;
1714
- }
1715
1672
  this.SetNodes({
1716
1673
  fabricURIs: [endpoint]
1717
1674
  });
@@ -1722,17 +1679,17 @@ exports.StreamConfig = /*#__PURE__*/function () {
1722
1679
  timeoutId = setTimeout(function () {
1723
1680
  controller.abort();
1724
1681
  }, 60 * 1000); // milliseconds
1725
- _context11.prev = 31;
1726
- _context11.next = 34;
1682
+ _context11.prev = 32;
1683
+ _context11.next = 35;
1727
1684
  return this.Rep({
1728
1685
  libraryId: libraryId,
1729
- objectId: objectId,
1686
+ objectId: conf.objectId,
1730
1687
  rep: "probe"
1731
1688
  });
1732
- case 34:
1689
+ case 35:
1733
1690
  probeUrl = _context11.sent;
1734
1691
  _context11.t0 = this.utils;
1735
- _context11.next = 38;
1692
+ _context11.next = 39;
1736
1693
  return HttpClient.Fetch(probeUrl, {
1737
1694
  body: JSON.stringify({
1738
1695
  "filename": streamUrl.href,
@@ -1741,82 +1698,80 @@ exports.StreamConfig = /*#__PURE__*/function () {
1741
1698
  method: "POST",
1742
1699
  signal: controller.signal
1743
1700
  });
1744
- case 38:
1701
+ case 39:
1745
1702
  _context11.t1 = _context11.sent;
1746
- _context11.next = 41;
1703
+ _context11.next = 42;
1747
1704
  return _context11.t0.ResponseToJson.call(_context11.t0, _context11.t1);
1748
- case 41:
1705
+ case 42:
1749
1706
  probe = _context11.sent;
1750
1707
  if (probe) {
1751
1708
  clearTimeout(timeoutId);
1752
1709
  }
1753
1710
  if (!probe.errors) {
1754
- _context11.next = 45;
1711
+ _context11.next = 46;
1755
1712
  break;
1756
1713
  }
1757
1714
  throw probe.errors[0];
1758
- case 45:
1759
- _context11.next = 54;
1715
+ case 46:
1716
+ _context11.next = 55;
1760
1717
  break;
1761
- case 47:
1762
- _context11.prev = 47;
1763
- _context11.t2 = _context11["catch"](31);
1718
+ case 48:
1719
+ _context11.prev = 48;
1720
+ _context11.t2 = _context11["catch"](32);
1764
1721
  if (!(_context11.t2.code === "ETIMEDOUT")) {
1765
- _context11.next = 53;
1722
+ _context11.next = 54;
1766
1723
  break;
1767
1724
  }
1768
1725
  throw "Stream probe time out - make sure the stream source is available";
1769
- case 53:
1770
- throw _context11.t2;
1771
1726
  case 54:
1772
- probe.format.filename = streamUrl.href;
1727
+ throw _context11.t2;
1773
1728
  case 55:
1729
+ probe.format.filename = streamUrl.href;
1730
+
1774
1731
  // Create live recording config
1775
1732
  lc = new LiveConf(probe, node.id, endpoint, false, false, true);
1776
- liveRecordingConfig = lc.generateLiveConf({
1777
- customSettings: customSettings
1778
- }); // Store live recording config into the stream object
1779
- _context11.next = 59;
1733
+ liveRecordingConfigStr = lc.generateLiveConf({
1734
+ audioBitrate: customSettings.audioBitrate,
1735
+ audioIndex: customSettings.audioIndex,
1736
+ partTtl: customSettings.partTtl,
1737
+ channelLayout: customSettings.channelLayout
1738
+ });
1739
+ liveRecordingConfig = JSON.parse(liveRecordingConfigStr);
1740
+ console.log("CONFIG", JSON.stringify(liveRecordingConfig.live_recording));
1741
+
1742
+ // Store live recording config into the stream object
1743
+ _context11.next = 62;
1780
1744
  return this.EditContentObject({
1781
1745
  libraryId: libraryId,
1782
- objectId: objectId
1746
+ objectId: conf.objectId
1783
1747
  });
1784
- case 59:
1748
+ case 62:
1785
1749
  e = _context11.sent;
1786
1750
  writeToken = e.write_token;
1787
- _context11.next = 63;
1751
+ _context11.next = 66;
1788
1752
  return this.ReplaceMetadata({
1789
1753
  libraryId: libraryId,
1790
- objectId: objectId,
1754
+ objectId: conf.objectId,
1791
1755
  writeToken: writeToken,
1792
1756
  metadataSubtree: "live_recording",
1793
1757
  metadata: liveRecordingConfig.live_recording
1794
1758
  });
1795
- case 63:
1796
- _context11.next = 65;
1797
- return this.ReplaceMetadata({
1798
- libraryId: libraryId,
1799
- objectId: objectId,
1800
- writeToken: writeToken,
1801
- metadataSubtree: "live_recording_config/probe_info",
1802
- metadata: probe
1803
- });
1804
- case 65:
1805
- _context11.next = 67;
1759
+ case 66:
1760
+ _context11.next = 68;
1806
1761
  return this.FinalizeContentObject({
1807
1762
  libraryId: libraryId,
1808
- objectId: objectId,
1763
+ objectId: conf.objectId,
1809
1764
  writeToken: writeToken,
1810
1765
  commitMessage: "Apply live stream configuration"
1811
1766
  });
1812
- case 67:
1767
+ case 68:
1813
1768
  status.fin = _context11.sent;
1814
1769
  return _context11.abrupt("return", status);
1815
- case 69:
1770
+ case 70:
1816
1771
  case "end":
1817
1772
  return _context11.stop();
1818
1773
  }
1819
- }, _callee11, this, [[31, 47]]);
1774
+ }, _callee11, this, [[32, 48]]);
1820
1775
  }));
1821
1776
  return function (_x11) {
1822
1777
  return _ref22.apply(this, arguments);
@@ -1828,12 +1783,12 @@ exports.StreamConfig = /*#__PURE__*/function () {
1828
1783
  *
1829
1784
  * @methodGroup Live Stream
1830
1785
  * @namedParams
1831
- * @param {string=} siteId - ID of the live stream site object
1786
+ * @param {string=} - ID of the live stream site object
1832
1787
  *
1833
1788
  * @return {Promise<Object>} - The list of stream URLs
1834
1789
  */
1835
1790
  exports.StreamListUrls = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
1836
- var _this2 = this;
1791
+ var _this = this;
1837
1792
  var _ref24,
1838
1793
  siteId,
1839
1794
  STATUS_MAP,
@@ -1893,8 +1848,7 @@ exports.StreamListUrls = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerat
1893
1848
  objectId: _context13.t2,
1894
1849
  metadataSubtree: "public/asset_metadata/live_streams",
1895
1850
  resolveLinks: true,
1896
- resolveIgnoreErrors: true,
1897
- resolveIncludeSource: true
1851
+ resolveIgnoreErrors: true
1898
1852
  };
1899
1853
  _context13.next = 20;
1900
1854
  return _context13.t0.ContentObjectMetadata.call(_context13.t0, _context13.t3);
@@ -1909,28 +1863,28 @@ exports.StreamListUrls = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerat
1909
1863
  while (1) switch (_context12.prev = _context12.next) {
1910
1864
  case 0:
1911
1865
  stream = streamMetadata[slug];
1912
- if (stream && stream["."] && stream["."].source) {
1913
- versionHash = stream["."].source;
1866
+ if (stream && stream.sources && stream.sources["default"] && stream.sources["default"]["."] && stream.sources["default"]["."].container || ((stream["/"] || "").match(/^\/?qfab\/([\w]+)\/?.+/) || [])[1]) {
1867
+ versionHash = stream.sources["default"]["."].container || ((stream["/"] || "").match(/^\/?qfab\/([\w]+)\/?.+/) || [])[1];
1914
1868
  }
1915
1869
  if (!versionHash) {
1916
1870
  _context12.next = 16;
1917
1871
  break;
1918
1872
  }
1919
- objectId = _this2.utils.DecodeVersionHash(versionHash).objectId;
1873
+ objectId = _this.utils.DecodeVersionHash(versionHash).objectId;
1920
1874
  _context12.next = 6;
1921
- return _this2.ContentObjectLibraryId({
1875
+ return _this.ContentObjectLibraryId({
1922
1876
  objectId: objectId
1923
1877
  });
1924
1878
  case 6:
1925
1879
  libraryId = _context12.sent;
1926
1880
  _context12.next = 9;
1927
- return _this2.StreamStatus({
1881
+ return _this.StreamStatus({
1928
1882
  name: objectId
1929
1883
  });
1930
1884
  case 9:
1931
1885
  status = _context12.sent;
1932
1886
  _context12.next = 12;
1933
- return _this2.ContentObjectMetadata({
1887
+ return _this.ContentObjectMetadata({
1934
1888
  objectId: objectId,
1935
1889
  libraryId: libraryId,
1936
1890
  select: ["live_recording_config/reference_url",
@@ -1999,483 +1953,4 @@ exports.StreamListUrls = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerat
1999
1953
  return _context13.stop();
2000
1954
  }
2001
1955
  }, _callee13, this, [[1, 40]]);
2002
- }));
2003
-
2004
- /**
2005
- * Copy a portion of a live stream recording into a standard VoD object using the zero-copy content fabric API
2006
- *
2007
- * Limitations:
2008
- * - currently requires the target object to be pre-created and have content encryption keys (CAPS)
2009
- * - for audio and video to be sync'd, the live stream needs to have the beginning of the desired recording period
2010
- * - for an event stream, make sure the TTL is long enough to allow running the live-to-vod command before the beginning of the recording expires
2011
- * - for 24/7 streams, make sure to reset the stream before the desired recording (as to create a new recording period) and have the TTL long enough
2012
- * to allow running the live-to-vod command before the beginning of the recording expires.
2013
- * - startTime and endTime are not currently implemented by this method
2014
- *
2015
- *
2016
- * @methodGroup Live Stream
2017
- * @namedParams
2018
- * @param {string} name - Object ID or name of the live stream
2019
- * @param {string} targetObjectId - Object ID of the target VOD object
2020
- * @param {string=} eventId -
2021
- * @param {boolean=} finalize - If enabled, target object will be finalized after copy to vod operations
2022
- * @param {number=} recordingPeriod - Determines which recording period to copy, which are 0-based. -1 copies the current (or last) period
2023
- *
2024
- * @return {Promise<Object>} - The status response for the stream
2025
- */
2026
-
2027
- /*
2028
- Example fabric API flow:
2029
-
2030
- https://host-76-74-34-194.contentfabric.io/qlibs/ilib24CtWSJeVt9DiAzym8jB6THE9e7H/q/$QWT/call/media/live_to_vod/init -d @r1 -H "Authorization: Bearer $TOK"
2031
-
2032
- {
2033
- "live_qhash": "hq__5Zk1jSN8vNLUAXjQwMJV8F8J8ESXNvmVKkhaXySmGc1BXnJPG2FvvaXee4CXqvFHuGuU3fqLJc",
2034
- "start_time": "",
2035
- "end_time": "",
2036
- "recording_period": -1,
2037
- "streams": ["video", "audio"],
2038
- "variant_key": "default"
2039
- }
2040
-
2041
- https://host-76-74-34-194.contentfabric.io/qlibs/ilib24CtWSJeVt9DiAzym8jB6THE9e7H/q/$QWT/call/media/abr_mezzanine/init -H "Authorization: Bearer $TOK" -d @r2
2042
-
2043
- {
2044
-
2045
- "abr_profile": { ... },
2046
- "offering_key": "default",
2047
- "prod_master_hash": "tqw__HSQHBt7vYxWfCMPH5yXwKTfhdPcQ4Lcs9WUMUbTtnMbTZPTLo4BfJWPMGpoy1Dpv1wWQVtUtAtAr429TnVs",
2048
- "variant_key": "default",
2049
- "keep_other_streams": false
2050
- }
2051
-
2052
- https://host-76-74-34-194.contentfabric.io/qlibs/ilib24CtWSJeVt9DiAzym8jB6THE9e7H/q/$QWT/call/media/live_to_vod/copy -d '{"variant_key":"","offering_key":""}' -H "Authorization: Bearer $TOK"
2053
-
2054
-
2055
- https://host-76-74-34-194.contentfabric.io/qlibs/ilib24CtWSJeVt9DiAzym8jB6THE9e7H/q/$QWT/call/media/abr_mezzanine/offerings/default/finalize -d '{}' -H "Authorization: Bearer $TOK"
2056
-
2057
- */
2058
-
2059
- exports.StreamCopyToVod = /*#__PURE__*/function () {
2060
- var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref26) {
2061
- var name, targetObjectId, eventId, _ref26$streams, streams, _ref26$finalize, finalize, _ref26$recordingPerio, recordingPeriod, _ref26$startTime, startTime, _ref26$endTime, endTime, objectId, abrProfile, status, libraryId, targetLibraryId, kmsAddress, kmsCapId, kmsCap, liveHash, event, _yield$this$EditConte2, writeToken, abrMezInitBody, finalizeResponse;
2062
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
2063
- while (1) switch (_context14.prev = _context14.next) {
2064
- case 0:
2065
- name = _ref26.name, targetObjectId = _ref26.targetObjectId, eventId = _ref26.eventId, _ref26$streams = _ref26.streams, streams = _ref26$streams === void 0 ? null : _ref26$streams, _ref26$finalize = _ref26.finalize, finalize = _ref26$finalize === void 0 ? true : _ref26$finalize, _ref26$recordingPerio = _ref26.recordingPeriod, recordingPeriod = _ref26$recordingPerio === void 0 ? -1 : _ref26$recordingPerio, _ref26$startTime = _ref26.startTime, startTime = _ref26$startTime === void 0 ? "" : _ref26$startTime, _ref26$endTime = _ref26.endTime, endTime = _ref26$endTime === void 0 ? "" : _ref26$endTime;
2066
- objectId = name;
2067
- abrProfile = require("../abr_profiles/abr_profile_live_to_vod.js");
2068
- _context14.next = 5;
2069
- return this.StreamStatus({
2070
- name: name
2071
- });
2072
- case 5:
2073
- status = _context14.sent;
2074
- libraryId = status.library_id;
2075
- this.Log("Copying stream ".concat(name, " to target ").concat(targetObjectId));
2076
- ValidateObject(targetObjectId);
2077
- _context14.next = 11;
2078
- return this.ContentObjectLibraryId({
2079
- objectId: targetObjectId
2080
- });
2081
- case 11:
2082
- targetLibraryId = _context14.sent;
2083
- _context14.next = 14;
2084
- return this.authClient.KMSAddress({
2085
- objectId: targetObjectId
2086
- });
2087
- case 14:
2088
- kmsAddress = _context14.sent;
2089
- kmsCapId = "eluv.caps.ikms".concat(this.utils.AddressToHash(kmsAddress));
2090
- _context14.next = 18;
2091
- return this.ContentObjectMetadata({
2092
- libraryId: targetLibraryId,
2093
- objectId: targetObjectId,
2094
- metadataSubtree: kmsCapId
2095
- });
2096
- case 18:
2097
- kmsCap = _context14.sent;
2098
- if (kmsCap) {
2099
- _context14.next = 21;
2100
- break;
2101
- }
2102
- throw Error("No content encryption key set for object ".concat(targetObjectId));
2103
- case 21:
2104
- _context14.prev = 21;
2105
- status.live_object_id = objectId;
2106
- _context14.next = 25;
2107
- return this.LatestVersionHash({
2108
- objectId: objectId,
2109
- libraryId: libraryId
2110
- });
2111
- case 25:
2112
- liveHash = _context14.sent;
2113
- status.live_hash = liveHash;
2114
- if (!eventId) {
2115
- _context14.next = 32;
2116
- break;
2117
- }
2118
- _context14.next = 30;
2119
- return this.CueInfo({
2120
- eventId: eventId,
2121
- status: status
2122
- });
2123
- case 30:
2124
- event = _context14.sent;
2125
- if (event.eventStart && event.eventEnd) {
2126
- startTime = event.eventStart;
2127
- endTime = event.eventEnd;
2128
- }
2129
- case 32:
2130
- _context14.next = 34;
2131
- return this.EditContentObject({
2132
- objectId: targetObjectId,
2133
- libraryId: targetLibraryId
2134
- });
2135
- case 34:
2136
- _yield$this$EditConte2 = _context14.sent;
2137
- writeToken = _yield$this$EditConte2.writeToken;
2138
- status.target_object_id = targetObjectId;
2139
- status.target_library_id = targetLibraryId;
2140
- status.target_write_token = writeToken;
2141
- this.Log("Process live source (takes around 20 sec per hour of content)");
2142
- _context14.next = 42;
2143
- return this.CallBitcodeMethod({
2144
- libraryId: targetLibraryId,
2145
- objectId: targetObjectId,
2146
- writeToken: writeToken,
2147
- method: "/media/live_to_vod/init",
2148
- body: {
2149
- "live_qhash": liveHash,
2150
- "start_time": startTime,
2151
- // eg. "2023-10-03T02:09:02.00Z",
2152
- "end_time": endTime,
2153
- // eg. "2023-10-03T02:15:00.00Z",
2154
- "streams": streams,
2155
- "recording_period": recordingPeriod,
2156
- "variant_key": "default"
2157
- },
2158
- constant: false,
2159
- format: "text"
2160
- });
2161
- case 42:
2162
- abrMezInitBody = {
2163
- abr_profile: abrProfile,
2164
- "offering_key": "default",
2165
- "prod_master_hash": writeToken,
2166
- "variant_key": "default",
2167
- "keep_other_streams": false
2168
- };
2169
- _context14.next = 45;
2170
- return this.CallBitcodeMethod({
2171
- libraryId: targetLibraryId,
2172
- objectId: targetObjectId,
2173
- writeToken: writeToken,
2174
- method: "/media/abr_mezzanine/init",
2175
- body: abrMezInitBody,
2176
- constant: false,
2177
- format: "text"
2178
- });
2179
- case 45:
2180
- _context14.prev = 45;
2181
- _context14.next = 48;
2182
- return this.CallBitcodeMethod({
2183
- libraryId: targetLibraryId,
2184
- objectId: targetObjectId,
2185
- writeToken: writeToken,
2186
- method: "/media/live_to_vod/copy",
2187
- body: {},
2188
- constant: false,
2189
- format: "text"
2190
- });
2191
- case 48:
2192
- _context14.next = 54;
2193
- break;
2194
- case 50:
2195
- _context14.prev = 50;
2196
- _context14.t0 = _context14["catch"](45);
2197
- console.error("Unable to call /media/live_to_vod/copy", _context14.t0);
2198
- throw _context14.t0;
2199
- case 54:
2200
- _context14.next = 56;
2201
- return this.CallBitcodeMethod({
2202
- libraryId: targetLibraryId,
2203
- objectId: targetObjectId,
2204
- writeToken: writeToken,
2205
- method: "/media/abr_mezzanine/offerings/default/finalize",
2206
- body: abrMezInitBody,
2207
- constant: false,
2208
- format: "text"
2209
- });
2210
- case 56:
2211
- if (!finalize) {
2212
- _context14.next = 61;
2213
- break;
2214
- }
2215
- _context14.next = 59;
2216
- return this.FinalizeContentObject({
2217
- libraryId: targetLibraryId,
2218
- objectId: targetObjectId,
2219
- writeToken: writeToken,
2220
- commitMessage: "Live Stream to VoD"
2221
- });
2222
- case 59:
2223
- finalizeResponse = _context14.sent;
2224
- status.target_hash = finalizeResponse.hash;
2225
- case 61:
2226
- // Clean up unnecessary status items
2227
- delete status.playout_urls;
2228
- delete status.lro_status_url;
2229
- delete status.recording_period;
2230
- delete status.recording_period_sequence;
2231
- delete status.edge_meta_size;
2232
- delete status.insertions;
2233
- return _context14.abrupt("return", status);
2234
- case 70:
2235
- _context14.prev = 70;
2236
- _context14.t1 = _context14["catch"](21);
2237
- this.Log(_context14.t1, true);
2238
- throw _context14.t1;
2239
- case 74:
2240
- case "end":
2241
- return _context14.stop();
2242
- }
2243
- }, _callee14, this, [[21, 70], [45, 50]]);
2244
- }));
2245
- return function (_x13) {
2246
- return _ref27.apply(this, arguments);
2247
- };
2248
- }();
2249
-
2250
- /**
2251
- * Remove a watermark for a live stream
2252
- *
2253
- * @methodGroup Live Stream
2254
- * @namedParams
2255
- * @param {string} objectId - Object ID of the live stream
2256
- * @param {Array<string>} types - Specify which type of watermark to remove. Possible values:
2257
- * - "image"
2258
- * - "text"
2259
- * @param {boolean=} finalize - If enabled, target object will be finalized after removing watermark
2260
- *
2261
- * @return {Promise<Object>} - The finalize response
2262
- */
2263
- exports.StreamRemoveWatermark = /*#__PURE__*/function () {
2264
- var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref28) {
2265
- var objectId, types, _ref28$finalize, finalize, libraryId, _yield$this$EditConte3, writeToken, edgeWriteToken, recordingParamsPath, recordingMetadata, finalizeResponse;
2266
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
2267
- while (1) switch (_context15.prev = _context15.next) {
2268
- case 0:
2269
- objectId = _ref28.objectId, types = _ref28.types, _ref28$finalize = _ref28.finalize, finalize = _ref28$finalize === void 0 ? true : _ref28$finalize;
2270
- ValidateObject(objectId);
2271
- _context15.next = 4;
2272
- return this.ContentObjectLibraryId({
2273
- objectId: objectId
2274
- });
2275
- case 4:
2276
- libraryId = _context15.sent;
2277
- _context15.next = 7;
2278
- return this.EditContentObject({
2279
- objectId: objectId,
2280
- libraryId: libraryId
2281
- });
2282
- case 7:
2283
- _yield$this$EditConte3 = _context15.sent;
2284
- writeToken = _yield$this$EditConte3.writeToken;
2285
- this.Log("Removing watermark types: ".concat(types.join(", "), " ").concat(libraryId, " ").concat(objectId));
2286
- _context15.next = 12;
2287
- return this.ContentObjectMetadata({
2288
- objectId: objectId,
2289
- libraryId: libraryId,
2290
- metadataSubtree: "/live_recording/fabric_config/edge_write_token"
2291
- });
2292
- case 12:
2293
- edgeWriteToken = _context15.sent;
2294
- recordingParamsPath = "live_recording/recording_config/recording_params";
2295
- _context15.next = 16;
2296
- return this.ContentObjectMetadata({
2297
- libraryId: libraryId,
2298
- objectId: objectId,
2299
- writeToken: writeToken,
2300
- metadataSubtree: recordingParamsPath,
2301
- resolveLinks: false
2302
- });
2303
- case 16:
2304
- recordingMetadata = _context15.sent;
2305
- if (recordingMetadata) {
2306
- _context15.next = 19;
2307
- break;
2308
- }
2309
- throw Error("Stream object must be configured");
2310
- case 19:
2311
- types.forEach(function (type) {
2312
- if (type === "text") {
2313
- delete recordingMetadata.simple_watermark;
2314
- } else if (type === "image") {
2315
- delete recordingMetadata.image_watermark;
2316
- }
2317
- });
2318
- _context15.next = 22;
2319
- return this.ReplaceMetadata({
2320
- libraryId: libraryId,
2321
- objectId: objectId,
2322
- writeToken: writeToken,
2323
- metadataSubtree: recordingParamsPath,
2324
- metadata: recordingMetadata
2325
- });
2326
- case 22:
2327
- if (!edgeWriteToken) {
2328
- _context15.next = 25;
2329
- break;
2330
- }
2331
- _context15.next = 25;
2332
- return this.ReplaceMetadata({
2333
- libraryId: libraryId,
2334
- objectId: objectId,
2335
- writeToken: edgeWriteToken,
2336
- metadataSubtree: recordingParamsPath,
2337
- metadata: recordingMetadata
2338
- });
2339
- case 25:
2340
- if (!finalize) {
2341
- _context15.next = 30;
2342
- break;
2343
- }
2344
- _context15.next = 28;
2345
- return this.FinalizeContentObject({
2346
- libraryId: libraryId,
2347
- objectId: objectId,
2348
- writeToken: writeToken,
2349
- commitMessage: "Watermark removed"
2350
- });
2351
- case 28:
2352
- finalizeResponse = _context15.sent;
2353
- return _context15.abrupt("return", finalizeResponse);
2354
- case 30:
2355
- case "end":
2356
- return _context15.stop();
2357
- }
2358
- }, _callee15, this);
2359
- }));
2360
- return function (_x14) {
2361
- return _ref29.apply(this, arguments);
2362
- };
2363
- }();
2364
-
2365
- /**
2366
- * Create a watermark for a live stream
2367
- *
2368
- * @methodGroup Live Stream
2369
- * @namedParams
2370
- * @param {string} objectId - Object ID of the live stream
2371
- * @param {Object} simpleWatermark - Text watermark
2372
- * @param {Object} imageWatermark - Image watermark
2373
- * @param {boolean=} finalize - If enabled, target object will be finalized after adding watermark
2374
- *
2375
- * @return {Promise<Object>} - The finalize response
2376
- */
2377
- exports.StreamAddWatermark = /*#__PURE__*/function () {
2378
- var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref30) {
2379
- var objectId, simpleWatermark, imageWatermark, _ref30$finalize, finalize, libraryId, _yield$this$EditConte4, writeToken, edgeWriteToken, recordingParamsPath, recordingMetadata, response, finalizeResponse;
2380
- return _regeneratorRuntime.wrap(function _callee16$(_context16) {
2381
- while (1) switch (_context16.prev = _context16.next) {
2382
- case 0:
2383
- objectId = _ref30.objectId, simpleWatermark = _ref30.simpleWatermark, imageWatermark = _ref30.imageWatermark, _ref30$finalize = _ref30.finalize, finalize = _ref30$finalize === void 0 ? true : _ref30$finalize;
2384
- ValidateObject(objectId);
2385
- _context16.next = 4;
2386
- return this.ContentObjectLibraryId({
2387
- objectId: objectId
2388
- });
2389
- case 4:
2390
- libraryId = _context16.sent;
2391
- _context16.next = 7;
2392
- return this.EditContentObject({
2393
- objectId: objectId,
2394
- libraryId: libraryId
2395
- });
2396
- case 7:
2397
- _yield$this$EditConte4 = _context16.sent;
2398
- writeToken = _yield$this$EditConte4.writeToken;
2399
- _context16.next = 11;
2400
- return this.ContentObjectMetadata({
2401
- objectId: objectId,
2402
- libraryId: libraryId,
2403
- metadataSubtree: "/live_recording/fabric_config/edge_write_token"
2404
- });
2405
- case 11:
2406
- edgeWriteToken = _context16.sent;
2407
- this.Log("Adding watermarking type: ".concat(imageWatermark ? "image" : "text", " ").concat(libraryId, " ").concat(objectId));
2408
- recordingParamsPath = "live_recording/recording_config/recording_params";
2409
- _context16.next = 16;
2410
- return this.ContentObjectMetadata({
2411
- libraryId: libraryId,
2412
- objectId: objectId,
2413
- writeToken: writeToken,
2414
- metadataSubtree: recordingParamsPath,
2415
- resolveLinks: false
2416
- });
2417
- case 16:
2418
- recordingMetadata = _context16.sent;
2419
- if (recordingMetadata) {
2420
- _context16.next = 19;
2421
- break;
2422
- }
2423
- throw Error("Stream object must be configured");
2424
- case 19:
2425
- if (simpleWatermark) {
2426
- recordingMetadata.simple_watermark = simpleWatermark;
2427
- } else if (imageWatermark) {
2428
- recordingMetadata.image_watermark = imageWatermark;
2429
- }
2430
- _context16.next = 22;
2431
- return this.ReplaceMetadata({
2432
- libraryId: libraryId,
2433
- objectId: objectId,
2434
- writeToken: writeToken,
2435
- metadataSubtree: recordingParamsPath,
2436
- metadata: recordingMetadata
2437
- });
2438
- case 22:
2439
- if (!edgeWriteToken) {
2440
- _context16.next = 25;
2441
- break;
2442
- }
2443
- _context16.next = 25;
2444
- return this.ReplaceMetadata({
2445
- libraryId: libraryId,
2446
- objectId: objectId,
2447
- writeToken: edgeWriteToken,
2448
- metadataSubtree: recordingParamsPath,
2449
- metadata: recordingMetadata
2450
- });
2451
- case 25:
2452
- response = {
2453
- "imageWatermark": recordingMetadata.image_watermark,
2454
- "textWatermark": recordingMetadata.simple_watermark
2455
- };
2456
- if (!finalize) {
2457
- _context16.next = 31;
2458
- break;
2459
- }
2460
- _context16.next = 29;
2461
- return this.FinalizeContentObject({
2462
- libraryId: libraryId,
2463
- objectId: objectId,
2464
- writeToken: writeToken,
2465
- commitMessage: "Watermark set"
2466
- });
2467
- case 29:
2468
- finalizeResponse = _context16.sent;
2469
- response.hash = finalizeResponse.hash;
2470
- case 31:
2471
- return _context16.abrupt("return", response);
2472
- case 32:
2473
- case "end":
2474
- return _context16.stop();
2475
- }
2476
- }, _callee16, this);
2477
- }));
2478
- return function (_x15) {
2479
- return _ref31.apply(this, arguments);
2480
- };
2481
- }();
1956
+ }));