From 27d770b3685befe0f56c96b6f033f299c851455c Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Sun, 27 Jan 2019 14:38:37 +0100 Subject: [PATCH] Do not subscribe to audio-only streams in BEST_FIT layout when video-only COMPOSED recording --- .../angular/frontend/src/app/app.routing.ts | 14 ++++---- .../layout-best-fit.component.ts | 32 ++++++++++++------- .../service/ComposedRecordingService.java | 2 +- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/openvidu-server/src/angular/frontend/src/app/app.routing.ts b/openvidu-server/src/angular/frontend/src/app/app.routing.ts index ab456c05..5955d489 100644 --- a/openvidu-server/src/angular/frontend/src/app/app.routing.ts +++ b/openvidu-server/src/angular/frontend/src/app/app.routing.ts @@ -8,20 +8,20 @@ import { LayoutBestFitComponent } from 'app/components/layouts/layout-best-fit/l const appRoutes: Routes = [ { path: '', - component: DashboardComponent, - pathMatch: 'full' + component: DashboardComponent }, { path: 'session/:sessionId', - component: SessionDetailsComponent, - pathMatch: 'full' + component: SessionDetailsComponent }, { path: 'layout-best-fit/:sessionId/:secret', - component: LayoutBestFitComponent, - pathMatch: 'full' + component: LayoutBestFitComponent + }, + { + path: 'layout-best-fit/:sessionId/:secret/:onlyVideo', + component: LayoutBestFitComponent } ]; export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes, { useHash: true }); - diff --git a/openvidu-server/src/angular/frontend/src/app/components/layouts/layout-best-fit/layout-best-fit.component.ts b/openvidu-server/src/angular/frontend/src/app/components/layouts/layout-best-fit/layout-best-fit.component.ts index b07e457f..753b20df 100644 --- a/openvidu-server/src/angular/frontend/src/app/components/layouts/layout-best-fit/layout-best-fit.component.ts +++ b/openvidu-server/src/angular/frontend/src/app/components/layouts/layout-best-fit/layout-best-fit.component.ts @@ -15,6 +15,7 @@ export class LayoutBestFitComponent implements OnInit, OnDestroy { openviduLayout: OpenViduLayout; sessionId: string; secret: string; + onlyVideo = false; session: Session; subscribers: Subscriber[] = []; @@ -41,6 +42,9 @@ export class LayoutBestFitComponent implements OnInit, OnDestroy { this.route.params.subscribe(params => { this.sessionId = params.sessionId; this.secret = params.secret; + if (params.onlyVideo !== null) { + this.onlyVideo = JSON.parse(params.onlyVideo); + } }); } @@ -66,18 +70,24 @@ export class LayoutBestFitComponent implements OnInit, OnDestroy { this.session = OV.initSession(); this.session.on('streamCreated', (event: StreamEvent) => { - let changeFixedRatio = false; - if (event.stream.typeOfVideo === 'SCREEN') { - this.numberOfScreenStreams++; - changeFixedRatio = true; + if (!(this.onlyVideo && !event.stream.hasVideo)) { + let changeFixedRatio = false; + if (event.stream.typeOfVideo === 'SCREEN') { + this.numberOfScreenStreams++; + changeFixedRatio = true; + } + const subscriber: Subscriber = this.session.subscribe( + event.stream, + undefined, + { subscribeToAudio: event.stream.hasAudio && !this.onlyVideo } + ); + subscriber.on('streamPlaying', (e: StreamManagerEvent) => { + const video: HTMLVideoElement = subscriber.videos[0].video; + video.parentElement.parentElement.classList.remove('custom-class'); + this.updateLayout(changeFixedRatio); + }); + this.addSubscriber(subscriber); } - const subscriber: Subscriber = this.session.subscribe(event.stream, undefined); - subscriber.on('streamPlaying', (e: StreamManagerEvent) => { - const video: HTMLVideoElement = subscriber.videos[0].video; - video.parentElement.parentElement.classList.remove('custom-class'); - this.updateLayout(changeFixedRatio); - }); - this.addSubscriber(subscriber); }); this.session.on('streamDestroyed', (event: StreamEvent) => { diff --git a/openvidu-server/src/main/java/io/openvidu/server/recording/service/ComposedRecordingService.java b/openvidu-server/src/main/java/io/openvidu/server/recording/service/ComposedRecordingService.java index a66f65ad..566373e6 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/recording/service/ComposedRecordingService.java +++ b/openvidu-server/src/main/java/io/openvidu/server/recording/service/ComposedRecordingService.java @@ -457,7 +457,7 @@ public class ComposedRecordingService extends RecordingService { } else { layout = recording.getRecordingLayout().name().toLowerCase().replaceAll("_", "-"); finalUrl = "https://OPENVIDUAPP:" + secret + "@" + location + "/#/layout-" + layout + "/" + shortSessionId - + "/" + secret; + + "/" + secret + "/" + !recording.hasAudio(); } return finalUrl;