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 { ActionService } from '../../services/action/action.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 { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.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 { PanelService } from '../../services/panel/panel.service';
|
||||
import { ParticipantService } from '../../services/participant/participant.service';
|
||||
import { PlatformService } from '../../services/platform/platform.service';
|
||||
import { RecordingService } from '../../services/recording/recording.service';
|
||||
import { TranslateService } from '../../services/translate/translate.service';
|
||||
import { VirtualBackgroundService } from '../../services/virtual-background/virtual-background.service';
|
||||
|
@ -102,8 +101,7 @@ export class SessionComponent implements OnInit, OnDestroy {
|
|||
private recordingService: RecordingService,
|
||||
private broadcastingService: BroadcastingService,
|
||||
private translateService: TranslateService,
|
||||
private captionService: CaptionService,
|
||||
private platformService: PlatformService,
|
||||
// private captionService: CaptionService,
|
||||
private backgroundService: VirtualBackgroundService,
|
||||
private cd: ChangeDetectorRef
|
||||
) {
|
||||
|
@ -191,7 +189,7 @@ export class SessionComponent implements OnInit, OnDestroy {
|
|||
// this.subscribeToBroadcastingEvents();
|
||||
}
|
||||
try {
|
||||
await this.participantService.connectLocalParticipant();
|
||||
await this.participantService.connect();
|
||||
this.cd.markForCheck();
|
||||
this.loading = false;
|
||||
this.onParticipantCreated.emit(this.participantService.getLocalParticipant());
|
||||
|
|
|
@ -2,10 +2,8 @@ import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/cor
|
|||
import { Subscription } from 'rxjs';
|
||||
import { CustomDevice } from '../../../models/device.model';
|
||||
import { DeviceService } from '../../../services/device/device.service';
|
||||
import { PanelService } from '../../../services/panel/panel.service';
|
||||
import { ParticipantService } from '../../../services/participant/participant.service';
|
||||
import { StorageService } from '../../../services/storage/storage.service';
|
||||
import { VirtualBackgroundService } from '../../../services/virtual-background/virtual-background.service';
|
||||
import { ParticipantModel } from '../../../models/participant.model';
|
||||
|
||||
/**
|
||||
|
@ -28,11 +26,9 @@ export class VideoDevicesComponent implements OnInit, OnDestroy {
|
|||
localParticipantSubscription: Subscription;
|
||||
|
||||
constructor(
|
||||
private panelService: PanelService,
|
||||
private storageSrv: StorageService,
|
||||
private deviceSrv: DeviceService,
|
||||
private participantService: ParticipantService,
|
||||
private backgroundService: VirtualBackgroundService
|
||||
private participantService: ParticipantService
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
|
|
|
@ -2,11 +2,10 @@ import { Injectable } from '@angular/core';
|
|||
import { CameraType, CustomDevice, DeviceType } from '../../models/device.model';
|
||||
import { ILogger } from '../../models/logger.model';
|
||||
import { OpenViduComponentsConfigService } from '../config/openvidu-components-angular.config.service';
|
||||
|
||||
import { LoggerService } from '../logger/logger.service';
|
||||
import { PlatformService } from '../platform/platform.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { LocalTrack, Room, Track, createLocalTracks } from 'livekit-client';
|
||||
import { LocalTrack, Room, createLocalTracks } from 'livekit-client';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -51,12 +50,6 @@ export class DeviceService {
|
|||
this.devices = await this.getLocalDevices();
|
||||
} catch (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 {
|
||||
if (this.deviceAccessDeniedError) {
|
||||
this.log.w('Media devices permissions were not granted.');
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ILogger } from '../../models/logger.model';
|
||||
|
||||
import { OpenViduComponentsConfigService } from '../config/openvidu-components-angular.config.service';
|
||||
import { DeviceService } from '../device/device.service';
|
||||
import { LoggerService } from '../logger/logger.service';
|
||||
import { PlatformService } from '../platform/platform.service';
|
||||
import {
|
||||
AudioCaptureOptions,
|
||||
ConnectionState,
|
||||
|
@ -49,8 +45,6 @@ export class OpenViduService {
|
|||
* @internal
|
||||
*/
|
||||
constructor(
|
||||
private openviduAngularConfigSrv: OpenViduComponentsConfigService,
|
||||
private platformService: PlatformService,
|
||||
private loggerSrv: LoggerService,
|
||||
private deviceService: DeviceService,
|
||||
private storageSrv: StorageService
|
||||
|
@ -97,7 +91,10 @@ export class OpenViduService {
|
|||
try {
|
||||
await this.room.connect(this.livekitUrl, this.livekitToken);
|
||||
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) {
|
||||
this.log.e('Error connecting to room:', error);
|
||||
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.
|
||||
* @internal
|
||||
*/
|
||||
async connectLocalParticipant(): Promise<void> {
|
||||
async connect(): Promise<void> {
|
||||
let isCameraEnabled: boolean = this.isMyCameraEnabled();
|
||||
let isMicrophoneEnabled: boolean = this.isMyMicrophoneEnabled();
|
||||
|
||||
//TODO: Las directivas audioEnabled y videoEnabled son ignoradas sin prejoin page
|
||||
// !FIXME
|
||||
|
||||
let prejoinTracks = this.openviduService.getLocalTracks();
|
||||
|
||||
if (prejoinTracks.length === 0 && (isCameraEnabled || isMicrophoneEnabled)) {
|
||||
prejoinTracks = await this.openviduService.createLocalTracks(isCameraEnabled, isMicrophoneEnabled);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue