mirror of https://github.com/OpenVidu/openvidu.git
ov-components: Refactored and cleaned code
parent
f28652b425
commit
d02b12141b
|
@ -23,7 +23,7 @@ import { DataTopic } from '../../models/data-topic.model';
|
||||||
import { RoomStatusData } from '../../models/room.model';
|
import { RoomStatusData } from '../../models/room.model';
|
||||||
import { ActionService } from '../../services/action/action.service';
|
import { ActionService } from '../../services/action/action.service';
|
||||||
import { BroadcastingService } from '../../services/broadcasting/broadcasting.service';
|
import { BroadcastingService } from '../../services/broadcasting/broadcasting.service';
|
||||||
import { CaptionService } from '../../services/caption/caption.service';
|
// import { CaptionService } from '../../services/caption/caption.service';
|
||||||
import { ChatService } from '../../services/chat/chat.service';
|
import { ChatService } from '../../services/chat/chat.service';
|
||||||
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
|
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
|
||||||
import { LayoutService } from '../../services/layout/layout.service';
|
import { LayoutService } from '../../services/layout/layout.service';
|
||||||
|
@ -31,7 +31,6 @@ import { LoggerService } from '../../services/logger/logger.service';
|
||||||
import { OpenViduService } from '../../services/openvidu/openvidu.service';
|
import { OpenViduService } from '../../services/openvidu/openvidu.service';
|
||||||
import { PanelService } from '../../services/panel/panel.service';
|
import { PanelService } from '../../services/panel/panel.service';
|
||||||
import { ParticipantService } from '../../services/participant/participant.service';
|
import { ParticipantService } from '../../services/participant/participant.service';
|
||||||
import { PlatformService } from '../../services/platform/platform.service';
|
|
||||||
import { RecordingService } from '../../services/recording/recording.service';
|
import { RecordingService } from '../../services/recording/recording.service';
|
||||||
import { TranslateService } from '../../services/translate/translate.service';
|
import { TranslateService } from '../../services/translate/translate.service';
|
||||||
import { VirtualBackgroundService } from '../../services/virtual-background/virtual-background.service';
|
import { VirtualBackgroundService } from '../../services/virtual-background/virtual-background.service';
|
||||||
|
@ -102,8 +101,7 @@ export class SessionComponent implements OnInit, OnDestroy {
|
||||||
private recordingService: RecordingService,
|
private recordingService: RecordingService,
|
||||||
private broadcastingService: BroadcastingService,
|
private broadcastingService: BroadcastingService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private captionService: CaptionService,
|
// private captionService: CaptionService,
|
||||||
private platformService: PlatformService,
|
|
||||||
private backgroundService: VirtualBackgroundService,
|
private backgroundService: VirtualBackgroundService,
|
||||||
private cd: ChangeDetectorRef
|
private cd: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
|
@ -191,7 +189,7 @@ export class SessionComponent implements OnInit, OnDestroy {
|
||||||
// this.subscribeToBroadcastingEvents();
|
// this.subscribeToBroadcastingEvents();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.participantService.connectLocalParticipant();
|
await this.participantService.connect();
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.onParticipantCreated.emit(this.participantService.getLocalParticipant());
|
this.onParticipantCreated.emit(this.participantService.getLocalParticipant());
|
||||||
|
|
|
@ -2,10 +2,8 @@ import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/cor
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { CustomDevice } from '../../../models/device.model';
|
import { CustomDevice } from '../../../models/device.model';
|
||||||
import { DeviceService } from '../../../services/device/device.service';
|
import { DeviceService } from '../../../services/device/device.service';
|
||||||
import { PanelService } from '../../../services/panel/panel.service';
|
|
||||||
import { ParticipantService } from '../../../services/participant/participant.service';
|
import { ParticipantService } from '../../../services/participant/participant.service';
|
||||||
import { StorageService } from '../../../services/storage/storage.service';
|
import { StorageService } from '../../../services/storage/storage.service';
|
||||||
import { VirtualBackgroundService } from '../../../services/virtual-background/virtual-background.service';
|
|
||||||
import { ParticipantModel } from '../../../models/participant.model';
|
import { ParticipantModel } from '../../../models/participant.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,11 +26,9 @@ export class VideoDevicesComponent implements OnInit, OnDestroy {
|
||||||
localParticipantSubscription: Subscription;
|
localParticipantSubscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private panelService: PanelService,
|
|
||||||
private storageSrv: StorageService,
|
private storageSrv: StorageService,
|
||||||
private deviceSrv: DeviceService,
|
private deviceSrv: DeviceService,
|
||||||
private participantService: ParticipantService,
|
private participantService: ParticipantService
|
||||||
private backgroundService: VirtualBackgroundService
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
|
|
@ -2,11 +2,10 @@ import { Injectable } from '@angular/core';
|
||||||
import { CameraType, CustomDevice, DeviceType } from '../../models/device.model';
|
import { CameraType, CustomDevice, DeviceType } from '../../models/device.model';
|
||||||
import { ILogger } from '../../models/logger.model';
|
import { ILogger } from '../../models/logger.model';
|
||||||
import { OpenViduComponentsConfigService } from '../config/openvidu-components-angular.config.service';
|
import { OpenViduComponentsConfigService } from '../config/openvidu-components-angular.config.service';
|
||||||
|
|
||||||
import { LoggerService } from '../logger/logger.service';
|
import { LoggerService } from '../logger/logger.service';
|
||||||
import { PlatformService } from '../platform/platform.service';
|
import { PlatformService } from '../platform/platform.service';
|
||||||
import { StorageService } from '../storage/storage.service';
|
import { StorageService } from '../storage/storage.service';
|
||||||
import { LocalTrack, Room, Track, createLocalTracks } from 'livekit-client';
|
import { LocalTrack, Room, createLocalTracks } from 'livekit-client';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
@ -51,12 +50,6 @@ export class DeviceService {
|
||||||
this.devices = await this.getLocalDevices();
|
this.devices = await this.getLocalDevices();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.log.e('Error getting media devices', error);
|
this.log.e('Error getting media devices', error);
|
||||||
// TODO: Fix this error
|
|
||||||
// this.deviceAccessDeniedError = (<OpenViduError>error).name === OpenViduErrorName.DEVICE_ACCESS_DENIED;
|
|
||||||
// if (this.deviceAccessDeniedError) {
|
|
||||||
// this.disableVideoDevices();
|
|
||||||
// this.disableAudioDevices();
|
|
||||||
// }
|
|
||||||
} finally {
|
} finally {
|
||||||
if (this.deviceAccessDeniedError) {
|
if (this.deviceAccessDeniedError) {
|
||||||
this.log.w('Media devices permissions were not granted.');
|
this.log.w('Media devices permissions were not granted.');
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { ILogger } from '../../models/logger.model';
|
import { ILogger } from '../../models/logger.model';
|
||||||
|
|
||||||
import { OpenViduComponentsConfigService } from '../config/openvidu-components-angular.config.service';
|
|
||||||
import { DeviceService } from '../device/device.service';
|
import { DeviceService } from '../device/device.service';
|
||||||
import { LoggerService } from '../logger/logger.service';
|
import { LoggerService } from '../logger/logger.service';
|
||||||
import { PlatformService } from '../platform/platform.service';
|
|
||||||
import {
|
import {
|
||||||
AudioCaptureOptions,
|
AudioCaptureOptions,
|
||||||
ConnectionState,
|
ConnectionState,
|
||||||
|
@ -49,8 +45,6 @@ export class OpenViduService {
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private openviduAngularConfigSrv: OpenViduComponentsConfigService,
|
|
||||||
private platformService: PlatformService,
|
|
||||||
private loggerSrv: LoggerService,
|
private loggerSrv: LoggerService,
|
||||||
private deviceService: DeviceService,
|
private deviceService: DeviceService,
|
||||||
private storageSrv: StorageService
|
private storageSrv: StorageService
|
||||||
|
@ -97,7 +91,10 @@ export class OpenViduService {
|
||||||
try {
|
try {
|
||||||
await this.room.connect(this.livekitUrl, this.livekitToken);
|
await this.room.connect(this.livekitUrl, this.livekitToken);
|
||||||
this.log.d(`Successfully connected to room ${this.room.name}`);
|
this.log.d(`Successfully connected to room ${this.room.name}`);
|
||||||
this.room.localParticipant.setName(this.storageSrv.getParticipantName());
|
const participantName = this.storageSrv.getParticipantName();
|
||||||
|
if (participantName) {
|
||||||
|
this.room.localParticipant.setName(participantName);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.log.e('Error connecting to room:', error);
|
this.log.e('Error connecting to room:', error);
|
||||||
throw { code: 'CONNECTION_ERROR', message: `Error connecting to the server at the following URL: ${this.livekitUrl}` };
|
throw { code: 'CONNECTION_ERROR', message: `Error connecting to the server at the following URL: ${this.livekitUrl}` };
|
||||||
|
|
|
@ -86,14 +86,11 @@ export class ParticipantService {
|
||||||
* Connects to the room and publishes the local tracks.
|
* Connects to the room and publishes the local tracks.
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
async connectLocalParticipant(): Promise<void> {
|
async connect(): Promise<void> {
|
||||||
let isCameraEnabled: boolean = this.isMyCameraEnabled();
|
let isCameraEnabled: boolean = this.isMyCameraEnabled();
|
||||||
let isMicrophoneEnabled: boolean = this.isMyMicrophoneEnabled();
|
let isMicrophoneEnabled: boolean = this.isMyMicrophoneEnabled();
|
||||||
|
|
||||||
//TODO: Las directivas audioEnabled y videoEnabled son ignoradas sin prejoin page
|
|
||||||
// !FIXME
|
|
||||||
|
|
||||||
let prejoinTracks = this.openviduService.getLocalTracks();
|
let prejoinTracks = this.openviduService.getLocalTracks();
|
||||||
|
|
||||||
if (prejoinTracks.length === 0 && (isCameraEnabled || isMicrophoneEnabled)) {
|
if (prejoinTracks.length === 0 && (isCameraEnabled || isMicrophoneEnabled)) {
|
||||||
prejoinTracks = await this.openviduService.createLocalTracks(isCameraEnabled, isMicrophoneEnabled);
|
prejoinTracks = await this.openviduService.createLocalTracks(isCameraEnabled, isMicrophoneEnabled);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue