@eluvio/elv-client-js 4.0.77 → 4.0.78
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.
- package/dist/ElvClient-min.js +2 -2
- package/dist/ElvClient-node-min.js +2 -2
- package/dist/ElvFrameClient-min.js +2 -2
- package/dist/ElvWalletClient-min.js +2 -2
- package/dist/ElvWalletClient-node-min.js +11 -11
- package/dist/src/FrameClient.js +1 -1
- package/dist/src/client/ContentAccess.js +46 -26
- package/dist/src/client/LiveConf.js +151 -20
- package/dist/src/client/LiveStream.js +270 -146
- package/package.json +1 -1
- package/src/FrameClient.js +1 -0
- package/src/client/ContentAccess.js +21 -0
- package/src/client/LiveConf.js +132 -16
- package/src/client/LiveStream.js +108 -21
- package/testScripts/Test.js +7 -0
|
@@ -372,29 +372,30 @@ exports.StreamStatus = /*#__PURE__*/function () {
|
|
|
372
372
|
});
|
|
373
373
|
case 13:
|
|
374
374
|
mainMeta = _context3.sent;
|
|
375
|
+
status.reference_url = mainMeta.live_recording_config.reference_url;
|
|
375
376
|
if (!(mainMeta.live_recording_config == undefined || mainMeta.live_recording_config.url == undefined)) {
|
|
376
|
-
_context3.next =
|
|
377
|
+
_context3.next = 18;
|
|
377
378
|
break;
|
|
378
379
|
}
|
|
379
380
|
status.state = "unconfigured";
|
|
380
381
|
return _context3.abrupt("return", status);
|
|
381
|
-
case
|
|
382
|
+
case 18:
|
|
382
383
|
if (!(mainMeta.live_recording == undefined || mainMeta.live_recording.fabric_config == undefined || mainMeta.live_recording.playout_config == undefined || mainMeta.live_recording.recording_config == undefined)) {
|
|
383
|
-
_context3.next =
|
|
384
|
+
_context3.next = 21;
|
|
384
385
|
break;
|
|
385
386
|
}
|
|
386
387
|
status.state = "uninitialized";
|
|
387
388
|
return _context3.abrupt("return", status);
|
|
388
|
-
case
|
|
389
|
+
case 21:
|
|
389
390
|
fabURI = mainMeta.live_recording.fabric_config.ingress_node_api;
|
|
390
391
|
if (!(fabURI === undefined)) {
|
|
391
|
-
_context3.next =
|
|
392
|
+
_context3.next = 26;
|
|
392
393
|
break;
|
|
393
394
|
}
|
|
394
395
|
console.log("bad fabric config - missing ingress node API");
|
|
395
396
|
status.state = "uninitialized";
|
|
396
397
|
return _context3.abrupt("return", status);
|
|
397
|
-
case
|
|
398
|
+
case 26:
|
|
398
399
|
// Support both hostname and URL ingress_node_api
|
|
399
400
|
if (!fabURI.startsWith("http")) {
|
|
400
401
|
// Assume https
|
|
@@ -403,38 +404,38 @@ exports.StreamStatus = /*#__PURE__*/function () {
|
|
|
403
404
|
status.fabric_api = fabURI;
|
|
404
405
|
status.url = mainMeta.live_recording.recording_config.recording_params.origin_url;
|
|
405
406
|
edgeWriteToken = mainMeta.live_recording.fabric_config.edge_write_token;
|
|
406
|
-
if (
|
|
407
|
-
_context3.next =
|
|
407
|
+
if (edgeWriteToken) {
|
|
408
|
+
_context3.next = 33;
|
|
408
409
|
break;
|
|
409
410
|
}
|
|
410
411
|
status.state = "inactive";
|
|
411
412
|
return _context3.abrupt("return", status);
|
|
412
|
-
case
|
|
413
|
+
case 33:
|
|
413
414
|
this.RecordWriteToken({
|
|
414
415
|
writeToken: edgeWriteToken,
|
|
415
416
|
fabricNodeUrl: fabURI
|
|
416
417
|
});
|
|
417
418
|
status.edge_write_token = edgeWriteToken;
|
|
418
419
|
status.stream_id = edgeWriteToken; // By convention the stream ID is its write token
|
|
419
|
-
_context3.next =
|
|
420
|
+
_context3.next = 38;
|
|
420
421
|
return this.ContentObjectMetadata({
|
|
421
422
|
libraryId: libraryId,
|
|
422
423
|
objectId: conf.objectId,
|
|
423
424
|
writeToken: edgeWriteToken,
|
|
424
425
|
select: ["live_recording"]
|
|
425
426
|
});
|
|
426
|
-
case
|
|
427
|
+
case 38:
|
|
427
428
|
edgeMeta = _context3.sent;
|
|
428
429
|
status.edge_meta_size = JSON.stringify(edgeMeta).length;
|
|
429
430
|
|
|
430
431
|
// If a stream has never been started return state 'inactive'
|
|
431
432
|
if (!(edgeMeta.live_recording === undefined || edgeMeta.live_recording.recordings === undefined || edgeMeta.live_recording.recordings.recording_sequence === undefined)) {
|
|
432
|
-
_context3.next =
|
|
433
|
+
_context3.next = 43;
|
|
433
434
|
break;
|
|
434
435
|
}
|
|
435
436
|
status.state = "stopped";
|
|
436
437
|
return _context3.abrupt("return", status);
|
|
437
|
-
case
|
|
438
|
+
case 43:
|
|
438
439
|
recordings = edgeMeta.live_recording.recordings;
|
|
439
440
|
status.recording_period_sequence = recordings.recording_sequence;
|
|
440
441
|
sequence = recordings.recording_sequence;
|
|
@@ -453,14 +454,14 @@ exports.StreamStatus = /*#__PURE__*/function () {
|
|
|
453
454
|
video_since_last_finalize_sec: sinceLastFinalize
|
|
454
455
|
};
|
|
455
456
|
status.recording_period = recording_period;
|
|
456
|
-
_context3.next =
|
|
457
|
+
_context3.next = 54;
|
|
457
458
|
return this.FabricUrl({
|
|
458
459
|
libraryId: libraryId,
|
|
459
460
|
objectId: conf.objectId,
|
|
460
461
|
writeToken: edgeWriteToken,
|
|
461
462
|
call: "live/status/" + tlro
|
|
462
463
|
});
|
|
463
|
-
case
|
|
464
|
+
case 54:
|
|
464
465
|
status.lro_status_url = _context3.sent;
|
|
465
466
|
status.insertions = [];
|
|
466
467
|
if (edgeMeta.live_recording.playout_config.interleaves != undefined && edgeMeta.live_recording.playout_config.interleaves[sequence] != undefined) {
|
|
@@ -480,27 +481,27 @@ exports.StreamStatus = /*#__PURE__*/function () {
|
|
|
480
481
|
}
|
|
481
482
|
state = "stopped";
|
|
482
483
|
lroStatus = "";
|
|
483
|
-
_context3.prev =
|
|
484
|
+
_context3.prev = 60;
|
|
484
485
|
_context3.t0 = this.utils;
|
|
485
|
-
_context3.next =
|
|
486
|
+
_context3.next = 64;
|
|
486
487
|
return HttpClient.Fetch(status.lro_status_url);
|
|
487
|
-
case
|
|
488
|
+
case 64:
|
|
488
489
|
_context3.t1 = _context3.sent;
|
|
489
|
-
_context3.next =
|
|
490
|
+
_context3.next = 67;
|
|
490
491
|
return _context3.t0.ResponseToJson.call(_context3.t0, _context3.t1);
|
|
491
|
-
case
|
|
492
|
+
case 67:
|
|
492
493
|
lroStatus = _context3.sent;
|
|
493
494
|
state = lroStatus.state;
|
|
494
|
-
_context3.next =
|
|
495
|
+
_context3.next = 77;
|
|
495
496
|
break;
|
|
496
|
-
case
|
|
497
|
-
_context3.prev =
|
|
498
|
-
_context3.t2 = _context3["catch"](
|
|
497
|
+
case 71:
|
|
498
|
+
_context3.prev = 71;
|
|
499
|
+
_context3.t2 = _context3["catch"](60);
|
|
499
500
|
console.log("LRO Status (failed): ", _context3.t2.response.statusCode);
|
|
500
501
|
status.state = "stopped";
|
|
501
502
|
status.error = _context3.t2.response;
|
|
502
503
|
return _context3.abrupt("return", status);
|
|
503
|
-
case
|
|
504
|
+
case 77:
|
|
504
505
|
// Convert LRO 'state' to desired 'state'
|
|
505
506
|
if (state === "running" && period.video_finalized_parts_info.last_finalization_time === 0) {
|
|
506
507
|
state = "starting";
|
|
@@ -511,98 +512,98 @@ exports.StreamStatus = /*#__PURE__*/function () {
|
|
|
511
512
|
}
|
|
512
513
|
status.state = state;
|
|
513
514
|
if (!((state === "running" || state === "stalled" || state === "starting") && stopLro)) {
|
|
514
|
-
_context3.next =
|
|
515
|
+
_context3.next = 98;
|
|
515
516
|
break;
|
|
516
517
|
}
|
|
517
|
-
_context3.next =
|
|
518
|
+
_context3.next = 82;
|
|
518
519
|
return this.FabricUrl({
|
|
519
520
|
libraryId: libraryId,
|
|
520
521
|
objectId: conf.objectId,
|
|
521
522
|
writeToken: edgeWriteToken,
|
|
522
523
|
call: "live/stop/" + tlro
|
|
523
524
|
});
|
|
524
|
-
case
|
|
525
|
+
case 82:
|
|
525
526
|
lroStopUrl = _context3.sent;
|
|
526
|
-
_context3.prev =
|
|
527
|
+
_context3.prev = 83;
|
|
527
528
|
_context3.t3 = this.utils;
|
|
528
|
-
_context3.next =
|
|
529
|
+
_context3.next = 87;
|
|
529
530
|
return HttpClient.Fetch(lroStopUrl);
|
|
530
|
-
case
|
|
531
|
+
case 87:
|
|
531
532
|
_context3.t4 = _context3.sent;
|
|
532
|
-
_context3.next =
|
|
533
|
+
_context3.next = 90;
|
|
533
534
|
return _context3.t3.ResponseToJson.call(_context3.t3, _context3.t4);
|
|
534
|
-
case
|
|
535
|
+
case 90:
|
|
535
536
|
console.log("LRO Stop: ", lroStatus.body);
|
|
536
|
-
_context3.next =
|
|
537
|
+
_context3.next = 96;
|
|
537
538
|
break;
|
|
538
|
-
case
|
|
539
|
-
_context3.prev =
|
|
540
|
-
_context3.t5 = _context3["catch"](
|
|
539
|
+
case 93:
|
|
540
|
+
_context3.prev = 93;
|
|
541
|
+
_context3.t5 = _context3["catch"](83);
|
|
541
542
|
console.log("LRO Stop (failed): ", _context3.t5.response.statusCode);
|
|
542
|
-
case
|
|
543
|
+
case 96:
|
|
543
544
|
state = "stopped";
|
|
544
545
|
status.state = state;
|
|
545
|
-
case
|
|
546
|
+
case 98:
|
|
546
547
|
if (!(state === "running")) {
|
|
547
|
-
_context3.next =
|
|
548
|
+
_context3.next = 130;
|
|
548
549
|
break;
|
|
549
550
|
}
|
|
550
551
|
playout_urls = {};
|
|
551
552
|
objectId = conf.objectId;
|
|
552
|
-
_context3.next =
|
|
553
|
+
_context3.next = 103;
|
|
553
554
|
return this.PlayoutOptions({
|
|
554
555
|
objectId: objectId,
|
|
555
556
|
linkPath: "public/asset_metadata/sources/default"
|
|
556
557
|
});
|
|
557
|
-
case
|
|
558
|
+
case 103:
|
|
558
559
|
playout_options = _context3.sent;
|
|
559
560
|
hls_clear_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods.clear !== undefined;
|
|
560
561
|
if (!hls_clear_enabled) {
|
|
561
|
-
_context3.next =
|
|
562
|
+
_context3.next = 109;
|
|
562
563
|
break;
|
|
563
564
|
}
|
|
564
|
-
_context3.next =
|
|
565
|
+
_context3.next = 108;
|
|
565
566
|
return this.FabricUrl({
|
|
566
567
|
libraryId: libraryId,
|
|
567
568
|
objectId: objectId,
|
|
568
569
|
rep: "playout/default/hls-clear/playlist.m3u8"
|
|
569
570
|
});
|
|
570
|
-
case 107:
|
|
571
|
-
playout_urls.hls_clear = _context3.sent;
|
|
572
571
|
case 108:
|
|
572
|
+
playout_urls.hls_clear = _context3.sent;
|
|
573
|
+
case 109:
|
|
573
574
|
hls_aes128_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods["aes-128"] !== undefined;
|
|
574
575
|
if (!hls_aes128_enabled) {
|
|
575
|
-
_context3.next =
|
|
576
|
+
_context3.next = 114;
|
|
576
577
|
break;
|
|
577
578
|
}
|
|
578
|
-
_context3.next =
|
|
579
|
+
_context3.next = 113;
|
|
579
580
|
return this.FabricUrl({
|
|
580
581
|
libraryId: libraryId,
|
|
581
582
|
objectId: objectId,
|
|
582
583
|
rep: "playout/default/hls-aes128/playlist.m3u8"
|
|
583
584
|
});
|
|
584
|
-
case 112:
|
|
585
|
-
playout_urls.hls_aes128 = _context3.sent;
|
|
586
585
|
case 113:
|
|
586
|
+
playout_urls.hls_aes128 = _context3.sent;
|
|
587
|
+
case 114:
|
|
587
588
|
hls_sample_aes_enabled = playout_options && playout_options.hls && playout_options.hls.playoutMethods && playout_options.hls.playoutMethods["sample-aes"] !== undefined;
|
|
588
589
|
if (!hls_sample_aes_enabled) {
|
|
589
|
-
_context3.next =
|
|
590
|
+
_context3.next = 119;
|
|
590
591
|
break;
|
|
591
592
|
}
|
|
592
|
-
_context3.next =
|
|
593
|
+
_context3.next = 118;
|
|
593
594
|
return this.FabricUrl({
|
|
594
595
|
libraryId: libraryId,
|
|
595
596
|
objectId: objectId,
|
|
596
597
|
rep: "playout/default/hls-sample-aes/playlist.m3u8"
|
|
597
598
|
});
|
|
598
|
-
case 117:
|
|
599
|
-
playout_urls.hls_sample_aes = _context3.sent;
|
|
600
599
|
case 118:
|
|
601
|
-
|
|
600
|
+
playout_urls.hls_sample_aes = _context3.sent;
|
|
601
|
+
case 119:
|
|
602
|
+
_context3.next = 121;
|
|
602
603
|
return this.NetworkInfo();
|
|
603
|
-
case
|
|
604
|
+
case 121:
|
|
604
605
|
networkInfo = _context3.sent;
|
|
605
|
-
_context3.next =
|
|
606
|
+
_context3.next = 124;
|
|
606
607
|
return this.authClient.AuthorizationToken({
|
|
607
608
|
libraryId: libraryId,
|
|
608
609
|
objectId: objectId,
|
|
@@ -610,7 +611,7 @@ exports.StreamStatus = /*#__PURE__*/function () {
|
|
|
610
611
|
noCache: true,
|
|
611
612
|
noAuth: true
|
|
612
613
|
});
|
|
613
|
-
case
|
|
614
|
+
case 124:
|
|
614
615
|
token = _context3.sent;
|
|
615
616
|
embed_net = "main";
|
|
616
617
|
if (networkInfo.name.includes("demo")) {
|
|
@@ -619,20 +620,20 @@ exports.StreamStatus = /*#__PURE__*/function () {
|
|
|
619
620
|
embed_url = "https://embed.v3.contentfabric.io/?net=".concat(embed_net, "&p&ct=h&oid=").concat(conf.objectId, "&mt=lv&ath=").concat(token);
|
|
620
621
|
playout_urls.embed_url = embed_url;
|
|
621
622
|
status.playout_urls = playout_urls;
|
|
622
|
-
case
|
|
623
|
-
_context3.next =
|
|
623
|
+
case 130:
|
|
624
|
+
_context3.next = 135;
|
|
624
625
|
break;
|
|
625
|
-
case
|
|
626
|
-
_context3.prev =
|
|
626
|
+
case 132:
|
|
627
|
+
_context3.prev = 132;
|
|
627
628
|
_context3.t6 = _context3["catch"](5);
|
|
628
629
|
console.error(_context3.t6);
|
|
629
|
-
case 134:
|
|
630
|
-
return _context3.abrupt("return", status);
|
|
631
630
|
case 135:
|
|
631
|
+
return _context3.abrupt("return", status);
|
|
632
|
+
case 136:
|
|
632
633
|
case "end":
|
|
633
634
|
return _context3.stop();
|
|
634
635
|
}
|
|
635
|
-
}, _callee3, this, [[5,
|
|
636
|
+
}, _callee3, this, [[5, 132], [60, 71], [83, 93]]);
|
|
636
637
|
}));
|
|
637
638
|
return function (_x3) {
|
|
638
639
|
return _ref6.apply(this, arguments);
|
|
@@ -801,31 +802,29 @@ exports.StreamStartOrStopOrReset = /*#__PURE__*/function () {
|
|
|
801
802
|
case 0:
|
|
802
803
|
name = _ref9.name, op = _ref9.op;
|
|
803
804
|
_context5.prev = 1;
|
|
804
|
-
|
|
805
|
-
_context5.next = 5;
|
|
805
|
+
_context5.next = 4;
|
|
806
806
|
return this.StreamStatus({
|
|
807
807
|
name: name
|
|
808
808
|
});
|
|
809
|
-
case
|
|
809
|
+
case 4:
|
|
810
810
|
status = _context5.sent;
|
|
811
811
|
if (!(status.state != "stopped")) {
|
|
812
|
-
_context5.next =
|
|
812
|
+
_context5.next = 9;
|
|
813
813
|
break;
|
|
814
814
|
}
|
|
815
815
|
if (!(op === "start")) {
|
|
816
|
-
_context5.next =
|
|
816
|
+
_context5.next = 9;
|
|
817
817
|
break;
|
|
818
818
|
}
|
|
819
819
|
status.error = "Unable to start stream - state: " + status.state;
|
|
820
820
|
return _context5.abrupt("return", status);
|
|
821
|
-
case
|
|
821
|
+
case 9:
|
|
822
822
|
if (!(status.state == "running" || status.state == "starting" || status.state == "stalled")) {
|
|
823
|
-
_context5.next =
|
|
823
|
+
_context5.next = 31;
|
|
824
824
|
break;
|
|
825
825
|
}
|
|
826
|
-
|
|
827
|
-
_context5.
|
|
828
|
-
_context5.next = 15;
|
|
826
|
+
_context5.prev = 10;
|
|
827
|
+
_context5.next = 13;
|
|
829
828
|
return this.CallBitcodeMethod({
|
|
830
829
|
libraryId: status.library_id,
|
|
831
830
|
objectId: status.object_id,
|
|
@@ -833,50 +832,50 @@ exports.StreamStartOrStopOrReset = /*#__PURE__*/function () {
|
|
|
833
832
|
method: "/live/stop/" + status.tlro,
|
|
834
833
|
constant: false
|
|
835
834
|
});
|
|
836
|
-
case
|
|
837
|
-
_context5.next =
|
|
835
|
+
case 13:
|
|
836
|
+
_context5.next = 17;
|
|
838
837
|
break;
|
|
838
|
+
case 15:
|
|
839
|
+
_context5.prev = 15;
|
|
840
|
+
_context5.t0 = _context5["catch"](10);
|
|
839
841
|
case 17:
|
|
840
|
-
_context5.prev = 17;
|
|
841
|
-
_context5.t0 = _context5["catch"](12);
|
|
842
|
-
case 19:
|
|
843
842
|
// Wait until LRO is terminated
|
|
844
843
|
_tries = 10;
|
|
845
|
-
case
|
|
844
|
+
case 18:
|
|
846
845
|
if (!(status.state != "stopped" && _tries-- > 0)) {
|
|
847
|
-
_context5.next =
|
|
846
|
+
_context5.next = 27;
|
|
848
847
|
break;
|
|
849
848
|
}
|
|
850
849
|
console.log("Wait to terminate - ", status.state);
|
|
851
|
-
_context5.next =
|
|
850
|
+
_context5.next = 22;
|
|
852
851
|
return Sleep(1000);
|
|
853
|
-
case
|
|
854
|
-
_context5.next =
|
|
852
|
+
case 22:
|
|
853
|
+
_context5.next = 24;
|
|
855
854
|
return this.StreamStatus({
|
|
856
855
|
name: name
|
|
857
856
|
});
|
|
858
|
-
case
|
|
857
|
+
case 24:
|
|
859
858
|
status = _context5.sent;
|
|
860
|
-
_context5.next =
|
|
859
|
+
_context5.next = 18;
|
|
861
860
|
break;
|
|
862
|
-
case
|
|
861
|
+
case 27:
|
|
863
862
|
console.log("Status after stop - ", status.state);
|
|
864
863
|
if (!(_tries <= 0)) {
|
|
865
|
-
_context5.next =
|
|
864
|
+
_context5.next = 31;
|
|
866
865
|
break;
|
|
867
866
|
}
|
|
868
867
|
console.log("Failed to stop");
|
|
869
868
|
return _context5.abrupt("return", status);
|
|
870
|
-
case
|
|
869
|
+
case 31:
|
|
871
870
|
if (!(op === "stop")) {
|
|
872
|
-
_context5.next =
|
|
871
|
+
_context5.next = 33;
|
|
873
872
|
break;
|
|
874
873
|
}
|
|
875
874
|
return _context5.abrupt("return", status);
|
|
876
|
-
case
|
|
875
|
+
case 33:
|
|
877
876
|
console.log("STARTING", "edge_write_token", status.edge_write_token);
|
|
878
|
-
_context5.prev =
|
|
879
|
-
_context5.next =
|
|
877
|
+
_context5.prev = 34;
|
|
878
|
+
_context5.next = 37;
|
|
880
879
|
return this.CallBitcodeMethod({
|
|
881
880
|
libraryId: status.library_id,
|
|
882
881
|
objectId: status.object_id,
|
|
@@ -884,49 +883,49 @@ exports.StreamStartOrStopOrReset = /*#__PURE__*/function () {
|
|
|
884
883
|
method: "/live/start",
|
|
885
884
|
constant: false
|
|
886
885
|
});
|
|
887
|
-
case
|
|
888
|
-
_context5.next =
|
|
886
|
+
case 37:
|
|
887
|
+
_context5.next = 43;
|
|
889
888
|
break;
|
|
890
|
-
case
|
|
891
|
-
_context5.prev =
|
|
892
|
-
_context5.t1 = _context5["catch"](
|
|
889
|
+
case 39:
|
|
890
|
+
_context5.prev = 39;
|
|
891
|
+
_context5.t1 = _context5["catch"](34);
|
|
893
892
|
console.log("LRO Start (failed): ", _context5.t1);
|
|
894
893
|
return _context5.abrupt("return", {
|
|
895
894
|
state: status.state,
|
|
896
895
|
error: "LRO start failed - must create a stream first"
|
|
897
896
|
});
|
|
898
|
-
case
|
|
897
|
+
case 43:
|
|
899
898
|
// Wait until LRO is 'starting'
|
|
900
899
|
tries = 10;
|
|
901
|
-
case
|
|
900
|
+
case 44:
|
|
902
901
|
if (!(status.state != "starting" && tries-- > 0)) {
|
|
903
|
-
_context5.next =
|
|
902
|
+
_context5.next = 53;
|
|
904
903
|
break;
|
|
905
904
|
}
|
|
906
905
|
console.log("Wait to start - ", status.state);
|
|
907
|
-
_context5.next =
|
|
906
|
+
_context5.next = 48;
|
|
908
907
|
return Sleep(1000);
|
|
909
|
-
case
|
|
910
|
-
_context5.next =
|
|
908
|
+
case 48:
|
|
909
|
+
_context5.next = 50;
|
|
911
910
|
return this.StreamStatus({
|
|
912
911
|
name: name
|
|
913
912
|
});
|
|
914
|
-
case
|
|
913
|
+
case 50:
|
|
915
914
|
status = _context5.sent;
|
|
916
|
-
_context5.next =
|
|
915
|
+
_context5.next = 44;
|
|
917
916
|
break;
|
|
918
|
-
case
|
|
917
|
+
case 53:
|
|
919
918
|
console.log("Status after restart - ", status.state);
|
|
920
919
|
return _context5.abrupt("return", status);
|
|
921
|
-
case
|
|
922
|
-
_context5.prev =
|
|
920
|
+
case 57:
|
|
921
|
+
_context5.prev = 57;
|
|
923
922
|
_context5.t2 = _context5["catch"](1);
|
|
924
923
|
console.error(_context5.t2);
|
|
925
|
-
case
|
|
924
|
+
case 60:
|
|
926
925
|
case "end":
|
|
927
926
|
return _context5.stop();
|
|
928
927
|
}
|
|
929
|
-
}, _callee5, this, [[1,
|
|
928
|
+
}, _callee5, this, [[1, 57], [10, 15], [34, 39]]);
|
|
930
929
|
}));
|
|
931
930
|
return function (_x5) {
|
|
932
931
|
return _ref10.apply(this, arguments);
|
|
@@ -1662,24 +1661,25 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1662
1661
|
mainMeta = _context11.sent;
|
|
1663
1662
|
userConfig = mainMeta.live_recording_config;
|
|
1664
1663
|
status.user_config = userConfig;
|
|
1664
|
+
console.log("userConfig", userConfig);
|
|
1665
1665
|
|
|
1666
1666
|
// Get node URI from user config
|
|
1667
|
-
hostName = userConfig.url.replace("udp://", "").replace("rtmp://", "").split(":")[0];
|
|
1667
|
+
hostName = userConfig.url.replace("udp://", "").replace("rtmp://", "").replace("srt://", "").split(":")[0];
|
|
1668
1668
|
streamUrl = new URL(userConfig.url);
|
|
1669
1669
|
console.log("Retrieving nodes...");
|
|
1670
|
-
_context11.next =
|
|
1670
|
+
_context11.next = 21;
|
|
1671
1671
|
return this.SpaceNodes({
|
|
1672
1672
|
matchEndpoint: hostName
|
|
1673
1673
|
});
|
|
1674
|
-
case
|
|
1674
|
+
case 21:
|
|
1675
1675
|
nodes = _context11.sent;
|
|
1676
1676
|
if (!(nodes.length < 1)) {
|
|
1677
|
-
_context11.next =
|
|
1677
|
+
_context11.next = 25;
|
|
1678
1678
|
break;
|
|
1679
1679
|
}
|
|
1680
1680
|
status.error = "No node matching stream URL " + streamUrl.href;
|
|
1681
1681
|
return _context11.abrupt("return", status);
|
|
1682
|
-
case
|
|
1682
|
+
case 25:
|
|
1683
1683
|
node = nodes[0];
|
|
1684
1684
|
status.node = node;
|
|
1685
1685
|
endpoint = node.endpoints[0];
|
|
@@ -1693,17 +1693,17 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1693
1693
|
timeoutId = setTimeout(function () {
|
|
1694
1694
|
controller.abort();
|
|
1695
1695
|
}, 60 * 1000); // milliseconds
|
|
1696
|
-
_context11.prev =
|
|
1697
|
-
_context11.next =
|
|
1696
|
+
_context11.prev = 32;
|
|
1697
|
+
_context11.next = 35;
|
|
1698
1698
|
return this.Rep({
|
|
1699
1699
|
libraryId: libraryId,
|
|
1700
1700
|
objectId: conf.objectId,
|
|
1701
1701
|
rep: "probe"
|
|
1702
1702
|
});
|
|
1703
|
-
case
|
|
1703
|
+
case 35:
|
|
1704
1704
|
probeUrl = _context11.sent;
|
|
1705
1705
|
_context11.t0 = this.utils;
|
|
1706
|
-
_context11.next =
|
|
1706
|
+
_context11.next = 39;
|
|
1707
1707
|
return HttpClient.Fetch(probeUrl, {
|
|
1708
1708
|
body: JSON.stringify({
|
|
1709
1709
|
"filename": streamUrl.href,
|
|
@@ -1712,35 +1712,34 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1712
1712
|
method: "POST",
|
|
1713
1713
|
signal: controller.signal
|
|
1714
1714
|
});
|
|
1715
|
-
case
|
|
1715
|
+
case 39:
|
|
1716
1716
|
_context11.t1 = _context11.sent;
|
|
1717
|
-
_context11.next =
|
|
1717
|
+
_context11.next = 42;
|
|
1718
1718
|
return _context11.t0.ResponseToJson.call(_context11.t0, _context11.t1);
|
|
1719
|
-
case
|
|
1719
|
+
case 42:
|
|
1720
1720
|
probe = _context11.sent;
|
|
1721
1721
|
if (probe) {
|
|
1722
1722
|
clearTimeout(timeoutId);
|
|
1723
1723
|
}
|
|
1724
1724
|
if (!probe.errors) {
|
|
1725
|
-
_context11.next =
|
|
1725
|
+
_context11.next = 46;
|
|
1726
1726
|
break;
|
|
1727
1727
|
}
|
|
1728
1728
|
throw probe.errors[0];
|
|
1729
|
-
case
|
|
1730
|
-
_context11.next =
|
|
1729
|
+
case 46:
|
|
1730
|
+
_context11.next = 55;
|
|
1731
1731
|
break;
|
|
1732
|
-
case
|
|
1733
|
-
_context11.prev =
|
|
1734
|
-
_context11.t2 = _context11["catch"](
|
|
1732
|
+
case 48:
|
|
1733
|
+
_context11.prev = 48;
|
|
1734
|
+
_context11.t2 = _context11["catch"](32);
|
|
1735
1735
|
if (!(_context11.t2.code === "ETIMEDOUT")) {
|
|
1736
|
-
_context11.next =
|
|
1736
|
+
_context11.next = 54;
|
|
1737
1737
|
break;
|
|
1738
1738
|
}
|
|
1739
1739
|
throw "Stream probe time out - make sure the stream source is available";
|
|
1740
|
-
case 53:
|
|
1741
|
-
throw _context11.t2;
|
|
1742
1740
|
case 54:
|
|
1743
|
-
|
|
1741
|
+
throw _context11.t2;
|
|
1742
|
+
case 55:
|
|
1744
1743
|
probe.format.filename = streamUrl.href;
|
|
1745
1744
|
|
|
1746
1745
|
// Create live recording config
|
|
@@ -1773,31 +1772,156 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1773
1772
|
});
|
|
1774
1773
|
case 66:
|
|
1775
1774
|
_context11.next = 68;
|
|
1776
|
-
return this.ReplaceMetadata({
|
|
1777
|
-
libraryId: libraryId,
|
|
1778
|
-
objectId: conf.objectId,
|
|
1779
|
-
writeToken: writeToken,
|
|
1780
|
-
metadataSubtree: "probe",
|
|
1781
|
-
metadata: probe
|
|
1782
|
-
});
|
|
1783
|
-
case 68:
|
|
1784
|
-
_context11.next = 70;
|
|
1785
1775
|
return this.FinalizeContentObject({
|
|
1786
1776
|
libraryId: libraryId,
|
|
1787
1777
|
objectId: conf.objectId,
|
|
1788
1778
|
writeToken: writeToken,
|
|
1789
1779
|
commitMessage: "Apply live stream configuration"
|
|
1790
1780
|
});
|
|
1791
|
-
case
|
|
1781
|
+
case 68:
|
|
1792
1782
|
status.fin = _context11.sent;
|
|
1793
1783
|
return _context11.abrupt("return", status);
|
|
1794
|
-
case
|
|
1784
|
+
case 70:
|
|
1795
1785
|
case "end":
|
|
1796
1786
|
return _context11.stop();
|
|
1797
1787
|
}
|
|
1798
|
-
}, _callee11, this, [[
|
|
1788
|
+
}, _callee11, this, [[32, 48]]);
|
|
1799
1789
|
}));
|
|
1800
1790
|
return function (_x11) {
|
|
1801
1791
|
return _ref22.apply(this, arguments);
|
|
1802
1792
|
};
|
|
1793
|
+
}();
|
|
1794
|
+
|
|
1795
|
+
/**
|
|
1796
|
+
* Deactivate the stream
|
|
1797
|
+
*
|
|
1798
|
+
* @methodGroup Live Stream
|
|
1799
|
+
* @namedParams
|
|
1800
|
+
* @param {string} name - Object ID or name of the live stream object
|
|
1801
|
+
*
|
|
1802
|
+
* @return {Promise<Object>} - The status response for the stream
|
|
1803
|
+
*/
|
|
1804
|
+
exports.StreamDeactivate = /*#__PURE__*/function () {
|
|
1805
|
+
var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref23) {
|
|
1806
|
+
var name, conf, objectId, libraryId, mainMeta, status, fabURI, edgeWriteToken, edgeMeta, newState, fin;
|
|
1807
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1808
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1809
|
+
case 0:
|
|
1810
|
+
name = _ref23.name;
|
|
1811
|
+
_context12.prev = 1;
|
|
1812
|
+
_context12.next = 4;
|
|
1813
|
+
return this.LoadConf({
|
|
1814
|
+
name: name
|
|
1815
|
+
});
|
|
1816
|
+
case 4:
|
|
1817
|
+
conf = _context12.sent;
|
|
1818
|
+
objectId = conf.objectId;
|
|
1819
|
+
_context12.next = 8;
|
|
1820
|
+
return this.ContentObjectLibraryId({
|
|
1821
|
+
objectId: objectId
|
|
1822
|
+
});
|
|
1823
|
+
case 8:
|
|
1824
|
+
libraryId = _context12.sent;
|
|
1825
|
+
_context12.next = 11;
|
|
1826
|
+
return this.ContentObjectMetadata({
|
|
1827
|
+
libraryId: libraryId,
|
|
1828
|
+
objectId: objectId
|
|
1829
|
+
});
|
|
1830
|
+
case 11:
|
|
1831
|
+
mainMeta = _context12.sent;
|
|
1832
|
+
_context12.next = 14;
|
|
1833
|
+
return this.StreamStatus({
|
|
1834
|
+
name: name
|
|
1835
|
+
});
|
|
1836
|
+
case 14:
|
|
1837
|
+
status = _context12.sent;
|
|
1838
|
+
if (mainMeta.live_recording) {
|
|
1839
|
+
_context12.next = 17;
|
|
1840
|
+
break;
|
|
1841
|
+
}
|
|
1842
|
+
return _context12.abrupt("return", {
|
|
1843
|
+
state: status.state,
|
|
1844
|
+
error: "Stream must be configured before deactivating"
|
|
1845
|
+
});
|
|
1846
|
+
case 17:
|
|
1847
|
+
if (!(status.state !== "stopped")) {
|
|
1848
|
+
_context12.next = 19;
|
|
1849
|
+
break;
|
|
1850
|
+
}
|
|
1851
|
+
return _context12.abrupt("return", {
|
|
1852
|
+
state: status.state,
|
|
1853
|
+
error: "Stream must be stopped before deactivating"
|
|
1854
|
+
});
|
|
1855
|
+
case 19:
|
|
1856
|
+
fabURI = mainMeta.live_recording.fabric_config.ingress_node_api; // Support both hostname and URL ingress_node_api
|
|
1857
|
+
if (!fabURI.startsWith("http")) {
|
|
1858
|
+
// Assume https
|
|
1859
|
+
fabURI = "https://" + fabURI;
|
|
1860
|
+
}
|
|
1861
|
+
this.SetNodes({
|
|
1862
|
+
fabricURIs: [fabURI]
|
|
1863
|
+
});
|
|
1864
|
+
edgeWriteToken = mainMeta.live_recording.fabric_config.edge_write_token;
|
|
1865
|
+
if (!(edgeWriteToken === undefined || edgeWriteToken === "")) {
|
|
1866
|
+
_context12.next = 25;
|
|
1867
|
+
break;
|
|
1868
|
+
}
|
|
1869
|
+
return _context12.abrupt("return", {
|
|
1870
|
+
state: "inactive",
|
|
1871
|
+
error: "stream is already inactive"
|
|
1872
|
+
});
|
|
1873
|
+
case 25:
|
|
1874
|
+
_context12.next = 27;
|
|
1875
|
+
return this.ContentObjectMetadata({
|
|
1876
|
+
libraryId: libraryId,
|
|
1877
|
+
objectId: objectId,
|
|
1878
|
+
writeToken: edgeWriteToken
|
|
1879
|
+
});
|
|
1880
|
+
case 27:
|
|
1881
|
+
edgeMeta = _context12.sent;
|
|
1882
|
+
// Set stop time
|
|
1883
|
+
edgeMeta.recording_stop_time = Math.floor(new Date().getTime() / 1000);
|
|
1884
|
+
newState = "inactive";
|
|
1885
|
+
edgeMeta.live_recording.status = {
|
|
1886
|
+
state: newState,
|
|
1887
|
+
recording_stop_time: edgeMeta.recording_stop_time
|
|
1888
|
+
};
|
|
1889
|
+
edgeMeta.live_recording.fabric_config.edge_write_token = "";
|
|
1890
|
+
_context12.next = 34;
|
|
1891
|
+
return this.ReplaceMetadata({
|
|
1892
|
+
libraryId: libraryId,
|
|
1893
|
+
objectId: objectId,
|
|
1894
|
+
writeToken: edgeWriteToken,
|
|
1895
|
+
metadata: edgeMeta
|
|
1896
|
+
});
|
|
1897
|
+
case 34:
|
|
1898
|
+
_context12.next = 36;
|
|
1899
|
+
return this.FinalizeContentObject({
|
|
1900
|
+
libraryId: libraryId,
|
|
1901
|
+
objectId: objectId,
|
|
1902
|
+
writeToken: edgeWriteToken,
|
|
1903
|
+
commitMessage: "Deactivate stream"
|
|
1904
|
+
});
|
|
1905
|
+
case 36:
|
|
1906
|
+
fin = _context12.sent;
|
|
1907
|
+
return _context12.abrupt("return", {
|
|
1908
|
+
reference_url: status.reference_url,
|
|
1909
|
+
fin: fin,
|
|
1910
|
+
name: name,
|
|
1911
|
+
edge_write_token: edgeWriteToken,
|
|
1912
|
+
state: newState
|
|
1913
|
+
});
|
|
1914
|
+
case 40:
|
|
1915
|
+
_context12.prev = 40;
|
|
1916
|
+
_context12.t0 = _context12["catch"](1);
|
|
1917
|
+
console.error(_context12.t0);
|
|
1918
|
+
case 43:
|
|
1919
|
+
case "end":
|
|
1920
|
+
return _context12.stop();
|
|
1921
|
+
}
|
|
1922
|
+
}, _callee12, this, [[1, 40]]);
|
|
1923
|
+
}));
|
|
1924
|
+
return function (_x12) {
|
|
1925
|
+
return _ref24.apply(this, arguments);
|
|
1926
|
+
};
|
|
1803
1927
|
}();
|