openvidu-testapp: Add button to show codec for each video [Only works in Chrome]

pull/600/head
cruizba 2020-09-08 14:26:50 +02:00
parent ea9776bccb
commit 02cccb9751
4 changed files with 62 additions and 6 deletions

View File

@ -25,6 +25,7 @@ import { EventsDialogComponent } from './components/dialogs/events-dialog/events
import { PublisherPropertiesDialogComponent } from './components/dialogs/publisher-properties-dialog/publisher-properties-dialog.component'; import { PublisherPropertiesDialogComponent } from './components/dialogs/publisher-properties-dialog/publisher-properties-dialog.component';
import { ScenarioPropertiesDialogComponent } from './components/dialogs/scenario-properties-dialog/scenario-properties-dialog.component'; import { ScenarioPropertiesDialogComponent } from './components/dialogs/scenario-properties-dialog/scenario-properties-dialog.component';
import { FilterDialogComponent } from './components/dialogs/filter-dialog/filter-dialog.component'; import { FilterDialogComponent } from './components/dialogs/filter-dialog/filter-dialog.component';
import { ShowCodecDialogComponent } from './components/dialogs/show-codec-dialog/show-codec-dialog.component';
import { OpenviduRestService } from './services/openvidu-rest.service'; import { OpenviduRestService } from './services/openvidu-rest.service';
import { OpenviduParamsService } from './services/openvidu-params.service'; import { OpenviduParamsService } from './services/openvidu-params.service';
@ -49,7 +50,8 @@ import { MuteSubscribersService } from './services/mute-subscribers.service';
ScenarioPropertiesDialogComponent, ScenarioPropertiesDialogComponent,
FilterDialogComponent, FilterDialogComponent,
UsersTableComponent, UsersTableComponent,
TableVideoComponent TableVideoComponent,
ShowCodecDialogComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
@ -74,7 +76,8 @@ import { MuteSubscribersService } from './services/mute-subscribers.service';
LocalRecordingDialogComponent, LocalRecordingDialogComponent,
PublisherPropertiesDialogComponent, PublisherPropertiesDialogComponent,
ScenarioPropertiesDialogComponent, ScenarioPropertiesDialogComponent,
FilterDialogComponent FilterDialogComponent,
ShowCodecDialogComponent
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })

View File

@ -0,0 +1,27 @@
import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
@Component({
selector: 'app-codec-used-dialog',
template: `
<div id="app-codec-dialog-container">
<h2 id="codec-used-title-dialog" mat-dialog-title>Used Codec: <span id="video-codec-used">{{usedVideoCodec}}</span></h2>
<button mat-button id="close-dialog-btn" [mat-dialog-close]="{}">CLOSE</button>
</div>
`,
styles: [`
#app-codec-dialog-container {
text-align: center
}
`]
})
export class ShowCodecDialogComponent {
usedVideoCodec;
constructor(public dialogRef: MatDialogRef<ShowCodecDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data) {
this.usedVideoCodec = data.usedVideoCodec;
}
}

View File

@ -5,7 +5,7 @@
<button class="video-btn events-btn bottom-left-rounded" title="Publisher events" (click)="openPublisherEventsDialog()"> <button class="video-btn events-btn bottom-left-rounded" title="Publisher events" (click)="openPublisherEventsDialog()">
<mat-icon aria-label="Publisher events" class="mat-icon material-icons" role="img" aria-hidden="true">notifications</mat-icon> <mat-icon aria-label="Publisher events" class="mat-icon material-icons" role="img" aria-hidden="true">notifications</mat-icon>
</button> </button>
<button class="video-btn events-btn bottom-left-rounded" title="Peer Connection Stats" (click)="showStats()"> <button class="video-btn events-btn bottom-left-rounded" title="Peer Connection Stats" (click)="showCodecUsed()">
<mat-icon aria-label="Peer Connection Stats" class="mat-icon material-icons" role="img" aria-hidden="true">info</mat-icon> <mat-icon aria-label="Peer Connection Stats" class="mat-icon material-icons" role="img" aria-hidden="true">info</mat-icon>
</button> </button>
</div> </div>
@ -44,6 +44,9 @@
<button *ngIf="subbed" class="video-btn events-btn bottom-left-rounded" title="Subscriber events" (click)="openSubscriberEventsDialog()"> <button *ngIf="subbed" class="video-btn events-btn bottom-left-rounded" title="Subscriber events" (click)="openSubscriberEventsDialog()">
<mat-icon aria-label="Subscriber events" class="mat-icon material-icons" role="img" aria-hidden="true">notifications</mat-icon> <mat-icon aria-label="Subscriber events" class="mat-icon material-icons" role="img" aria-hidden="true">notifications</mat-icon>
</button> </button>
<button class="video-btn events-btn bottom-left-rounded" title="Peer Connection Stats" (click)="showCodecUsed()">
<mat-icon aria-label="Peer Connection Stats" class="mat-icon material-icons" role="img" aria-hidden="true">info</mat-icon>
</button>
</div> </div>
<div class="bottom-div"> <div class="bottom-div">
<button class="video-btn sub-btn" title="Subscribe/Unsubscribe" (click)="subUnsub()"> <button class="video-btn sub-btn" title="Subscribe/Unsubscribe" (click)="subUnsub()">

View File

@ -21,6 +21,7 @@ import { LocalRecordingDialogComponent } from '../dialogs/local-recording-dialog
import { ExtensionDialogComponent } from '../dialogs/extension-dialog/extension-dialog.component'; import { ExtensionDialogComponent } from '../dialogs/extension-dialog/extension-dialog.component';
import { FilterDialogComponent } from '../dialogs/filter-dialog/filter-dialog.component'; import { FilterDialogComponent } from '../dialogs/filter-dialog/filter-dialog.component';
import { OpenViduEvent } from '../openvidu-instance/openvidu-instance.component'; import { OpenViduEvent } from '../openvidu-instance/openvidu-instance.component';
import { ShowCodecDialogComponent } from '../dialogs/show-codec-dialog/show-codec-dialog.component';
@Component({ @Component({
selector: 'app-video', selector: 'app-video',
@ -67,6 +68,9 @@ export class VideoComponent implements OnInit, OnDestroy {
recordIcon = 'fiber_manual_record'; recordIcon = 'fiber_manual_record';
pauseRecordIcon = ''; pauseRecordIcon = '';
// Stats
usedVideoCodec: string;
constructor(private dialog: MatDialog, private muteSubscribersService: MuteSubscribersService constructor(private dialog: MatDialog, private muteSubscribersService: MuteSubscribersService
) { } ) { }
@ -727,11 +731,30 @@ export class VideoComponent implements OnInit, OnDestroy {
}); });
} }
async showStats() { async showCodecUsed() {
let stats = await this.streamManager.stream.getWebRtcPeer().pc.getStats(null); let stats = await this.streamManager.stream.getWebRtcPeer().pc.getStats(null);
let codecIdIndex = null;
// Search codec Index
stats.forEach(report => { stats.forEach(report => {
console.log(report); if (!this.streamManager.remote && report.id.includes("RTCOutboundRTPVideoStream")) {
codecIdIndex = report.codecId;
} else if (this.streamManager.remote && report.id.includes("RTCInboundRTPVideoStream")) {
codecIdIndex = report.codecId;
}
}) })
// Search codec Info
stats.forEach(report => {
if (report.id === codecIdIndex) {
this.usedVideoCodec = report.mimeType;
}
})
this.dialog.open(ShowCodecDialogComponent, {
data: {
usedVideoCodec: this.usedVideoCodec
},
width: '450px'
});
} }
} }