eyevinn-channel-engine 3.3.6 → 3.3.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.js +14 -7
- package/engine/session_live.js +29 -4
- package/package.json +1 -1
package/engine/session.js
CHANGED
|
@@ -512,7 +512,7 @@ class Session {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
const sessionState = await this._sessionState.getValues(["vodMediaSeqVideo", "discSeq"]);
|
|
515
|
-
|
|
515
|
+
let playheadState = await this._playheadState.getValues(["mediaSeq", "vodMediaSeqVideo"]);
|
|
516
516
|
|
|
517
517
|
if (this.prevVodMediaSeq.video === null) {
|
|
518
518
|
this.prevVodMediaSeq.video = playheadState.vodMediaSeqVideo;
|
|
@@ -522,13 +522,20 @@ class Session {
|
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
if (playheadState.vodMediaSeqVideo > sessionState.vodMediaSeqVideo) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
525
|
+
const state = await this._sessionState.get("state");
|
|
526
|
+
if ([SessionState.VOD_RELOAD_INIT, SessionState.VOD_NEXT_INITIATING].includes(state)) {
|
|
527
|
+
debug(`[${this._sessionId}]: Recently reloaded Vod. PlayheadState not up-to-date. Waiting 500ms before reading from store again`);
|
|
528
|
+
await timer(500);
|
|
529
|
+
playheadState = await this._playheadState.getValues(["mediaSeq", "vodMediaSeqVideo"]);
|
|
530
530
|
} else {
|
|
531
|
-
debug(`[${this._sessionId}]:
|
|
531
|
+
debug(`[${this._sessionId}]: Recently Loaded Next Vod. PlayheadState not up-to-date. Return the last generated m3u8`);
|
|
532
|
+
const m3u8 = await this._playheadState.getLastM3u8();
|
|
533
|
+
if (m3u8) {
|
|
534
|
+
this.prevVodMediaSeq.video = playheadState.vodMediaSeqVideo;
|
|
535
|
+
return m3u8;
|
|
536
|
+
} else {
|
|
537
|
+
debug(`[${this._sessionId}]: We don't have any previously generated m3u8`);
|
|
538
|
+
}
|
|
532
539
|
}
|
|
533
540
|
}
|
|
534
541
|
|
package/engine/session_live.js
CHANGED
|
@@ -588,9 +588,10 @@ class SessionLive {
|
|
|
588
588
|
return;
|
|
589
589
|
}
|
|
590
590
|
|
|
591
|
+
let liveSegsInStore = await this.sessionLiveState.get("liveSegsForFollowers");
|
|
591
592
|
attempts = 10;
|
|
592
593
|
// CHECK AGAIN CASE 2: Store Old
|
|
593
|
-
while (leadersMediaSeqRaw <= this.lastRequestedMediaSeqRaw && attempts > 0) {
|
|
594
|
+
while ((leadersMediaSeqRaw <= this.lastRequestedMediaSeqRaw && attempts > 0) || (this._containsSegment(this.liveSegsForFollowers, liveSegsInStore) && attempts > 0)) {
|
|
594
595
|
if (!this.allowedToSet) {
|
|
595
596
|
debug(`[${this.sessionId}]: We are about to switch away from LIVE. Abort fetching from Store`);
|
|
596
597
|
break;
|
|
@@ -602,22 +603,26 @@ class SessionLive {
|
|
|
602
603
|
return;
|
|
603
604
|
}
|
|
604
605
|
}
|
|
605
|
-
|
|
606
|
+
if (this._containsSegment(this.liveSegsForFollowers, liveSegsInStore)) {
|
|
607
|
+
debug(`[${this.sessionId}]: FOLLOWER: _containsSegment=true,${leadersMediaSeqRaw},${this.lastRequestedMediaSeqRaw}`);
|
|
608
|
+
}
|
|
606
609
|
const segDur = this._getAnyFirstSegmentDurationMs() || DEFAULT_PLAYHEAD_INTERVAL_MS;
|
|
607
610
|
const waitTimeMs = parseInt(segDur / 3, 10);
|
|
608
611
|
debug(`[${this.sessionId}]: FOLLOWER: Cannot find anything NEW in store... Will check again in ${waitTimeMs}ms (Tries left=[${attempts}])`);
|
|
609
612
|
await timer(waitTimeMs);
|
|
610
613
|
this.timerCompensation = false;
|
|
611
614
|
leadersMediaSeqRaw = await this.sessionLiveState.get("lastRequestedMediaSeqRaw");
|
|
615
|
+
liveSegsInStore = await this.sessionLiveState.get("liveSegsForFollowers");
|
|
612
616
|
attempts--;
|
|
613
617
|
}
|
|
614
|
-
|
|
618
|
+
// FINALLY
|
|
619
|
+
if (leadersMediaSeqRaw <= this.lastRequestedMediaSeqRaw) {
|
|
615
620
|
debug(`[${this.instanceId}][${this.sessionId}]: The leader is still alive`);
|
|
616
621
|
return;
|
|
617
622
|
}
|
|
618
623
|
// Follower updates its manifest building blocks (segment holders & counts)
|
|
619
624
|
this.lastRequestedMediaSeqRaw = leadersMediaSeqRaw;
|
|
620
|
-
this.liveSegsForFollowers =
|
|
625
|
+
this.liveSegsForFollowers = liveSegsInStore;
|
|
621
626
|
debug(`[${this.sessionId}]: These are the segments from store: [${JSON.stringify(this.liveSegsForFollowers)}]`);
|
|
622
627
|
this._updateLiveSegQueue();
|
|
623
628
|
return;
|
|
@@ -1445,6 +1450,26 @@ class SessionLive {
|
|
|
1445
1450
|
}
|
|
1446
1451
|
return true;
|
|
1447
1452
|
}
|
|
1453
|
+
|
|
1454
|
+
_containsSegment(segments, newSegments) {
|
|
1455
|
+
if (!segments || !newSegments) {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
if (Object.keys(segments).length === 0 || Object.keys(newSegments).length === 0) {
|
|
1459
|
+
return false;
|
|
1460
|
+
}
|
|
1461
|
+
const someBw = Object.keys(segments)[0];
|
|
1462
|
+
const segList = segments[someBw];
|
|
1463
|
+
const mostRecentSegment = segList[segList.length - 1];
|
|
1464
|
+
|
|
1465
|
+
const segListNew = newSegments[someBw];
|
|
1466
|
+
const mostRecentSegmentNew = segListNew[segListNew.length - 1];
|
|
1467
|
+
|
|
1468
|
+
if (mostRecentSegmentNew.uri === mostRecentSegment.uri) {
|
|
1469
|
+
return true;
|
|
1470
|
+
}
|
|
1471
|
+
return false;
|
|
1472
|
+
}
|
|
1448
1473
|
}
|
|
1449
1474
|
|
|
1450
1475
|
module.exports = SessionLive;
|