eyevinn-channel-engine 4.0.8 → 4.0.9
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/engine/redis_state_store.d.ts +1 -0
- package/dist/engine/redis_state_store.js +8 -3
- package/dist/engine/server.d.ts +1 -0
- package/dist/engine/server.js +3 -0
- package/dist/engine/session.js +6 -2
- package/dist/package.json +1 -1
- package/engine/redis_state_store.js +8 -3
- package/engine/server.ts +4 -0
- package/engine/session.js +6 -2
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
var redis = require("redis");
|
|
38
38
|
var debug = require("debug")("redis-state-store");
|
|
39
|
-
var
|
|
39
|
+
var DEFAULT_VOLATILE_KEY_TTL = 5; // Timeout so it should not expire within one normal increment iteration (in seconds)
|
|
40
40
|
var RedisStateStore = /** @class */ (function () {
|
|
41
41
|
function RedisStateStore(keyPrefix, opts) {
|
|
42
42
|
this.keyPrefix = keyPrefix;
|
|
@@ -45,6 +45,11 @@ var RedisStateStore = /** @class */ (function () {
|
|
|
45
45
|
this.keyPrefix = prependPrefix + this.keyPrefix;
|
|
46
46
|
debug("Prepending keyprefix with ".concat(prependPrefix, " => ").concat(this.keyPrefix));
|
|
47
47
|
}
|
|
48
|
+
this.volatileKeyTTL = DEFAULT_VOLATILE_KEY_TTL;
|
|
49
|
+
if (opts.volatileKeyTTL) {
|
|
50
|
+
debug("Overriding default, volatileKeyTTL=".concat(opts.volatileKeyTTL, "s"));
|
|
51
|
+
this.volatileKeyTTL = opts.volatileKeyTTL;
|
|
52
|
+
}
|
|
48
53
|
this.client = redis.createClient(opts.redisUrl);
|
|
49
54
|
}
|
|
50
55
|
RedisStateStore.prototype.initAsync = function (id, initData) {
|
|
@@ -187,9 +192,9 @@ var RedisStateStore = /** @class */ (function () {
|
|
|
187
192
|
data = _a.sent();
|
|
188
193
|
storeKey = "" + this.keyPrefix + id + key;
|
|
189
194
|
expireAsync = new Promise(function (resolve, reject) {
|
|
190
|
-
_this.client.expire(storeKey,
|
|
195
|
+
_this.client.expire(storeKey, _this.volatileKeyTTL, function (err, res) {
|
|
191
196
|
if (!err) {
|
|
192
|
-
debug("REDIS expire ".concat(storeKey, " ").concat(
|
|
197
|
+
debug("REDIS expire ".concat(storeKey, " ").concat(_this.volatileKeyTTL, "s: ").concat(res === 1 ? "OK" : "KEY DOES NOT EXIST"));
|
|
193
198
|
resolve();
|
|
194
199
|
}
|
|
195
200
|
else {
|
package/dist/engine/server.d.ts
CHANGED
package/dist/engine/server.js
CHANGED
|
@@ -101,11 +101,13 @@ var ChannelEngine = /** @class */ (function () {
|
|
|
101
101
|
redisUrl: options.redisUrl,
|
|
102
102
|
memcachedUrl: options.memcachedUrl,
|
|
103
103
|
cacheTTL: options.sharedStoreCacheTTL,
|
|
104
|
+
volatileKeyTTL: options.volatileKeyTTL,
|
|
104
105
|
}),
|
|
105
106
|
playheadStateStore: new PlayheadStateStore({
|
|
106
107
|
redisUrl: options.redisUrl,
|
|
107
108
|
memcachedUrl: options.memcachedUrl,
|
|
108
109
|
cacheTTL: options.sharedStoreCacheTTL,
|
|
110
|
+
volatileKeyTTL: options.volatileKeyTTL,
|
|
109
111
|
}),
|
|
110
112
|
instanceId: this.instanceId,
|
|
111
113
|
};
|
|
@@ -114,6 +116,7 @@ var ChannelEngine = /** @class */ (function () {
|
|
|
114
116
|
redisUrl: options.redisUrl,
|
|
115
117
|
memcachedUrl: options.memcachedUrl,
|
|
116
118
|
cacheTTL: options.sharedStoreCacheTTL,
|
|
119
|
+
volatileKeyTTL: options.volatileKeyTTL,
|
|
117
120
|
}),
|
|
118
121
|
instanceId: this.instanceId,
|
|
119
122
|
};
|
package/dist/engine/session.js
CHANGED
|
@@ -1031,6 +1031,7 @@ var Session = /** @class */ (function () {
|
|
|
1031
1031
|
index = 0;
|
|
1032
1032
|
audioSeqLastIdx = currentVod_1.getLiveMediaSequencesCount("audio") - 1;
|
|
1033
1033
|
thresh = 0.5;
|
|
1034
|
+
debug("[".concat(this._sessionId, "]: About to determine audio increment"));
|
|
1034
1035
|
_o.label = 19;
|
|
1035
1036
|
case 19: return [4 /*yield*/, this._getAudioPlayheadPosition(sessionState_1.vodMediaSeqAudio + index)];
|
|
1036
1037
|
case 20:
|
|
@@ -1058,6 +1059,7 @@ var Session = /** @class */ (function () {
|
|
|
1058
1059
|
audioIncrement = index;
|
|
1059
1060
|
_o.label = 23;
|
|
1060
1061
|
case 23:
|
|
1062
|
+
debug("[".concat(this._sessionId, "]: Will increment audio with ").concat(audioIncrement));
|
|
1061
1063
|
_d = sessionState;
|
|
1062
1064
|
return [4 /*yield*/, this._sessionState.increment("vodMediaSeqAudio", audioIncrement)];
|
|
1063
1065
|
case 24:
|
|
@@ -1636,7 +1638,8 @@ var Session = /** @class */ (function () {
|
|
|
1636
1638
|
cloudWatchLog(!this.cloudWatchLogging, 'engine-session', { event: 'loadVod', channel: this._sessionId, loadTimeMs: Date.now() - loadStart });
|
|
1637
1639
|
debug("[".concat(this._sessionId, "]: first VOD loaded"));
|
|
1638
1640
|
debug("[".concat(this._sessionId, "]: ").concat(currentVod.getDeltaTimes()));
|
|
1639
|
-
debug("[".concat(this._sessionId, "]: ").concat(currentVod.getPlayheadPositions()));
|
|
1641
|
+
debug("[".concat(this._sessionId, "]: playhead positions [V]=").concat(currentVod.getPlayheadPositions("video")));
|
|
1642
|
+
debug("[".concat(this._sessionId, "]: playhead positions [A]=").concat(currentVod.getPlayheadPositions("audio")));
|
|
1640
1643
|
//debug(newVod);
|
|
1641
1644
|
_c = sessionState;
|
|
1642
1645
|
return [4 /*yield*/, this._sessionState.set("mediaSeq", 0)];
|
|
@@ -1858,7 +1861,8 @@ var Session = /** @class */ (function () {
|
|
|
1858
1861
|
cloudWatchLog(!this.cloudWatchLogging, 'engine-session', { event: 'loadVod', channel: this._sessionId, loadTimeMs: Date.now() - loadStart });
|
|
1859
1862
|
this.leaderIsSettingNextVod = true;
|
|
1860
1863
|
debug("[".concat(this._sessionId, "]: next VOD loaded (").concat(newVod.getDeltaTimes(), ")"));
|
|
1861
|
-
debug("[".concat(this._sessionId, "]: ").concat(newVod.getPlayheadPositions()));
|
|
1864
|
+
debug("[".concat(this._sessionId, "]: playhead positions [V]=").concat(newVod.getPlayheadPositions("video")));
|
|
1865
|
+
debug("[".concat(this._sessionId, "]: playhead positions [A]=").concat(newVod.getPlayheadPositions("audio")));
|
|
1862
1866
|
currentVod = newVod;
|
|
1863
1867
|
debug("[".concat(this._sessionId, "]: msequences=").concat(currentVod.getLiveMediaSequencesCount(), "; audio msequences=").concat(currentVod.getLiveMediaSequencesCount("audio")));
|
|
1864
1868
|
_r = sessionState;
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const redis = require("redis");
|
|
2
2
|
const debug = require("debug")("redis-state-store");
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const DEFAULT_VOLATILE_KEY_TTL = 5; // Timeout so it should not expire within one normal increment iteration (in seconds)
|
|
5
5
|
|
|
6
6
|
class RedisStateStore {
|
|
7
7
|
constructor(keyPrefix, opts) {
|
|
@@ -11,6 +11,11 @@ class RedisStateStore {
|
|
|
11
11
|
this.keyPrefix = prependPrefix + this.keyPrefix;
|
|
12
12
|
debug(`Prepending keyprefix with ${prependPrefix} => ${this.keyPrefix}`);
|
|
13
13
|
}
|
|
14
|
+
this.volatileKeyTTL = DEFAULT_VOLATILE_KEY_TTL;
|
|
15
|
+
if (opts.volatileKeyTTL) {
|
|
16
|
+
debug(`Overriding default, volatileKeyTTL=${opts.volatileKeyTTL}s`);
|
|
17
|
+
this.volatileKeyTTL = opts.volatileKeyTTL;
|
|
18
|
+
}
|
|
14
19
|
this.client = redis.createClient(opts.redisUrl);
|
|
15
20
|
}
|
|
16
21
|
|
|
@@ -82,9 +87,9 @@ class RedisStateStore {
|
|
|
82
87
|
const data = await this.setAsync(id, key, value);
|
|
83
88
|
const storeKey = "" + this.keyPrefix + id + key;
|
|
84
89
|
const expireAsync = new Promise((resolve, reject) => {
|
|
85
|
-
this.client.expire(storeKey,
|
|
90
|
+
this.client.expire(storeKey, this.volatileKeyTTL, (err, res) => {
|
|
86
91
|
if (!err) {
|
|
87
|
-
debug(`REDIS expire ${storeKey} ${
|
|
92
|
+
debug(`REDIS expire ${storeKey} ${this.volatileKeyTTL}s: ${res === 1 ? "OK" : "KEY DOES NOT EXIST"}`);
|
|
88
93
|
resolve();
|
|
89
94
|
} else {
|
|
90
95
|
reject(err);
|
package/engine/server.ts
CHANGED
|
@@ -47,6 +47,7 @@ export interface ChannelEngineOpts {
|
|
|
47
47
|
adCopyMgrUri?: string; // deprecated
|
|
48
48
|
adXchangeUri?: string; // deprecated
|
|
49
49
|
noSessionDataTags?: boolean;
|
|
50
|
+
volatileKeyTTL?: number;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
interface StreamerOpts {
|
|
@@ -206,11 +207,13 @@ export class ChannelEngine {
|
|
|
206
207
|
redisUrl: options.redisUrl,
|
|
207
208
|
memcachedUrl: options.memcachedUrl,
|
|
208
209
|
cacheTTL: options.sharedStoreCacheTTL,
|
|
210
|
+
volatileKeyTTL: options.volatileKeyTTL,
|
|
209
211
|
}),
|
|
210
212
|
playheadStateStore: new PlayheadStateStore({
|
|
211
213
|
redisUrl: options.redisUrl,
|
|
212
214
|
memcachedUrl: options.memcachedUrl,
|
|
213
215
|
cacheTTL: options.sharedStoreCacheTTL,
|
|
216
|
+
volatileKeyTTL: options.volatileKeyTTL,
|
|
214
217
|
}),
|
|
215
218
|
instanceId: this.instanceId,
|
|
216
219
|
};
|
|
@@ -220,6 +223,7 @@ export class ChannelEngine {
|
|
|
220
223
|
redisUrl: options.redisUrl,
|
|
221
224
|
memcachedUrl: options.memcachedUrl,
|
|
222
225
|
cacheTTL: options.sharedStoreCacheTTL,
|
|
226
|
+
volatileKeyTTL: options.volatileKeyTTL,
|
|
223
227
|
}),
|
|
224
228
|
instanceId: this.instanceId,
|
|
225
229
|
};
|
package/engine/session.js
CHANGED
|
@@ -733,6 +733,7 @@ class Session {
|
|
|
733
733
|
let index = 0;
|
|
734
734
|
const audioSeqLastIdx = currentVod.getLiveMediaSequencesCount("audio") - 1;
|
|
735
735
|
const thresh = 0.5;
|
|
736
|
+
debug(`[${this._sessionId}]: About to determine audio increment`);
|
|
736
737
|
do {
|
|
737
738
|
const audioPosition = (await this._getAudioPlayheadPosition(sessionState.vodMediaSeqAudio + index)) * 1000;
|
|
738
739
|
posDiff = position - audioPosition;
|
|
@@ -752,6 +753,7 @@ class Session {
|
|
|
752
753
|
} while (!(-thresh < posDiff && posDiff < thresh));
|
|
753
754
|
audioIncrement = index;
|
|
754
755
|
}
|
|
756
|
+
debug(`[${this._sessionId}]: Will increment audio with ${audioIncrement}`);
|
|
755
757
|
sessionState.vodMediaSeqAudio = await this._sessionState.increment("vodMediaSeqAudio", audioIncrement);
|
|
756
758
|
}
|
|
757
759
|
|
|
@@ -1160,7 +1162,8 @@ class Session {
|
|
|
1160
1162
|
{ event: 'loadVod', channel: this._sessionId, loadTimeMs: Date.now() - loadStart });
|
|
1161
1163
|
debug(`[${this._sessionId}]: first VOD loaded`);
|
|
1162
1164
|
debug(`[${this._sessionId}]: ${currentVod.getDeltaTimes()}`);
|
|
1163
|
-
debug(`[${this._sessionId}]:
|
|
1165
|
+
debug(`[${this._sessionId}]: playhead positions [V]=${currentVod.getPlayheadPositions("video")}`);
|
|
1166
|
+
debug(`[${this._sessionId}]: playhead positions [A]=${currentVod.getPlayheadPositions("audio")}`);
|
|
1164
1167
|
//debug(newVod);
|
|
1165
1168
|
sessionState.mediaSeq = await this._sessionState.set("mediaSeq", 0);
|
|
1166
1169
|
sessionState.mediaSeqAudio = await this._sessionState.set("mediaSeqAudio", 0);
|
|
@@ -1323,7 +1326,8 @@ class Session {
|
|
|
1323
1326
|
{ event: 'loadVod', channel: this._sessionId, loadTimeMs: Date.now() - loadStart });
|
|
1324
1327
|
this.leaderIsSettingNextVod = true;
|
|
1325
1328
|
debug(`[${this._sessionId}]: next VOD loaded (${newVod.getDeltaTimes()})`);
|
|
1326
|
-
debug(`[${this._sessionId}]:
|
|
1329
|
+
debug(`[${this._sessionId}]: playhead positions [V]=${newVod.getPlayheadPositions("video")}`);
|
|
1330
|
+
debug(`[${this._sessionId}]: playhead positions [A]=${newVod.getPlayheadPositions("audio")}`);
|
|
1327
1331
|
currentVod = newVod;
|
|
1328
1332
|
debug(`[${this._sessionId}]: msequences=${currentVod.getLiveMediaSequencesCount()}; audio msequences=${currentVod.getLiveMediaSequencesCount("audio")}`);
|
|
1329
1333
|
sessionState.vodMediaSeqVideo = await this._sessionState.set("vodMediaSeqVideo", 0);
|