@vpalmisano/webrtcperf 4.0.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.
Files changed (53) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +296 -0
  3. package/app.min.js +2 -0
  4. package/build/src/app.d.ts +6 -0
  5. package/build/src/app.js +207 -0
  6. package/build/src/app.js.map +1 -0
  7. package/build/src/config.d.ts +104 -0
  8. package/build/src/config.js +880 -0
  9. package/build/src/config.js.map +1 -0
  10. package/build/src/generate-config-docs.d.ts +1 -0
  11. package/build/src/generate-config-docs.js +41 -0
  12. package/build/src/generate-config-docs.js.map +1 -0
  13. package/build/src/index.d.ts +9 -0
  14. package/build/src/index.js +26 -0
  15. package/build/src/index.js.map +1 -0
  16. package/build/src/media.d.ts +33 -0
  17. package/build/src/media.js +113 -0
  18. package/build/src/media.js.map +1 -0
  19. package/build/src/rtcstats.d.ts +302 -0
  20. package/build/src/rtcstats.js +418 -0
  21. package/build/src/rtcstats.js.map +1 -0
  22. package/build/src/server.d.ts +173 -0
  23. package/build/src/server.js +639 -0
  24. package/build/src/server.js.map +1 -0
  25. package/build/src/session.d.ts +277 -0
  26. package/build/src/session.js +1552 -0
  27. package/build/src/session.js.map +1 -0
  28. package/build/src/stats.d.ts +243 -0
  29. package/build/src/stats.js +1383 -0
  30. package/build/src/stats.js.map +1 -0
  31. package/build/src/utils.d.ts +249 -0
  32. package/build/src/utils.js +1220 -0
  33. package/build/src/utils.js.map +1 -0
  34. package/build/src/visqol.d.ts +6 -0
  35. package/build/src/visqol.js +61 -0
  36. package/build/src/visqol.js.map +1 -0
  37. package/build/src/vmaf.d.ts +83 -0
  38. package/build/src/vmaf.js +624 -0
  39. package/build/src/vmaf.js.map +1 -0
  40. package/build/tsconfig.tsbuildinfo +1 -0
  41. package/package.json +129 -0
  42. package/src/app.ts +241 -0
  43. package/src/config.ts +852 -0
  44. package/src/generate-config-docs.ts +47 -0
  45. package/src/index.ts +9 -0
  46. package/src/media.ts +151 -0
  47. package/src/rtcstats.ts +507 -0
  48. package/src/server.ts +645 -0
  49. package/src/session.ts +1908 -0
  50. package/src/stats.ts +1668 -0
  51. package/src/utils.ts +1295 -0
  52. package/src/visqol.ts +62 -0
  53. package/src/vmaf.ts +771 -0
@@ -0,0 +1,880 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getConfigDocs = getConfigDocs;
40
+ exports.loadConfig = loadConfig;
41
+ const convict_1 = __importStar(require("convict"));
42
+ const convict_format_with_validator_1 = require("convict-format-with-validator");
43
+ const fs_1 = require("fs");
44
+ const os_1 = __importDefault(require("os"));
45
+ const path_1 = require("path");
46
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
47
+ const puppeteer = require('puppeteer-core');
48
+ const utils_1 = require("./utils");
49
+ const log = (0, utils_1.logger)('webrtcperf:config');
50
+ const float = {
51
+ name: 'float',
52
+ coerce: (v) => parseFloat(v),
53
+ validate: (v) => {
54
+ if (!Number.isFinite(v))
55
+ throw new Error(`Invalid float: ${v}`);
56
+ },
57
+ };
58
+ const index = {
59
+ name: 'index',
60
+ coerce: (v) => v,
61
+ validate: (v) => {
62
+ if (typeof v === 'string') {
63
+ if (v === 'true' || v === 'false' || v === '')
64
+ return;
65
+ if (v.includes('-')) {
66
+ v.split('-').forEach(n => {
67
+ if (isNaN(parseInt(n)) || !isFinite(parseInt(n)))
68
+ throw new Error(`Invalid string index: ${n}`);
69
+ });
70
+ return;
71
+ }
72
+ if (v.includes(',')) {
73
+ v.split(',').forEach(n => {
74
+ if (isNaN(parseInt(n)) || !isFinite(parseInt(n)))
75
+ throw new Error(`Invalid string index: ${n}`);
76
+ });
77
+ return;
78
+ }
79
+ if (isNaN(parseInt(v)) || !isFinite(parseInt(v)))
80
+ throw new Error(`Invalid string index: ${v}`);
81
+ return;
82
+ }
83
+ else if (typeof v === 'number' || typeof v === 'boolean') {
84
+ return;
85
+ }
86
+ throw new Error(`Invalid index: "${v}" (type: ${typeof v})`);
87
+ },
88
+ };
89
+ (0, convict_1.addFormats)({ ipaddress: convict_format_with_validator_1.ipaddress, url: convict_format_with_validator_1.url, float, index });
90
+ // config schema
91
+ const configSchema = (0, convict_1.default)({
92
+ url: {
93
+ doc: `The page url to load.`,
94
+ format: String,
95
+ default: '',
96
+ nullable: true,
97
+ env: 'URL',
98
+ arg: 'url',
99
+ },
100
+ urlQuery: {
101
+ doc: `The query string to append to the page url; the following template \
102
+ variables are replaced: \`$p\` the process pid, \`$s\` the session index, \
103
+ \`$S\` the total sessions, \`$t\` the tab index, \`$T\` the total tabs per \
104
+ session, \`$i\` the tab absolute index.`,
105
+ format: String,
106
+ default: '',
107
+ nullable: true,
108
+ env: 'URL_QUERY',
109
+ arg: 'url-query',
110
+ },
111
+ customUrlHandler: {
112
+ doc: `This argument specifies the file path for the custom page URL handler that will be exported by default. \
113
+ The custom page URL handler allows you to define custom URLs that can be used to open your application, \
114
+ and provides the following variables for customization: \`$p\`: the process pid, \`$s\`: the session index, \
115
+ \`$S\`: the total sessions, \`$t\`: the tab index, \`$T\`: the total tabs per session, \`$i\`: the tab absolute index.
116
+ You can use these variables to create custom URL schemes that suit your application's needs.`,
117
+ format: String,
118
+ default: '',
119
+ nullable: true,
120
+ env: 'CUSTOM_URL_HANDLER',
121
+ arg: 'custom-url-handler',
122
+ },
123
+ // fake video/audio
124
+ videoPath: {
125
+ doc: `The fake video path; if set, the video will be used as fake \
126
+ media source. It accepts a single path or a comma-separated list of videos \
127
+ paths that will be used in round-robin by the started sessions. \
128
+ The docker pre-built image contains a 2 minutes video sequence stored at \
129
+ \`/app/video.mp4\`. \
130
+ It accepts a local file, an http endpoint or a string starting with
131
+ \`generate:\` (example: \`generate:null\` will generate a black video with \
132
+ silent audio). \
133
+ The temporary files containing the raw video and audio will be stored at \
134
+ \`\${VIDEO_CACHE_PATH}/video.\${VIDEO_FORMAT}\` and \
135
+ \`\${VIDEO_CACHE_PATH}/audio.wav\`.`,
136
+ format: String,
137
+ default: 'https://github.com/vpalmisano/webrtcperf/releases/download/v2.0.4/video.mp4',
138
+ env: 'VIDEO_PATH',
139
+ arg: 'video-path',
140
+ },
141
+ videoWidth: {
142
+ doc: `The fake video resize width.`,
143
+ format: 'nat',
144
+ default: 1280,
145
+ env: 'VIDEO_WIDTH',
146
+ arg: 'video-width',
147
+ },
148
+ videoHeight: {
149
+ doc: `The fake video resize height.`,
150
+ format: 'nat',
151
+ default: 720,
152
+ env: 'VIDEO_HEIGHT',
153
+ arg: 'video-height',
154
+ },
155
+ videoFramerate: {
156
+ doc: `The fake video framerate.`,
157
+ format: 'nat',
158
+ default: 25,
159
+ env: 'VIDEO_FRAMERATE',
160
+ arg: 'video-framerate',
161
+ },
162
+ videoSeek: {
163
+ doc: `The fake audio/video seek position in seconds.`,
164
+ format: 'nat',
165
+ default: 0,
166
+ env: 'VIDEO_SEEK',
167
+ arg: 'video-seek',
168
+ },
169
+ videoDuration: {
170
+ doc: `The fake audio/video duration in seconds.`,
171
+ format: 'nat',
172
+ default: 120,
173
+ env: 'VIDEO_DURATION',
174
+ arg: 'video-duration',
175
+ },
176
+ videoCacheRaw: {
177
+ doc: `If the temporary video and audio raw files can be reused across \
178
+ multiple runs.`,
179
+ format: 'Boolean',
180
+ default: true,
181
+ env: 'VIDEO_CACHE_RAW',
182
+ arg: 'video-cache-raw',
183
+ },
184
+ videoCachePath: {
185
+ doc: `The path where the video and audio raw files are stored.`,
186
+ format: String,
187
+ default: (0, path_1.join)(os_1.default.homedir(), '.webrtcperf/cache'),
188
+ env: 'VIDEO_CACHE_PATH',
189
+ arg: 'video-cache-path',
190
+ },
191
+ videoFormat: {
192
+ doc: `The fake video file format presented to the browser.`,
193
+ format: ['y4m', 'mjpeg'],
194
+ default: 'y4m',
195
+ env: 'VIDEO_FORMAT',
196
+ arg: 'video-format',
197
+ },
198
+ useFakeMedia: {
199
+ doc: `If true, the audio/video/screenshare will be generated using the browser fake device.
200
+ Otherwise, the audio and video streams will be captured from a video element attached to the page,
201
+ while the screenshare will be captured from a new browser tab.`,
202
+ format: 'Boolean',
203
+ default: true,
204
+ env: 'USE_FAKE_MEDIA',
205
+ arg: 'use-fake-media',
206
+ },
207
+ //
208
+ runDuration: {
209
+ doc: `If greater than 0, the test will stop after the provided number of \
210
+ seconds.`,
211
+ format: 'nat',
212
+ default: 0,
213
+ env: 'RUN_DURATION',
214
+ arg: 'run-duration',
215
+ },
216
+ throttleConfig: {
217
+ doc: `A JSON5 string with a valid throtter configuration (https://github.com/vpalmisano/throttler).`,
218
+ format: String,
219
+ nullable: true,
220
+ default: '',
221
+ env: 'THROTTLE_CONFIG',
222
+ arg: 'throttle-config',
223
+ },
224
+ randomAudioPeriod: {
225
+ doc: `If not zero, it specifies the maximum period in seconds after which \
226
+ a new random active tab is selected, enabling the getUserMedia audio tracks in \
227
+ that tab and disabling all of the other tabs.`,
228
+ format: 'nat',
229
+ default: 0,
230
+ env: 'RANDOM_AUDIO_PERIOD',
231
+ arg: 'random-audio-period',
232
+ },
233
+ randomAudioProbability: {
234
+ doc: `When using random audio period, it defines the probability % that \
235
+ the selected audio will be activated (value: 0-100).`,
236
+ format: 'nat',
237
+ default: 100,
238
+ env: 'RANDOM_AUDIO_PROBABILITY',
239
+ arg: 'random-audio-probability',
240
+ },
241
+ randomAudioRange: {
242
+ doc: `When using random audio period, it defines the number of pages \
243
+ to be included into the random selection.`,
244
+ format: 'nat',
245
+ default: 0,
246
+ env: 'RANDOM_AUDIO_RANGE',
247
+ arg: 'random-audio-range',
248
+ },
249
+ // Session config
250
+ chromiumPath: {
251
+ doc: `The Chromium executable path.`,
252
+ format: String,
253
+ nullable: true,
254
+ default: '',
255
+ env: 'CHROMIUM_PATH',
256
+ arg: 'chromium-path',
257
+ },
258
+ chromiumVersion: {
259
+ doc: `The Chromium version. It will be downloaded if the chromium \
260
+ path is not provided.`,
261
+ format: String,
262
+ nullable: false,
263
+ default: puppeteer.PUPPETEER_REVISIONS.chrome,
264
+ env: 'CHROMIUM_VERSION',
265
+ arg: 'chromium-version',
266
+ },
267
+ chromiumUrl: {
268
+ doc: `The remote Chromium URL (\`http://HOST:PORT\`).
269
+ If provided, the remote instance will be used instead of running a local
270
+ chromium process.`,
271
+ format: String,
272
+ default: '',
273
+ nullable: true,
274
+ env: 'CHROMIUM_URL',
275
+ arg: 'chromium-url',
276
+ },
277
+ chromiumFieldTrials: {
278
+ doc: `Chromium additional field trials.`,
279
+ format: String,
280
+ nullable: true,
281
+ default: '',
282
+ env: 'CHROMIUM_FIELD_TRIALS',
283
+ arg: 'chromium-field-trials',
284
+ },
285
+ windowWidth: {
286
+ doc: `The browser window width.`,
287
+ format: 'nat',
288
+ default: 1920,
289
+ env: 'WINDOW_WIDTH',
290
+ arg: 'window-width',
291
+ },
292
+ windowHeight: {
293
+ doc: `The browser window height.`,
294
+ format: 'nat',
295
+ default: 1080,
296
+ env: 'WINDOW_HEIGHT',
297
+ arg: 'window-height',
298
+ },
299
+ deviceScaleFactor: {
300
+ doc: `The browser device scale factor.`,
301
+ format: 'float',
302
+ default: 1,
303
+ env: 'DEVICE_SCALE_FACTOR',
304
+ arg: 'device-scale-factor',
305
+ },
306
+ maxVideoDecoders: {
307
+ doc: `Specifies the maximum number of concurrent WebRTC video decoder \
308
+ instances that can be created on the same host.
309
+ If set it will disable the received video resolution and jitter buffer stats. \
310
+ This option is supported only when using the custom chromium build. \
311
+ The total decoders count is stored into the virtual file \`/dev/shm/chromium-video-decoders\``,
312
+ format: Number,
313
+ default: -1,
314
+ env: 'MAX_VIDEO_DECODERS',
315
+ arg: 'max-video-decoders',
316
+ },
317
+ maxVideoDecodersAt: {
318
+ doc: `Applies the maxVideoDecoders option starting from this session \`ID\`.`,
319
+ format: Number,
320
+ default: -1,
321
+ env: 'MAX_VIDEO_DECODERS_AT',
322
+ arg: 'max-video-decoders-at',
323
+ },
324
+ incognito: {
325
+ doc: `Runs the browser in incognito mode.`,
326
+ format: 'Boolean',
327
+ default: false,
328
+ env: 'INCOGNITO',
329
+ arg: 'incognito',
330
+ },
331
+ display: {
332
+ doc: `If unset, the browser will run in headless mode.
333
+ When running on MacOS or Windows, set it to any not-empty string.
334
+ On Linux, set it to a valid X server \`DISPLAY\` string (e.g. \`:0\`).`,
335
+ format: String,
336
+ default: '',
337
+ nullable: true,
338
+ env: 'DISPLAY',
339
+ arg: 'display',
340
+ },
341
+ /* audioRedForOpus: {
342
+ doc: `Enables RED for OPUS codec (experimental).`,
343
+ format: 'Boolean',
344
+ default: false,
345
+ env: 'AUDIO_RED_FOR_OPUS',
346
+ arg: 'audio-red-for-opus',
347
+ }, */
348
+ sessions: {
349
+ doc: `The number of browser sessions to start.`,
350
+ format: 'nat',
351
+ default: 1,
352
+ env: 'SESSIONS',
353
+ arg: 'sessions',
354
+ },
355
+ tabsPerSession: {
356
+ doc: `The number of tabs to open in each browser session.`,
357
+ format: 'nat',
358
+ default: 1,
359
+ env: 'TABS_PER_SESSION',
360
+ arg: 'tabs-per-session',
361
+ },
362
+ startSessionId: {
363
+ doc: `The starting ID assigned to sessions.`,
364
+ format: 'nat',
365
+ default: 0,
366
+ env: 'START_SESSION_ID',
367
+ arg: 'start-session-id',
368
+ },
369
+ startTimestamp: {
370
+ doc: `The start timestamp (in milliseconds). If 0, the value will be \
371
+ calculated using \`Date.now()\``,
372
+ format: 'nat',
373
+ default: 0,
374
+ env: 'START_TIMESTAMP',
375
+ arg: 'start-timestamp',
376
+ },
377
+ enableDetailedStats: {
378
+ doc: `If detailed participant metrics values should be collected.`,
379
+ format: 'index',
380
+ default: '',
381
+ nullable: true,
382
+ env: 'ENABLE_DETAILED_STATS',
383
+ arg: 'enable-detailed-stats',
384
+ },
385
+ spawnRate: {
386
+ doc: `The pages spawn rate (pages/s).`,
387
+ format: 'float',
388
+ default: 1,
389
+ env: 'SPAWN_RATE',
390
+ arg: 'spawn-rate',
391
+ },
392
+ showPageLog: {
393
+ doc: `If \`true\`, the pages console logs will be shown on console.`,
394
+ format: 'Boolean',
395
+ default: true,
396
+ env: 'SHOW_PAGE_LOG',
397
+ arg: 'show-page-log',
398
+ },
399
+ pageLogFilter: {
400
+ doc: `If set, only the logs with the matching text will be printed \
401
+ on console. Regexp string allowed.`,
402
+ format: String,
403
+ default: '',
404
+ nullable: true,
405
+ env: 'PAGE_LOG_FILTER',
406
+ arg: 'page-log-filter',
407
+ },
408
+ pageLogPath: {
409
+ doc: `If set, page console logs will be saved on the selected file path.`,
410
+ format: String,
411
+ default: '',
412
+ nullable: true,
413
+ env: 'PAGE_LOG_PATH',
414
+ arg: 'page-log-path',
415
+ },
416
+ userAgent: {
417
+ doc: `The user agent override.`,
418
+ format: String,
419
+ default: '',
420
+ nullable: true,
421
+ env: 'USER_AGENT',
422
+ arg: 'user-agent',
423
+ },
424
+ scriptPath: {
425
+ doc: `One or more JavaScript file paths (comma-separated). \
426
+ If set, the files contents will be executed inside each opened tab page; \
427
+ the following global variables will be attached to the \`webrtcperf\` global object: \
428
+ \`WEBRTC_PERF_SESSION\` the session number (0-indexed); \
429
+ \`WEBRTC_PERF_TAB\` the tab number inside the same session (0-indexed); \
430
+ \`WEBRTC_PERF_INDEX\` the page absolute index (0-indexed). \
431
+ `,
432
+ format: String,
433
+ default: '',
434
+ env: 'SCRIPT_PATH',
435
+ arg: 'script-path',
436
+ },
437
+ scriptParams: {
438
+ doc: `Additional parameters (in JSON format) that will be exposed into
439
+ the page context as \`webrtcperf.params\`.`,
440
+ format: String,
441
+ nullable: true,
442
+ default: '',
443
+ env: 'SCRIPT_PARAMS',
444
+ arg: 'script-params',
445
+ },
446
+ disabledVideoCodecs: {
447
+ doc: `A string with the video codecs to disable (comma-separated); e.g. \`vp9,av1\``,
448
+ format: String,
449
+ nullable: true,
450
+ default: '',
451
+ env: 'DISABLED_VIDEO_CODECS',
452
+ arg: 'disabled-video-codecs',
453
+ },
454
+ localStorage: {
455
+ doc: `A JSON string with the \`localStorage\` object to be set on page \
456
+ load.`,
457
+ format: String,
458
+ nullable: true,
459
+ default: '',
460
+ env: 'LOCAL_STORAGE',
461
+ arg: 'local-storage',
462
+ },
463
+ sessionStorage: {
464
+ doc: `A JSON string with the \`sessionStorage\` object to be set on page \
465
+ load.`,
466
+ format: String,
467
+ nullable: true,
468
+ default: '',
469
+ env: 'SESSION_STORAGE',
470
+ arg: 'session-storage',
471
+ },
472
+ clearCookies: {
473
+ doc: `If true, all the page cookies are cleared.`,
474
+ format: 'Boolean',
475
+ default: false,
476
+ env: 'CLEAR_COOKIES',
477
+ arg: 'clear-cookies',
478
+ },
479
+ enableGpu: {
480
+ doc: `It enables the GPU acceleration (experimental). Set to "desktop" to \
481
+ use the host X server instance.`,
482
+ format: String,
483
+ nullable: true,
484
+ default: '',
485
+ env: 'ENABLE_GPU',
486
+ arg: 'enable-gpu',
487
+ },
488
+ enableBrowserLogging: {
489
+ doc: `It enables the Chromium browser logging for the specified session indexes.`,
490
+ format: 'index',
491
+ nullable: true,
492
+ default: '',
493
+ env: 'ENABLE_BROWSER_LOGGING',
494
+ arg: 'enable-browser-logging',
495
+ },
496
+ blockedUrls: {
497
+ doc: `A comma-separated list of request URLs that will be automatically \
498
+ blocked.`,
499
+ format: String,
500
+ nullable: true,
501
+ default: '',
502
+ env: 'BLOCKED_URLS',
503
+ arg: 'blocked-urls',
504
+ },
505
+ extraHeaders: {
506
+ doc: `A dictionary of headers keyed by the url in JSON5 format (e.g. \
507
+ \`{ "https://url.com/*": { "header-name": "value" } }\`).`,
508
+ format: String,
509
+ nullable: true,
510
+ default: '',
511
+ env: 'EXTRA_HEADERS',
512
+ arg: 'extra-headers',
513
+ },
514
+ responseModifiers: {
515
+ doc: `A dictionary of content replacements keyed by the url in JSON5 format.
516
+ Examples:
517
+ - replace strings using a regular expression:
518
+ \`{ "https://url.com/*": [{ search: "searchString": replace: "anotherString" }] }\`
519
+ - completely replace the content:
520
+ \`{ "https://url.com/file.js": [{ file: "path/to/newFile.js" }] }\`
521
+ `,
522
+ format: String,
523
+ nullable: true,
524
+ default: '',
525
+ env: 'RESPONSE_MODIFIERS',
526
+ arg: 'response-modifiers',
527
+ },
528
+ downloadResponses: {
529
+ doc: `An array of url responses that will be saved to the disk, keyed by the url in JSON5 format.
530
+ Example: \`[{ urlPattern: "https://url.com/*", output: "save/directory" }]\`
531
+ `,
532
+ format: String,
533
+ nullable: true,
534
+ default: '',
535
+ env: 'DOWNLOAD_RESPONSES',
536
+ arg: 'download-responses',
537
+ },
538
+ extraCSS: {
539
+ doc: `A string with a CSS styles to inject into each page. \
540
+ Rules containing "important" will be replaced with "!important".`,
541
+ format: String,
542
+ nullable: true,
543
+ default: '',
544
+ env: 'EXTRA_CSS',
545
+ arg: 'extra-css',
546
+ },
547
+ cookies: {
548
+ doc: `A string with an array of [CookieParam](https://pptr.dev/api/puppeteer.cookieparam) to set into each page in JSON5 format.`,
549
+ format: String,
550
+ nullable: true,
551
+ default: '',
552
+ env: 'COOKIES',
553
+ arg: 'cookies',
554
+ },
555
+ overridePermissions: {
556
+ doc: `A comma-separated list of permissions to grant to the opened url.`,
557
+ format: String,
558
+ nullable: true,
559
+ default: '',
560
+ env: 'OVERRIDE_PERMISSIONS',
561
+ arg: 'override-permissions',
562
+ },
563
+ hardwareConcurrency: {
564
+ doc: `When set, it overrides the navigator.hardwareConcurrency property.`,
565
+ format: 'nat',
566
+ default: 0,
567
+ env: 'HARDWARE_CONCURRENCY',
568
+ arg: 'hardware-concurrency',
569
+ },
570
+ debuggingPort: {
571
+ doc: `The chrome debugging port. If this value != 0, the chrome instance \
572
+ will listen on the provided port + the start-session-id value.`,
573
+ format: 'nat',
574
+ default: 0,
575
+ env: 'DEBUGGING_PORT',
576
+ arg: 'debugging-port',
577
+ },
578
+ debuggingAddress: {
579
+ doc: `The chrome debugging listening address. If unset, the network default interface address will be used.`,
580
+ format: String,
581
+ nullable: true,
582
+ default: '127.0.0.1',
583
+ env: 'DEBUGGING_ADDRESS',
584
+ arg: 'debugging-address',
585
+ },
586
+ // stats config
587
+ showStats: {
588
+ doc: `If the statistics should be displayed on the console output.`,
589
+ format: 'Boolean',
590
+ default: true,
591
+ env: 'SHOW_STATS',
592
+ arg: 'show-stats',
593
+ },
594
+ statsPath: {
595
+ doc: `The log file path; if set, the stats will be written in \
596
+ a .csv file inside that file.`,
597
+ format: String,
598
+ default: '',
599
+ env: 'STATS_PATH',
600
+ arg: 'stats-path',
601
+ },
602
+ detailedStatsPath: {
603
+ doc: `The log file path; if set, the detailed stats will be written in \
604
+ a .csv file inside that file.`,
605
+ format: String,
606
+ default: '',
607
+ env: 'DETAILED_STATS_PATH',
608
+ arg: 'detailed-stats-path',
609
+ },
610
+ statsInterval: {
611
+ doc: `The stats collect interval in seconds. It should be lower than the \
612
+ Prometheus scraping interval.`,
613
+ format: 'nat',
614
+ default: 15,
615
+ env: 'STATS_INTERVAL',
616
+ arg: 'stats-interval',
617
+ },
618
+ rtcStatsTimeout: {
619
+ doc: `The timeout in seconds after which the RTC stats coming from inactive\
620
+ hosts are removed. It should be higher than the \`statsInterval\` value.`,
621
+ format: 'nat',
622
+ default: 60,
623
+ env: 'RTC_STATS_TIMEOUT',
624
+ arg: 'rtc-stats-timeout',
625
+ },
626
+ customMetrics: {
627
+ doc: `A dictionary of custom metrics keys in JSON5 format (e.g. \
628
+ '{ statName1: { labels: ["label1"] } }').`,
629
+ format: String,
630
+ nullable: true,
631
+ default: '',
632
+ env: 'CUSTOM_METRICS',
633
+ arg: 'custom-metrics',
634
+ },
635
+ //
636
+ prometheusPushgateway: {
637
+ doc: `If set, logs are sent to the specified Prometheus Pushgateway \
638
+ service (example: "http://127.0.0.1:9091").`,
639
+ format: 'String',
640
+ default: '',
641
+ nullable: true,
642
+ env: 'PROMETHEUS_PUSHGATEWAY',
643
+ arg: 'prometheus-pushgateway',
644
+ },
645
+ prometheusPushgatewayJobName: {
646
+ doc: `The Prometheus Pushgateway job name.`,
647
+ format: 'String',
648
+ default: 'default',
649
+ env: 'PROMETHEUS_PUSHGATEWAY_JOB_NAME',
650
+ arg: 'prometheus-pushgateway-job-name',
651
+ },
652
+ prometheusPushgatewayAuth: {
653
+ doc: `The Prometheus Pushgateway basic auth (username:password).`,
654
+ format: 'String',
655
+ default: '',
656
+ nullable: true,
657
+ env: 'PROMETHEUS_PUSHGATEWAY_AUTH',
658
+ arg: 'prometheus-pushgateway-auth',
659
+ },
660
+ prometheusPushgatewayGzip: {
661
+ doc: `Allows to use gzip encoded pushgateway requests.`,
662
+ format: 'Boolean',
663
+ default: true,
664
+ env: 'PROMETHEUS_PUSHGATEWAY_GZIP',
665
+ arg: 'prometheus-pushgateway-gzip',
666
+ },
667
+ //
668
+ alertRules: {
669
+ doc: `Alert rules definition (in JSON format).`,
670
+ format: String,
671
+ nullable: true,
672
+ default: '',
673
+ env: 'ALERT_RULES',
674
+ arg: 'alert-rules',
675
+ },
676
+ alertRulesFilename: {
677
+ doc: `The alert rules report output filename.`,
678
+ format: String,
679
+ nullable: true,
680
+ default: '',
681
+ env: 'ALERT_RULES_FILENAME',
682
+ arg: 'alert-rules-filename',
683
+ },
684
+ alertRulesFailPercentile: {
685
+ doc: `The alert rules report fails percentile (0-100). With the default value the \
686
+ alert will be successful only when at least 95% of the checks pass.`,
687
+ format: 'nat',
688
+ nullable: false,
689
+ default: 95,
690
+ env: 'ALERT_RULES_FAIL_PERCENTILE',
691
+ arg: 'alert-rules-fail-percentile',
692
+ },
693
+ pushStatsUrl: {
694
+ doc: `The URL to push the collected stats.`,
695
+ format: String,
696
+ nullable: true,
697
+ default: '',
698
+ env: 'PUSH_STATS_URL',
699
+ arg: 'push-stats-url',
700
+ },
701
+ pushStatsId: {
702
+ doc: `The ID of the collected stats to push.`,
703
+ format: String,
704
+ nullable: true,
705
+ default: 'default',
706
+ env: 'PUSH_STATS_ID',
707
+ arg: 'push-stats-id',
708
+ },
709
+ // server config
710
+ serverPort: {
711
+ doc: `The HTTP server listening port.`,
712
+ format: 'nat',
713
+ nullable: true,
714
+ default: 0,
715
+ env: 'SERVER_PORT',
716
+ arg: 'server-port',
717
+ },
718
+ serverSecret: {
719
+ doc: `The HTTP server basic auth secret. The auth user name is set to \`admin\` by default.`,
720
+ format: String,
721
+ default: 'secret',
722
+ env: 'SERVER_SECRET',
723
+ arg: 'server-secret',
724
+ },
725
+ serverUseHttps: {
726
+ doc: `If true, the server will use the HTTPS protocol.`,
727
+ format: 'Boolean',
728
+ default: false,
729
+ env: 'SERVER_USE_HTTPS',
730
+ arg: 'server-use-https',
731
+ },
732
+ serverData: {
733
+ doc: `An optional path that the HTTP server will expose with the /data endpoint.`,
734
+ format: String,
735
+ nullable: true,
736
+ default: '',
737
+ env: 'SERVER_DATA',
738
+ arg: 'server-data',
739
+ },
740
+ // VMAF config
741
+ vmafPath: {
742
+ doc: `When set, it runs the VMAF calculator for the video files saved under the provided directory path.`,
743
+ format: String,
744
+ nullable: true,
745
+ default: '',
746
+ env: 'VMAF_PATH',
747
+ arg: 'vmaf-path',
748
+ },
749
+ vmafPreview: {
750
+ doc: `If true, for each VMAF comparison it creates a side-by-side video with \
751
+ the reference and degraded versions.`,
752
+ format: 'Boolean',
753
+ default: false,
754
+ env: 'VMAF_PREVIEW',
755
+ arg: 'vmaf-preview',
756
+ },
757
+ vmafKeepIntermediateFiles: {
758
+ doc: `If true, the VMAF intermediate files will not be deleted.`,
759
+ format: 'Boolean',
760
+ default: false,
761
+ env: 'VMAF_KEEP_INTERMEDIATE_FILES',
762
+ arg: 'vmaf-keep-intermediate-files',
763
+ },
764
+ vmafKeepSourceFiles: {
765
+ doc: `If true, the VMAF source files will not be deleted.`,
766
+ format: 'Boolean',
767
+ default: true,
768
+ env: 'VMAF_KEEP_SOURCE_FILES',
769
+ arg: 'vmaf-keep-source-files',
770
+ },
771
+ vmafCrop: {
772
+ doc: `If set, the reference and degraded videos will be cropped using the specified configuration in JSON5 format. \
773
+ Crop configuration should be expressed using the ffmpeg crop filter syntax (https://ffmpeg.org/ffmpeg-filters.html#crop). \
774
+ E.g. \`{ "Participant-000001_recv-by_Participant-000000': { ref: { w: "iw-10", h: "ih-5" }, deg: { w: "200", h: "200" } } }\``,
775
+ format: String,
776
+ nullable: true,
777
+ default: '',
778
+ env: 'VMAF_CROP',
779
+ arg: 'vmaf-crop',
780
+ },
781
+ vmafPrepareVideo: {
782
+ doc: `When set, it prepares the selected video applying a timestamp overlay on top of it. \
783
+ The filename must be provided in the format \`<video path>,<ID>\`, where the selected ID will be used unique video identifier in the overlay.`,
784
+ format: String,
785
+ nullable: true,
786
+ default: '',
787
+ env: 'VMAF_PREPARE_VIDEO',
788
+ arg: 'vmaf-prepare-video',
789
+ },
790
+ vmafProcessVideo: {
791
+ doc: `When set, it runs the VMAF video preprocessor, that converts a video file into the IVF format with timestamps matching the overlay recognition. \
792
+ The filename must contain a \`recv\` or \`send\` string to identify if the video was a reference (send) or a degraded version (recv), e.g. \`Participant1_recv.mp4\`.`,
793
+ format: String,
794
+ nullable: true,
795
+ default: '',
796
+ env: 'VMAF_PROCESS_VIDEO',
797
+ arg: 'vmaf-process-video',
798
+ },
799
+ vmafVideoCrop: {
800
+ doc: `If set, the vmaf prepared/processed video will be cropped using the specified configuration in JSON5 format. \
801
+ Crop configuration should be expressed using the ffmpeg crop filter syntax (https://ffmpeg.org/ffmpeg-filters.html#crop). \
802
+ E.g. \`{ w: "iw-10", h: "ih-5", x: "10", y: '5' }\``,
803
+ format: String,
804
+ nullable: true,
805
+ default: '',
806
+ env: 'VMAF_VIDEO_CROP',
807
+ arg: 'vmaf-video-crop',
808
+ },
809
+ // VISQOL config
810
+ visqolPath: {
811
+ doc: `When set, it runs the visqol calculator for the audio files saved under the provided directory path.`,
812
+ format: String,
813
+ nullable: true,
814
+ default: '',
815
+ env: 'VISQOL_PATH',
816
+ arg: 'visqol-path',
817
+ },
818
+ visqolKeepSourceFiles: {
819
+ doc: `If true, the visqol source files will not be deleted.`,
820
+ format: 'Boolean',
821
+ default: true,
822
+ env: 'VISQOL_KEEP_SOURCE_FILES',
823
+ arg: 'visqol-keep-source-files',
824
+ },
825
+ });
826
+ /**
827
+ * Formats the schema documentation, calling the same function recursively.
828
+ * @param docs the documentation object to extend
829
+ * @param property the root property
830
+ * @param schema the config schema fragment
831
+ * @return the documentation object
832
+ */
833
+ function formatDocs(docs, property,
834
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
835
+ schema) {
836
+ if (schema._cvtProperties) {
837
+ Object.entries(schema._cvtProperties).forEach(([name, value]) => {
838
+ formatDocs(docs, `${property ? `${property}.` : ''}${name}`, value);
839
+ });
840
+ return docs;
841
+ }
842
+ if (property) {
843
+ docs[property] = {
844
+ doc: schema.doc,
845
+ format: JSON.stringify(schema.format, null, 2),
846
+ default: JSON.stringify(schema.default, null, 2),
847
+ };
848
+ }
849
+ return docs;
850
+ }
851
+ /**
852
+ * It returns the formatted configuration docs.
853
+ */
854
+ function getConfigDocs() {
855
+ return formatDocs({}, null, configSchema.getSchema());
856
+ }
857
+ const _schemaProperties = configSchema.getProperties();
858
+ /**
859
+ * Loads the config object.
860
+ */
861
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
862
+ function loadConfig(filePath, values) {
863
+ if (filePath && (0, fs_1.existsSync)(filePath)) {
864
+ log.debug(`Loading config from ${filePath}`);
865
+ configSchema.loadFile(filePath);
866
+ }
867
+ else if (values) {
868
+ log.debug('Loading config from values.');
869
+ configSchema.load(values);
870
+ }
871
+ else {
872
+ log.debug('Using default values.');
873
+ configSchema.load({});
874
+ }
875
+ configSchema.validate({ allowed: 'strict' });
876
+ const config = configSchema.getProperties();
877
+ log.debug('Using config:', config);
878
+ return config;
879
+ }
880
+ //# sourceMappingURL=config.js.map