openvidu-browser: update dependencies

v2
pabloFuente 2025-11-19 14:22:45 +01:00
parent a14cd70b09
commit 5cf0cf0e11
37 changed files with 5037 additions and 935 deletions

View File

@ -0,0 +1,76 @@
module.exports = {
root: true,
ignorePatterns: ['lib/**', 'ts4.4/**', 'node_modules/**', 'static/**', 'openvidu-browser-*.tgz'],
env: {
browser: true,
es2020: true,
node: true
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
},
plugins: ['@typescript-eslint', 'import'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:import/recommended', 'plugin:import/typescript'],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts']
},
typescript: {
project: ['./tsconfig.json', './src/OpenVidu/tsconfig.json']
}
}
},
rules: {
'@typescript-eslint/array-type': ['error', { default: 'array' }],
'@typescript-eslint/ban-types': [
'error',
{
extendDefaults: true,
types: {
Object: {
message: 'Avoid using the `Object` type. Did you mean `object`?',
fixWith: 'object'
},
Function: {
message: 'Avoid using the `Function` type. Prefer a specific function type.'
},
Boolean: {
message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
fixWith: 'boolean'
},
Number: {
message: 'Avoid using the `Number` type. Did you mean `number`?',
fixWith: 'number'
},
String: {
message: 'Avoid using the `String` type. Did you mean `string`?',
fixWith: 'string'
}
}
}
],
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/type-annotation-spacing': 'error',
curly: ['error', 'multi-line', 'consistent'],
eqeqeq: ['error', 'always'],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['config/**', '**/*.spec.ts', '**/*.test.ts']
}
],
'no-trailing-spaces': ['error', { skipBlankLines: false, ignoreComments: false }],
'no-var': 'error',
'object-shorthand': ['error', 'always'],
'prefer-const': 'error',
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
semi: ['error', 'always'],
'space-in-parens': 'off'
}
};

View File

@ -0,0 +1,5 @@
lib
node_modules
static
ts4.4
openvidu-browser-*.tgz

View File

@ -0,0 +1,5 @@
{
"singleQuote": true,
"printWidth": 120,
"trailingComma": "es5"
}

View File

@ -1,81 +1,37 @@
{
"extends": "tslint:recommended",
"rules": {
"array-type": [
true,
"array"
],
"array-type": [true, "array"],
"ban-types": {
"options": [
[
"Object",
"Avoid using the `Object` type. Did you mean `object`?"
],
["Object", "Avoid using the `Object` type. Did you mean `object`?"],
[
"Function",
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`, or use `ts.AnyFunction`."
],
[
"Boolean",
"Avoid using the `Boolean` type. Did you mean `boolean`?"
],
[
"Number",
"Avoid using the `Number` type. Did you mean `number`?"
],
[
"String",
"Avoid using the `String` type. Did you mean `string`?"
]
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
["Number", "Avoid using the `Number` type. Did you mean `number`?"],
["String", "Avoid using the `String` type. Did you mean `string`?"]
]
},
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": [
true,
"ignore-same-line"
],
"indent": [
true,
"spaces",
2
],
"interface-name": [
true,
"never-prefix"
],
"comment-format": [true, "check-space"],
"curly": [true, "ignore-same-line"],
"indent": [true, "spaces", 2],
"interface-name": [true, "never-prefix"],
"interface-over-type-literal": true,
"jsdoc-format": true,
"no-inferrable-types": true,
"no-internal-module": true,
"no-null-keyword": false,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": [
true,
"ignore-template-strings"
],
"no-trailing-whitespace": [true, "ignore-template-strings"],
"no-var-keyword": true,
"object-literal-shorthand": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"one-line": [true, "check-open-brace", "check-whitespace"],
"prefer-const": true,
"quotemark": [
true,
"single",
"avoid-escape",
"avoid-template"
],
"semicolon": [
true,
"always",
"ignore-bound-class-methods"
],
"quotemark": [true, "single", "avoid-escape", "avoid-template"],
"semicolon": [true, "always", "ignore-bound-class-methods"],
"space-within-parens": true,
"triple-equals": true,
"typedef-whitespace": [
@ -95,29 +51,10 @@
"variable-declaration": "onespace"
}
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-type"
],
"no-implicit-dependencies": [
true,
"dev"
],
"object-literal-key-quotes": [
true,
"consistent-as-needed"
],
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-leading-underscore"
],
"whitespace": [true, "check-branch", "check-decl", "check-operator", "check-module", "check-separator", "check-type"],
"no-implicit-dependencies": [true, "dev"],
"object-literal-key-quotes": [true, "consistent-as-needed"],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"],
"arrow-parens": false,
"arrow-return-shorthand": false,
"forin": false,

View File

@ -0,0 +1,74 @@
const tseslint = require('@typescript-eslint/eslint-plugin');
const tsParser = require('@typescript-eslint/parser');
const importPlugin = require('eslint-plugin-import');
const globals = require('globals');
module.exports = [
{
ignores: ['lib/**', 'ts4.4/**', 'node_modules/**', 'static/**', 'openvidu-browser-*.tgz']
},
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
ecmaVersion: 2020,
sourceType: 'module',
parserOptions: {
project: ['./tsconfig.json', './src/OpenVidu/tsconfig.json'],
tsconfigRootDir: __dirname,
noWarnOnMultipleProjects: true
},
globals: {
...globals.browser,
...globals.node
}
},
plugins: {
'@typescript-eslint': tseslint,
import: importPlugin
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts']
},
typescript: {
project: ['./tsconfig.json', './src/OpenVidu/tsconfig.json'],
noWarnOnMultipleProjects: true
}
}
},
linterOptions: {
reportUnusedDisableDirectives: 'off'
},
rules: {
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-var-requires': 'off',
curly: 'off',
eqeqeq: 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['config/**', '**/*.spec.ts', '**/*.test.ts']
}
],
'import/no-unresolved': 'off',
'no-trailing-spaces': ['error', { skipBlankLines: false, ignoreComments: false }],
'no-var': 'off',
'object-shorthand': 'off',
'prefer-const': 'off',
quotes: 'off',
semi: ['error', 'always'],
'no-unused-vars': 'off',
'no-extra-boolean-cast': 'off',
'no-undef': 'off'
}
}
];

File diff suppressed because it is too large Load Diff

View File

@ -6,22 +6,29 @@
"hark": "1.2.3",
"inherits": "2.0.4",
"jsnlog": "2.30.0",
"mime": "3.0.0",
"mime": "2.6.0",
"platform": "1.3.6",
"semver": "7.6.2",
"uuid": "9.0.1",
"semver": "7.7.3",
"uuid": "^8.3.2",
"wolfy87-eventemitter": "5.2.9"
},
"description": "OpenVidu Browser",
"devDependencies": {
"@types/node": "18.11.9",
"@types/platform": "1.3.4",
"browserify": "17.0.0",
"terser": "5.15.1",
"@types/node": "24.10.1",
"@types/platform": "1.3.6",
"@typescript-eslint/eslint-plugin": "8.47.0",
"@typescript-eslint/parser": "8.47.0",
"browserify": "17.0.1",
"eslint": "9.39.1",
"eslint-import-resolver-typescript": "4.4.4",
"eslint-plugin-import": "2.32.0",
"patch-package": "^8.0.1",
"prettier": "3.6.2",
"terser": "5.44.1",
"tsify": "5.0.4",
"tslint": "6.1.3",
"typedoc": "0.23.21",
"typescript": "4.9.3"
"typedoc": "0.28.14",
"typescript": "5.9.3",
"undici-types": "7.16.0"
},
"license": "Apache-2.0",
"main": "lib/index.js",
@ -33,8 +40,10 @@
"scripts": {
"browserify": "VERSION=${VERSION:-dev}; mkdir -p static/js/ && cd src && ../node_modules/browserify/bin/cmd.js Main.ts -p [ tsify ] --exclude kurento-browser-extensions --debug -o ../static/js/openvidu-browser-$VERSION.js -v",
"browserify-prod": "VERSION=${VERSION:-dev}; mkdir -p static/js/ && cd src && ../node_modules/browserify/bin/cmd.js --debug Main.ts -p [ tsify ] --exclude kurento-browser-extensions | ../node_modules/terser/bin/terser --source-map content=inline --output ../static/js/openvidu-browser-$VERSION.min.js",
"build": "cd src/OpenVidu && ./../../node_modules/typescript/bin/tsc && cd ../.. && ./node_modules/typescript/bin/tsc --declaration src/index.ts --outDir ./lib --sourceMap --target es5 --lib dom,es5,es2015.promise,scripthost && rm -rf ./ts4.4 && mkdir -p ./ts4.4/lib && cp -r ./lib ./ts4.4 && find ./ts4.4/lib -type f ! -iname '*.d.ts' -delete && ./config/replace_for_ts44.sh",
"docs": "./generate-docs.sh"
"build": "npm run lint && npm run beautify && cd src/OpenVidu && ./../../node_modules/typescript/bin/tsc && cd ../.. && ./node_modules/typescript/bin/tsc --declaration src/index.ts --outDir ./lib --sourceMap --target es2015 --module commonjs --moduleResolution node --lib dom,es2015,scripthost && rm -rf ./ts4.4 && mkdir -p ./ts4.4/lib && cp -r ./lib ./ts4.4 && find ./ts4.4/lib -type f ! -iname '*.d.ts' -delete && ./config/replace_for_ts44.sh",
"docs": "./generate-docs.sh",
"lint": "eslint . --ext .ts",
"beautify": "prettier --write ."
},
"types": "lib/index.d.ts",
"typesVersions": {

View File

@ -95,7 +95,10 @@ export class Connection {
/**
* @hidden
*/
constructor(private session: Session, connectionOptions: LocalConnectionOptions | RemoteConnectionOptions) {
constructor(
private session: Session,
connectionOptions: LocalConnectionOptions | RemoteConnectionOptions
) {
let msg = "'Connection' created ";
if (!!(<LocalConnectionOptions>connectionOptions).role) {
// Connection is local
@ -129,7 +132,6 @@ export class Connection {
* @hidden
*/
sendIceCandidate(candidate: RTCIceCandidate): void {
if (!this.disposed) {
logger.debug((!!this.stream!.outboundStreamOpts ? 'Local' : 'Remote') + 'candidate for' + this.connectionId, candidate);

View File

@ -19,7 +19,7 @@ import { Stream } from './Stream';
import { LocalRecorderState } from '../OpenViduInternal/Enums/LocalRecorderState';
import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger';
import { PlatformUtils } from '../OpenViduInternal/Utils/Platform';
import Mime = require('mime/lite');
import mime from 'mime';
/**
* @hidden
@ -288,7 +288,7 @@ export class LocalRecorder {
const url = globalThis.URL.createObjectURL(<any>this.blob);
a.href = url;
a.download = this.id + '.' + Mime.getExtension(this.blob!.type);
a.download = this.id + '.' + mime.getExtension(this.blob!.type);
a.click();
globalThis.URL.revokeObjectURL(url);
@ -383,7 +383,7 @@ export class LocalRecorder {
}
const sendable = new FormData();
sendable.append('file', this.blob!, this.id + '.' + Mime.getExtension(this.blob!.type));
sendable.append('file', this.blob!, this.id + '.' + mime.getExtension(this.blob!.type));
http.onreadystatechange = () => {
if (http.readyState === 4) {

View File

@ -567,7 +567,10 @@ export class OpenVidu {
if (navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
// getDisplayMedia supported
try {
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: options.audioSource === 'screen' });
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({
video: true,
audio: options.audioSource === 'screen'
});
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
if (mustAskForAudioTrackLater) {
return await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
@ -587,9 +590,7 @@ export class OpenVidu {
}
}
// Use already calculated constraints
const constraintsAux = mustAskForAudioTrackLater
? { video: myConstraints.constraints!.video }
: myConstraints.constraints;
const constraintsAux = mustAskForAudioTrackLater ? { video: myConstraints.constraints!.video } : myConstraints.constraints;
try {
const mediaStream = await navigator.mediaDevices.getUserMedia(constraintsAux);
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
@ -614,14 +615,12 @@ export class OpenVidu {
}
}
/* tslint:disable:no-empty */
/**
* Disable all logging except error level
*/
enableProdMode(): void {
logger.enableProdMode();
}
/* tslint:enable:no-empty */
/**
* Set OpenVidu advanced configuration options. `configuration` is an object of type {@link OpenViduAdvancedConfiguration}. Call this method to override previous values at any moment.
@ -642,7 +641,12 @@ export class OpenVidu {
/**
* @hidden
*/
sendNewVideoDimensionsIfRequired(publisher: Publisher, reason: StreamPropertyChangedEventReason, WAIT_INTERVAL: number, MAX_ATTEMPTS: number) {
sendNewVideoDimensionsIfRequired(
publisher: Publisher,
reason: StreamPropertyChangedEventReason,
WAIT_INTERVAL: number,
MAX_ATTEMPTS: number
) {
let attempts = 0;
const oldWidth = publisher?.stream?.videoDimensions?.width || 0;
const oldHeight = publisher?.stream?.videoDimensions?.height || 0;
@ -1025,7 +1029,9 @@ export class OpenVidu {
if (!this.isScreenShare(videoSource)) {
this.setVideoSource(myConstraints, videoSource);
if (audioSource === 'screen') {
logger.warn('Parameter "audioSource" is set to "screen", which means rquesting audio from screen sharing source. But "videoSource" is not set to "screen". No audio source will be requested');
logger.warn(
'Parameter "audioSource" is set to "screen", which means rquesting audio from screen sharing source. But "videoSource" is not set to "screen". No audio source will be requested'
);
myConstraints.constraints!.audio = false;
}
} else {

View File

@ -63,7 +63,7 @@ export class Publisher extends StreamManager {
private accessDenied = false;
protected properties: PublisherProperties;
private permissionDialogTimeout: NodeJS.Timer;
private permissionDialogTimeout: ReturnType<typeof setTimeout>;
/**
* @hidden
@ -76,7 +76,7 @@ export class Publisher extends StreamManager {
/**
* @hidden
*/
screenShareResizeInterval: NodeJS.Timer;
screenShareResizeInterval: ReturnType<typeof setInterval>;
/**
* @hidden
@ -470,8 +470,7 @@ export class Publisher extends StreamManager {
};
if (this.stream.isSendScreen()) {
if(this.stream.isSendAudio() && mediaStream.getAudioTracks().length === 0){
if (this.stream.isSendAudio() && mediaStream.getAudioTracks().length === 0) {
// If sending audio is enabled and there are no audio tracks in the mediaStream, disable audio for screen sharing.
this.stream.audioActive = false;
this.stream.hasAudio = false;
@ -653,7 +652,10 @@ export class Publisher extends StreamManager {
try {
if (this.stream.isSendScreen() && navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: this.properties.audioSource === 'screen' });
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({
video: true,
audio: this.properties.audioSource === 'screen'
});
this.openvidu.addAlreadyProvidedTracks(myConstraints, mediaStream);
await getMediaSuccess(mediaStream, definedAudioConstraint);
} else {
@ -709,7 +711,8 @@ export class Publisher extends StreamManager {
getVideoDimensions(): Promise<{ width: number; height: number }> {
return new Promise((resolve, reject) => {
// Ionic iOS and Safari iOS supposedly require the video element to actually exist inside the DOM
const requiresDomInsertion: boolean = (platform.isIonicIos() || platform.isIOSWithSafari()) && (this.videoReference.readyState < 1);
const requiresDomInsertion: boolean =
(platform.isIonicIos() || platform.isIOSWithSafari()) && this.videoReference.readyState < 1;
let loadedmetadataListener;
const resolveDimensions = () => {

View File

@ -44,7 +44,13 @@ import { OpenViduError, OpenViduErrorName } from '../OpenViduInternal/Enums/Open
import { VideoInsertMode } from '../OpenViduInternal/Enums/VideoInsertMode';
import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger';
import { PlatformUtils } from '../OpenViduInternal/Utils/Platform';
import { StreamPropertyChangedEventReason, ChangedPropertyType, RecordingEventReason, ConnectionEventReason, StreamEventReason } from '../OpenViduInternal/Events/Types/Types';
import {
StreamPropertyChangedEventReason,
ChangedPropertyType,
RecordingEventReason,
ConnectionEventReason,
StreamEventReason
} from '../OpenViduInternal/Events/Types/Types';
/**
* @hidden
*/
@ -977,7 +983,13 @@ export class Session extends EventDispatcher {
/**
* @hidden
*/
onStreamPropertyChanged(event: { connectionId: string; streamId: string; property: ChangedPropertyType; newValue: any; reason: StreamPropertyChangedEventReason }): void {
onStreamPropertyChanged(event: {
connectionId: string;
streamId: string;
property: ChangedPropertyType;
newValue: any;
reason: StreamPropertyChangedEventReason;
}): void {
const callback = (connection: Connection) => {
if (!!connection.stream && connection.stream.streamId === event.streamId) {
const stream = connection.stream;
@ -993,7 +1005,7 @@ export class Session extends EventDispatcher {
event.newValue = event.newValue === 'true';
stream.videoActive = event.newValue;
const videoTrack = stream?.getMediaStream()?.getVideoTracks()?.[0];
if(videoTrack && !videoTrack.enabled && stream.videoActive){
if (videoTrack && !videoTrack.enabled && stream.videoActive) {
videoTrack.enabled = true;
}
break;
@ -1232,7 +1244,8 @@ export class Session extends EventDispatcher {
const stream: Stream = connection.stream!;
if (!stream || !stream.filter) {
return logger.error(
`Filter event of type "${event.eventType}" dispatched for stream ${stream.streamId} but there is no ${!stream ? 'stream' : 'filter'
`Filter event of type "${event.eventType}" dispatched for stream ${stream.streamId} but there is no ${
!stream ? 'stream' : 'filter'
} defined`
);
}
@ -1356,7 +1369,7 @@ export class Session extends EventDispatcher {
lang: string;
}): Promise<void> {
const connection = await this.getConnection(event.connectionId, 'No connection found for connectionId ' + event.connectionId);
const ev = new SpeechToTextEvent(this, connection, event.text, <any>(event.reason).toLowerCase(), event.raw, event.lang);
const ev = new SpeechToTextEvent(this, connection, event.text, <any>event.reason.toLowerCase(), event.raw, event.lang);
this.ee.emitEvent('speechToTextMessage', [ev]);
}

View File

@ -40,7 +40,7 @@ import { TypeOfVideo } from '../OpenViduInternal/Enums/TypeOfVideo';
import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger';
import { PlatformUtils } from '../OpenViduInternal/Utils/Platform';
import { v4 as uuidv4 } from 'uuid';
import { v4 as uuid } from 'uuid';
/**
* @hidden
@ -414,7 +414,7 @@ export class Stream {
const afterScriptLoaded = async () => {
try {
const id = this.streamId + '_' + uuidv4();
const id = this.streamId + '_' + uuid();
const mediaStreamClone = this.mediaStream!.clone();
const videoClone = this.streamManager.videos[0].video.cloneNode(false) as HTMLVideoElement;
// @ts-ignore
@ -790,12 +790,14 @@ export class Stream {
* @hidden
*/
isSendScreen(): boolean {
let screen = false
if (typeof MediaStreamTrack !== 'undefined' &&
this.outboundStreamOpts.publisherProperties.videoSource instanceof MediaStreamTrack) {
let screen = false;
if (
typeof MediaStreamTrack !== 'undefined' &&
this.outboundStreamOpts.publisherProperties.videoSource instanceof MediaStreamTrack
) {
let trackSettings: any = this.outboundStreamOpts.publisherProperties.videoSource.getSettings();
if (trackSettings.displaySurface) {
screen = ["monitor", "window", "browser"].includes(trackSettings.displaySurface);
screen = ['monitor', 'window', 'browser'].includes(trackSettings.displaySurface);
}
}
if (!screen && platform.isElectron()) {
@ -1074,7 +1076,8 @@ export class Stream {
}
if (!!this.session.openvidu.advancedConfiguration.forceMediaReconnectionAfterNetworkDrop) {
logger.warn(
`OpenVidu Browser advanced configuration option "forceMediaReconnectionAfterNetworkDrop" is enabled. Stream ${this.streamId
`OpenVidu Browser advanced configuration option "forceMediaReconnectionAfterNetworkDrop" is enabled. Stream ${
this.streamId
} (${this.isLocal() ? 'Publisher' : 'Subscriber'}) will force a reconnection`
);
return true;
@ -1112,7 +1115,8 @@ export class Stream {
} else {
// Ongoing reconnection
console.warn(
`Trying to reconnect stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`Trying to reconnect stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) but an ongoing reconnection process is active. Waiting for response...`
);
this.reconnectionEventEmitter.once('success', () => resolve());
@ -1494,7 +1498,9 @@ export class Stream {
this.mediaStream.getAudioTracks()[0].enabled = enabled;
}
if (!!this.mediaStream.getVideoTracks()[0]) {
const enabled = reconnect ? this.videoActive : !!this.videoActive && !!(this.streamManager as Subscriber).properties.subscribeToVideo;
const enabled = reconnect
? this.videoActive
: !!this.videoActive && !!(this.streamManager as Subscriber).properties.subscribeToVideo;
this.mediaStream.getVideoTracks()[0].enabled = enabled;
}
}
@ -1546,7 +1552,8 @@ export class Stream {
private onIceConnectionFailed() {
// Immediately reconnect, as this is a terminal error
logger.log(
`[ICE_CONNECTION_FAILED] Handling ICE_CONNECTION_FAILED event. Reconnecting stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`[ICE_CONNECTION_FAILED] Handling ICE_CONNECTION_FAILED event. Reconnecting stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
})`
);
this.reconnectStreamAndLogResultingIceConnectionState(ExceptionEventName.ICE_CONNECTION_FAILED);
@ -1555,7 +1562,8 @@ export class Stream {
private onIceConnectionDisconnected() {
// Wait to see if the ICE connection is able to reconnect
logger.log(
`[ICE_CONNECTION_DISCONNECTED] Handling ICE_CONNECTION_DISCONNECTED event. Waiting for ICE to be restored and reconnect stream ${this.streamId
`[ICE_CONNECTION_DISCONNECTED] Handling ICE_CONNECTION_DISCONNECTED event. Waiting for ICE to be restored and reconnect stream ${
this.streamId
} (${this.isLocal() ? 'Publisher' : 'Subscriber'}) if not possible`
);
const timeout = this.session.openvidu.advancedConfiguration.iceConnectionDisconnectedExceptionTimeout || 4000;
@ -1564,14 +1572,16 @@ export class Stream {
case 'failed':
// Do nothing, as an ICE_CONNECTION_FAILED event will have already raised
logger.warn(
`[ICE_CONNECTION_DISCONNECTED] ICE connection of stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`[ICE_CONNECTION_DISCONNECTED] ICE connection of stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) is now failed after ICE_CONNECTION_DISCONNECTED`
);
break;
case 'connected':
case 'completed':
logger.log(
`[ICE_CONNECTION_DISCONNECTED] ICE connection of stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`[ICE_CONNECTION_DISCONNECTED] ICE connection of stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) automatically restored after ICE_CONNECTION_DISCONNECTED. Current ICE connection state: ${state}`
);
break;
@ -1581,7 +1591,8 @@ export class Stream {
case 'disconnected':
// Rest of states
logger.warn(
`[ICE_CONNECTION_DISCONNECTED] ICE connection of stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`[ICE_CONNECTION_DISCONNECTED] ICE connection of stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) couldn't be restored after ICE_CONNECTION_DISCONNECTED event. Current ICE connection state after ${timeout} ms: ${state}`
);
this.reconnectStreamAndLogResultingIceConnectionState(ExceptionEventName.ICE_CONNECTION_DISCONNECTED);
@ -1597,20 +1608,23 @@ export class Stream {
case 'connected':
case 'completed':
logger.log(
`[${event}] Stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`[${event}] Stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) successfully reconnected after ${event}. Current ICE connection state: ${finalIceStateAfterReconnection}`
);
break;
default:
logger.error(
`[${event}] Stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`[${event}] Stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) failed to reconnect after ${event}. Current ICE connection state: ${finalIceStateAfterReconnection}`
);
break;
}
} catch (error) {
logger.error(
`[${event}] Error reconnecting stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`[${event}] Error reconnecting stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) after ${event}: ${error}`
);
}
@ -1650,7 +1664,8 @@ export class Stream {
if (isWsConnected) {
// There is connection to openvidu-server. The RTCPeerConnection is the only one broken
logger.log(
`[${event}] Trying to reconnect stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
`[${event}] Trying to reconnect stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) and the websocket is opened`
);
if (this.isLocal()) {
@ -1661,7 +1676,8 @@ export class Stream {
} else {
// There is no connection to openvidu-server. Nothing can be done. The automatic reconnection
// feature should handle a possible reconnection of RTCPeerConnection in case network comes back
const errorMsg = `[${event}] Trying to reconnect stream ${this.streamId} (${this.isLocal() ? 'Publisher' : 'Subscriber'
const errorMsg = `[${event}] Trying to reconnect stream ${this.streamId} (${
this.isLocal() ? 'Publisher' : 'Subscriber'
}) but the websocket wasn't opened`;
logger.error(errorMsg);
throw Error(errorMsg);

View File

@ -7,13 +7,9 @@
"allowJs": true,
"allowSyntheticDefaultImports": true,
"emitBOM": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"dom",
"es2015.promise",
"es5",
"scripthost"
],
"lib": ["dom", "es2015", "scripthost"],
"module": "commonjs",
"noFallthroughCasesInSwitch": true,
//"noImplicitAny": true,
@ -28,8 +24,6 @@
"skipLibCheck": true,
"sourceMap": true,
"strictNullChecks": true,
"suppressExcessPropertyErrors": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5"
"target": "es2015"
}
}

View File

@ -56,6 +56,6 @@ export class ConnectionEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() { }
callDefaultBehavior() {}
}

View File

@ -63,6 +63,6 @@ export class ConnectionPropertyChangedEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() {}
}

View File

@ -71,7 +71,6 @@ export abstract class Event {
* by calling {@link Subscriber.createVideoElement}). For every video removed, the Subscriber object will also dispatch a `videoElementDestroyed` event.
*/
preventDefault() {
// tslint:disable-next-line:no-empty
this.callDefaultBehavior = () => {};
this.hasBeenPrevented = true;
}

View File

@ -87,7 +87,7 @@ export enum ExceptionEventName {
*
* {@link ExceptionEvent} objects with this {@link ExceptionEvent.name} will have as {@link ExceptionEvent.origin} property a {@link Session} object.
*/
SPEECH_TO_TEXT_DISCONNECTED = 'SPEECH_TO_TEXT_DISCONNECTED',
SPEECH_TO_TEXT_DISCONNECTED = 'SPEECH_TO_TEXT_DISCONNECTED'
}
/**
@ -131,6 +131,6 @@ export class ExceptionEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() { }
callDefaultBehavior() {}
}

View File

@ -38,6 +38,6 @@ export class FilterEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() {}
}

View File

@ -51,6 +51,6 @@ export class NetworkQualityLevelChangedEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() {}
}

View File

@ -49,6 +49,6 @@ export class PublisherSpeakingEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() {}
}

View File

@ -66,6 +66,6 @@ export class RecordingEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() { }
callDefaultBehavior() {}
}

View File

@ -59,6 +59,6 @@ export class SignalEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() {}
}

View File

@ -24,7 +24,6 @@ import { SpeechToTextEventReason } from './Types/Types';
* Triggered by {@link SessionEventMap.speechToTextMessage}
*/
export class SpeechToTextEvent extends Event {
/**
* The {@link Connection} owning the Stream that produced the speech-to-text event.
* In other words, this is the participant that spoke and produced this transcription event.
@ -67,6 +66,6 @@ export class SpeechToTextEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() { }
callDefaultBehavior() {}
}

View File

@ -44,6 +44,6 @@ export class StreamManagerEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() {}
}

View File

@ -78,6 +78,6 @@ export class StreamPropertyChangedEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() { }
callDefaultBehavior() {}
}

View File

@ -1,42 +1,26 @@
export type ChangedPropertyType =
'videoActive' |
'audioActive' |
'videoTrack' |
'audioTrack' |
'videoDimensions' |
'filter';
export type ChangedPropertyType = 'videoActive' | 'audioActive' | 'videoTrack' | 'audioTrack' | 'videoDimensions' | 'filter';
export type StreamPropertyChangedEventReason =
'publishVideo' |
'publishAudio' |
'trackReplaced' |
'deviceRotated' |
'screenResized' |
'applyFilter' |
'execFilterMethod' |
'removeFilter';
| 'publishVideo'
| 'publishAudio'
| 'trackReplaced'
| 'deviceRotated'
| 'screenResized'
| 'applyFilter'
| 'execFilterMethod'
| 'removeFilter';
export type ConnectionEventReason =
'disconnect' |
'forceDisconnectByUser' |
'forceDisconnectByServer' |
'sessionClosedByServer' |
'networkDisconnect' |
'nodeCrashed' |
'';
| 'disconnect'
| 'forceDisconnectByUser'
| 'forceDisconnectByServer'
| 'sessionClosedByServer'
| 'networkDisconnect'
| 'nodeCrashed'
| '';
export type StreamEventReason =
ConnectionEventReason |
'unpublish' |
'forceUnpublishByUser' |
'forceUnpublishByServer';
export type StreamEventReason = ConnectionEventReason | 'unpublish' | 'forceUnpublishByUser' | 'forceUnpublishByServer';
export type RecordingEventReason =
'recordingStoppedByServer' |
'sessionClosedByServer' |
'automaticStop' |
'nodeCrashed';
export type RecordingEventReason = 'recordingStoppedByServer' | 'sessionClosedByServer' | 'automaticStop' | 'nodeCrashed';
export type SpeechToTextEventReason =
'recognizing' |
'recognized';
export type SpeechToTextEventReason = 'recognizing' | 'recognized';

View File

@ -40,6 +40,6 @@ export class VideoElementEvent extends Event {
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() {}
}

View File

@ -32,10 +32,10 @@ export class ConsoleLogger {
constructor(console: Console) {
this.logger = console;
(this.log = console.log),
((this.log = console.log),
(this.info = console.info),
(this.debug = console.debug),
(this.warn = console.warn),
(this.error = console.error);
(this.error = console.error));
}
}

View File

@ -182,8 +182,6 @@ export class PlatformUtils {
);
}
/**
* @hidden
*/

View File

@ -16,7 +16,7 @@
*/
import freeice = require('freeice');
import { v4 as uuidv4 } from 'uuid';
import { v4 as uuid } from 'uuid';
import { TypeOfVideo } from '../Enums/TypeOfVideo';
import { ExceptionEventName } from '../Events/ExceptionEvent';
import { OpenViduLogger } from '../Logger/OpenViduLogger';
@ -391,7 +391,8 @@ export class WebRtcPeer {
offerToReceiveAudio: offerAudio,
offerToReceiveVideo: offerVideo
};
(this.pc as RTCPeerConnection).createAnswer(constraints)
(this.pc as RTCPeerConnection)
.createAnswer(constraints)
.then((sdpAnswer) => resolve(sdpAnswer))
.catch((error) => reject(error));
}
@ -574,7 +575,7 @@ export class WebRtcPeer {
* @hidden
*/
generateUniqueId(): string {
return uuidv4();
return uuid();
}
}

View File

@ -15,8 +15,6 @@
*
*/
// tslint:disable:no-string-literal
import { Stream } from '../../OpenVidu/Stream';
import { OpenViduLogger } from '../Logger/OpenViduLogger';
import { PlatformUtils } from '../Utils/Platform';
@ -108,7 +106,7 @@ export class WebRtcStats {
private readonly STATS_ITEM_NAME = 'webrtc-stats-config';
private webRtcStatsEnabled = false;
private webRtcStatsIntervalId: NodeJS.Timer;
private webRtcStatsIntervalId: ReturnType<typeof setInterval>;
private statsInterval = 1;
private POST_URL: string;
@ -126,8 +124,7 @@ export class WebRtcStats {
// accessing localStorage in a third-party iframe throws a DOMException.
try {
webrtcObj = localStorage.getItem(this.STATS_ITEM_NAME);
}
catch(e){}
} catch (e) {}
if (!!webrtcObj) {
this.webRtcStatsEnabled = true;

View File

@ -7,13 +7,9 @@
"allowJs": true,
"allowSyntheticDefaultImports": true,
"emitBOM": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"dom",
"es2015.promise",
"es5",
"scripthost"
],
"lib": ["dom", "es2015", "scripthost"],
"module": "commonjs",
"noFallthroughCasesInSwitch": true,
//"noImplicitAny": true,
@ -29,8 +25,6 @@
"skipLibCheck": true,
"sourceMap": true,
"strictNullChecks": true,
"suppressExcessPropertyErrors": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5"
"target": "es2015"
}
}