+
+
+ Audio
+ Video
+
+
+
+
+
+
+ 0">
+ {{audioDevice.label}}
+
+
+
+
+
+
+ 0">
+ {{videoDevice.label}}
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/openvidu-testapp/src/app/components/dialogs/scenario-properties-dialog/scenario-properties-dialog.component.ts b/openvidu-testapp/src/app/components/dialogs/scenario-properties-dialog/scenario-properties-dialog.component.ts
new file mode 100644
index 00000000..4757e515
--- /dev/null
+++ b/openvidu-testapp/src/app/components/dialogs/scenario-properties-dialog/scenario-properties-dialog.component.ts
@@ -0,0 +1,109 @@
+import { Component, Inject } from '@angular/core';
+import { MAT_DIALOG_DATA, MatDialogRef, MAT_CHECKBOX_CLICK_ACTION } from '@angular/material';
+
+import { PublisherProperties, OpenVidu } from 'openvidu-browser';
+
+@Component({
+ selector: 'app-scenario-properties-dialog',
+ templateUrl: './scenario-properties-dialog.component.html',
+ styleUrls: ['./scenario-properties-dialog.component.css'],
+ providers: [
+ { provide: MAT_CHECKBOX_CLICK_ACTION, useValue: 'noop' }
+ ]
+})
+export class ScenarioPropertiesDialogComponent {
+
+ OV: OpenVidu;
+ publisherProperties: PublisherProperties;
+ initValue: PublisherProperties;
+
+ audioSource;
+ videoSource;
+
+ audioSourceAux;
+ videoSourceAux;
+
+ audioDevices = [];
+ videoDevices = [];
+
+ turnConf: string;
+ manualTurnConf: RTCIceServer = {};
+
+ constructor(public dialogRef: MatDialogRefScenario properties
+
+
+ Auto
+ Freeice
+ Manual
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{token}}
+{{token}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Report
+
+
+
+
\ No newline at end of file
diff --git a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.spec.ts b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.spec.ts
new file mode 100644
index 00000000..dafcd550
--- /dev/null
+++ b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { TestScenariosComponent } from './test-scenarios.component';
+
+describe('TestScenariosComponent', () => {
+ let component: TestScenariosComponent;
+ let fixture: ComponentFixture' + JSON.stringify(newEvent)); + }); + } + + ngOnDestroy() { + this.endScenario(); + this.paramsSubscription.unsubscribe(); + this.eventsInfoSubscription.unsubscribe(); + } + + loadScenario(subsPubs: number, pubs: number, subs: number): void { + + this.totalNumberOfStreams = pubs + subsPubs; // Number of outgoing streams + this.totalNumberOfStreams += pubs * (subs + subsPubs); // Publishers only times total number of subscribers + if (subsPubs > 0) { + // Publihsers/Subscribers times total number of subscribers (minus 1 for not being subscribed to their own publisher) + this.totalNumberOfStreams += subsPubs * (subs + (subsPubs - 1)); + } + + this.users = []; + this.report = { 'streamsOut': { 'count': 0, 'items': [] }, 'streamsIn': { 'count': 0, 'items': [] } }; + this.loadSubsPubs(subsPubs); + this.loadPubs(pubs); + this.loadSubs(subs); + this.startSession(); + this.scenarioPlaying = true; + } + + endScenario() { + for (const session of this.sessions) { + session.disconnect(); + } + this.publishers = []; + this.subscribers = []; + this.OVs = []; + this.sessions = []; + this.connections = []; + this.scenarioPlaying = false; + delete this.report; + this.numberOfReports = 0; + this.textAreaValue = ''; + this.stringifyAllReports = ''; + } + + private loadSubsPubs(n: number): void { + for (let i = 0; i < n; i++) { + this.users.push({ + subscribeTo: true, + publishTo: true, + startSession: true + }); + } + } + + private loadSubs(n: number): void { + for (let i = 0; i < n; i++) { + this.users.push({ + subscribeTo: true, + publishTo: false, + startSession: true + }); + } + } + + private loadPubs(n: number): void { + for (let i = 0; i < n; i++) { + this.users.push({ + subscribeTo: false, + publishTo: true, + startSession: true + }); + } + } + + private startSession() { + for (const user of this.users) { + + this.getToken().then(token => { + const OV = new OpenVidu(); + const session = OV.initSession(); + + this.OVs.push(OV); + this.sessions.push(session); + + session.on('connectionCreated', (event: ConnectionEvent) => { + if (this.connections.indexOf(event.connection.connectionId) === -1) { + this.connections.push(event.connection.connectionId); + } + }); + + if (user.subscribeTo) { + session.on('streamCreated', (event: StreamEvent) => { + const subscriber = session.subscribe(event.stream, undefined, (error) => { + const subAux = this.subscribers + .find(s => s.connectionId === session.connection.connectionId).subs + .find(s => s.streamManager.stream.connection.connectionId === subscriber.stream.connection.connectionId); + if (!!error) { + subAux.state['errorConnecting'] = Date.now(); + } else { + subAux.state['connected'] = Date.now(); + } + }); + + const sub = this.subscribers.find(s => s.connectionId === session.connection.connectionId); + if (!sub) { + this.subscribers.push({ + connectionId: session.connection.connectionId, + subs: [{ + connectionId: session.connection.connectionId, + streamManager: subscriber, + state: { 'connecting': Date.now() } + }] + }); + } else { + sub.subs.push({ + connectionId: session.connection.connectionId, + streamManager: subscriber, + state: { 'connecting': Date.now() } + }); + } + + subscriber.on('streamPlaying', (e: StreamManagerEvent) => { + this.subscribers + .find(s => s.connectionId === session.connection.connectionId).subs + .find(s => s.streamManager.stream.connection.connectionId === subscriber.stream.connection.connectionId) + .state['playing'] = Date.now(); + }); + }); + } + + session.connect(token) + .then(() => { + if (user.publishTo) { + + const publisher = OV.initPublisher(undefined, this.publisherProperties); + const publisherWrapper = { + connectionId: session.connection.connectionId, + streamManager: publisher, + state: { 'connecting': Date.now() } + }; + + publisher.on('streamCreated', () => { + publisherWrapper.state['connected'] = Date.now(); + }); + publisher.on('streamPlaying', () => { + publisherWrapper.state['playing'] = Date.now(); + }); + session.publish(publisher).catch(() => { + publisherWrapper.state['errorConnecting'] = Date.now(); + }); + this.publishers.push(publisherWrapper); + + } + }) + .catch(); + }); + } + } + + private getToken(): Promise
+
+
+ {{success() ? 'done' : 'warning'}}
+
+
+ STREAMS ++ OUT + ++ IN + + |
+
+ {{publisher.streamManager.stream.connection.connectionId}} | {{publisher.streamManager.stream.streamId}} + |
+
---|---|
{{connectionId}} | +
+ |
+
-
+