eyevinn-channel-engine 3.3.5 → 3.3.6

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/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM node:slim
1
+ FROM node:12.16.1-alpine
2
2
 
3
3
  WORKDIR /app
4
4
 
@@ -85,7 +85,7 @@ class SessionLive {
85
85
  if (resetDelay === null || resetDelay < 0) {
86
86
  resetDelay = RESET_DELAY;
87
87
  }
88
-
88
+ debug(`[${this.instanceId}][${this.sessionId}]: LEADER: Resetting SessionLive values in Store ${resetDelay === 0 ? "Immediately" : `after a delay=(${resetDelay}ms)`}`);
89
89
  await timer(resetDelay);
90
90
  await this.sessionLiveState.set("liveSegsForFollowers", null);
91
91
  await this.sessionLiveState.set("lastRequestedMediaSeqRaw", null);
@@ -95,7 +95,7 @@ class SessionLive {
95
95
  mediaSeqCount: null,
96
96
  discSeqCount: null,
97
97
  });
98
- debug(`[${this.instanceId}][${this.sessionId}]: LEADER: Resetting SessionLive values in Store ${resetDelay === 0 ? "Immediately" : `after a delay=(${resetDelay}ms)`}`);
98
+ debug(`[${this.instanceId}][${this.sessionId}]: LEADER: SessionLive values in Store have now been reset!`);
99
99
  }
100
100
 
101
101
  async resetSession() {
@@ -562,6 +562,18 @@ class SessionLive {
562
562
  let attempts = 10;
563
563
  // CHECK AGAIN CASE 1: Store Empty
564
564
  while (!leadersMediaSeqRaw && attempts > 0) {
565
+ if (!leadersMediaSeqRaw) {
566
+ isLeader = await this.sessionLiveStateStore.isLeader(this.instanceId);
567
+ if (isLeader) {
568
+ debug(`[${this.instanceId}]: I'm the new leader`);
569
+ return;
570
+ }
571
+ }
572
+
573
+ if (!this.allowedToSet) {
574
+ debug(`[${this.sessionId}]: We are about to switch away from LIVE. Abort fetching from Store`);
575
+ break;
576
+ }
565
577
  const segDur = this._getAnyFirstSegmentDurationMs() || DEFAULT_PLAYHEAD_INTERVAL_MS;
566
578
  const waitTimeMs = parseInt(segDur / 3, 10);
567
579
  debug(`[${this.sessionId}]: FOLLOWER: Leader has not put anything in store... Will check again in ${waitTimeMs}ms (Tries left=[${attempts}])`);
@@ -572,19 +584,25 @@ class SessionLive {
572
584
  }
573
585
 
574
586
  if (!leadersMediaSeqRaw) {
575
- isLeader = await this.sessionLiveStateStore.isLeader(this.instanceId);
576
- if (isLeader) {
577
- debug(`[${this.instanceId}]: I'm the new leader`);
578
- return;
579
- } else {
580
- debug(`[${this.instanceId}]: The leader is still alive`);
581
- return;
582
- }
587
+ debug(`[${this.instanceId}]: The leader is still alive`);
588
+ return;
583
589
  }
584
590
 
585
591
  attempts = 10;
586
592
  // CHECK AGAIN CASE 2: Store Old
587
593
  while (leadersMediaSeqRaw <= this.lastRequestedMediaSeqRaw && attempts > 0) {
594
+ if (!this.allowedToSet) {
595
+ debug(`[${this.sessionId}]: We are about to switch away from LIVE. Abort fetching from Store`);
596
+ break;
597
+ }
598
+ if (leadersMediaSeqRaw <= this.lastRequestedMediaSeqRaw) {
599
+ isLeader = await this.sessionLiveStateStore.isLeader(this.instanceId);
600
+ if (isLeader) {
601
+ debug(`[${this.instanceId}][${this.sessionId}]: I'm the new leader`);
602
+ return;
603
+ }
604
+ }
605
+
588
606
  const segDur = this._getAnyFirstSegmentDurationMs() || DEFAULT_PLAYHEAD_INTERVAL_MS;
589
607
  const waitTimeMs = parseInt(segDur / 3, 10);
590
608
  debug(`[${this.sessionId}]: FOLLOWER: Cannot find anything NEW in store... Will check again in ${waitTimeMs}ms (Tries left=[${attempts}])`);
@@ -593,18 +611,10 @@ class SessionLive {
593
611
  leadersMediaSeqRaw = await this.sessionLiveState.get("lastRequestedMediaSeqRaw");
594
612
  attempts--;
595
613
  }
596
-
597
- if (leadersMediaSeqRaw <= this.lastRequestedMediaSeqRaw) {
598
- isLeader = await this.sessionLiveStateStore.isLeader(this.instanceId);
599
- if (isLeader) {
600
- debug(`[${this.instanceId}][${this.sessionId}]: I'm the new leader`);
601
- return;
602
- } else {
603
- debug(`[${this.instanceId}][${this.sessionId}]: The leader is still alive`);
604
- return;
605
- }
614
+ if(leadersMediaSeqRaw <= this.lastRequestedMediaSeqRaw) {
615
+ debug(`[${this.instanceId}][${this.sessionId}]: The leader is still alive`);
616
+ return;
606
617
  }
607
-
608
618
  // Follower updates its manifest building blocks (segment holders & counts)
609
619
  this.lastRequestedMediaSeqRaw = leadersMediaSeqRaw;
610
620
  this.liveSegsForFollowers = await this.sessionLiveState.get("liveSegsForFollowers");
@@ -807,7 +817,7 @@ class SessionLive {
807
817
  const leadersCurrentMseqRaw = await this.sessionLiveState.get("lastRequestedMediaSeqRaw");
808
818
  const counts = await this.sessionLiveState.get("firstCounts");
809
819
  const leadersFirstMseqRaw = counts.liveSourceMseqCount;
810
- if (leadersCurrentMseqRaw !== null && leadersCurrentMseqRaw !== currentMseqRaw) {
820
+ if (leadersCurrentMseqRaw !== null && leadersCurrentMseqRaw > currentMseqRaw) {
811
821
  // if leader never had any segs from prev mseq
812
822
  if (leadersFirstMseqRaw !== null && leadersFirstMseqRaw === leadersCurrentMseqRaw) {
813
823
  // Follower updates it's manifest ingedients (segment holders & counts)
@@ -855,8 +865,8 @@ class SessionLive {
855
865
  // Do not replace old data with empty data
856
866
  if (segListSize > 0) {
857
867
  debug(`[${this.sessionId}]: LEADER: Adding data to store!`);
858
- await this.sessionLiveState.set("liveSegsForFollowers", this.liveSegsForFollowers);
859
868
  await this.sessionLiveState.set("lastRequestedMediaSeqRaw", this.lastRequestedMediaSeqRaw);
869
+ await this.sessionLiveState.set("liveSegsForFollowers", this.liveSegsForFollowers);
860
870
  }
861
871
  }
862
872
 
@@ -307,9 +307,6 @@ class StreamSwitcher {
307
307
  liveSegments = await sessionLive.getCurrentMediaSequenceSegments();
308
308
  liveCounts = await sessionLive.getCurrentMediaAndDiscSequenceCount();
309
309
 
310
- await sessionLive.resetSession();
311
- sessionLive.resetLiveStoreAsync(RESET_DELAY); // In parallel
312
-
313
310
  if (scheduleObj && !scheduleObj.duration) {
314
311
  debug(`[${this.sessionId}]: Cannot switch VOD. No duration specified for schedule item: [${scheduleObj.assetId}]`);
315
312
  }
@@ -331,6 +328,9 @@ class StreamSwitcher {
331
328
  await session.setCurrentMediaAndDiscSequenceCount(liveCounts.mediaSeq, liveCounts.discSeq);
332
329
  await session.setCurrentMediaSequenceSegments(liveSegments.currMseqSegs, liveSegments.segCount);
333
330
 
331
+ await sessionLive.resetSession();
332
+ sessionLive.resetLiveStoreAsync(RESET_DELAY); // In parallel
333
+
334
334
  this.working = false;
335
335
  this.streamTypeLive = false;
336
336
  debug(`[${this.sessionId}]: [ Switched from LIVE->V2L ]`);
@@ -349,8 +349,6 @@ class StreamSwitcher {
349
349
  this.eventId = scheduleObj.eventId;
350
350
  liveSegments = await sessionLive.getCurrentMediaSequenceSegments();
351
351
  liveCounts = await sessionLive.getCurrentMediaAndDiscSequenceCount();
352
- await sessionLive.resetSession();
353
- sessionLive.resetLiveStoreAsync(RESET_DELAY); // In parallel
354
352
 
355
353
  eventSegments = await session.getTruncatedVodSegments(scheduleObj.uri, scheduleObj.duration / 1000);
356
354
  if (!eventSegments) {
@@ -369,9 +367,11 @@ class StreamSwitcher {
369
367
  const prerollSegments = this.prerollsCache[this.sessionId].segments;
370
368
  eventSegments = this._mergeSegments(prerollSegments, eventSegments, true);
371
369
  }
372
-
373
370
  await session.setCurrentMediaSequenceSegments(eventSegments, 0, true);
374
371
 
372
+ await sessionLive.resetSession();
373
+ sessionLive.resetLiveStoreAsync(RESET_DELAY); // In parallel
374
+
375
375
  this.working = false;
376
376
  this.streamTypeLive = false;
377
377
  debug(`[${this.sessionId}]: Switched from LIVE->VOD`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyevinn-channel-engine",
3
- "version": "3.3.5",
3
+ "version": "3.3.6",
4
4
  "description": "OTT TV Channel Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {