openvidu-components: Subscribed to STT only for camera type

pull/748/head
Carlos Santos 2022-10-31 13:40:39 +01:00
parent 8925d09bd6
commit d68326a374
2 changed files with 15 additions and 6 deletions

View File

@ -299,12 +299,16 @@ export class SessionComponent implements OnInit {
const subscriber: Subscriber = this.session.subscribe(event.stream, undefined); const subscriber: Subscriber = this.session.subscribe(event.stream, undefined);
this.participantService.addRemoteConnection(connectionId, data, subscriber); this.participantService.addRemoteConnection(connectionId, data, subscriber);
// this.oVSessionService.sendNicknameSignal(event.stream.connection); // this.oVSessionService.sendNicknameSignal(event.stream.connection);
if (this.participantService.getTypeConnectionData(data) === VideoType.CAMERA) {
// Only subscribe to STT when stream is CAMERA type and it is a remote stream
try { try {
await this.session.subscribeToSpeechToText(event.stream, this.captionService.getLangSelected().ISO); await this.session.subscribeToSpeechToText(event.stream, this.captionService.getLangSelected().ISO);
} catch (error) { } catch (error) {
this.log.e('Error subscribing from STT: ', error); this.log.e('Error subscribing from STT: ', error);
} }
} }
}
}); });
} }

View File

@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { Publisher, Subscriber } from 'openvidu-browser'; import { Publisher, Subscriber } from 'openvidu-browser';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs';
import { ILogger } from '../../models/logger.model'; import { ILogger } from '../../models/logger.model';
import { StreamModel, ParticipantAbstractModel, ParticipantModel, ParticipantProperties } from '../../models/participant.model'; import { ParticipantAbstractModel, ParticipantModel, ParticipantProperties, StreamModel } from '../../models/participant.model';
import { VideoType } from '../../models/video-type.model'; import { VideoType } from '../../models/video-type.model';
import { OpenViduAngularConfigService } from '../config/openvidu-angular.config.service'; import { OpenViduAngularConfigService } from '../config/openvidu-angular.config.service';
import { LoggerService } from '../logger/logger.service'; import { LoggerService } from '../logger/logger.service';
@ -399,7 +399,12 @@ export class ParticipantService {
this._remoteParticipants.next([...this.remoteParticipants]); this._remoteParticipants.next([...this.remoteParticipants]);
} }
protected getTypeConnectionData(data: string): VideoType { /**
* @internal
* @param data
* @returns Stream video type
*/
getTypeConnectionData(data: string): VideoType {
try { try {
return JSON.parse(data).type; return JSON.parse(data).type;
} catch (error) { } catch (error) {