2022-01-19 17:24:11 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { Publisher, Subscriber } from 'openvidu-browser';
|
|
|
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
|
|
import { ILogger } from '../../models/logger.model';
|
2023-02-24 20:26:48 +01:00
|
|
|
import {
|
|
|
|
OpenViduRole,
|
|
|
|
ParticipantAbstractModel,
|
|
|
|
ParticipantModel,
|
|
|
|
ParticipantProperties,
|
|
|
|
StreamModel
|
|
|
|
} from '../../models/participant.model';
|
2022-01-19 17:24:11 +01:00
|
|
|
import { VideoType } from '../../models/video-type.model';
|
2022-02-15 16:24:01 +01:00
|
|
|
import { OpenViduAngularConfigService } from '../config/openvidu-angular.config.service';
|
2022-01-19 17:24:11 +01:00
|
|
|
import { LoggerService } from '../logger/logger.service';
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class ParticipantService {
|
2022-04-07 10:03:50 +02:00
|
|
|
/**
|
|
|
|
* Local participant Observable which pushes the local participant object in every update.
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
localParticipantObs: Observable<ParticipantAbstractModel>;
|
2022-08-11 17:24:11 +02:00
|
|
|
protected _localParticipant: BehaviorSubject<ParticipantAbstractModel | null> = new BehaviorSubject<ParticipantAbstractModel | null>(
|
|
|
|
null
|
|
|
|
);
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-04-07 10:03:50 +02:00
|
|
|
/**
|
|
|
|
* Remote participants Observable which pushes the remote participants array in every update.
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
remoteParticipantsObs: Observable<ParticipantAbstractModel[]>;
|
2022-08-11 17:24:11 +02:00
|
|
|
protected _remoteParticipants: BehaviorSubject<ParticipantAbstractModel[]> = new BehaviorSubject<ParticipantAbstractModel[]>([]);
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
protected localParticipant: ParticipantAbstractModel;
|
|
|
|
protected remoteParticipants: ParticipantAbstractModel[] = [];
|
|
|
|
|
|
|
|
protected log: ILogger;
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-15 16:24:01 +01:00
|
|
|
constructor(protected openviduAngularConfigSrv: OpenViduAngularConfigService, protected loggerSrv: LoggerService) {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.log = this.loggerSrv.get('ParticipantService');
|
|
|
|
|
|
|
|
this.localParticipantObs = this._localParticipant.asObservable();
|
|
|
|
this.remoteParticipantsObs = this._remoteParticipants.asObservable();
|
2022-03-02 17:35:14 +01:00
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
initLocalParticipant(props: ParticipantProperties) {
|
2022-03-02 17:35:14 +01:00
|
|
|
this.localParticipant = this.newParticipant(props);
|
2022-01-19 17:24:11 +01:00
|
|
|
this.updateLocalParticipant();
|
|
|
|
}
|
|
|
|
|
2022-02-14 14:12:58 +01:00
|
|
|
getLocalParticipant(): ParticipantAbstractModel {
|
|
|
|
return this.localParticipant;
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
getMyCameraPublisher(): Publisher {
|
|
|
|
return <Publisher>this.localParticipant.getCameraConnection().streamManager;
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
setMyCameraPublisher(publisher: Publisher) {
|
|
|
|
this.localParticipant.setCameraPublisher(publisher);
|
|
|
|
}
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
setMyCameraConnectionId(connectionId: string) {
|
|
|
|
this.localParticipant.setCameraConnectionId(connectionId);
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:45:30 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
getMyScreenPublisher(): Publisher {
|
|
|
|
return <Publisher>this.localParticipant.getScreenConnection()?.streamManager;
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
setMyScreenPublisher(publisher: Publisher) {
|
|
|
|
this.localParticipant.setScreenPublisher(publisher);
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
setMyScreenConnectionId(connectionId: string) {
|
|
|
|
this.localParticipant.setScreenConnectionId(connectionId);
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:45:30 +01:00
|
|
|
/**
|
2022-03-23 13:48:17 +01:00
|
|
|
* @internal
|
|
|
|
*/
|
2022-03-23 13:45:30 +01:00
|
|
|
enableWebcamStream() {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.localParticipant.enableCamera();
|
|
|
|
this.updateLocalParticipant();
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:45:30 +01:00
|
|
|
/**
|
2022-03-23 13:48:17 +01:00
|
|
|
* @internal
|
|
|
|
*/
|
2022-03-23 13:45:30 +01:00
|
|
|
disableWebcamStream() {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.localParticipant.disableCamera();
|
|
|
|
this.updateLocalParticipant();
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-25 13:53:49 +01:00
|
|
|
activeMyScreenShare(screenPublisher: Publisher) {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.log.d('Enabling screen publisher');
|
|
|
|
|
2022-01-26 11:30:30 +01:00
|
|
|
const steramModel: StreamModel = {
|
2022-01-19 17:24:11 +01:00
|
|
|
type: VideoType.SCREEN,
|
|
|
|
videoEnlarged: true,
|
|
|
|
streamManager: screenPublisher,
|
|
|
|
connected: true,
|
2022-08-11 17:24:11 +02:00
|
|
|
connectionId: ''
|
2022-01-19 17:24:11 +01:00
|
|
|
};
|
|
|
|
|
2022-02-25 13:53:49 +01:00
|
|
|
this.resetRemoteStreamsToNormalSize();
|
|
|
|
this.resetMyStreamsToNormalSize();
|
2022-01-26 11:30:30 +01:00
|
|
|
this.localParticipant.addConnection(steramModel);
|
2022-01-19 17:24:11 +01:00
|
|
|
this.updateLocalParticipant();
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:45:30 +01:00
|
|
|
/**
|
2022-03-23 13:48:17 +01:00
|
|
|
* @internal
|
|
|
|
*/
|
2022-03-23 13:45:30 +01:00
|
|
|
disableScreenStream() {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.localParticipant.disableScreen();
|
|
|
|
this.updateLocalParticipant();
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-28 14:37:35 +01:00
|
|
|
setMyNickname(nickname: string) {
|
|
|
|
this.localParticipant.setNickname(nickname);
|
2022-03-02 11:02:06 +01:00
|
|
|
this.updateLocalParticipant();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-28 13:48:58 +01:00
|
|
|
getMyNickname(): string {
|
|
|
|
return this.localParticipant.nickname;
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-06-02 10:57:47 +02:00
|
|
|
getMyRole(): string {
|
|
|
|
return this.localParticipant.getRole();
|
|
|
|
}
|
|
|
|
|
2022-12-23 16:17:04 +01:00
|
|
|
amIModerator(): boolean {
|
|
|
|
return this.getMyRole() === OpenViduRole.MODERATOR;
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:45:30 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-07 15:40:05 +01:00
|
|
|
toggleMyVideoEnlarged(connectionId: string) {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.localParticipant.toggleVideoEnlarged(connectionId);
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-25 13:53:49 +01:00
|
|
|
resetMyStreamsToNormalSize() {
|
2022-03-23 13:45:30 +01:00
|
|
|
if (this.localParticipant.someHasVideoEnlarged()) {
|
2022-02-25 13:53:49 +01:00
|
|
|
this.localParticipant.setAllVideoEnlarged(false);
|
|
|
|
this.updateLocalParticipant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
clear() {
|
2022-03-23 13:45:30 +01:00
|
|
|
this.disableScreenStream();
|
2022-01-19 17:24:11 +01:00
|
|
|
this.remoteParticipants = [];
|
2022-08-11 17:24:11 +02:00
|
|
|
this.updateRemoteParticipants();
|
2022-01-19 17:24:11 +01:00
|
|
|
this.updateLocalParticipant();
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-25 11:19:21 +01:00
|
|
|
isMyCameraActive(): boolean {
|
|
|
|
return this.localParticipant.isCameraActive();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-04-05 15:44:24 +02:00
|
|
|
isMyVideoActive(): boolean {
|
|
|
|
return this.localParticipant.isCameraVideoActive();
|
|
|
|
}
|
|
|
|
|
|
|
|
isMyAudioActive(): boolean {
|
2022-06-16 14:01:07 +02:00
|
|
|
return this.localParticipant?.hasAudioActive();
|
2022-04-05 15:44:24 +02:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-25 11:19:21 +01:00
|
|
|
isMyScreenActive(): boolean {
|
|
|
|
return this.localParticipant.isScreenActive();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-25 11:19:21 +01:00
|
|
|
isOnlyMyCameraActive(): boolean {
|
|
|
|
return this.isMyCameraActive() && !this.isMyScreenActive();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-25 11:19:21 +01:00
|
|
|
isOnlyMyScreenActive(): boolean {
|
|
|
|
return this.isMyScreenActive() && !this.isMyCameraActive();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-25 11:19:21 +01:00
|
|
|
haveICameraAndScreenActive(): boolean {
|
|
|
|
return this.isMyCameraActive() && this.isMyScreenActive();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
hasScreenAudioActive(): boolean {
|
|
|
|
return this.localParticipant.isScreenAudioActive();
|
|
|
|
}
|
|
|
|
|
2022-04-07 10:03:50 +02:00
|
|
|
/**
|
|
|
|
* Force to update the local participant object and fire a new {@link localParticipantObs} Observable event.
|
|
|
|
*/
|
2022-02-14 14:12:58 +01:00
|
|
|
updateLocalParticipant() {
|
2023-02-24 20:26:48 +01:00
|
|
|
this._localParticipant.next(
|
|
|
|
Object.assign(Object.create(Object.getPrototypeOf(this.localParticipant)), { ...this.localParticipant })
|
|
|
|
);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* REMOTE USERS
|
|
|
|
*/
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
addRemoteConnection(connectionId: string, data: string, subscriber: Subscriber) {
|
2022-02-25 13:53:49 +01:00
|
|
|
const type: VideoType = this.getTypeConnectionData(data);
|
|
|
|
const streamModel: StreamModel = {
|
|
|
|
type,
|
|
|
|
videoEnlarged: type === VideoType.SCREEN,
|
2022-01-19 17:24:11 +01:00
|
|
|
streamManager: subscriber,
|
2022-03-23 13:48:17 +01:00
|
|
|
connected: true,
|
2022-01-19 17:24:11 +01:00
|
|
|
connectionId
|
|
|
|
};
|
|
|
|
|
2022-03-08 17:20:19 +01:00
|
|
|
// Avoiding create a new participant if participantId param is not exist in connection data
|
|
|
|
// participant Id is necessary for allowing to have multiple connection in one participant
|
|
|
|
const participantId = this.getParticipantIdFromData(data) || connectionId;
|
|
|
|
|
2022-01-19 17:24:11 +01:00
|
|
|
const participantAdded = this.getRemoteParticipantById(participantId);
|
|
|
|
if (!!participantAdded) {
|
|
|
|
this.log.d('Adding connection to existing participant: ', participantId);
|
2022-03-23 13:48:17 +01:00
|
|
|
if (participantAdded.hasConnectionType(streamModel.type)) {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.log.d('Participant has publisher, updating it');
|
2022-02-25 13:53:49 +01:00
|
|
|
participantAdded.setPublisher(streamModel.type, subscriber);
|
2022-01-19 17:24:11 +01:00
|
|
|
} else {
|
|
|
|
this.log.d('Participant has not publisher, adding it');
|
2022-03-23 13:48:17 +01:00
|
|
|
if (streamModel.type === VideoType.SCREEN) {
|
2022-03-03 10:36:17 +01:00
|
|
|
this.resetRemoteStreamsToNormalSize();
|
|
|
|
this.resetMyStreamsToNormalSize();
|
|
|
|
}
|
2022-02-25 13:53:49 +01:00
|
|
|
participantAdded.addConnection(streamModel);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
} else {
|
2022-02-25 13:53:49 +01:00
|
|
|
this.log.w('Creating new participant with id: ', participantId);
|
2022-03-02 17:35:14 +01:00
|
|
|
const props: ParticipantProperties = {
|
|
|
|
nickname: this.getNicknameFromConnectionData(data),
|
|
|
|
local: false,
|
|
|
|
id: participantId
|
2022-03-23 13:48:17 +01:00
|
|
|
};
|
2022-03-02 17:35:14 +01:00
|
|
|
const remoteParticipant = this.newParticipant(props, streamModel);
|
2022-01-19 17:24:11 +01:00
|
|
|
this.remoteParticipants.push(remoteParticipant);
|
|
|
|
}
|
|
|
|
this.updateRemoteParticipants();
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
getRemoteParticipants(): ParticipantAbstractModel[] {
|
|
|
|
return this.remoteParticipants;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-25 13:53:49 +01:00
|
|
|
resetRemoteStreamsToNormalSize() {
|
2022-03-23 13:48:17 +01:00
|
|
|
this.remoteParticipants.forEach((participant) => participant.setAllVideoEnlarged(false));
|
2022-02-25 13:53:49 +01:00
|
|
|
this.updateRemoteParticipants();
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
removeConnectionByConnectionId(connectionId: string) {
|
|
|
|
this.log.w('Deleting connection: ', connectionId);
|
2022-08-11 17:24:11 +02:00
|
|
|
let participant: ParticipantAbstractModel | undefined;
|
2022-01-19 17:24:11 +01:00
|
|
|
if (this.localParticipant.hasConnectionId(connectionId)) {
|
|
|
|
participant = this.localParticipant;
|
|
|
|
} else {
|
|
|
|
participant = this.getRemoteParticipantByConnectionId(connectionId);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (participant) {
|
2022-02-25 13:53:49 +01:00
|
|
|
const removeStream: StreamModel = participant.removeConnection(connectionId);
|
2022-01-19 17:24:11 +01:00
|
|
|
//TODO: Timeout of X seconds?? Its possible sometimes the connections map was empty but must not be deleted
|
2022-02-15 13:24:08 +01:00
|
|
|
if (participant.streams.size === 0) {
|
2022-01-19 17:24:11 +01:00
|
|
|
// Remove participants without connections
|
|
|
|
this.remoteParticipants = this.remoteParticipants.filter((p) => p !== participant);
|
|
|
|
}
|
2022-03-23 13:48:17 +01:00
|
|
|
if (removeStream.type === VideoType.SCREEN) {
|
|
|
|
const remoteScreens = this.remoteParticipants.filter((p) => p.isScreenActive());
|
|
|
|
if (remoteScreens.length > 0) {
|
2022-02-25 13:53:49 +01:00
|
|
|
// Enlarging the last screen connection active
|
2022-03-23 13:48:17 +01:00
|
|
|
const lastScreenActive = remoteScreens[remoteScreens.length - 1];
|
2022-02-25 13:53:49 +01:00
|
|
|
lastScreenActive.setScreenEnlarged(true);
|
2022-03-23 13:48:17 +01:00
|
|
|
} else if (this.localParticipant.isScreenActive()) {
|
2022-02-25 13:53:49 +01:00
|
|
|
// Enlarging my screen if thereare not any remote screen active
|
|
|
|
this.localParticipant.setScreenEnlarged(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-19 17:24:11 +01:00
|
|
|
this.updateRemoteParticipants();
|
|
|
|
}
|
|
|
|
}
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-08-11 17:24:11 +02:00
|
|
|
getRemoteParticipantByConnectionId(connectionId: string): ParticipantAbstractModel | undefined {
|
2022-01-19 17:24:11 +01:00
|
|
|
return this.remoteParticipants.find((p) => p.hasConnectionId(connectionId));
|
|
|
|
}
|
|
|
|
|
2022-08-11 17:24:11 +02:00
|
|
|
protected getRemoteParticipantById(id: string): ParticipantAbstractModel | undefined {
|
2022-01-19 17:24:11 +01:00
|
|
|
return this.remoteParticipants.find((p) => p.id === id);
|
|
|
|
}
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
someoneIsSharingScreen(): boolean {
|
|
|
|
return this.remoteParticipants.some((p) => p.someHasVideoEnlarged());
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-07 15:40:05 +01:00
|
|
|
toggleRemoteVideoEnlarged(connectionId: string) {
|
2022-08-11 17:24:11 +02:00
|
|
|
const participant = this.getRemoteParticipantByConnectionId(connectionId);
|
|
|
|
participant?.toggleVideoEnlarged(connectionId);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
getNicknameFromConnectionData(data: string): string {
|
|
|
|
try {
|
2023-04-24 14:09:31 +02:00
|
|
|
const dataClean = data.replace('%/%{}', '');
|
|
|
|
return JSON.parse(dataClean).clientData;
|
2022-01-19 17:24:11 +01:00
|
|
|
} catch (error) {
|
|
|
|
return 'OpenVidu_User';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-02-28 14:37:35 +01:00
|
|
|
setRemoteNickname(connectionId: string, nickname: string) {
|
|
|
|
const participant = this.getRemoteParticipantByConnectionId(connectionId);
|
|
|
|
if (participant) {
|
|
|
|
participant.setNickname(nickname);
|
2022-04-01 11:05:25 +02:00
|
|
|
this.updateRemoteParticipants();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-05 15:44:24 +02:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-04-01 11:05:25 +02:00
|
|
|
setRemoteMutedForcibly(id: string, value: boolean) {
|
|
|
|
const participant = this.getRemoteParticipantById(id);
|
|
|
|
if (participant) {
|
|
|
|
participant.setMutedForcibly(value);
|
|
|
|
this.updateRemoteParticipants();
|
2022-02-28 14:37:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 10:03:50 +02:00
|
|
|
/**
|
|
|
|
* Force to update the remote participants object and fire a new {@link remoteParticipantsObs} Observable event.
|
|
|
|
*/
|
2022-02-25 13:53:49 +01:00
|
|
|
updateRemoteParticipants() {
|
2022-03-03 10:21:33 +01:00
|
|
|
this._remoteParticipants.next([...this.remoteParticipants]);
|
2022-02-25 13:53:49 +01:00
|
|
|
}
|
|
|
|
|
2022-10-31 13:40:39 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param data
|
|
|
|
* @returns Stream video type
|
|
|
|
*/
|
|
|
|
getTypeConnectionData(data: string): VideoType {
|
2022-01-19 17:24:11 +01:00
|
|
|
try {
|
|
|
|
return JSON.parse(data).type;
|
|
|
|
} catch (error) {
|
|
|
|
return VideoType.CAMERA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected getParticipantIdFromData(data: string): string {
|
|
|
|
try {
|
|
|
|
return JSON.parse(data).participantId;
|
|
|
|
} catch (error) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 17:35:14 +01:00
|
|
|
protected newParticipant(props: ParticipantProperties, streamModel?: StreamModel) {
|
2022-03-23 13:48:17 +01:00
|
|
|
if (this.openviduAngularConfigSrv.hasParticipantFactory()) {
|
2022-03-02 17:35:14 +01:00
|
|
|
return this.openviduAngularConfigSrv.getParticipantFactory().apply(this, [props, streamModel]);
|
2022-02-14 14:12:58 +01:00
|
|
|
}
|
2022-03-02 17:35:14 +01:00
|
|
|
return new ParticipantModel(props, streamModel);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
}
|