From 4fe0a4fda2a4a8a8354138ed574780a813e409f8 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Thu, 27 Jan 2022 14:42:01 +0100 Subject: [PATCH] openvidu-browser: add TypeOfVideo --- openvidu-browser/src/OpenVidu/Stream.ts | 17 ++++++++------ .../src/OpenViduInternal/Enums/TypeOfVideo.ts | 23 +++++++++++++++++++ .../Private/InboundStreamOptions.ts | 3 ++- .../Interfaces/Private/StreamOptionsServer.ts | 3 ++- .../OpenViduInternal/WebRtcPeer/WebRtcPeer.ts | 3 +++ openvidu-browser/src/index.ts | 1 + 6 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 openvidu-browser/src/OpenViduInternal/Enums/TypeOfVideo.ts diff --git a/openvidu-browser/src/OpenVidu/Stream.ts b/openvidu-browser/src/OpenVidu/Stream.ts index 4cb8dcff..6a9e5166 100644 --- a/openvidu-browser/src/OpenVidu/Stream.ts +++ b/openvidu-browser/src/OpenVidu/Stream.ts @@ -29,6 +29,7 @@ import { PublisherSpeakingEvent } from '../OpenViduInternal/Events/PublisherSpea import { StreamManagerEvent } from '../OpenViduInternal/Events/StreamManagerEvent'; import { StreamPropertyChangedEvent } from '../OpenViduInternal/Events/StreamPropertyChangedEvent'; import { OpenViduError, OpenViduErrorName } from '../OpenViduInternal/Enums/OpenViduError'; +import { TypeOfVideo } from '../OpenViduInternal/Enums/TypeOfVideo'; import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger'; import { PlatformUtils } from '../OpenViduInternal/Utils/Platform'; @@ -117,7 +118,7 @@ export class Stream { * * If [[hasVideo]] is false, this property is undefined */ - typeOfVideo?: string; + typeOfVideo?: TypeOfVideo; /** * StreamManager object ([[Publisher]] or [[Subscriber]]) in charge of displaying this stream in the DOM @@ -264,9 +265,9 @@ export class Stream { this.videoActive = !!this.outboundStreamOpts.publisherProperties.publishVideo; this.frameRate = this.outboundStreamOpts.publisherProperties.frameRate; if (typeof MediaStreamTrack !== 'undefined' && this.outboundStreamOpts.publisherProperties.videoSource instanceof MediaStreamTrack) { - this.typeOfVideo = 'CUSTOM'; + this.typeOfVideo = TypeOfVideo.CUSTOM; } else { - this.typeOfVideo = this.isSendScreen() ? 'SCREEN' : 'CAMERA'; + this.typeOfVideo = this.isSendScreen() ? TypeOfVideo.SCREEN : TypeOfVideo.CAMERA; } } if (!!this.outboundStreamOpts.publisherProperties.filter) { @@ -864,9 +865,9 @@ export class Stream { sdpString: sdpOfferParam } } else { - let typeOfVideo = ''; + let typeOfVideo; if (this.isSendVideo()) { - typeOfVideo = (typeof MediaStreamTrack !== 'undefined' && this.outboundStreamOpts.publisherProperties.videoSource instanceof MediaStreamTrack) ? 'CUSTOM' : (this.isSendScreen() ? 'SCREEN' : 'CAMERA'); + typeOfVideo = (typeof MediaStreamTrack !== 'undefined' && this.outboundStreamOpts.publisherProperties.videoSource instanceof MediaStreamTrack) ? TypeOfVideo.CUSTOM : (this.isSendScreen() ? TypeOfVideo.SCREEN : TypeOfVideo.CAMERA); } params = { doLoopback: this.displayMyRemote() || false, @@ -928,7 +929,8 @@ export class Stream { onIceConnectionStateException: (exceptionName: ExceptionEventName, message: string, data?: any) => { this.session.emitEvent('exception', [new ExceptionEvent(this.session, exceptionName, this, message, data)]) }, iceServers: this.getIceServersConf(), mediaStream: this.mediaStream, - mediaServer: this.session.openvidu.mediaServer + mediaServer: this.session.openvidu.mediaServer, + typeOfVideo: this.typeOfVideo }; if (this.session.openvidu.mediaServer !== 'mediasoup') { @@ -1092,7 +1094,8 @@ export class Stream { onIceCandidate: this.connection.sendIceCandidate.bind(this.connection), onIceConnectionStateException: (exceptionName: ExceptionEventName, message: string, data?: any) => { this.session.emitEvent('exception', [new ExceptionEvent(this.session, exceptionName, this, message, data)]) }, iceServers: this.getIceServersConf(), - mediaServer: this.session.openvidu.mediaServer + mediaServer: this.session.openvidu.mediaServer, + typeOfVideo: this.typeOfVideo }; if (reconnect) { diff --git a/openvidu-browser/src/OpenViduInternal/Enums/TypeOfVideo.ts b/openvidu-browser/src/OpenViduInternal/Enums/TypeOfVideo.ts new file mode 100644 index 00000000..6edcb221 --- /dev/null +++ b/openvidu-browser/src/OpenViduInternal/Enums/TypeOfVideo.ts @@ -0,0 +1,23 @@ +/* + * (C) Copyright 2017-2022 OpenVidu (https://openvidu.io) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +export enum TypeOfVideo { + CAMERA = 'CAMERA', + SCREEN = 'SCREEN', + CUSTOM = 'CUSTOM', + IPCAM = 'IPCAM' +} \ No newline at end of file diff --git a/openvidu-browser/src/OpenViduInternal/Interfaces/Private/InboundStreamOptions.ts b/openvidu-browser/src/OpenViduInternal/Interfaces/Private/InboundStreamOptions.ts index 146001ea..6d41d2fc 100644 --- a/openvidu-browser/src/OpenViduInternal/Interfaces/Private/InboundStreamOptions.ts +++ b/openvidu-browser/src/OpenViduInternal/Interfaces/Private/InboundStreamOptions.ts @@ -17,6 +17,7 @@ import { Connection } from '../../../OpenVidu/Connection'; import { Filter } from '../../../OpenVidu/Filter'; +import { TypeOfVideo } from '../../Enums/TypeOfVideo'; export interface InboundStreamOptions { id: string; @@ -26,7 +27,7 @@ export interface InboundStreamOptions { hasVideo: boolean; audioActive: boolean; videoActive: boolean; - typeOfVideo: string; + typeOfVideo: TypeOfVideo; frameRate: number; videoDimensions: { width: number, height: number }; filter?: Filter; diff --git a/openvidu-browser/src/OpenViduInternal/Interfaces/Private/StreamOptionsServer.ts b/openvidu-browser/src/OpenViduInternal/Interfaces/Private/StreamOptionsServer.ts index 9b947419..c0bb366d 100644 --- a/openvidu-browser/src/OpenViduInternal/Interfaces/Private/StreamOptionsServer.ts +++ b/openvidu-browser/src/OpenViduInternal/Interfaces/Private/StreamOptionsServer.ts @@ -16,6 +16,7 @@ */ import { Filter } from '../../../OpenVidu/Filter'; +import { TypeOfVideo } from '../../Enums/TypeOfVideo'; export interface StreamOptionsServer { id: string; @@ -24,7 +25,7 @@ export interface StreamOptionsServer { hasVideo: boolean; audioActive: boolean; videoActive: boolean; - typeOfVideo: string; + typeOfVideo: TypeOfVideo; frameRate: number; videoDimensions: string; filter: Filter; diff --git a/openvidu-browser/src/OpenViduInternal/WebRtcPeer/WebRtcPeer.ts b/openvidu-browser/src/OpenViduInternal/WebRtcPeer/WebRtcPeer.ts index bacc289a..998b9e1b 100644 --- a/openvidu-browser/src/OpenViduInternal/WebRtcPeer/WebRtcPeer.ts +++ b/openvidu-browser/src/OpenViduInternal/WebRtcPeer/WebRtcPeer.ts @@ -17,6 +17,7 @@ import freeice = require('freeice'); import { v4 as uuidv4 } from 'uuid'; +import { TypeOfVideo } from '../Enums/TypeOfVideo'; import { ExceptionEventName } from '../Events/ExceptionEvent'; import { OpenViduLogger } from '../Logger/OpenViduLogger'; import { PlatformUtils } from '../Utils/Platform'; @@ -104,6 +105,7 @@ export interface WebRtcPeerConfiguration { mediaStream?: MediaStream | null; mode?: 'sendonly' | 'recvonly' | 'sendrecv'; id?: string; + typeOfVideo: TypeOfVideo | undefined } export class WebRtcPeer { @@ -133,6 +135,7 @@ export class WebRtcPeer { : null, mode: !!configuration.mode ? configuration.mode : "sendrecv", id: !!configuration.id ? configuration.id : this.generateUniqueId(), + typeOfVideo: configuration.typeOfVideo }; this.pc = new RTCPeerConnection({ iceServers: this.configuration.iceServers }); diff --git a/openvidu-browser/src/index.ts b/openvidu-browser/src/index.ts index 8554eeb9..90a7ba0e 100644 --- a/openvidu-browser/src/index.ts +++ b/openvidu-browser/src/index.ts @@ -12,6 +12,7 @@ export { Filter } from './OpenVidu/Filter'; export { LocalRecorderState } from './OpenViduInternal/Enums/LocalRecorderState'; export { OpenViduError, OpenViduErrorName } from './OpenViduInternal/Enums/OpenViduError'; +export { TypeOfVideo } from './OpenViduInternal/Enums/TypeOfVideo'; export { VideoInsertMode } from './OpenViduInternal/Enums/VideoInsertMode'; export { Event } from './OpenViduInternal/Events/Event';