mirror of https://github.com/OpenVidu/openvidu.git
openvidu-components: Updated participant model
Moved local and nickname properties to Participant Model from Stream Modelpull/707/head
parent
5f22072f71
commit
8f2d598236
|
@ -1,13 +1,19 @@
|
||||||
<mat-list>
|
<mat-list>
|
||||||
<mat-list-item>
|
<mat-list-item>
|
||||||
<mat-icon matListAvatar class="participant-avatar">person</mat-icon>
|
<mat-icon matListAvatar class="participant-avatar">person</mat-icon>
|
||||||
<h3 matLine class="participant-nickname">{{ _participant | nickname }}</h3>
|
<h3 matLine class="participant-nickname">{{ _participant.nickname }}</h3>
|
||||||
<p matLine class="participant-subtitle">{{ _participant | streamsEnabled }}</p>
|
<p matLine class="participant-subtitle">{{ _participant | streamsEnabled }}</p>
|
||||||
<!-- <p matLine>
|
<!-- <p matLine>
|
||||||
<span class="participant-subtitle"></span>
|
<span class="participant-subtitle"></span>
|
||||||
</p> -->
|
</p> -->
|
||||||
|
|
||||||
<button mat-icon-button id="action-btn" [class.warn-btn]="_participant.isMutedForcibly" (click)="toggleMuteForcibly()">
|
<button
|
||||||
|
mat-icon-button
|
||||||
|
id="action-btn"
|
||||||
|
*ngIf="!_participant.local"
|
||||||
|
[class.warn-btn]="_participant.isMutedForcibly"
|
||||||
|
(click)="toggleMuteForcibly()"
|
||||||
|
>
|
||||||
<mat-icon *ngIf="!_participant.isMutedForcibly">volume_up</mat-icon>
|
<mat-icon *ngIf="!_participant.isMutedForcibly">volume_up</mat-icon>
|
||||||
<mat-icon *ngIf="_participant.isMutedForcibly">volume_off</mat-icon>
|
<mat-icon *ngIf="_participant.isMutedForcibly">volume_off</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -197,7 +197,7 @@ export class SessionComponent implements OnInit {
|
||||||
|
|
||||||
//Sending nicnkanme signal to new participants
|
//Sending nicnkanme signal to new participants
|
||||||
if (this.openviduService.needSendNicknameSignal()) {
|
if (this.openviduService.needSendNicknameSignal()) {
|
||||||
const data = { clientData: this.participantService.getWebcamNickname() };
|
const data = { clientData: this.participantService.getMyNickname() };
|
||||||
this.openviduService.sendSignal(Signal.NICKNAME_CHANGED, [event.connection], data);
|
this.openviduService.sendSignal(Signal.NICKNAME_CHANGED, [event.connection], data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
>
|
>
|
||||||
<div class="nickname" [class.fullscreen]="isFullscreen" *ngIf="showNickname">
|
<div class="nickname" [class.fullscreen]="isFullscreen" *ngIf="showNickname">
|
||||||
<div (click)="toggleNicknameForm()" class="nicknameContainer" selected *ngIf="!toggleNickname">
|
<div (click)="toggleNicknameForm()" class="nicknameContainer" selected *ngIf="!toggleNickname">
|
||||||
<span id="nickname">{{ this._stream.nickname }}</span>
|
<span id="nickname" *ngIf="this._stream.type === 'CAMERA'">{{ this._stream.participant.nickname }}</span>
|
||||||
|
<span id="nickname" *ngIf="this._stream.type === 'SCREEN'">{{ this._stream.participant.nickname }}_SCREEN</span>
|
||||||
|
|
||||||
<span *ngIf="_stream.local || (_stream.streamManager && !_stream.streamManager?.remote)"> (edit)</span>
|
<span *ngIf="_stream.local || (_stream.streamManager && !_stream.streamManager?.remote)"> (edit)</span>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="toggleNickname && !this._stream.streamManager?.remote" [class.fullscreen]="isFullscreen" id="dialogNickname">
|
<div *ngIf="toggleNickname && !this._stream.streamManager?.remote" [class.fullscreen]="isFullscreen" id="dialogNickname">
|
||||||
|
@ -36,7 +38,7 @@
|
||||||
<ov-video
|
<ov-video
|
||||||
(dblclick)="toggleVideoEnlarged()"
|
(dblclick)="toggleVideoEnlarged()"
|
||||||
[streamManager]="_stream.streamManager"
|
[streamManager]="_stream.streamManager"
|
||||||
[mutedSound]="_stream.participant.isMutedForcibly"
|
[mutedSound]="_stream?.participant?.isMutedForcibly"
|
||||||
></ov-video>
|
></ov-video>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,9 @@ export class StreamComponent implements OnInit {
|
||||||
set stream(stream: StreamModel) {
|
set stream(stream: StreamModel) {
|
||||||
this._stream = stream;
|
this._stream = stream;
|
||||||
this.checkVideoEnlarged();
|
this.checkVideoEnlarged();
|
||||||
this.nicknameFormControl = new FormControl(this._stream.nickname, [Validators.maxLength(25), Validators.required]);
|
if(this._stream.participant) {
|
||||||
|
this.nicknameFormControl = new FormControl(this._stream.participant.nickname, [Validators.maxLength(25), Validators.required]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewChild('nicknameInput')
|
@ViewChild('nicknameInput')
|
||||||
|
@ -104,7 +106,7 @@ export class StreamComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleNicknameForm() {
|
toggleNicknameForm() {
|
||||||
if (this._stream.local) {
|
if (this._stream.participant.local) {
|
||||||
this.toggleNickname = !this.toggleNickname;
|
this.toggleNickname = !this.toggleNickname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,7 @@ import { Publisher, StreamManager } from 'openvidu-browser';
|
||||||
import { VideoType } from './video-type.model';
|
import { VideoType } from './video-type.model';
|
||||||
|
|
||||||
export interface StreamModel {
|
export interface StreamModel {
|
||||||
local: boolean;
|
|
||||||
connected: boolean;
|
connected: boolean;
|
||||||
nickname: string;
|
|
||||||
type: VideoType;
|
type: VideoType;
|
||||||
streamManager: StreamManager;
|
streamManager: StreamManager;
|
||||||
videoEnlarged: boolean;
|
videoEnlarged: boolean;
|
||||||
|
@ -15,13 +13,17 @@ export interface StreamModel {
|
||||||
export abstract class ParticipantAbstractModel {
|
export abstract class ParticipantAbstractModel {
|
||||||
streams: Map<VideoType, StreamModel> = new Map();
|
streams: Map<VideoType, StreamModel> = new Map();
|
||||||
id: string;
|
id: string;
|
||||||
|
local: boolean;
|
||||||
|
nickname: string;
|
||||||
isMutedForcibly: boolean;
|
isMutedForcibly: boolean;
|
||||||
|
|
||||||
constructor(model?: StreamModel, id?: string) {
|
constructor(model?: StreamModel, id?: string, local?: boolean, nickname?: string) {
|
||||||
|
this.id = id ? id : new Date().getTime().toString();
|
||||||
|
this.local = local ? local : true,
|
||||||
|
this.nickname = nickname ? nickname : 'OpenVidu_User',
|
||||||
|
this.isMutedForcibly = false;
|
||||||
let streamModel: StreamModel = {
|
let streamModel: StreamModel = {
|
||||||
local: model ? model.local : true,
|
|
||||||
connected: true,
|
connected: true,
|
||||||
nickname: model ? model.nickname : 'OpenVidu_User',
|
|
||||||
type: model ? model.type : VideoType.CAMERA,
|
type: model ? model.type : VideoType.CAMERA,
|
||||||
streamManager: model ? model.streamManager : null,
|
streamManager: model ? model.streamManager : null,
|
||||||
videoEnlarged: model ? model.videoEnlarged : false,
|
videoEnlarged: model ? model.videoEnlarged : false,
|
||||||
|
@ -29,11 +31,10 @@ export abstract class ParticipantAbstractModel {
|
||||||
participant: this
|
participant: this
|
||||||
};
|
};
|
||||||
this.streams.set(streamModel.type, streamModel);
|
this.streams.set(streamModel.type, streamModel);
|
||||||
this.id = id ? id : new Date().getTime().toString();
|
|
||||||
this.isMutedForcibly = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addConnection(streamModel: StreamModel) {
|
addConnection(streamModel: StreamModel) {
|
||||||
|
streamModel.participant = this;
|
||||||
this.streams.set(streamModel.type, streamModel);
|
this.streams.set(streamModel.type, streamModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,26 +104,32 @@ export abstract class ParticipantAbstractModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
isLocal(): boolean {
|
isLocal(): boolean {
|
||||||
return Array.from(this.streams.values()).every((conn) => conn.local);
|
return this.local;
|
||||||
|
// return Array.from(this.streams.values()).every((conn) => conn.local);
|
||||||
}
|
}
|
||||||
|
|
||||||
setNickname(nickname: string) {
|
setNickname(nickname: string) {
|
||||||
this.streams.forEach((conn) => {
|
this.nickname = nickname;
|
||||||
if (conn.type === VideoType.CAMERA) {
|
// this.streams.forEach((conn) => {
|
||||||
conn.nickname = nickname;
|
// if (conn.type === VideoType.CAMERA) {
|
||||||
} else {
|
// conn.nickname = nickname;
|
||||||
conn.nickname = `${nickname}_${conn.type}`;
|
// } else {
|
||||||
}
|
// conn.nickname = `${nickname}_${conn.type}`;
|
||||||
});
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
getCameraNickname(): string {
|
getNickname() {
|
||||||
return this.getCameraConnection()?.nickname;
|
return this.nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
getScreenNickname(): string {
|
// getCameraNickname(): string {
|
||||||
return this.getScreenConnection()?.nickname;
|
// return this.getCameraConnection()?.nickname;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// getScreenNickname(): string {
|
||||||
|
// return this.getScreenConnection()?.nickname;
|
||||||
|
// }
|
||||||
|
|
||||||
setCameraPublisher(publisher: Publisher) {
|
setCameraPublisher(publisher: Publisher) {
|
||||||
const cameraConnection = this.getCameraConnection();
|
const cameraConnection = this.getCameraConnection();
|
||||||
|
|
|
@ -36,7 +36,7 @@ import { StreamComponent } from './components/stream/stream.component';
|
||||||
import { DialogTemplateComponent } from './components/material/dialog.component';
|
import { DialogTemplateComponent } from './components/material/dialog.component';
|
||||||
|
|
||||||
import { LinkifyPipe } from './pipes/linkify.pipe';
|
import { LinkifyPipe } from './pipes/linkify.pipe';
|
||||||
import { StreamsEnabledPipe, NicknamePipe, ParticipantStreamsPipe } from './pipes/participant.pipe';
|
import { StreamsEnabledPipe, ParticipantStreamsPipe } from './pipes/participant.pipe';
|
||||||
|
|
||||||
import { OpenViduAngularConfig } from './config/openvidu-angular.config';
|
import { OpenViduAngularConfig } from './config/openvidu-angular.config';
|
||||||
import { CdkOverlayContainer } from './config/custom-cdk-overlay';
|
import { CdkOverlayContainer } from './config/custom-cdk-overlay';
|
||||||
|
@ -74,7 +74,6 @@ import { ChatPanelDirective, LayoutDirective, PanelDirective, ParticipantPanelIt
|
||||||
LinkifyPipe,
|
LinkifyPipe,
|
||||||
ParticipantStreamsPipe,
|
ParticipantStreamsPipe,
|
||||||
StreamsEnabledPipe,
|
StreamsEnabledPipe,
|
||||||
NicknamePipe,
|
|
||||||
ParticipantPanelItemComponent,
|
ParticipantPanelItemComponent,
|
||||||
ParticipantsPanelComponent,
|
ParticipantsPanelComponent,
|
||||||
VideoconferenceComponent,
|
VideoconferenceComponent,
|
||||||
|
@ -146,7 +145,6 @@ import { ChatPanelDirective, LayoutDirective, PanelDirective, ParticipantPanelIt
|
||||||
AudioWaveComponent,
|
AudioWaveComponent,
|
||||||
ParticipantStreamsPipe,
|
ParticipantStreamsPipe,
|
||||||
StreamsEnabledPipe,
|
StreamsEnabledPipe,
|
||||||
NicknamePipe,
|
|
||||||
CommonModule,
|
CommonModule,
|
||||||
ToolbarDirective,
|
ToolbarDirective,
|
||||||
PanelDirective,
|
PanelDirective,
|
||||||
|
|
|
@ -26,11 +26,3 @@ export class StreamsEnabledPipe implements PipeTransform {
|
||||||
return `(${participant?.getConnectionTypesActive().toString().replace(',', ', ')})`;
|
return `(${participant?.getConnectionTypesActive().toString().replace(',', ', ')})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Pipe({ name: 'nickname', pure: false })
|
|
||||||
export class NicknamePipe implements PipeTransform {
|
|
||||||
constructor() {}
|
|
||||||
transform(participant: ParticipantAbstractModel): string {
|
|
||||||
return participant?.getCameraNickname();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ export class ChatService {
|
||||||
if (message !== '' && message !== ' ') {
|
if (message !== '' && message !== ' ') {
|
||||||
const data = {
|
const data = {
|
||||||
message: message,
|
message: message,
|
||||||
nickname: this.participantService.getWebcamNickname()
|
nickname: this.participantService.getMyNickname()
|
||||||
};
|
};
|
||||||
|
|
||||||
this.openviduService.sendSignal(Signal.CHAT, undefined, data);
|
this.openviduService.sendSignal(Signal.CHAT, undefined, data);
|
||||||
|
|
|
@ -78,7 +78,7 @@ export class OpenViduService {
|
||||||
|
|
||||||
async connectSession(session: Session, token: string): Promise<void> {
|
async connectSession(session: Session, token: string): Promise<void> {
|
||||||
if (!!token && session) {
|
if (!!token && session) {
|
||||||
const nickname = this.participantService.getWebcamNickname();
|
const nickname = this.participantService.getMyNickname();
|
||||||
const participantId = this.participantService.getMyParticipantId();
|
const participantId = this.participantService.getMyParticipantId();
|
||||||
if (session === this.webcamSession) {
|
if (session === this.webcamSession) {
|
||||||
this.log.d('Connecting webcam session');
|
this.log.d('Connecting webcam session');
|
||||||
|
@ -248,10 +248,11 @@ export class OpenViduService {
|
||||||
};
|
};
|
||||||
this.webcamSession.signal(signalOptions);
|
this.webcamSession.signal(signalOptions);
|
||||||
|
|
||||||
if (type === Signal.NICKNAME_CHANGED && !!this.getScreenSession().connection) {
|
// TODO: Check if it is necessary
|
||||||
signalOptions.data = JSON.stringify({ clientData: this.participantService.getScreenNickname() });
|
// if (type === Signal.NICKNAME_CHANGED && !!this.getScreenSession().connection) {
|
||||||
this.getScreenSession()?.signal(signalOptions);
|
// signalOptions.data = JSON.stringify({ clientData: this.participantService.getScreenNickname() });
|
||||||
}
|
// this.getScreenSession()?.signal(signalOptions);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
async replaceTrack(videoType: VideoType, props: PublisherProperties) {
|
async replaceTrack(videoType: VideoType, props: PublisherProperties) {
|
||||||
|
@ -353,7 +354,7 @@ export class OpenViduService {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.log.e(error);
|
this.log.e(error);
|
||||||
}
|
}
|
||||||
return oldNickname !== this.participantService.getWebcamNickname();
|
return oldNickname !== this.participantService.getMyNickname();
|
||||||
}
|
}
|
||||||
|
|
||||||
isMyOwnConnection(connectionId: string): boolean {
|
isMyOwnConnection(connectionId: string): boolean {
|
||||||
|
|
|
@ -82,11 +82,9 @@ export class ParticipantService {
|
||||||
this.log.d('Enabling screen publisher');
|
this.log.d('Enabling screen publisher');
|
||||||
|
|
||||||
const steramModel: StreamModel = {
|
const steramModel: StreamModel = {
|
||||||
local: true,
|
|
||||||
type: VideoType.SCREEN,
|
type: VideoType.SCREEN,
|
||||||
videoEnlarged: true,
|
videoEnlarged: true,
|
||||||
streamManager: screenPublisher,
|
streamManager: screenPublisher,
|
||||||
nickname: `${this.localParticipant.getCameraNickname()}_${VideoType.SCREEN}`,
|
|
||||||
connected: true,
|
connected: true,
|
||||||
connectionId: null
|
connectionId: null
|
||||||
};
|
};
|
||||||
|
@ -115,13 +113,16 @@ export class ParticipantService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getWebcamNickname(): string {
|
getMyNickname(): string {
|
||||||
return this.localParticipant.getCameraNickname();
|
return this.localParticipant.nickname;
|
||||||
}
|
}
|
||||||
|
// getWebcamNickname(): string {
|
||||||
|
// return this.localParticipant.getCameraNickname();
|
||||||
|
// }
|
||||||
|
|
||||||
getScreenNickname(): string {
|
// getScreenNickname(): string {
|
||||||
return this.localParticipant.getScreenNickname();
|
// return this.localParticipant.getScreenNickname();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
toggleMyVideoEnlarged(connectionId: string) {
|
toggleMyVideoEnlarged(connectionId: string) {
|
||||||
|
@ -195,11 +196,9 @@ export class ParticipantService {
|
||||||
|
|
||||||
const type: VideoType = this.getTypeConnectionData(data);
|
const type: VideoType = this.getTypeConnectionData(data);
|
||||||
const streamModel: StreamModel = {
|
const streamModel: StreamModel = {
|
||||||
local: false,
|
|
||||||
type,
|
type,
|
||||||
videoEnlarged: type === VideoType.SCREEN,
|
videoEnlarged: type === VideoType.SCREEN,
|
||||||
streamManager: subscriber,
|
streamManager: subscriber,
|
||||||
nickname: this.getNicknameFromConnectionData(data),
|
|
||||||
connected: true,
|
connected: true,
|
||||||
connectionId
|
connectionId
|
||||||
};
|
};
|
||||||
|
@ -219,7 +218,9 @@ export class ParticipantService {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.log.w('Creating new participant with id: ', participantId);
|
this.log.w('Creating new participant with id: ', participantId);
|
||||||
const remoteParticipant = this.newParticipant(streamModel, participantId);
|
const nickname = this.getNicknameFromConnectionData(data);
|
||||||
|
const local = false;
|
||||||
|
const remoteParticipant = this.newParticipant(streamModel, participantId, local, nickname);
|
||||||
this.remoteParticipants.push(remoteParticipant);
|
this.remoteParticipants.push(remoteParticipant);
|
||||||
}
|
}
|
||||||
this.updateRemoteParticipants();
|
this.updateRemoteParticipants();
|
||||||
|
@ -305,11 +306,11 @@ export class ParticipantService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected newParticipant(streamModel?: StreamModel, participantId?: string) {
|
protected newParticipant(streamModel?: StreamModel, participantId?: string, local?: boolean, nickname?: string) {
|
||||||
|
|
||||||
if(this.openviduAngularConfigSrv.hasParticipantFactory()){
|
if(this.openviduAngularConfigSrv.hasParticipantFactory()){
|
||||||
return this.openviduAngularConfigSrv.getParticipantFactory().apply(this, [streamModel, participantId]);
|
return this.openviduAngularConfigSrv.getParticipantFactory().apply(this, [streamModel, participantId, local, nickname]);
|
||||||
}
|
}
|
||||||
return new ParticipantModel(streamModel, participantId);
|
return new ParticipantModel(streamModel, participantId, local, nickname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue