From c8400a6d69d7478e2133da5d454fee8b827abb4e Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Tue, 19 Jun 2018 09:34:35 +0200 Subject: [PATCH] openvidu-testapp: TURN conf in scenarios. Reload stream info button --- .../test-scenarios.component.css | 2 +- .../test-scenarios.component.html | 6 +- .../test-scenarios.component.ts | 109 ++++++++++-------- 3 files changed, 65 insertions(+), 52 deletions(-) diff --git a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.css b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.css index 60790150..de8a8fa9 100644 --- a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.css +++ b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.css @@ -27,6 +27,6 @@ app-openvidu-instance { width: 100%; } -#back-report-btn { +.report-btn{ float: right; } \ No newline at end of file diff --git a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.html b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.html index 6e01ba85..835bd51c 100644 --- a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.html +++ b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.html @@ -22,9 +22,13 @@
Report - +
\ No newline at end of file diff --git a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.ts b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.ts index 6f1f840c..d1a65a5a 100644 --- a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.ts +++ b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.ts @@ -182,6 +182,12 @@ export class TestScenariosComponent implements OnInit, OnDestroy { this.getToken().then(token => { const OV = new OpenVidu(); + + if (this.turnConf === 'freeice') { + OV.setAdvancedConfiguration({ iceServers: 'freeice' }); + } else if (this.turnConf === 'manual') { + OV.setAdvancedConfiguration({ iceServers: [this.manualTurnConf] }); + } const session = OV.initSession(); this.OVs.push(OV); @@ -294,48 +300,6 @@ export class TestScenariosComponent implements OnInit, OnDestroy { } addReportForStream(event: StreamManagerWrapper) { - - const getSessionInfo = () => { - let headers = new HttpHeaders(); - headers = headers.append('Authorization', 'Basic ' + btoa('OPENVIDUAPP:' + this.openviduSecret)); - this.http.get(this.openviduUrl + 'api/sessions/' + this.fixedSessionId, { headers }).subscribe( - sessionInfo => { - - this.report.streamsOut.items.forEach(report => { - const streamOutRemoteInfo = sessionInfo['connections'] - .find(c => c.connectionId === report.connectionId).publishers - .find(p => { - report.webrtcTagName = p.webrtcTagName; - return p.webrtcTagName === report.streamId; - }); - report.remoteCandidatePair = { - localCandidate: this.parseRemoteCandidatePair(streamOutRemoteInfo.localCandidate), - remoteCandidate: this.parseRemoteCandidatePair(streamOutRemoteInfo.remoteCandidate) - }; - }); - - this.report.streamsIn.items.forEach(report => { - const streamInRemoteInfo = sessionInfo['connections'] - .find(c => c.connectionId === report.connectionId).subscribers - .find(p => { - report.webrtcTagName = p.webrtcTagName; - return p.webrtcTagName === report.connectionId + '_' + report.streamId; - }); - report.remoteCandidatePair = { - localCandidate: this.parseRemoteCandidatePair(streamInRemoteInfo.localCandidate), - remoteCandidate: this.parseRemoteCandidatePair(streamInRemoteInfo.remoteCandidate) - }; - }); - - this.stringifyAllReports = JSON.stringify(this.report, null, '\t'); - if (!this.textAreaValue) { - this.textAreaValue = this.stringifyAllReports; - } - }, - error => { } - ); - }; - event.streamManager.stream.getSelectedIceCandidate() .then(localCandidatePair => { @@ -346,14 +310,16 @@ export class TestScenariosComponent implements OnInit, OnDestroy { connectionId: event.connectionId, streamId: event.streamManager.stream.streamId, state: event.state, - localCandidatePair: { + candidatePairSelectedByBrowser: { localCandidate: localCandidatePair.localCandidate, remoteCandidate: localCandidatePair.remoteCandidate }, - remoteCandidatePair: { + candidatePairSelectedByKms: { localCandidate: {}, remoteCandidate: {} - } + }, + iceCandidatesSentByBrowser: event.streamManager.stream.getLocalIceCandidateList(), + iceCandidatesReceivedByBrowser: event.streamManager.stream.getRemoteIceCandidateList() }; this.report.streamsIn.count++; @@ -363,14 +329,16 @@ export class TestScenariosComponent implements OnInit, OnDestroy { connectionId: event.connectionId, streamId: event.streamManager.stream.streamId, state: event.state, - localCandidatePair: { + candidatePairSelectedByBrowser: { localCandidate: localCandidatePair.localCandidate, remoteCandidate: localCandidatePair.remoteCandidate }, - remoteCandidatePair: { + candidatePairSelectedByKms: { localCandidate: {}, remoteCandidate: {} - } + }, + iceCandidatesSentByBrowser: event.streamManager.stream.getLocalIceCandidateList(), + iceCandidatesReceivedByBrowser: event.streamManager.stream.getRemoteIceCandidateList() }; this.report.streamsOut.count++; @@ -378,13 +346,53 @@ export class TestScenariosComponent implements OnInit, OnDestroy { } if (++this.numberOfReports === this.totalNumberOfStreams) { - getSessionInfo(); + this.updateRemoteStreamsInfo(); } }) .catch(); } + private updateRemoteStreamsInfo() { + let headers = new HttpHeaders(); + headers = headers.append('Authorization', 'Basic ' + btoa('OPENVIDUAPP:' + this.openviduSecret)); + this.http.get(this.openviduUrl + 'api/sessions/' + this.fixedSessionId, { headers }).subscribe( + sessionInfo => { + + this.report.streamsOut.items.forEach(report => { + const streamOutRemoteInfo = sessionInfo['connections'] + .find(c => c.connectionId === report.connectionId).publishers + .find(p => { + report.webrtcTagName = p.webrtcTagName; + return p.webrtcTagName === report.streamId; + }); + report.candidatePairSelectedByKms = { + localCandidate: this.parseRemoteCandidatePair(streamOutRemoteInfo.localCandidate), + remoteCandidate: this.parseRemoteCandidatePair(streamOutRemoteInfo.remoteCandidate) + }; + }); + + this.report.streamsIn.items.forEach(report => { + const streamInRemoteInfo = sessionInfo['connections'] + .find(c => c.connectionId === report.connectionId).subscribers + .find(p => { + report.webrtcTagName = p.webrtcTagName; + return p.webrtcTagName === report.connectionId + '_' + report.streamId; + }); + report.candidatePairSelectedByKms = { + localCandidate: this.parseRemoteCandidatePair(streamInRemoteInfo.localCandidate), + remoteCandidate: this.parseRemoteCandidatePair(streamInRemoteInfo.remoteCandidate) + }; + }); + + this.stringifyAllReports = JSON.stringify(this.report, null, '\t'); + console.log('Info has changed: ' + !(this.stringifyAllReports === this.textAreaValue)); + this.textAreaValue = this.stringifyAllReports; + }, + error => { } + ); + } + private parseRemoteCandidatePair(candidateStr: string) { const array = candidateStr.split(/\s+/); return { @@ -392,7 +400,8 @@ export class TestScenariosComponent implements OnInit, OnDestroy { ipAddress: array[4], transport: array[2].toLowerCase(), candidateType: array[7], - priority: array[3] + priority: array[3], + raw: candidateStr }; }