eyevinn-channel-engine 5.0.6 → 5.1.2

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.
Files changed (36) hide show
  1. package/.github/workflows/nodejs.yml +4 -4
  2. package/.github/workflows/publish.yml +5 -5
  3. package/.github/workflows/rc.yml +5 -5
  4. package/dist/engine/chaos_monkey.js +12 -51
  5. package/dist/engine/event_stream.js +9 -10
  6. package/dist/engine/index.d.ts +1 -0
  7. package/dist/engine/index.js +2 -0
  8. package/dist/engine/memcached_state_store.js +53 -165
  9. package/dist/engine/memory_state_store.js +52 -129
  10. package/dist/engine/playhead_state.js +53 -156
  11. package/dist/engine/preflight.js +13 -52
  12. package/dist/engine/redis_state_store.js +162 -332
  13. package/dist/engine/server.js +799 -1287
  14. package/dist/engine/session.js +1793 -2543
  15. package/dist/engine/session_live.js +1759 -2254
  16. package/dist/engine/session_live_state.js +84 -206
  17. package/dist/engine/session_state.js +178 -356
  18. package/dist/engine/shared_state_store.js +69 -206
  19. package/dist/engine/stream_switcher.js +675 -902
  20. package/dist/engine/subtitle_slicer.js +135 -200
  21. package/dist/engine/util.js +133 -200
  22. package/dist/examples/autocreate.js +34 -35
  23. package/dist/examples/default.js +32 -32
  24. package/dist/examples/demux.js +29 -32
  25. package/dist/examples/drm.js +25 -28
  26. package/dist/examples/livemix-demux.js +79 -80
  27. package/dist/examples/livemix.js +71 -72
  28. package/dist/examples/multicodec.js +26 -29
  29. package/dist/examples/truncate.js +31 -32
  30. package/dist/package.json +16 -14
  31. package/engine/server.ts +1 -1
  32. package/package.json +16 -14
  33. package/tsconfig.json +3 -1
  34. package/dist/engine/ad_request.d.ts +0 -14
  35. package/dist/engine/ad_request.js +0 -121
  36. package/engine/ad_request.js +0 -188
@@ -1,175 +1,72 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
- var SharedStateStore = require('./shared_state_store.js');
53
- var PlayheadState = Object.freeze({
1
+ "use strict";
2
+ const SharedStateStore = require('./shared_state_store.js');
3
+ const PlayheadState = Object.freeze({
54
4
  RUNNING: 1,
55
5
  STOPPED: 2,
56
6
  CRASHED: 3,
57
7
  IDLE: 4
58
8
  });
59
- var SharedPlayheadState = /** @class */ (function () {
60
- function SharedPlayheadState(store, sessionId, opts) {
9
+ class SharedPlayheadState {
10
+ constructor(store, sessionId, opts) {
61
11
  this.sessionId = sessionId;
62
12
  this.store = store;
63
13
  this.state = PlayheadState.IDLE;
64
14
  this.lastM3u8 = null;
65
15
  }
66
- SharedPlayheadState.prototype.get = function (key) {
67
- return __awaiter(this, void 0, void 0, function () {
68
- return __generator(this, function (_a) {
69
- switch (_a.label) {
70
- case 0: return [4 /*yield*/, this.store.get(this.sessionId, key)];
71
- case 1: return [2 /*return*/, _a.sent()];
72
- }
73
- });
74
- });
75
- };
76
- SharedPlayheadState.prototype.getState = function () {
77
- return __awaiter(this, void 0, void 0, function () {
78
- return __generator(this, function (_a) {
79
- return [2 /*return*/, this.state];
80
- });
81
- });
82
- };
83
- SharedPlayheadState.prototype.getLastM3u8 = function () {
84
- return __awaiter(this, void 0, void 0, function () {
85
- return __generator(this, function (_a) {
86
- return [2 /*return*/, this.lastM3u8];
87
- });
88
- });
89
- };
90
- SharedPlayheadState.prototype.getValues = function (keys) {
91
- return __awaiter(this, void 0, void 0, function () {
92
- return __generator(this, function (_a) {
93
- switch (_a.label) {
94
- case 0: return [4 /*yield*/, this.store.getValues(this.sessionId, keys)];
95
- case 1: return [2 /*return*/, _a.sent()];
96
- }
97
- });
98
- });
99
- };
100
- SharedPlayheadState.prototype.set = function (key, value, isLeader) {
101
- return __awaiter(this, void 0, void 0, function () {
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0:
105
- if (!isLeader) return [3 /*break*/, 2];
106
- return [4 /*yield*/, this.store.set(this.sessionId, key, value)];
107
- case 1: return [2 /*return*/, _a.sent()];
108
- case 2: return [4 /*yield*/, this.store.get(this.sessionId, key)];
109
- case 3: return [2 /*return*/, _a.sent()];
110
- }
111
- });
112
- });
113
- };
114
- SharedPlayheadState.prototype.setValues = function (keyValues, isLeader) {
115
- return __awaiter(this, void 0, void 0, function () {
116
- return __generator(this, function (_a) {
117
- switch (_a.label) {
118
- case 0:
119
- if (!isLeader) return [3 /*break*/, 2];
120
- return [4 /*yield*/, this.store.setValues(this.sessionId, keyValues)];
121
- case 1: return [2 /*return*/, _a.sent()];
122
- case 2: return [4 /*yield*/, this.store.getValues(this.sessionId, Object.keys(keyValues))];
123
- case 3: return [2 /*return*/, _a.sent()];
124
- }
125
- });
126
- });
127
- };
128
- SharedPlayheadState.prototype.setState = function (newState) {
129
- return __awaiter(this, void 0, void 0, function () {
130
- return __generator(this, function (_a) {
131
- this.state = newState;
132
- return [2 /*return*/, this.state];
133
- });
134
- });
135
- };
136
- SharedPlayheadState.prototype.setLastM3u8 = function (m3u8) {
137
- return __awaiter(this, void 0, void 0, function () {
138
- return __generator(this, function (_a) {
139
- this.lastM3u8 = m3u8;
140
- return [2 /*return*/, this.lastM3u8];
141
- });
142
- });
143
- };
144
- return SharedPlayheadState;
145
- }());
146
- var PlayheadStateStore = /** @class */ (function (_super) {
147
- __extends(PlayheadStateStore, _super);
148
- function PlayheadStateStore(opts) {
149
- return _super.call(this, "playhead", opts, {
16
+ async get(key) {
17
+ return await this.store.get(this.sessionId, key);
18
+ }
19
+ async getState() {
20
+ return this.state;
21
+ }
22
+ async getLastM3u8() {
23
+ return this.lastM3u8;
24
+ }
25
+ async getValues(keys) {
26
+ return await this.store.getValues(this.sessionId, keys);
27
+ }
28
+ async set(key, value, isLeader) {
29
+ if (isLeader) {
30
+ return await this.store.set(this.sessionId, key, value);
31
+ }
32
+ else {
33
+ return await this.store.get(this.sessionId, key);
34
+ }
35
+ }
36
+ async setValues(keyValues, isLeader) {
37
+ if (isLeader) {
38
+ return await this.store.setValues(this.sessionId, keyValues);
39
+ }
40
+ else {
41
+ return await this.store.getValues(this.sessionId, Object.keys(keyValues));
42
+ }
43
+ }
44
+ async setState(newState) {
45
+ this.state = newState;
46
+ return this.state;
47
+ }
48
+ async setLastM3u8(m3u8) {
49
+ this.lastM3u8 = m3u8;
50
+ return this.lastM3u8;
51
+ }
52
+ }
53
+ class PlayheadStateStore extends SharedStateStore {
54
+ constructor(opts) {
55
+ super("playhead", opts, {
150
56
  state: PlayheadState.IDLE,
151
57
  tickInterval: opts ? (opts.averageSegmentDuration / 1000) : 3,
152
58
  mediaSeq: 0,
153
59
  vodMediaSeqVideo: 0,
154
60
  vodMediaSeqAudio: 0,
155
61
  vodMediaSeqSubtitle: 0,
156
- }) || this;
157
- }
158
- PlayheadStateStore.prototype.create = function (sessionId) {
159
- return __awaiter(this, void 0, void 0, function () {
160
- return __generator(this, function (_a) {
161
- switch (_a.label) {
162
- case 0: return [4 /*yield*/, this.init(sessionId)];
163
- case 1:
164
- _a.sent();
165
- return [2 /*return*/, new SharedPlayheadState(this, sessionId)];
166
- }
167
- });
168
62
  });
169
- };
170
- return PlayheadStateStore;
171
- }(SharedStateStore));
63
+ }
64
+ async create(sessionId) {
65
+ await this.init(sessionId);
66
+ return new SharedPlayheadState(this, sessionId);
67
+ }
68
+ }
172
69
  module.exports = {
173
- PlayheadState: PlayheadState,
174
- PlayheadStateStore: PlayheadStateStore
70
+ PlayheadState,
71
+ PlayheadStateStore
175
72
  };
@@ -1,40 +1,5 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var constants = {
1
+ "use strict";
2
+ const constants = {
38
3
  ALLOW_HEADERS: [
39
4
  'accept',
40
5
  'accept-version',
@@ -66,19 +31,15 @@ var constants = {
66
31
  STR_ORIGIN: 'origin',
67
32
  HTTP_NO_CONTENT: 204
68
33
  };
69
- module.exports.handler = function (req, res) {
70
- return __awaiter(this, void 0, void 0, function () {
71
- return __generator(this, function (_a) {
72
- if (req.method !== 'OPTIONS')
73
- return [2 /*return*/];
74
- res
75
- .header(constants.AC_ALLOW_ORIGIN, '*')
76
- .header(constants.AC_ALLOW_CREDS, 'true')
77
- .header(constants.AC_ALLOW_METHODS, 'GET, OPTIONS')
78
- .header(constants.AC_ALLOW_HEADERS, 'x-health-key')
79
- .status(204)
80
- .send();
81
- return [2 /*return*/];
82
- });
83
- });
34
+ module.exports.handler = async function (req, res) {
35
+ if (req.method !== 'OPTIONS')
36
+ return;
37
+ res
38
+ .header(constants.AC_ALLOW_ORIGIN, '*')
39
+ .header(constants.AC_ALLOW_CREDS, 'true')
40
+ .header(constants.AC_ALLOW_METHODS, 'GET, OPTIONS')
41
+ .header(constants.AC_ALLOW_HEADERS, 'x-health-key')
42
+ .status(204)
43
+ .send();
44
+ return;
84
45
  };