From 9cb60f9ce6650e8ef7d3e9711acdf82917386c1f Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Tue, 21 Mar 2017 10:36:18 +0100 Subject: [PATCH] Signaling and ICE connection events are now monitored --- .../src/main/resources/ts/Stream.ts | 4 ++ .../src/app/app.component.html | 16 +++++--- openvidu-ng-testapp/src/app/app.component.ts | 40 +++++++++++++++++-- .../src/app/stream.component.ts | 1 - 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/openvidu-browser/src/main/resources/ts/Stream.ts b/openvidu-browser/src/main/resources/ts/Stream.ts index 6edd2caa..2b0bac25 100644 --- a/openvidu-browser/src/main/resources/ts/Stream.ts +++ b/openvidu-browser/src/main/resources/ts/Stream.ts @@ -252,6 +252,10 @@ export class Stream { } } + getRTCPeerConnection(){ + return this.getWebRtcPeer().peerConnection; + } + requestCameraAccess(callback: Callback) { this.participant.addStream(this); diff --git a/openvidu-ng-testapp/src/app/app.component.html b/openvidu-ng-testapp/src/app/app.component.html index 1473b5fb..54aadd79 100644 --- a/openvidu-ng-testapp/src/app/app.component.html +++ b/openvidu-ng-testapp/src/app/app.component.html @@ -47,16 +47,22 @@ Toggle your video Toggle your audio
-
-
+
+
-
-
+
+
+ Show conexion state +
+

Signaling state: {{signalingState[i]}}

+

Ice connection state: {{iceConnectionState[i]}}

+
+ Show statistics

Bitrate: {{stats[i].bitrate}}

- +
diff --git a/openvidu-ng-testapp/src/app/app.component.ts b/openvidu-ng-testapp/src/app/app.component.ts index f7aada2c..930f3769 100644 --- a/openvidu-ng-testapp/src/app/app.component.ts +++ b/openvidu-ng-testapp/src/app/app.component.ts @@ -29,6 +29,8 @@ export class AppComponent { stats = []; bytesPrev = []; timestampPrev = []; + signalingState = []; + iceConnectionState = []; constructor() { @@ -47,7 +49,26 @@ export class AppComponent { private addVideoTag(stream: Stream) { console.log("Stream added"); - this.streams.push(stream); + let ind = (this.streams.push(stream) - 1); + + this.signalingState[ind] = ''; + this.iceConnectionState[ind] = ''; + + //Connection events + stream.getRTCPeerConnection().onsignalingstatechange = (event) => { + this.signalingState[ind] += " => " + stream.getRTCPeerConnection().signalingState; + console.info("Stream " + stream.getId() + " signaling state: " + stream.getRTCPeerConnection().signalingState); + } + + stream.getRTCPeerConnection().oniceconnectionstatechange = (event) => { + /*if (stream.getRTCPeerConnection().iceconnectionstate === "failed" || + stream.getRTCPeerConnection().iceconnectionstate === "disconnected" || + stream.getRTCPeerConnection().iceconnectionstate === "closed") { + // Handle the failure + };*/ + this.iceConnectionState[ind] += " => " + stream.getRTCPeerConnection().iceConnectionState; + console.info("Stream " + stream.getId() + " ice connection state: " + stream.getRTCPeerConnection().iceConnectionState); + } //For statistics this.timestampPrev.push(0); @@ -62,6 +83,9 @@ export class AppComponent { this.stats.splice(index, 1); this.timestampPrev.splice(index, 1); this.bytesPrev.splice(index, 1); + + this.signalingState.splice(index, 1); + this.iceConnectionState.splice(index, 1); } joinSession() { @@ -109,10 +133,10 @@ export class AppComponent { this.session = session; - this.addVideoTag(camera); - camera.publish(); + this.addVideoTag(camera); + this.intervalStats().subscribe(); session.addEventListener("stream-added", streamEvent => { @@ -149,6 +173,16 @@ export class AppComponent { console.log(msg); } + updateToggleStatistics(i) { + let table = (document.getElementById('table-' + i)); + (table.style.display == "none") ? table.style.display = "block" : table.style.display = "none"; + } + + updateToggleState(i) { + let state = (document.getElementById('state-' + i)); + (state.style.display == "none") ? state.style.display = "block" : state.style.display = "none"; + } + /*obtainSupportedConstraints() { let constraints = Object.keys(navigator.mediaDevices.getSupportedConstraints()); this.supportedVideoContstraints = constraints.filter((e) => { diff --git a/openvidu-ng-testapp/src/app/stream.component.ts b/openvidu-ng-testapp/src/app/stream.component.ts index 55261dda..b35073bd 100644 --- a/openvidu-ng-testapp/src/app/stream.component.ts +++ b/openvidu-ng-testapp/src/app/stream.component.ts @@ -6,7 +6,6 @@ import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; selector: 'stream', styles: [` .participant { - float: left; margin: 10px; } .participant video {
Type Time