From d81124150a96df019bc5206750fabd9e8dc51bc3 Mon Sep 17 00:00:00 2001 From: csantosm <4a.santos@gmail.com> Date: Wed, 23 Mar 2022 13:45:30 +0100 Subject: [PATCH] openvidu-components: Refactored methods name --- .../components/pre-join/pre-join.component.ts | 4 +-- .../components/toolbar/toolbar.component.ts | 14 ++++---- .../lib/services/openvidu/openvidu.service.ts | 8 ++--- .../participant/participant.service.ts | 34 ++++++++----------- 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/pre-join/pre-join.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/pre-join/pre-join.component.ts index 7a4efe65..e3dfdaa2 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/pre-join/pre-join.component.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/pre-join/pre-join.component.ts @@ -131,11 +131,11 @@ export class PreJoinComponent implements OnInit, OnDestroy { if (this.participantService.haveICameraAndScreenActive()) { // Cam will not published, disable webcam with screensharing active - this.participantService.disableWebcamUser(); + this.participantService.disableWebcamStream(); this.openviduService.publishAudio(this.participantService.getMyScreenPublisher(), publish); } else if (this.participantService.isOnlyMyScreenActive()) { // Cam will be published, enable webcam - this.participantService.enableWebcamUser(); + this.participantService.enableWebcamStream(); } this.isVideoMuted = !this.isVideoMuted; diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/toolbar/toolbar.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/toolbar/toolbar.component.ts index 7410d4af..c133bd61 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/toolbar/toolbar.component.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/toolbar/toolbar.component.ts @@ -175,7 +175,7 @@ export class ToolbarComponent implements OnInit, OnDestroy { // Disabling webcam if (this.participantService.haveICameraAndScreenActive()) { this.openviduService.publishVideo(this.participantService.getMyCameraPublisher(), publishVideo); - this.participantService.disableWebcamUser(); + this.participantService.disableWebcamStream(); this.openviduService.unpublish(this.participantService.getMyCameraPublisher()); this.openviduService.publishAudio(this.participantService.getMyScreenPublisher(), publishAudio); return; @@ -190,7 +190,7 @@ export class ToolbarComponent implements OnInit, OnDestroy { await this.openviduService.publish(this.participantService.getMyCameraPublisher()); this.openviduService.publishAudio(this.participantService.getMyScreenPublisher(), false); this.openviduService.publishAudio(this.participantService.getMyCameraPublisher(), hasAudio); - this.participantService.enableWebcamUser(); + this.participantService.enableWebcamStream(); } // Muting/unmuting webcam this.openviduService.publishVideo(this.participantService.getMyCameraPublisher(), publishVideo); @@ -206,7 +206,7 @@ export class ToolbarComponent implements OnInit, OnDestroy { try { // Disabling screenShare if (this.participantService.haveICameraAndScreenActive()) { - this.participantService.disableScreenUser(); + this.participantService.disableScreenStream(); this.openviduService.unpublish(this.participantService.getMyScreenPublisher()); return; } @@ -246,7 +246,7 @@ export class ToolbarComponent implements OnInit, OnDestroy { // this.openviduService.sendNicknameSignal(); if (!this.participantService.hasCameraVideoActive()) { // Disabling webcam - this.participantService.disableWebcamUser(); + this.participantService.disableWebcamStream(); this.openviduService.unpublish(this.participantService.getMyCameraPublisher()); } }); @@ -268,8 +268,8 @@ export class ToolbarComponent implements OnInit, OnDestroy { await this.openviduService.publish(this.participantService.getMyCameraPublisher()); this.openviduService.publishAudio(this.participantService.getMyScreenPublisher(), false); this.openviduService.publishAudio(this.participantService.getMyCameraPublisher(), hasAudio); - this.participantService.enableWebcamUser(); - this.participantService.disableScreenUser(); + this.participantService.enableWebcamStream(); + this.participantService.disableScreenStream(); this.openviduService.unpublish(this.participantService.getMyScreenPublisher()); } catch (error) { this.log.e('There was an error toggling screen share:', error.code, error.message); @@ -331,7 +331,7 @@ export class ToolbarComponent implements OnInit, OnDestroy { } protected subscribeToUserMediaProperties() { this.localParticipantSubscription = this.participantService.localParticipantObs.subscribe((p) => { - if(p) { + if (p) { this.isWebcamVideoActive = p.isCameraVideoActive(); this.isWebcamAudioActive = p.isCameraAudioActive(); this.isScreenShareActive = p.isScreenActive(); diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/openvidu/openvidu.service.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/openvidu/openvidu.service.ts index 5ae10377..26cd0f7e 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/openvidu/openvidu.service.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/openvidu/openvidu.service.ts @@ -79,7 +79,7 @@ export class OpenViduService { async connectSession(session: Session, token: string): Promise { if (!!token && session) { const nickname = this.participantService.getMyNickname(); - const participantId = this.participantService.getMyParticipantId(); + const participantId = this.participantService.getLocalParticipant().id; if (session === this.webcamSession) { this.log.d('Connecting webcam session'); await this.webcamSession.connect(token, { @@ -207,7 +207,7 @@ export class OpenViduService { // TODO: Remove this method when replaceTrack issue is fixed // https://github.com/OpenVidu/openvidu/pull/700 republishTrack(properties: PublisherProperties): Promise { - const {videoSource, audioSource, mirror} = properties; + const { videoSource, audioSource, mirror } = properties; return new Promise(async (resolve, reject) => { if (!!videoSource) { this.log.d('Replacing video track ' + videoSource); @@ -262,7 +262,7 @@ export class OpenViduService { if (videoType === VideoType.CAMERA) { //TODO: Uncomment this section when replaceTrack issue is fixed // https://github.com/OpenVidu/openvidu/pull/700 - throw('Replace track feature has a bug. We are trying to fix it'); + throw 'Replace track feature has a bug. We are trying to fix it'; // let mediaStream: MediaStream; // const oldMediaStream = this.participantService.getMyCameraPublisher().stream.getMediaStream(); // const isFirefoxPlatform = this.platformService.isFirefox(); @@ -363,7 +363,7 @@ export class OpenViduService { ); } - getRemoteCameraConnections(): Connection[] { + getRemoteConnections(): Connection[] { // Avoid screen connections const remoteCameraConnections: Connection[] = Array.from(this.webcamSession.remoteConnections.values()).filter((conn) => { let type: VideoType; diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/participant/participant.service.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/participant/participant.service.ts index ea88e921..a817d1a4 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/participant/participant.service.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/participant/participant.service.ts @@ -39,9 +39,6 @@ export class ParticipantService { getLocalParticipant(): ParticipantAbstractModel { return this.localParticipant; } - getMyParticipantId(): string { - return this.localParticipant.id; - } getMyCameraPublisher(): Publisher { return this.localParticipant.getCameraConnection().streamManager; @@ -54,10 +51,9 @@ export class ParticipantService { this.localParticipant.setCameraConnectionId(connectionId); } - getMyCameraConnectionId(): string { - return this.localParticipant.getCameraConnection().connectionId; - } - + /** + * @internal + */ getMyScreenPublisher(): Publisher { return this.localParticipant.getScreenConnection()?.streamManager; } @@ -70,12 +66,14 @@ export class ParticipantService { this.localParticipant.setScreenConnectionId(connectionId); } - enableWebcamUser() { + /** + enableWebcamStream() { this.localParticipant.enableCamera(); this.updateLocalParticipant(); } - disableWebcamUser() { + /** + disableWebcamStream() { this.localParticipant.disableCamera(); this.updateLocalParticipant(); } @@ -97,7 +95,8 @@ export class ParticipantService { this.updateLocalParticipant(); } - disableScreenUser() { + /** + disableScreenStream() { this.localParticipant.disableScreen(); this.updateLocalParticipant(); } @@ -110,13 +109,10 @@ export class ParticipantService { getMyNickname(): string { return this.localParticipant.nickname; } - // getWebcamNickname(): string { - // return this.localParticipant.getCameraNickname(); - // } - // getScreenNickname(): string { - // return this.localParticipant.getScreenNickname(); - // } + /** + * @internal + */ toggleMyVideoEnlarged(connectionId: string) { @@ -125,14 +121,14 @@ export class ParticipantService { resetMyStreamsToNormalSize() { - if(this.localParticipant.someHasVideoEnlarged()){ + if (this.localParticipant.someHasVideoEnlarged()) { this.localParticipant.setAllVideoEnlarged(false); this.updateLocalParticipant(); } } clear() { - this.disableScreenUser(); + this.disableScreenStream(); // this.localParticipant = this.newParticipant(); // this._screensharing.next(false); this.remoteParticipants = []; @@ -174,7 +170,7 @@ export class ParticipantService { } updateLocalParticipant() { - this._localParticipant.next(Object.assign(Object.create(this.localParticipant),this.localParticipant)); + this._localParticipant.next(Object.assign(Object.create(this.localParticipant), this.localParticipant)); } /**