eyevinn-channel-engine 4.2.9 → 4.3.0
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/README.md +1 -0
- package/dist/engine/server.d.ts +5 -0
- package/dist/engine/server.js +10 -0
- package/dist/engine/session.d.ts +3 -0
- package/dist/engine/session.js +173 -157
- package/dist/engine/session_state.js +33 -18
- package/dist/examples/truncate.js +2 -1
- package/dist/package.json +3 -3
- package/engine/server.ts +15 -0
- package/engine/session.js +45 -31
- package/engine/session_state.js +13 -1
- package/examples/truncate.ts +2 -1
- package/package.json +3 -3
package/dist/engine/session.js
CHANGED
|
@@ -101,10 +101,19 @@ var Session = /** @class */ (function () {
|
|
|
101
101
|
};
|
|
102
102
|
this.isAllowedToClearVodCache = null;
|
|
103
103
|
this.alwaysNewSegments = null;
|
|
104
|
+
this.alwaysMapBandwidthByNearest = null;
|
|
105
|
+
this.partialStoreHLSVod = null;
|
|
106
|
+
this.currentPlayheadRef = null;
|
|
104
107
|
if (config) {
|
|
105
108
|
if (config.alwaysNewSegments) {
|
|
106
109
|
this.alwaysNewSegments = config.alwaysNewSegments;
|
|
107
110
|
}
|
|
111
|
+
if (config.partialStoreHLSVod) {
|
|
112
|
+
this.partialStoreHLSVod = config.partialStoreHLSVod;
|
|
113
|
+
}
|
|
114
|
+
if (config.alwaysMapBandwidthByNearest) {
|
|
115
|
+
this.alwaysMapBandwidthByNearest = config.alwaysMapBandwidthByNearest;
|
|
116
|
+
}
|
|
108
117
|
if (config.sessionId) {
|
|
109
118
|
this._sessionId = config.sessionId;
|
|
110
119
|
}
|
|
@@ -876,7 +885,7 @@ var Session = /** @class */ (function () {
|
|
|
876
885
|
};
|
|
877
886
|
Session.prototype.getCurrentAudioManifestAsync = function (audioGroupId, audioLanguage, playbackSessionId) {
|
|
878
887
|
return __awaiter(this, void 0, void 0, function () {
|
|
879
|
-
var currentVod, sessionState, playheadState, state, DELAY_TIME_MS, ACTION,
|
|
888
|
+
var currentVod, sessionState, playheadState, state, DELAY_TIME_MS, ACTION, manifestMseq, manifestDseq, mediaSequenceValue, m3u8_2, err_5;
|
|
880
889
|
return __generator(this, function (_a) {
|
|
881
890
|
switch (_a.label) {
|
|
882
891
|
case 0:
|
|
@@ -887,7 +896,7 @@ var Session = /** @class */ (function () {
|
|
|
887
896
|
return [4 /*yield*/, this._sessionState.getValues(["discSeqAudio", "vodMediaSeqAudio"])];
|
|
888
897
|
case 1:
|
|
889
898
|
sessionState = _a.sent();
|
|
890
|
-
return [4 /*yield*/, this._playheadState.getValues(["mediaSeqAudio", "vodMediaSeqAudio"])];
|
|
899
|
+
return [4 /*yield*/, this._playheadState.getValues(["mediaSeqAudio", "vodMediaSeqAudio", "playheadRef"])];
|
|
891
900
|
case 2:
|
|
892
901
|
playheadState = _a.sent();
|
|
893
902
|
if (!(playheadState.vodMediaSeqAudio > sessionState.vodMediaSeqAudio || (playheadState.vodMediaSeqAudio < sessionState.vodMediaSeqAudio && playheadState.mediaSeqAudio === this.prevMediaSeqOffset.audio))) return [3 /*break*/, 6];
|
|
@@ -917,16 +926,12 @@ var Session = /** @class */ (function () {
|
|
|
917
926
|
currentVod = _a.sent();
|
|
918
927
|
if (!currentVod) return [3 /*break*/, 15];
|
|
919
928
|
if (!(playheadState.vodMediaSeqAudio < 2 || playheadState.mediaSeqAudio !== this.prevMediaSeqOffset.audio)) return [3 /*break*/, 11];
|
|
920
|
-
|
|
921
|
-
cacheAge = null;
|
|
922
|
-
if (this._sessionState.cache && this._sessionState.cache.currentVod.ts) {
|
|
923
|
-
cacheAge = Date.now() - this._sessionState.cache.currentVod.ts;
|
|
924
|
-
}
|
|
925
|
-
if (!(cacheAge !== null && cacheAge > AGE_THRESH)) return [3 /*break*/, 11];
|
|
929
|
+
if (!(playheadState.playheadRef > this.currentPlayheadRef)) return [3 /*break*/, 11];
|
|
926
930
|
return [4 /*yield*/, timer(500)];
|
|
927
931
|
case 8:
|
|
928
932
|
_a.sent();
|
|
929
|
-
|
|
933
|
+
this.currentPlayheadRef = playheadState.playheadRef;
|
|
934
|
+
debug("[".concat(this._sessionId, "]: While requesting audio manifest for ").concat(audioGroupId, "-").concat(audioLanguage, ", (mseq=").concat(playheadState.vodMediaSeqAudio, ")"));
|
|
930
935
|
return [4 /*yield*/, this._sessionState.clearCurrentVodCache()];
|
|
931
936
|
case 9:
|
|
932
937
|
_a.sent(); // force reading up from shared store
|
|
@@ -969,7 +974,7 @@ var Session = /** @class */ (function () {
|
|
|
969
974
|
};
|
|
970
975
|
Session.prototype.getCurrentSubtitleManifestAsync = function (subtitleGroupId, subtitleLanguage) {
|
|
971
976
|
return __awaiter(this, void 0, void 0, function () {
|
|
972
|
-
var currentVod, sessionState, playheadState, state, DELAY_TIME_MS, ACTION,
|
|
977
|
+
var currentVod, sessionState, playheadState, state, DELAY_TIME_MS, ACTION, manifestMseq, manifestDseq, mediaSequenceValue, m3u8_3, err_6;
|
|
973
978
|
return __generator(this, function (_a) {
|
|
974
979
|
switch (_a.label) {
|
|
975
980
|
case 0:
|
|
@@ -980,7 +985,7 @@ var Session = /** @class */ (function () {
|
|
|
980
985
|
return [4 /*yield*/, this._sessionState.getValues(["discSeqSubtitle", "vodMediaSeqSubtitle"])];
|
|
981
986
|
case 1:
|
|
982
987
|
sessionState = _a.sent();
|
|
983
|
-
return [4 /*yield*/, this._playheadState.getValues(["mediaSeqSubtitle", "vodMediaSeqSubtitle"])];
|
|
988
|
+
return [4 /*yield*/, this._playheadState.getValues(["mediaSeqSubtitle", "vodMediaSeqSubtitle", "playheadRef"])];
|
|
984
989
|
case 2:
|
|
985
990
|
playheadState = _a.sent();
|
|
986
991
|
if (!(playheadState.vodMediaSeqSubtitle > sessionState.vodMediaSeqSubtitle || (playheadState.vodMediaSeqSubtitle < sessionState.vodMediaSeqSubtitle && playheadState.mediaSeqSubtitle === this.prevMediaSeqOffset.subtitle))) return [3 /*break*/, 6];
|
|
@@ -1010,16 +1015,12 @@ var Session = /** @class */ (function () {
|
|
|
1010
1015
|
currentVod = _a.sent();
|
|
1011
1016
|
if (!currentVod) return [3 /*break*/, 15];
|
|
1012
1017
|
if (!(playheadState.vodMediaSeqSubtitle < 2 || playheadState.mediaSeqSubtitle !== this.prevMediaSeqOffset.subtitle)) return [3 /*break*/, 11];
|
|
1013
|
-
|
|
1014
|
-
cacheAge = null;
|
|
1015
|
-
if (this._sessionState.cache && this._sessionState.cache.currentVod.ts) {
|
|
1016
|
-
cacheAge = Date.now() - this._sessionState.cache.currentVod.ts;
|
|
1017
|
-
}
|
|
1018
|
-
if (!(cacheAge !== null && cacheAge > AGE_THRESH)) return [3 /*break*/, 11];
|
|
1018
|
+
if (!(playheadState.playheadRef > this.currentPlayheadRef)) return [3 /*break*/, 11];
|
|
1019
1019
|
return [4 /*yield*/, timer(500)];
|
|
1020
1020
|
case 8:
|
|
1021
1021
|
_a.sent();
|
|
1022
|
-
|
|
1022
|
+
this.currentPlayheadRef = playheadState.playheadRef;
|
|
1023
|
+
debug("[".concat(this._sessionId, "]: While requesting subtitle manifest for ").concat(subtitleGroupId, "-").concat(subtitleLanguage, ", (mseq=").concat(playheadState.vodMediaSeqSubtitle, ")"));
|
|
1023
1024
|
return [4 /*yield*/, this._sessionState.clearCurrentVodCache()];
|
|
1024
1025
|
case 9:
|
|
1025
1026
|
_a.sent(); // force reading up from shared store
|
|
@@ -1142,7 +1143,7 @@ var Session = /** @class */ (function () {
|
|
|
1142
1143
|
return [4 /*yield*/, this._getCurrentPlayheadPosition()];
|
|
1143
1144
|
case 16:
|
|
1144
1145
|
position = (_s.sent()) * 1000;
|
|
1145
|
-
positionV = position / 1000;
|
|
1146
|
+
positionV = position ? position / 1000 : 0;
|
|
1146
1147
|
return [4 /*yield*/, this._sessionState.getCurrentVod()];
|
|
1147
1148
|
case 17:
|
|
1148
1149
|
currentVod_1 = _s.sent();
|
|
@@ -1160,11 +1161,10 @@ var Session = /** @class */ (function () {
|
|
|
1160
1161
|
case 19: return [4 /*yield*/, this._getAudioPlayheadPosition(sessionState_1.vodMediaSeqAudio + index)];
|
|
1161
1162
|
case 20:
|
|
1162
1163
|
audioPosition = (_s.sent()) * 1000;
|
|
1163
|
-
positionA = audioPosition / 1000;
|
|
1164
|
+
positionA = audioPosition ? audioPosition / 1000 : 0;
|
|
1164
1165
|
posDiff = (positionV - positionA).toFixed(3);
|
|
1165
|
-
debug("[".concat(this._sessionId, "]: positionV=").concat(positionV, ";positionA=").concat(positionA, ";posDiff=").concat(posDiff
|
|
1166
|
+
debug("[".concat(this._sessionId, "]: positionV=").concat(positionV, ";positionA=").concat(positionA, ";posDiff=").concat(posDiff));
|
|
1166
1167
|
if (posDiff <= maxAcceptableDiff) {
|
|
1167
|
-
debug("[".concat(this._sessionId, "]: posDiff value (").concat(posDiff, ") is acceptable"));
|
|
1168
1168
|
return [3 /*break*/, 22];
|
|
1169
1169
|
}
|
|
1170
1170
|
if (posDiff > thresh) {
|
|
@@ -1181,7 +1181,7 @@ var Session = /** @class */ (function () {
|
|
|
1181
1181
|
}
|
|
1182
1182
|
_s.label = 21;
|
|
1183
1183
|
case 21:
|
|
1184
|
-
if (!(-thresh < posDiff && posDiff < thresh)) return [3 /*break*/, 19];
|
|
1184
|
+
if (!(-thresh < posDiff && posDiff < thresh) && !isNaN(posDiff)) return [3 /*break*/, 19];
|
|
1185
1185
|
_s.label = 22;
|
|
1186
1186
|
case 22:
|
|
1187
1187
|
audioIncrement = index;
|
|
@@ -1701,19 +1701,19 @@ var Session = /** @class */ (function () {
|
|
|
1701
1701
|
};
|
|
1702
1702
|
Session.prototype._insertSlate = function (currentVod) {
|
|
1703
1703
|
return __awaiter(this, void 0, void 0, function () {
|
|
1704
|
-
var slateVod, sessionState, endValue, endValueAudio, lastDiscontinuity, lastDiscontinuityAudio, isLeader;
|
|
1705
|
-
return __generator(this, function (
|
|
1706
|
-
switch (
|
|
1704
|
+
var slateVod, sessionState, endValue, endValueAudio, lastDiscontinuity, lastDiscontinuityAudio, isLeader, _a;
|
|
1705
|
+
return __generator(this, function (_b) {
|
|
1706
|
+
switch (_b.label) {
|
|
1707
1707
|
case 0:
|
|
1708
1708
|
if (!this.slateUri) return [3 /*break*/, 14];
|
|
1709
1709
|
console.error("[".concat(this._sessionId, "]: Will insert slate"));
|
|
1710
1710
|
return [4 /*yield*/, this._loadSlate(currentVod)];
|
|
1711
1711
|
case 1:
|
|
1712
|
-
slateVod =
|
|
1712
|
+
slateVod = _b.sent();
|
|
1713
1713
|
debug("[".concat(this._sessionId, "]: slate loaded"));
|
|
1714
1714
|
return [4 /*yield*/, this._sessionState.getValues(["slateCount", "mediaSeq", "discSeq", "mediaSeqAudio", "discSeqAudio"])];
|
|
1715
1715
|
case 2:
|
|
1716
|
-
sessionState =
|
|
1716
|
+
sessionState = _b.sent();
|
|
1717
1717
|
endValue = 0;
|
|
1718
1718
|
endValueAudio = 0;
|
|
1719
1719
|
lastDiscontinuity = 0;
|
|
@@ -1732,37 +1732,38 @@ var Session = /** @class */ (function () {
|
|
|
1732
1732
|
}
|
|
1733
1733
|
return [4 /*yield*/, this._sessionStateStore.isLeader(this._instanceId)];
|
|
1734
1734
|
case 3:
|
|
1735
|
-
isLeader =
|
|
1735
|
+
isLeader = _b.sent();
|
|
1736
1736
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqVideo", 0)];
|
|
1737
1737
|
case 4:
|
|
1738
|
-
|
|
1738
|
+
_b.sent();
|
|
1739
1739
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqAudio", 0)];
|
|
1740
1740
|
case 5:
|
|
1741
|
-
|
|
1741
|
+
_b.sent();
|
|
1742
1742
|
return [4 /*yield*/, this._sessionState.set("state", SessionState.VOD_NEXT_INITIATING)];
|
|
1743
1743
|
case 6:
|
|
1744
|
-
|
|
1744
|
+
_b.sent();
|
|
1745
1745
|
return [4 /*yield*/, this._sessionState.setCurrentVod(slateVod)];
|
|
1746
1746
|
case 7:
|
|
1747
|
-
|
|
1747
|
+
_b.sent();
|
|
1748
1748
|
return [4 /*yield*/, this._sessionState.set("mediaSeq", sessionState.mediaSeq + endValue)];
|
|
1749
1749
|
case 8:
|
|
1750
|
-
|
|
1750
|
+
_b.sent();
|
|
1751
1751
|
return [4 /*yield*/, this._sessionState.set("mediaSeqAudio", sessionState.mediaSeqAudio + endValueAudio)];
|
|
1752
1752
|
case 9:
|
|
1753
|
-
|
|
1753
|
+
_b.sent();
|
|
1754
1754
|
return [4 /*yield*/, this._sessionState.set("discSeq", sessionState.discSeq + lastDiscontinuity)];
|
|
1755
1755
|
case 10:
|
|
1756
|
-
|
|
1756
|
+
_b.sent();
|
|
1757
1757
|
return [4 /*yield*/, this._sessionState.set("discSeqAudio", sessionState.discSeqAudio + lastDiscontinuityAudio)];
|
|
1758
1758
|
case 11:
|
|
1759
|
-
|
|
1759
|
+
_b.sent();
|
|
1760
1760
|
return [4 /*yield*/, this._sessionState.set("slateCount", sessionState.slateCount + 1)];
|
|
1761
1761
|
case 12:
|
|
1762
|
-
|
|
1762
|
+
_b.sent();
|
|
1763
|
+
_a = this;
|
|
1763
1764
|
return [4 /*yield*/, this._playheadState.set("playheadRef", Date.now(), isLeader)];
|
|
1764
1765
|
case 13:
|
|
1765
|
-
_a.sent();
|
|
1766
|
+
_a.currentPlayheadRef = _b.sent();
|
|
1766
1767
|
cloudWatchLog(!this.cloudWatchLogging, 'engine-session', { event: 'slateInserted', channel: this._sessionId });
|
|
1767
1768
|
return [2 /*return*/, slateVod];
|
|
1768
1769
|
case 14: return [2 /*return*/, null];
|
|
@@ -1772,19 +1773,19 @@ var Session = /** @class */ (function () {
|
|
|
1772
1773
|
};
|
|
1773
1774
|
Session.prototype._tickAsync = function () {
|
|
1774
1775
|
return __awaiter(this, void 0, void 0, function () {
|
|
1775
|
-
var newVod, sessionState, isLeader, currentVod, vodResponse, _a, nextVodPromise, nextVodStart, _b, loadPromise, hlsOpts, _c, mediaManifestLoader, audioManifestLoader, loadStart, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, err_7,
|
|
1776
|
+
var newVod, sessionState, isLeader, currentVod, vodResponse, _a, nextVodPromise, nextVodStart, _b, loadPromise, hlsOpts, _c, mediaManifestLoader, audioManifestLoader, loadStart, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, err_7, _t, length_1, endMseqValue, endMseqValueAudio, endMseqValueSubtitle, lastDiscontinuity, lastDiscontinuityAudio, lastDiscontinuitySubtitle, _u, vodPromise, gracePeriod, nextVodStart, _v, loadPromise, hlsOpts, _w, mediaManifestLoader, audioManifestLoader, loadStart, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, diffMs, err_8, startTS, _10, mSeq, currentVod_2, dSeq, mSeqOffset, reloadBehind, segments, playheadState, nextMseq, _11, _12, err_9;
|
|
1776
1777
|
var _this = this;
|
|
1777
|
-
return __generator(this, function (
|
|
1778
|
-
switch (
|
|
1778
|
+
return __generator(this, function (_13) {
|
|
1779
|
+
switch (_13.label) {
|
|
1779
1780
|
case 0: return [4 /*yield*/, this._sessionState.getValues(["state", "assetId", "vodMediaSeqVideo", "vodMediaSeqAudio", "vodMediaSeqSubtitle", "mediaSeq", "mediaSeqAudio", "mediaSeqSubtitle", "discSeq", "discSeqAudio", "discSeqSubtitle", "nextVod"])];
|
|
1780
1781
|
case 1:
|
|
1781
|
-
sessionState =
|
|
1782
|
+
sessionState = _13.sent();
|
|
1782
1783
|
return [4 /*yield*/, this._sessionStateStore.isLeader(this._instanceId)];
|
|
1783
1784
|
case 2:
|
|
1784
|
-
isLeader =
|
|
1785
|
+
isLeader = _13.sent();
|
|
1785
1786
|
return [4 /*yield*/, this._sessionState.getCurrentVod()];
|
|
1786
1787
|
case 3:
|
|
1787
|
-
currentVod =
|
|
1788
|
+
currentVod = _13.sent();
|
|
1788
1789
|
if (!sessionState.state) {
|
|
1789
1790
|
sessionState.state = SessionState.VOD_INIT;
|
|
1790
1791
|
}
|
|
@@ -1800,15 +1801,15 @@ var Session = /** @class */ (function () {
|
|
|
1800
1801
|
}
|
|
1801
1802
|
return [3 /*break*/, 104];
|
|
1802
1803
|
case 4:
|
|
1803
|
-
|
|
1804
|
+
_13.trys.push([4, 32, , 35]);
|
|
1804
1805
|
// Needed if store was reset
|
|
1805
1806
|
return [4 /*yield*/, this._sessionStateStore.clearLeaderCache()];
|
|
1806
1807
|
case 5:
|
|
1807
1808
|
// Needed if store was reset
|
|
1808
|
-
|
|
1809
|
+
_13.sent();
|
|
1809
1810
|
return [4 /*yield*/, this._sessionStateStore.isLeader(this._instanceId)];
|
|
1810
1811
|
case 6:
|
|
1811
|
-
isLeader =
|
|
1812
|
+
isLeader = _13.sent();
|
|
1812
1813
|
nextVodPromise = void 0;
|
|
1813
1814
|
if (sessionState.state === SessionState.VOD_INIT) {
|
|
1814
1815
|
debug("[".concat(this._sessionId, "]: state=VOD_INIT"));
|
|
@@ -1822,11 +1823,11 @@ var Session = /** @class */ (function () {
|
|
|
1822
1823
|
nextVodStart = Date.now();
|
|
1823
1824
|
return [4 /*yield*/, nextVodPromise];
|
|
1824
1825
|
case 7:
|
|
1825
|
-
vodResponse =
|
|
1826
|
+
vodResponse = _13.sent();
|
|
1826
1827
|
_b = sessionState;
|
|
1827
1828
|
return [4 /*yield*/, this._sessionState.set("nextVod", vodResponse)];
|
|
1828
1829
|
case 8:
|
|
1829
|
-
_b.nextVod =
|
|
1830
|
+
_b.nextVod = _13.sent();
|
|
1830
1831
|
cloudWatchLog(!this.cloudWatchLogging, 'engine-session', { event: 'nextVod', channel: this._sessionId, reqTimeMs: Date.now() - nextVodStart });
|
|
1831
1832
|
loadPromise = void 0;
|
|
1832
1833
|
if (!!vodResponse.type) return [3 /*break*/, 12];
|
|
@@ -1836,7 +1837,9 @@ var Session = /** @class */ (function () {
|
|
|
1836
1837
|
dummySubtitleEndpoint: this.dummySubtitleEndpoint,
|
|
1837
1838
|
subtitleSliceEndpoint: this.subtitleSliceEndpoint,
|
|
1838
1839
|
shouldContainSubtitles: this.use_vtt_subtitles,
|
|
1839
|
-
expectedSubtitleTracks: this._subtitleTracks
|
|
1840
|
+
expectedSubtitleTracks: this._subtitleTracks,
|
|
1841
|
+
alwaysMapBandwidthByNearest: this.alwaysMapBandwidthByNearest,
|
|
1842
|
+
skipSerializeMediaSequences: this.partialStoreHLSVod
|
|
1840
1843
|
};
|
|
1841
1844
|
newVod = new HLSVod(vodResponse.uri, [], vodResponse.unixTs, vodResponse.offset * 1000, m3u8Header(this._instanceId), hlsOpts);
|
|
1842
1845
|
if (vodResponse.timedMetadata) {
|
|
@@ -1848,12 +1851,12 @@ var Session = /** @class */ (function () {
|
|
|
1848
1851
|
if (!vodResponse.desiredDuration) return [3 /*break*/, 10];
|
|
1849
1852
|
return [4 /*yield*/, this._truncateVod(vodResponse)];
|
|
1850
1853
|
case 9:
|
|
1851
|
-
_c =
|
|
1854
|
+
_c = _13.sent(), mediaManifestLoader = _c.mediaManifestLoader, audioManifestLoader = _c.audioManifestLoader;
|
|
1852
1855
|
loadPromise = currentVod.load(null, mediaManifestLoader, audioManifestLoader);
|
|
1853
1856
|
return [3 /*break*/, 11];
|
|
1854
1857
|
case 10:
|
|
1855
1858
|
loadPromise = currentVod.load();
|
|
1856
|
-
|
|
1859
|
+
_13.label = 11;
|
|
1857
1860
|
case 11: return [3 /*break*/, 13];
|
|
1858
1861
|
case 12:
|
|
1859
1862
|
if (vodResponse.type === 'gap') {
|
|
@@ -1865,12 +1868,12 @@ var Session = /** @class */ (function () {
|
|
|
1865
1868
|
}).catch(reject);
|
|
1866
1869
|
});
|
|
1867
1870
|
}
|
|
1868
|
-
|
|
1871
|
+
_13.label = 13;
|
|
1869
1872
|
case 13:
|
|
1870
1873
|
loadStart = Date.now();
|
|
1871
1874
|
return [4 /*yield*/, loadPromise];
|
|
1872
1875
|
case 14:
|
|
1873
|
-
|
|
1876
|
+
_13.sent();
|
|
1874
1877
|
cloudWatchLog(!this.cloudWatchLogging, 'engine-session', { event: 'loadVod', channel: this._sessionId, loadTimeMs: Date.now() - loadStart });
|
|
1875
1878
|
debug("[".concat(this._sessionId, "]: first VOD loaded"));
|
|
1876
1879
|
debug("[".concat(this._sessionId, "]: ").concat(currentVod.getDeltaTimes()));
|
|
@@ -1881,42 +1884,39 @@ var Session = /** @class */ (function () {
|
|
|
1881
1884
|
return [4 /*yield*/, this._sessionState.set("mediaSeq", 0)];
|
|
1882
1885
|
case 15:
|
|
1883
1886
|
//debug(newVod);
|
|
1884
|
-
_d.mediaSeq =
|
|
1887
|
+
_d.mediaSeq = _13.sent();
|
|
1885
1888
|
_e = sessionState;
|
|
1886
1889
|
return [4 /*yield*/, this._sessionState.set("mediaSeqAudio", 0)];
|
|
1887
1890
|
case 16:
|
|
1888
|
-
_e.mediaSeqAudio =
|
|
1891
|
+
_e.mediaSeqAudio = _13.sent();
|
|
1889
1892
|
_f = sessionState;
|
|
1890
1893
|
return [4 /*yield*/, this._sessionState.set("mediaSeqSubtitle", 0)];
|
|
1891
1894
|
case 17:
|
|
1892
|
-
_f.mediaSeqSubtitle =
|
|
1895
|
+
_f.mediaSeqSubtitle = _13.sent();
|
|
1893
1896
|
_g = sessionState;
|
|
1894
1897
|
return [4 /*yield*/, this._sessionState.set("discSeq", 0)];
|
|
1895
1898
|
case 18:
|
|
1896
|
-
_g.discSeq =
|
|
1899
|
+
_g.discSeq = _13.sent();
|
|
1897
1900
|
_h = sessionState;
|
|
1898
1901
|
return [4 /*yield*/, this._sessionState.set("discSeqAudio", 0)];
|
|
1899
1902
|
case 19:
|
|
1900
|
-
_h.discSeqAudio =
|
|
1903
|
+
_h.discSeqAudio = _13.sent();
|
|
1901
1904
|
_j = sessionState;
|
|
1902
1905
|
return [4 /*yield*/, this._sessionState.set("discSeqSubtitle", 0)];
|
|
1903
1906
|
case 20:
|
|
1904
|
-
_j.discSeqSubtitle =
|
|
1907
|
+
_j.discSeqSubtitle = _13.sent();
|
|
1905
1908
|
_k = sessionState;
|
|
1906
1909
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqVideo", 0)];
|
|
1907
1910
|
case 21:
|
|
1908
|
-
_k.vodMediaSeqVideo =
|
|
1911
|
+
_k.vodMediaSeqVideo = _13.sent();
|
|
1909
1912
|
_l = sessionState;
|
|
1910
1913
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqAudio", 0)];
|
|
1911
1914
|
case 22:
|
|
1912
|
-
_l.vodMediaSeqAudio =
|
|
1915
|
+
_l.vodMediaSeqAudio = _13.sent();
|
|
1913
1916
|
_m = sessionState;
|
|
1914
1917
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqSubtitle", 0)];
|
|
1915
1918
|
case 23:
|
|
1916
|
-
_m.vodMediaSeqSubtitle =
|
|
1917
|
-
return [4 /*yield*/, this._playheadState.set("playheadRef", Date.now(), isLeader)];
|
|
1918
|
-
case 24:
|
|
1919
|
-
_10.sent();
|
|
1919
|
+
_m.vodMediaSeqSubtitle = _13.sent();
|
|
1920
1920
|
this.produceEvent({
|
|
1921
1921
|
type: 'NOW_PLAYING',
|
|
1922
1922
|
data: {
|
|
@@ -1926,30 +1926,34 @@ var Session = /** @class */ (function () {
|
|
|
1926
1926
|
});
|
|
1927
1927
|
_o = sessionState;
|
|
1928
1928
|
return [4 /*yield*/, this._sessionState.set("state", SessionState.VOD_PLAYING)];
|
|
1929
|
-
case
|
|
1930
|
-
_o.state =
|
|
1929
|
+
case 24:
|
|
1930
|
+
_o.state = _13.sent();
|
|
1931
1931
|
_p = sessionState;
|
|
1932
1932
|
return [4 /*yield*/, this._sessionState.setCurrentVod(currentVod, { ttl: currentVod.getDuration() * 1000 })];
|
|
1933
|
+
case 25:
|
|
1934
|
+
_p.currentVod = _13.sent();
|
|
1935
|
+
_q = this;
|
|
1936
|
+
return [4 /*yield*/, this._playheadState.set("playheadRef", Date.now(), isLeader)];
|
|
1933
1937
|
case 26:
|
|
1934
|
-
|
|
1938
|
+
_q.currentPlayheadRef = _13.sent();
|
|
1935
1939
|
return [4 /*yield*/, this._sessionState.remove("nextVod")];
|
|
1936
1940
|
case 27:
|
|
1937
|
-
|
|
1941
|
+
_13.sent();
|
|
1938
1942
|
return [2 /*return*/];
|
|
1939
1943
|
case 28:
|
|
1940
1944
|
debug("[".concat(this._sessionId, "]: not a leader so will go directly to state VOD_PLAYING"));
|
|
1941
|
-
|
|
1945
|
+
_r = sessionState;
|
|
1942
1946
|
return [4 /*yield*/, this._sessionState.set("state", SessionState.VOD_PLAYING)];
|
|
1943
1947
|
case 29:
|
|
1944
|
-
|
|
1945
|
-
|
|
1948
|
+
_r.state = _13.sent();
|
|
1949
|
+
_s = sessionState;
|
|
1946
1950
|
return [4 /*yield*/, this._sessionState.getCurrentVod()];
|
|
1947
1951
|
case 30:
|
|
1948
|
-
|
|
1952
|
+
_s.currentVod = _13.sent();
|
|
1949
1953
|
return [2 /*return*/];
|
|
1950
1954
|
case 31: return [3 /*break*/, 35];
|
|
1951
1955
|
case 32:
|
|
1952
|
-
err_7 =
|
|
1956
|
+
err_7 = _13.sent();
|
|
1953
1957
|
console.error("[".concat(this._sessionId, "]: Failed to init first VOD"));
|
|
1954
1958
|
if (this._assetManager.handleError) {
|
|
1955
1959
|
this._assetManager.handleError(new Error("Failed to init first VOD"), vodResponse);
|
|
@@ -1958,10 +1962,10 @@ var Session = /** @class */ (function () {
|
|
|
1958
1962
|
debug(err_7);
|
|
1959
1963
|
return [4 /*yield*/, this._sessionState.remove("nextVod")];
|
|
1960
1964
|
case 33:
|
|
1961
|
-
|
|
1965
|
+
_13.sent();
|
|
1962
1966
|
return [4 /*yield*/, this._insertSlate(currentVod)];
|
|
1963
1967
|
case 34:
|
|
1964
|
-
currentVod =
|
|
1968
|
+
currentVod = _13.sent();
|
|
1965
1969
|
if (!currentVod) {
|
|
1966
1970
|
debug("No slate to load");
|
|
1967
1971
|
throw err_7;
|
|
@@ -1996,14 +2000,14 @@ var Session = /** @class */ (function () {
|
|
|
1996
2000
|
debug("[".concat(this._sessionId, "]: state=VOD_PLAYING, current[").concat(sessionState.vodMediaSeqVideo, "], prev[").concat(this.prevVodMediaSeq.video, "], total[").concat(currentVod.getLiveMediaSequencesCount(), "]"));
|
|
1997
2001
|
return [4 /*yield*/, this._sessionState.clearCurrentVodCache()];
|
|
1998
2002
|
case 36:
|
|
1999
|
-
|
|
2003
|
+
_13.sent();
|
|
2000
2004
|
return [4 /*yield*/, this._sessionState.getCurrentVod()];
|
|
2001
2005
|
case 37:
|
|
2002
|
-
currentVod =
|
|
2006
|
+
currentVod = _13.sent();
|
|
2003
2007
|
this.prevVodMediaSeq.video = sessionState.vodMediaSeqVideo;
|
|
2004
2008
|
this.prevVodMediaSeq.audio = sessionState.vodMediaSeqAudio;
|
|
2005
2009
|
this.prevVodMediaSeq.subtitle = sessionState.vodMediaSeqSubtitle;
|
|
2006
|
-
|
|
2010
|
+
_13.label = 38;
|
|
2007
2011
|
case 38: return [3 /*break*/, 40];
|
|
2008
2012
|
case 39:
|
|
2009
2013
|
// Handle edge case where Leader loaded next vod but Follower remained in state=VOD_PLAYING
|
|
@@ -2013,7 +2017,7 @@ var Session = /** @class */ (function () {
|
|
|
2013
2017
|
// Allow Follower to clear VodCache...
|
|
2014
2018
|
this.isAllowedToClearVodCache = true;
|
|
2015
2019
|
}
|
|
2016
|
-
|
|
2020
|
+
_13.label = 40;
|
|
2017
2021
|
case 40:
|
|
2018
2022
|
debug("[".concat(this._sessionId, "]: state=VOD_PLAYING (").concat(sessionState.vodMediaSeqVideo, "_").concat(sessionState.vodMediaSeqAudio, "_").concat(sessionState.vodMediaSeqSubtitle, ", ").concat(currentVod.getLiveMediaSequencesCount(), "_").concat(currentVod.getLiveMediaSequencesCount("audio"), "_").concat(currentVod.getLiveMediaSequencesCount("subtitle"), ")"));
|
|
2019
2023
|
return [2 /*return*/];
|
|
@@ -2026,15 +2030,15 @@ var Session = /** @class */ (function () {
|
|
|
2026
2030
|
this.isAllowedToClearVodCache = true;
|
|
2027
2031
|
return [2 /*return*/];
|
|
2028
2032
|
case 42:
|
|
2029
|
-
|
|
2033
|
+
_13.trys.push([42, 74, , 77]);
|
|
2030
2034
|
debug("[".concat(this._sessionId, "]: state=VOD_NEXT_INIT"));
|
|
2031
2035
|
if (!isLeader) return [3 /*break*/, 69];
|
|
2032
2036
|
if (!!currentVod) return [3 /*break*/, 44];
|
|
2033
2037
|
debug("[".concat(this._sessionId, "]: no VOD to append to, assume first VOD to init"));
|
|
2034
|
-
|
|
2038
|
+
_t = sessionState;
|
|
2035
2039
|
return [4 /*yield*/, this._sessionState.set("state", SessionState.VOD_INIT)];
|
|
2036
2040
|
case 43:
|
|
2037
|
-
|
|
2041
|
+
_t.state = _13.sent();
|
|
2038
2042
|
return [2 /*return*/];
|
|
2039
2043
|
case 44:
|
|
2040
2044
|
length_1 = currentVod.getLiveMediaSequencesCount();
|
|
@@ -2054,27 +2058,27 @@ var Session = /** @class */ (function () {
|
|
|
2054
2058
|
lastDiscontinuity = currentVod.getLastDiscontinuity();
|
|
2055
2059
|
lastDiscontinuityAudio = currentVod.getLastDiscontinuityAudio();
|
|
2056
2060
|
lastDiscontinuitySubtitle = currentVod.getLastDiscontinuitySubtitle();
|
|
2057
|
-
|
|
2061
|
+
_u = sessionState;
|
|
2058
2062
|
return [4 /*yield*/, this._sessionState.set("state", SessionState.VOD_NEXT_INITIATING)];
|
|
2059
2063
|
case 45:
|
|
2060
|
-
|
|
2064
|
+
_u.state = _13.sent();
|
|
2061
2065
|
vodPromise = this._getNextVod();
|
|
2062
2066
|
if (!(length_1 === 1)) return [3 /*break*/, 47];
|
|
2063
2067
|
gracePeriod = (this.averageSegmentDuration / 2);
|
|
2064
2068
|
debug("[".concat(this._sessionId, "]: adding a grace period before calling nextVod: ").concat(gracePeriod, "ms"));
|
|
2065
2069
|
return [4 /*yield*/, timer(gracePeriod)];
|
|
2066
2070
|
case 46:
|
|
2067
|
-
|
|
2068
|
-
|
|
2071
|
+
_13.sent();
|
|
2072
|
+
_13.label = 47;
|
|
2069
2073
|
case 47:
|
|
2070
2074
|
nextVodStart = Date.now();
|
|
2071
2075
|
return [4 /*yield*/, vodPromise];
|
|
2072
2076
|
case 48:
|
|
2073
|
-
vodResponse =
|
|
2074
|
-
|
|
2077
|
+
vodResponse = _13.sent();
|
|
2078
|
+
_v = sessionState;
|
|
2075
2079
|
return [4 /*yield*/, this._sessionState.set("nextVod", vodResponse)];
|
|
2076
2080
|
case 49:
|
|
2077
|
-
|
|
2081
|
+
_v.nextVod = _13.sent();
|
|
2078
2082
|
cloudWatchLog(!this.cloudWatchLogging, 'engine-session', { event: 'nextVod', channel: this._sessionId, reqTimeMs: Date.now() - nextVodStart });
|
|
2079
2083
|
loadPromise = void 0;
|
|
2080
2084
|
if (!!vodResponse.type) return [3 /*break*/, 53];
|
|
@@ -2084,7 +2088,9 @@ var Session = /** @class */ (function () {
|
|
|
2084
2088
|
dummySubtitleEndpoint: this.dummySubtitleEndpoint,
|
|
2085
2089
|
subtitleSliceEndpoint: this.subtitleSliceEndpoint,
|
|
2086
2090
|
shouldContainSubtitles: this.use_vtt_subtitles,
|
|
2087
|
-
expectedSubtitleTracks: this._subtitleTracks
|
|
2091
|
+
expectedSubtitleTracks: this._subtitleTracks,
|
|
2092
|
+
alwaysMapBandwidthByNearest: this.alwaysMapBandwidthByNearest,
|
|
2093
|
+
skipSerializeMediaSequences: this.partialStoreHLSVod
|
|
2088
2094
|
};
|
|
2089
2095
|
newVod = new HLSVod(vodResponse.uri, null, vodResponse.unixTs, vodResponse.offset * 1000, m3u8Header(this._instanceId), hlsOpts);
|
|
2090
2096
|
if (vodResponse.timedMetadata) {
|
|
@@ -2103,12 +2109,12 @@ var Session = /** @class */ (function () {
|
|
|
2103
2109
|
if (!vodResponse.desiredDuration) return [3 /*break*/, 51];
|
|
2104
2110
|
return [4 /*yield*/, this._truncateVod(vodResponse)];
|
|
2105
2111
|
case 50:
|
|
2106
|
-
|
|
2112
|
+
_w = _13.sent(), mediaManifestLoader = _w.mediaManifestLoader, audioManifestLoader = _w.audioManifestLoader;
|
|
2107
2113
|
loadPromise = newVod.loadAfter(currentVod, null, mediaManifestLoader, audioManifestLoader);
|
|
2108
2114
|
return [3 /*break*/, 52];
|
|
2109
2115
|
case 51:
|
|
2110
2116
|
loadPromise = newVod.loadAfter(currentVod);
|
|
2111
|
-
|
|
2117
|
+
_13.label = 52;
|
|
2112
2118
|
case 52:
|
|
2113
2119
|
if (vodResponse.diffMs) {
|
|
2114
2120
|
this.diffCompensation = vodResponse.diffMs;
|
|
@@ -2129,12 +2135,12 @@ var Session = /** @class */ (function () {
|
|
|
2129
2135
|
resolve(newVod);
|
|
2130
2136
|
}).catch(reject);
|
|
2131
2137
|
});
|
|
2132
|
-
|
|
2138
|
+
_13.label = 54;
|
|
2133
2139
|
case 54:
|
|
2134
2140
|
loadStart = Date.now();
|
|
2135
2141
|
return [4 /*yield*/, ChaosMonkey.loadVod(loadPromise)];
|
|
2136
2142
|
case 55:
|
|
2137
|
-
|
|
2143
|
+
_13.sent();
|
|
2138
2144
|
cloudWatchLog(!this.cloudWatchLogging, 'engine-session', { event: 'loadVod', channel: this._sessionId, loadTimeMs: Date.now() - loadStart });
|
|
2139
2145
|
this.leaderIsSettingNextVod = true;
|
|
2140
2146
|
debug("[".concat(this._sessionId, "]: next VOD loaded (").concat(newVod.getDeltaTimes(), ")"));
|
|
@@ -2142,57 +2148,58 @@ var Session = /** @class */ (function () {
|
|
|
2142
2148
|
debug("[".concat(this._sessionId, "]: playhead positions [A]=").concat(newVod.getPlayheadPositions("audio")));
|
|
2143
2149
|
currentVod = newVod;
|
|
2144
2150
|
debug("[".concat(this._sessionId, "]: msequences=").concat(currentVod.getLiveMediaSequencesCount(), "; audio msequences=").concat(currentVod.getLiveMediaSequencesCount("audio"), "; subtitle msequences=").concat(currentVod.getLiveMediaSequencesCount("subtitle")));
|
|
2145
|
-
|
|
2151
|
+
_x = sessionState;
|
|
2146
2152
|
return [4 /*yield*/, this._sessionState.setCurrentVod(currentVod, { ttl: currentVod.getDuration() * 1000 })];
|
|
2147
2153
|
case 56:
|
|
2148
|
-
|
|
2154
|
+
_x.currentVod = _13.sent();
|
|
2155
|
+
_y = this;
|
|
2149
2156
|
return [4 /*yield*/, this._playheadState.set("playheadRef", Date.now(), isLeader)];
|
|
2150
2157
|
case 57:
|
|
2151
|
-
|
|
2152
|
-
|
|
2158
|
+
_y.currentPlayheadRef = _13.sent();
|
|
2159
|
+
_z = sessionState;
|
|
2153
2160
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqVideo", 0)];
|
|
2154
2161
|
case 58:
|
|
2155
|
-
|
|
2156
|
-
|
|
2162
|
+
_z.vodMediaSeqVideo = _13.sent();
|
|
2163
|
+
_0 = sessionState;
|
|
2157
2164
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqAudio", 0)];
|
|
2158
2165
|
case 59:
|
|
2159
|
-
|
|
2160
|
-
|
|
2166
|
+
_0.vodMediaSeqAudio = _13.sent();
|
|
2167
|
+
_1 = sessionState;
|
|
2161
2168
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqSubtitle", 0)];
|
|
2162
2169
|
case 60:
|
|
2163
|
-
|
|
2164
|
-
|
|
2170
|
+
_1.vodMediaSeqSubtitle = _13.sent();
|
|
2171
|
+
_2 = sessionState;
|
|
2165
2172
|
return [4 /*yield*/, this._sessionState.set("mediaSeq", sessionState.mediaSeq + endMseqValue)];
|
|
2166
2173
|
case 61:
|
|
2167
|
-
|
|
2168
|
-
|
|
2174
|
+
_2.mediaSeq = _13.sent();
|
|
2175
|
+
_3 = sessionState;
|
|
2169
2176
|
return [4 /*yield*/, this._sessionState.set("mediaSeqAudio", sessionState.mediaSeqAudio + endMseqValueAudio)];
|
|
2170
2177
|
case 62:
|
|
2171
|
-
|
|
2172
|
-
|
|
2178
|
+
_3.mediaSeqAudio = _13.sent();
|
|
2179
|
+
_4 = sessionState;
|
|
2173
2180
|
return [4 /*yield*/, this._sessionState.set("mediaSeqSubtitle", sessionState.mediaSeqSubtitle + endMseqValueSubtitle)];
|
|
2174
2181
|
case 63:
|
|
2175
|
-
|
|
2176
|
-
|
|
2182
|
+
_4.mediaSeqSubtitle = _13.sent();
|
|
2183
|
+
_5 = sessionState;
|
|
2177
2184
|
return [4 /*yield*/, this._sessionState.set("discSeq", sessionState.discSeq + lastDiscontinuity)];
|
|
2178
2185
|
case 64:
|
|
2179
|
-
|
|
2180
|
-
|
|
2186
|
+
_5.discSeq = _13.sent();
|
|
2187
|
+
_6 = sessionState;
|
|
2181
2188
|
return [4 /*yield*/, this._sessionState.set("discSeqAudio", sessionState.discSeqAudio + lastDiscontinuityAudio)];
|
|
2182
2189
|
case 65:
|
|
2183
|
-
|
|
2184
|
-
|
|
2190
|
+
_6.discSeqAudio = _13.sent();
|
|
2191
|
+
_7 = sessionState;
|
|
2185
2192
|
return [4 /*yield*/, this._sessionState.set("discSeqSubtitle", sessionState.discSeqSubtitle + lastDiscontinuitySubtitle)];
|
|
2186
2193
|
case 66:
|
|
2187
|
-
|
|
2194
|
+
_7.discSeqSubtitle = _13.sent();
|
|
2188
2195
|
debug("[".concat(this._sessionId, "]: new sequence data set in store V[").concat(sessionState.mediaSeq, "][").concat(sessionState.discSeq, "]_A[").concat(sessionState.mediaSeqAudio, "][").concat(sessionState.discSeqAudio, "]_S[").concat(sessionState.mediaSeqSubtitle, "][").concat(sessionState.discSeqSubtitle, "]"));
|
|
2189
2196
|
return [4 /*yield*/, this._sessionState.remove("nextVod")];
|
|
2190
2197
|
case 67:
|
|
2191
|
-
|
|
2198
|
+
_13.sent();
|
|
2192
2199
|
this.leaderIsSettingNextVod = false;
|
|
2193
2200
|
return [4 /*yield*/, this._playheadState.set("diffCompensation", this.diffCompensation, isLeader)];
|
|
2194
2201
|
case 68:
|
|
2195
|
-
|
|
2202
|
+
_13.sent();
|
|
2196
2203
|
debug("[".concat(this._sessionId, "]: sharing durrent vods diffCompensation=").concat(this.diffCompensation));
|
|
2197
2204
|
this.produceEvent({
|
|
2198
2205
|
type: 'NOW_PLAYING',
|
|
@@ -2205,19 +2212,19 @@ var Session = /** @class */ (function () {
|
|
|
2205
2212
|
case 69:
|
|
2206
2213
|
debug("[".concat(this._sessionId, "]: not a leader so will go directly to state VOD_NEXT_INITIATING"));
|
|
2207
2214
|
this.waitingForNextVod = true;
|
|
2208
|
-
|
|
2215
|
+
_8 = sessionState;
|
|
2209
2216
|
return [4 /*yield*/, this._sessionState.set("state", SessionState.VOD_NEXT_INITIATING)];
|
|
2210
2217
|
case 70:
|
|
2211
|
-
|
|
2218
|
+
_8.state = _13.sent();
|
|
2212
2219
|
// Allow Leader|Follower to clear vodCache...
|
|
2213
2220
|
this.isAllowedToClearVodCache = true;
|
|
2214
|
-
|
|
2221
|
+
_9 = sessionState;
|
|
2215
2222
|
return [4 /*yield*/, this._sessionState.getCurrentVod()];
|
|
2216
2223
|
case 71:
|
|
2217
|
-
|
|
2224
|
+
_9.currentVod = _13.sent();
|
|
2218
2225
|
return [4 /*yield*/, this._playheadState.get("diffCompensation")];
|
|
2219
2226
|
case 72:
|
|
2220
|
-
diffMs =
|
|
2227
|
+
diffMs = _13.sent();
|
|
2221
2228
|
if (diffMs) {
|
|
2222
2229
|
this.diffCompensation = diffMs;
|
|
2223
2230
|
debug("[".concat(this._sessionId, "]: Setting diffCompensation=").concat(this.diffCompensation));
|
|
@@ -2229,10 +2236,10 @@ var Session = /** @class */ (function () {
|
|
|
2229
2236
|
this.timePositionOffset = 0;
|
|
2230
2237
|
}
|
|
2231
2238
|
}
|
|
2232
|
-
|
|
2239
|
+
_13.label = 73;
|
|
2233
2240
|
case 73: return [3 /*break*/, 77];
|
|
2234
2241
|
case 74:
|
|
2235
|
-
err_8 =
|
|
2242
|
+
err_8 = _13.sent();
|
|
2236
2243
|
console.error("[".concat(this._sessionId, "]: Failed to init next VOD"));
|
|
2237
2244
|
debug("[".concat(this._sessionId, "]: ").concat(err_8));
|
|
2238
2245
|
if (this._assetManager.handleError) {
|
|
@@ -2241,10 +2248,10 @@ var Session = /** @class */ (function () {
|
|
|
2241
2248
|
cloudWatchLog(!this.cloudWatchLogging, 'engine-session', { event: 'error', on: 'nextvod', channel: this._sessionId, err: err_8, vod: vodResponse });
|
|
2242
2249
|
return [4 /*yield*/, this._sessionState.remove("nextVod")];
|
|
2243
2250
|
case 75:
|
|
2244
|
-
|
|
2251
|
+
_13.sent();
|
|
2245
2252
|
return [4 /*yield*/, this._insertSlate(currentVod)];
|
|
2246
2253
|
case 76:
|
|
2247
|
-
currentVod =
|
|
2254
|
+
currentVod = _13.sent();
|
|
2248
2255
|
if (!currentVod) {
|
|
2249
2256
|
debug("No slate to load");
|
|
2250
2257
|
throw err_8;
|
|
@@ -2254,20 +2261,20 @@ var Session = /** @class */ (function () {
|
|
|
2254
2261
|
return [3 /*break*/, 77];
|
|
2255
2262
|
case 77: return [3 /*break*/, 105];
|
|
2256
2263
|
case 78:
|
|
2257
|
-
|
|
2264
|
+
_13.trys.push([78, 98, , 99]);
|
|
2258
2265
|
debug("[".concat(this._sessionId, "]: state=VOD_RELOAD_INIT"));
|
|
2259
2266
|
if (!isLeader) return [3 /*break*/, 95];
|
|
2260
2267
|
startTS = Date.now();
|
|
2261
2268
|
// 1) To tell Follower that, Leader is working on it!
|
|
2262
|
-
|
|
2269
|
+
_10 = sessionState;
|
|
2263
2270
|
return [4 /*yield*/, this._sessionState.set("state", SessionState.VOD_RELOAD_INITIATING)];
|
|
2264
2271
|
case 79:
|
|
2265
2272
|
// 1) To tell Follower that, Leader is working on it!
|
|
2266
|
-
|
|
2273
|
+
_10.state = _13.sent();
|
|
2267
2274
|
mSeq = this.switchDataForSession.mediaSeq;
|
|
2268
2275
|
return [4 /*yield*/, this._sessionState.getCurrentVod()];
|
|
2269
2276
|
case 80:
|
|
2270
|
-
currentVod_2 =
|
|
2277
|
+
currentVod_2 = _13.sent();
|
|
2271
2278
|
if (currentVod_2.sequenceAlwaysContainNewSegments) {
|
|
2272
2279
|
// (!) will need to compensate if using this setting on HLSVod Object.
|
|
2273
2280
|
Object.keys(this.switchDataForSession.transitionSegments).forEach(function (bw) {
|
|
@@ -2287,20 +2294,20 @@ var Session = /** @class */ (function () {
|
|
|
2287
2294
|
}
|
|
2288
2295
|
return [4 /*yield*/, this._sessionState.set("mediaSeq", mSeq)];
|
|
2289
2296
|
case 81:
|
|
2290
|
-
|
|
2297
|
+
_13.sent();
|
|
2291
2298
|
return [4 /*yield*/, this._playheadState.set("mediaSeq", mSeq, isLeader)];
|
|
2292
2299
|
case 82:
|
|
2293
|
-
|
|
2300
|
+
_13.sent();
|
|
2294
2301
|
return [4 /*yield*/, this._sessionState.set("discSeq", dSeq)];
|
|
2295
2302
|
case 83:
|
|
2296
|
-
|
|
2303
|
+
_13.sent();
|
|
2297
2304
|
// TODO: support demux^
|
|
2298
2305
|
debug("[".concat(this._sessionId, "]: Setting current media and discontinuity count -> [").concat(mSeq, "]:[").concat(dSeq, "]"));
|
|
2299
2306
|
// 3) Set new media segments/currentVod, to carry on the continuity from session-live
|
|
2300
2307
|
debug("[".concat(this._sessionId, "]: LEADER: making changes to current VOD. I will also update currentVod in store."));
|
|
2301
2308
|
return [4 /*yield*/, this._playheadState.getValues(["vodMediaSeqVideo"])];
|
|
2302
2309
|
case 84:
|
|
2303
|
-
playheadState =
|
|
2310
|
+
playheadState = _13.sent();
|
|
2304
2311
|
nextMseq = playheadState.vodMediaSeqVideo + 1;
|
|
2305
2312
|
if (nextMseq > currentVod_2.getLiveMediaSequencesCount() - 1) {
|
|
2306
2313
|
nextMseq = currentVod_2.getLiveMediaSequencesCount() - 1;
|
|
@@ -2313,34 +2320,35 @@ var Session = /** @class */ (function () {
|
|
|
2313
2320
|
// ---------------------------------------------------.
|
|
2314
2321
|
// TODO: Support reloading with audioSegments and SubtitleSegments as well |
|
|
2315
2322
|
// ---------------------------------------------------'
|
|
2316
|
-
|
|
2323
|
+
_13.sent();
|
|
2317
2324
|
return [4 /*yield*/, this._sessionState.setCurrentVod(currentVod_2, { ttl: currentVod_2.getDuration() * 1000 })];
|
|
2318
2325
|
case 86:
|
|
2319
|
-
|
|
2326
|
+
_13.sent();
|
|
2320
2327
|
return [4 /*yield*/, this._sessionState.set("vodReloaded", 1)];
|
|
2321
2328
|
case 87:
|
|
2322
|
-
|
|
2329
|
+
_13.sent();
|
|
2323
2330
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqVideo", 0)];
|
|
2324
2331
|
case 88:
|
|
2325
|
-
|
|
2332
|
+
_13.sent();
|
|
2326
2333
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqAudio", 0)];
|
|
2327
2334
|
case 89:
|
|
2328
|
-
|
|
2335
|
+
_13.sent();
|
|
2329
2336
|
return [4 /*yield*/, this._sessionState.set("vodMediaSeqSubtitle", 0)];
|
|
2330
2337
|
case 90:
|
|
2331
|
-
|
|
2338
|
+
_13.sent();
|
|
2332
2339
|
return [4 /*yield*/, this._playheadState.set("vodMediaSeqVideo", 0, isLeader)];
|
|
2333
2340
|
case 91:
|
|
2334
|
-
|
|
2341
|
+
_13.sent();
|
|
2335
2342
|
return [4 /*yield*/, this._playheadState.set("vodMediaSeqAudio", 0, isLeader)];
|
|
2336
2343
|
case 92:
|
|
2337
|
-
|
|
2344
|
+
_13.sent();
|
|
2338
2345
|
return [4 /*yield*/, this._playheadState.set("vodMediaSeqSubtitle", 0, isLeader)];
|
|
2339
2346
|
case 93:
|
|
2340
|
-
|
|
2347
|
+
_13.sent();
|
|
2348
|
+
_11 = this;
|
|
2341
2349
|
return [4 /*yield*/, this._playheadState.set("playheadRef", Date.now(), isLeader)];
|
|
2342
2350
|
case 94:
|
|
2343
|
-
|
|
2351
|
+
_11.currentPlayheadRef = _13.sent();
|
|
2344
2352
|
// 4) Log to debug and cloudwatch
|
|
2345
2353
|
debug("[".concat(this._sessionId, "]: LEADER: Set new Reloaded VOD and vodMediaSeq counts in store."));
|
|
2346
2354
|
debug("[".concat(this._sessionId, "]: next VOD Reloaded (").concat(currentVod_2.getDeltaTimes(), ")"));
|
|
@@ -2350,14 +2358,14 @@ var Session = /** @class */ (function () {
|
|
|
2350
2358
|
return [2 /*return*/];
|
|
2351
2359
|
case 95:
|
|
2352
2360
|
debug("[".concat(this._sessionId, "]: not a leader so will go directly to state VOD_RELOAD_INITIATING"));
|
|
2353
|
-
|
|
2361
|
+
_12 = sessionState;
|
|
2354
2362
|
return [4 /*yield*/, this._sessionState.set("state", SessionState.VOD_RELOAD_INITIATING)];
|
|
2355
2363
|
case 96:
|
|
2356
|
-
|
|
2357
|
-
|
|
2364
|
+
_12.state = _13.sent();
|
|
2365
|
+
_13.label = 97;
|
|
2358
2366
|
case 97: return [3 /*break*/, 99];
|
|
2359
2367
|
case 98:
|
|
2360
|
-
err_9 =
|
|
2368
|
+
err_9 = _13.sent();
|
|
2361
2369
|
debug("Failed to init reload vod");
|
|
2362
2370
|
throw err_9;
|
|
2363
2371
|
case 99: return [3 /*break*/, 105];
|
|
@@ -2369,11 +2377,11 @@ var Session = /** @class */ (function () {
|
|
|
2369
2377
|
debug("[".concat(this._sessionId, "]: First mediasequence in VOD and I am not the leader so invalidate current VOD cache and fetch the new one from the leader"));
|
|
2370
2378
|
return [4 /*yield*/, this._sessionState.clearCurrentVodCache()];
|
|
2371
2379
|
case 101:
|
|
2372
|
-
|
|
2373
|
-
|
|
2380
|
+
_13.sent();
|
|
2381
|
+
_13.label = 102;
|
|
2374
2382
|
case 102:
|
|
2375
2383
|
this.waitingForNextVod = true;
|
|
2376
|
-
|
|
2384
|
+
_13.label = 103;
|
|
2377
2385
|
case 103:
|
|
2378
2386
|
// Allow Leader|Follower to clear vodCache...
|
|
2379
2387
|
this.isAllowedToClearVodCache = true;
|
|
@@ -2429,7 +2437,9 @@ var Session = /** @class */ (function () {
|
|
|
2429
2437
|
dummySubtitleEndpoint: _this.dummySubtitleEndpoint,
|
|
2430
2438
|
subtitleSliceEndpoint: _this.subtitleSliceEndpoint,
|
|
2431
2439
|
shouldContainSubtitles: _this.use_vtt_subtitles,
|
|
2432
|
-
expectedSubtitleTracks: _this._subtitleTracks
|
|
2440
|
+
expectedSubtitleTracks: _this._subtitleTracks,
|
|
2441
|
+
alwaysMapBandwidthByNearest: _this.alwaysMapBandwidthByNearest,
|
|
2442
|
+
skipSerializeMediaSequences: _this.partialStoreHLSVod
|
|
2433
2443
|
};
|
|
2434
2444
|
var timestamp = Date.now();
|
|
2435
2445
|
hlsVod_1 = new HLSVod(_this.slateUri, null, timestamp, null, m3u8Header(_this._instanceId), hlsOpts);
|
|
@@ -2482,7 +2492,11 @@ var Session = /** @class */ (function () {
|
|
|
2482
2492
|
var _this = this;
|
|
2483
2493
|
return new Promise(function (resolve, reject) {
|
|
2484
2494
|
try {
|
|
2485
|
-
var
|
|
2495
|
+
var options = {};
|
|
2496
|
+
if (vodResponse.startOffset) {
|
|
2497
|
+
options.offset = vodResponse.startOffset / 1000;
|
|
2498
|
+
}
|
|
2499
|
+
var truncatedVod_1 = new HLSTruncateVod(vodResponse.uri, vodResponse.desiredDuration / 1000, options);
|
|
2486
2500
|
truncatedVod_1.load()
|
|
2487
2501
|
.then(function () {
|
|
2488
2502
|
var audioManifestLoader;
|
|
@@ -2532,7 +2546,9 @@ var Session = /** @class */ (function () {
|
|
|
2532
2546
|
dummySubtitleEndpoint: _this.dummySubtitleEndpoint,
|
|
2533
2547
|
subtitleSliceEndpoint: _this.subtitleSliceEndpoint,
|
|
2534
2548
|
shouldContainSubtitles: _this.use_vtt_subtitles,
|
|
2535
|
-
expectedSubtitleTracks: _this._subtitleTracks
|
|
2549
|
+
expectedSubtitleTracks: _this._subtitleTracks,
|
|
2550
|
+
alwaysMapBandwidthByNearest: _this.alwaysMapBandwidthByNearest,
|
|
2551
|
+
skipSerializeMediaSequences: _this.partialStoreHLSVod
|
|
2536
2552
|
};
|
|
2537
2553
|
var timestamp = Date.now();
|
|
2538
2554
|
hlsVod_2 = new HLSVod(nexVodUri, null, timestamp, null, m3u8Header(_this._instanceId), hlsOpts);
|