eyevinn-channel-engine 3.1.6 → 3.1.7
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/engine/session_live.js +26 -14
- package/package.json +1 -1
package/engine/session_live.js
CHANGED
|
@@ -499,8 +499,14 @@ class SessionLive {
|
|
|
499
499
|
if (!this.liveSegQueue[liveBw]) {
|
|
500
500
|
this.liveSegQueue[liveBw] = [];
|
|
501
501
|
}
|
|
502
|
-
|
|
503
|
-
|
|
502
|
+
// Do not push duplicates
|
|
503
|
+
const liveSegURIs = this.liveSegQueue[liveBw].filter(seg => seg.uri).map(seg => seg.uri);
|
|
504
|
+
if (liveSegFromLeader.uri && liveSegURIs.includes(liveSegFromLeader.uri)) {
|
|
505
|
+
debug(`[${this.sessionId}]: FOLLOWER: Found duplicate live segment. Skip push!`);
|
|
506
|
+
} else {
|
|
507
|
+
this.liveSegQueue[liveBw].push(liveSegFromLeader);
|
|
508
|
+
debug(`[${this.sessionId}]: FOLLOWER: Pushed segment (${liveSegFromLeader.uri ? liveSegFromLeader.uri : "Disc-tag"}) to 'liveSegQueue' (${liveBw})`);
|
|
509
|
+
}
|
|
504
510
|
}
|
|
505
511
|
}
|
|
506
512
|
// Remove older segments and update counts
|
|
@@ -520,13 +526,13 @@ class SessionLive {
|
|
|
520
526
|
*/
|
|
521
527
|
async _loadAllMediaManifests() {
|
|
522
528
|
debug(`[${this.sessionId}]: Attempting to load all media manifest URIs in=${Object.keys(this.mediaManifestURIs)}`);
|
|
523
|
-
|
|
529
|
+
let currentMseqRaw = null;
|
|
524
530
|
// -------------------------------------
|
|
525
531
|
// If I am a Follower-node then my job
|
|
526
532
|
// ends here, where I only read from store.
|
|
527
533
|
// -------------------------------------
|
|
528
534
|
let isLeader = await this.sessionLiveStateStore.isLeader(this.instanceId);
|
|
529
|
-
if (!isLeader && this.lastRequestedMediaSeqRaw) {
|
|
535
|
+
if (!isLeader && this.lastRequestedMediaSeqRaw !== null) {
|
|
530
536
|
debug(`[${this.sessionId}]: FOLLOWER: Reading data from store!`);
|
|
531
537
|
|
|
532
538
|
let leadersMediaSeqRaw = await this.sessionLiveState.get("lastRequestedMediaSeqRaw");
|
|
@@ -659,6 +665,8 @@ class SessionLive {
|
|
|
659
665
|
continue;
|
|
660
666
|
}
|
|
661
667
|
|
|
668
|
+
currentMseqRaw = allMediaSeqCounts[0];
|
|
669
|
+
|
|
662
670
|
if (!isLeader) {
|
|
663
671
|
let leadersFirstSeqCounts = await this.sessionLiveState.get("firstCounts");
|
|
664
672
|
let tries = 20;
|
|
@@ -687,9 +695,13 @@ class SessionLive {
|
|
|
687
695
|
|
|
688
696
|
// Respawners never do this, only starter followers.
|
|
689
697
|
// Edge Case: FOLLOWER transitioned from session with different segments from LEADER
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
698
|
+
if (leadersFirstSeqCounts.discSeqCount !== this.discSeqCount) {
|
|
699
|
+
this.discSeqCount = leadersFirstSeqCounts.discSeqCount;
|
|
700
|
+
}
|
|
701
|
+
if (leadersFirstSeqCounts.mediaSeqCount !== this.mediaSeqCount) {
|
|
702
|
+
this.mediaSeqCount = leadersFirstSeqCounts.mediaSeqCount;
|
|
703
|
+
debug(`[${this.sessionId}]: FOLLOWER transistioned with wrong V2L segments, updating counts to [${
|
|
704
|
+
this.mediaSeqCount}][${this.discSeqCount}], and reading 'transitSegs' from store`);
|
|
693
705
|
const transitSegs = await this.sessionLiveState.get("transitSegs");
|
|
694
706
|
if (!this._isEmpty(transitSegs)) {
|
|
695
707
|
this.vodSegments = transitSegs;
|
|
@@ -697,12 +709,12 @@ class SessionLive {
|
|
|
697
709
|
}
|
|
698
710
|
|
|
699
711
|
// Prepare to load segments...
|
|
700
|
-
debug(`[${this.instanceId}][${this.sessionId}]: Newest mseq from LIVE=${
|
|
701
|
-
if (
|
|
712
|
+
debug(`[${this.instanceId}][${this.sessionId}]: Newest mseq from LIVE=${currentMseqRaw} First mseq in store=${leadersFirstSeqCounts.liveSourceMseqCount}`);
|
|
713
|
+
if (currentMseqRaw === leadersFirstSeqCounts.liveSourceMseqCount) {
|
|
702
714
|
this.pushAmount = 1; // Follower from start
|
|
703
715
|
} else {
|
|
704
716
|
// RESPAWNED NODES
|
|
705
|
-
this.pushAmount =
|
|
717
|
+
this.pushAmount = currentMseqRaw - leadersFirstSeqCounts.liveSourceMseqCount + 1;
|
|
706
718
|
|
|
707
719
|
const transitSegs = await this.sessionLiveState.get("transitSegs");
|
|
708
720
|
//debug(`[${this.sessionId}]: NEW FOLLOWER: I tried to get 'transitSegs'. This is what I found ${JSON.stringify(transitSegs)}`);
|
|
@@ -716,8 +728,8 @@ class SessionLive {
|
|
|
716
728
|
if (this.firstTime) {
|
|
717
729
|
this.pushAmount = 1; // Leader from start
|
|
718
730
|
} else {
|
|
719
|
-
this.pushAmount =
|
|
720
|
-
debug(`[${this.sessionId}]: ...calculating pushAmount=${
|
|
731
|
+
this.pushAmount = currentMseqRaw - this.lastRequestedMediaSeqRaw;
|
|
732
|
+
debug(`[${this.sessionId}]: ...calculating pushAmount=${currentMseqRaw}-${this.lastRequestedMediaSeqRaw}=${this.pushAmount}`);
|
|
721
733
|
}
|
|
722
734
|
debug(`[${this.sessionId}]: ...pushAmount=${this.pushAmount}`);
|
|
723
735
|
break;
|
|
@@ -737,9 +749,9 @@ class SessionLive {
|
|
|
737
749
|
const leadersCurrentMseqRaw = await this.sessionLiveState.get("lastRequestedMediaSeqRaw");
|
|
738
750
|
const counts = await this.sessionLiveState.get("firstCounts");
|
|
739
751
|
const leadersFirstMseqRaw = counts.liveSourceMseqCount;
|
|
740
|
-
if (leadersCurrentMseqRaw && leadersCurrentMseqRaw !==
|
|
752
|
+
if (leadersCurrentMseqRaw !== null && leadersCurrentMseqRaw !== currentMseqRaw) {
|
|
741
753
|
// if leader never had any segs from prev mseq
|
|
742
|
-
if (leadersFirstMseqRaw && leadersFirstMseqRaw === leadersCurrentMseqRaw) {
|
|
754
|
+
if (leadersFirstMseqRaw !== null && leadersFirstMseqRaw === leadersCurrentMseqRaw) {
|
|
743
755
|
// Follower updates it's manifest ingedients (segment holders & counts)
|
|
744
756
|
this.lastRequestedMediaSeqRaw = leadersCurrentMseqRaw;
|
|
745
757
|
this.liveSegsForFollowers = await this.sessionLiveState.get("liveSegsForFollowers");
|