openvidu-testapp: StreamPropertyChangedEvent

pull/88/merge
pabloFuente 2018-07-03 15:48:21 +02:00
parent 4a99ea5fe8
commit 492c10ea42
3 changed files with 65 additions and 13 deletions

View File

@ -6,7 +6,7 @@ import {
import { import {
OpenVidu, Session, Subscriber, Publisher, VideoInsertMode, StreamEvent, ConnectionEvent, OpenVidu, Session, Subscriber, Publisher, VideoInsertMode, StreamEvent, ConnectionEvent,
SessionDisconnectedEvent, SignalEvent, RecordingEvent, SessionDisconnectedEvent, SignalEvent, RecordingEvent,
PublisherSpeakingEvent, PublisherProperties PublisherSpeakingEvent, PublisherProperties, StreamPropertyChangedEvent
} from 'openvidu-browser'; } from 'openvidu-browser';
import { import {
OpenVidu as OpenViduAPI, OpenVidu as OpenViduAPI,
@ -101,6 +101,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
sessionDisconnected: true, sessionDisconnected: true,
streamCreated: true, streamCreated: true,
streamDestroyed: true, streamDestroyed: true,
streamPropertyChanged: true,
recordingStarted: true, recordingStarted: true,
recordingStopped: true, recordingStopped: true,
signal: true, signal: true,
@ -190,6 +191,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
sessionDisconnected: false, sessionDisconnected: false,
streamCreated: false, streamCreated: false,
streamDestroyed: false, streamDestroyed: false,
streamPropertyChanged: false,
recordingStarted: false, recordingStarted: false,
recordingStopped: false, recordingStopped: false,
signal: false, signal: false,
@ -284,7 +286,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
type: 'chat' type: 'chat'
}) })
.then(() => { .then(() => {
console.log('Message succesfully sent'); console.log('Message successfully sent');
}) })
.catch(error => { .catch(error => {
console.error(error); console.error(error);
@ -320,6 +322,16 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
} }
} }
if (this.sessionEvents.streamPropertyChanged !== oldValues.streamPropertyChanged || firstTime) {
this.session.off('streamPropertyChanged');
if (this.sessionEvents.streamPropertyChanged) {
this.session.on('streamPropertyChanged', (event: StreamPropertyChangedEvent) => {
const newValue = event.changedProperty === 'videoDimensions' ? JSON.stringify(event.newValue) : event.newValue.toString();
this.updateEventList('streamPropertyChanged', event.changedProperty + ' [' + newValue + ']');
});
}
}
if (this.sessionEvents.connectionCreated !== oldValues.connectionCreated || firstTime) { if (this.sessionEvents.connectionCreated !== oldValues.connectionCreated || firstTime) {
this.session.off('connectionCreated'); this.session.off('connectionCreated');
if (this.sessionEvents.connectionCreated) { if (this.sessionEvents.connectionCreated) {
@ -514,6 +526,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
sessionDisconnected: this.sessionEvents.sessionDisconnected, sessionDisconnected: this.sessionEvents.sessionDisconnected,
streamCreated: this.sessionEvents.streamCreated, streamCreated: this.sessionEvents.streamCreated,
streamDestroyed: this.sessionEvents.streamDestroyed, streamDestroyed: this.sessionEvents.streamDestroyed,
streamPropertyChanged: this.sessionEvents.streamPropertyChanged,
recordingStarted: this.sessionEvents.recordingStarted, recordingStarted: this.sessionEvents.recordingStarted,
recordingStopped: this.sessionEvents.recordingStopped, recordingStopped: this.sessionEvents.recordingStopped,
signal: this.sessionEvents.signal, signal: this.sessionEvents.signal,
@ -543,6 +556,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
sessionDisconnected: result.sessionDisconnected, sessionDisconnected: result.sessionDisconnected,
streamCreated: result.streamCreated, streamCreated: result.streamCreated,
streamDestroyed: result.streamDestroyed, streamDestroyed: result.streamDestroyed,
streamPropertyChanged: result.streamPropertyChanged,
recordingStarted: result.recordingStarted, recordingStarted: result.recordingStarted,
recordingStopped: result.recordingStopped, recordingStopped: result.recordingStopped,
signal: result.signal, signal: result.signal,

View File

@ -15,7 +15,8 @@ import {
StreamEvent, StreamEvent,
StreamManagerEvent, StreamManagerEvent,
PublisherProperties, PublisherProperties,
ConnectionEvent ConnectionEvent,
StreamPropertyChangedEvent
} from 'openvidu-browser'; } from 'openvidu-browser';
import { import {
OpenVidu as OpenViduAPI, OpenVidu as OpenViduAPI,
@ -367,7 +368,7 @@ export class TestScenariosComponent implements OnInit, OnDestroy {
private updateRemoteStreamsInfo() { private updateRemoteStreamsInfo() {
let headers = new HttpHeaders(); let headers = new HttpHeaders();
headers = headers.append('Authorization', 'Basic ' + btoa('OPENVIDUAPP:' + this.openviduSecret)); headers = headers.append('Authorization', 'Basic ' + btoa('OPENVIDUAPP:' + this.openviduSecret));
this.http.get(this.openviduUrl + 'api/sessions/' + this.fixedSessionId, { headers }).subscribe( this.http.get(this.openviduUrl + 'api/sessions/' + this.fixedSessionId + '?webRtcStats=true', { headers }).subscribe(
sessionInfo => { sessionInfo => {
this.report.streamsOut.items.forEach(report => { this.report.streamsOut.items.forEach(report => {
@ -444,7 +445,7 @@ export class TestScenariosComponent implements OnInit, OnDestroy {
/*addReportForStreamConcurrent(event: StreamManagerWrapper) { /*addReportForStreamConcurrent(event: StreamManagerWrapper) {
let headers = new HttpHeaders(); let headers = new HttpHeaders();
headers = headers.append('Authorization', 'Basic ' + btoa('OPENVIDUAPP:' + this.openviduSecret)); headers = headers.append('Authorization', 'Basic ' + btoa('OPENVIDUAPP:' + this.openviduSecret));
this.http.get(this.openviduUrl + 'api/sessions/' + this.fixedSessionId, { headers }).subscribe( this.http.get(this.openviduUrl + 'api/sessions/' + this.fixedSessionId + '?webRtcStats=true', { headers }).subscribe(
sessionInfo => { sessionInfo => {
event.streamManager.stream.getSelectedIceCandidate() event.streamManager.stream.getSelectedIceCandidate()

View File

@ -4,6 +4,7 @@ import { MatDialog, MatDialogRef } from '@angular/material';
import { import {
StreamManager, StreamManager,
StreamManagerEvent, StreamManagerEvent,
StreamPropertyChangedEvent,
VideoElementEvent, VideoElementEvent,
Subscriber, Subscriber,
OpenVidu, OpenVidu,
@ -73,12 +74,14 @@ export class VideoComponent implements OnInit, OnDestroy {
this.eventCollection = { this.eventCollection = {
videoElementCreated: true, videoElementCreated: true,
videoElementDestroyed: true, videoElementDestroyed: true,
streamPlaying: true streamPlaying: true,
streamPropertyChanged: false
}; };
this.updateSubscriberEvents({ this.updateSubscriberEvents({
videoElementCreated: false, videoElementCreated: false,
videoElementDestroyed: false, videoElementDestroyed: false,
streamPlaying: false streamPlaying: false,
streamPropertyChanged: true
}); });
} else { } else {
@ -92,7 +95,8 @@ export class VideoComponent implements OnInit, OnDestroy {
accessDialogOpened: true, accessDialogOpened: true,
accessDialogClosed: true, accessDialogClosed: true,
streamCreated: true, streamCreated: true,
streamDestroyed: true streamDestroyed: true,
streamPropertyChanged: false
}; };
this.updatePublisherEvents( this.updatePublisherEvents(
<Publisher>this.streamManager, <Publisher>this.streamManager,
@ -105,7 +109,8 @@ export class VideoComponent implements OnInit, OnDestroy {
accessDialogOpened: false, accessDialogOpened: false,
accessDialogClosed: false, accessDialogClosed: false,
streamCreated: false, streamCreated: false,
streamDestroyed: false streamDestroyed: false,
streamPropertyChanged: true
}); });
this.sendAudio = this.streamManager.stream.hasAudio; this.sendAudio = this.streamManager.stream.hasAudio;
this.sendVideo = this.streamManager.stream.hasVideo; this.sendVideo = this.streamManager.stream.hasVideo;
@ -149,7 +154,8 @@ export class VideoComponent implements OnInit, OnDestroy {
const oldValues = { const oldValues = {
videoElementCreated: this.eventCollection.videoElementCreated, videoElementCreated: this.eventCollection.videoElementCreated,
videoElementDestroyed: this.eventCollection.videoElementDestroyed, videoElementDestroyed: this.eventCollection.videoElementDestroyed,
streamPlaying: this.eventCollection.streamPlaying streamPlaying: this.eventCollection.streamPlaying,
streamPropertyChanged: this.eventCollection.streamPropertyChanged
}; };
this.streamManager = this.streamManager.stream.session.subscribe(subscriber.stream, undefined); this.streamManager = this.streamManager.stream.session.subscribe(subscriber.stream, undefined);
this.reSubbed.emit(this.streamManager); this.reSubbed.emit(this.streamManager);
@ -271,7 +277,8 @@ export class VideoComponent implements OnInit, OnDestroy {
accessDialogOpened: !this.eventCollection.accessDialogOpened, accessDialogOpened: !this.eventCollection.accessDialogOpened,
accessDialogClosed: !this.eventCollection.accessDialogClosed, accessDialogClosed: !this.eventCollection.accessDialogClosed,
streamCreated: !this.eventCollection.streamCreated, streamCreated: !this.eventCollection.streamCreated,
streamDestroyed: !this.eventCollection.streamDestroyed streamDestroyed: !this.eventCollection.streamDestroyed,
streamPropertyChanged: !this.eventCollection.streamPropertyChanged,
}); });
const oldPublisher = <Publisher>this.streamManager; const oldPublisher = <Publisher>this.streamManager;
@ -341,6 +348,20 @@ export class VideoComponent implements OnInit, OnDestroy {
} else { } else {
sub.off('streamPlaying'); sub.off('streamPlaying');
} }
if (this.eventCollection.streamPropertyChanged) {
if (!oldValues.streamPropertyChanged) {
sub.on('streamPropertyChanged', (e: StreamPropertyChangedEvent) => {
const newValue = e.changedProperty === 'videoDimensions' ? JSON.stringify(e.newValue) : e.newValue.toString();
this.updateEventListInParent.emit({
event: 'streamPropertyChanged',
content: e.changedProperty + ' [' + newValue + ']'
});
});
}
} else {
sub.off('streamPropertyChanged');
}
} }
updatePublisherEvents(pub: Publisher, oldValues: any) { updatePublisherEvents(pub: Publisher, oldValues: any) {
@ -435,6 +456,20 @@ export class VideoComponent implements OnInit, OnDestroy {
pub.off('streamDestroyed'); pub.off('streamDestroyed');
} }
if (this.eventCollection.streamPropertyChanged) {
if (!oldValues.streamPropertyChanged) {
pub.on('streamPropertyChanged', (e: StreamPropertyChangedEvent) => {
const newValue = e.changedProperty === 'videoDimensions' ? JSON.stringify(e.newValue) : e.newValue.toString();
this.updateEventListInParent.emit({
event: 'streamPropertyChanged',
content: e.changedProperty + ' [' + newValue + ']'
});
});
}
} else {
pub.off('streamPropertyChanged');
}
if (this.eventCollection.videoElementDestroyed) { if (this.eventCollection.videoElementDestroyed) {
if (!oldValues.videoElementDestroyed) { if (!oldValues.videoElementDestroyed) {
pub.on('videoElementDestroyed', (e: VideoElementEvent) => { pub.on('videoElementDestroyed', (e: VideoElementEvent) => {
@ -474,7 +509,8 @@ export class VideoComponent implements OnInit, OnDestroy {
const oldValues = { const oldValues = {
videoElementCreated: this.eventCollection.videoElementCreated, videoElementCreated: this.eventCollection.videoElementCreated,
videoElementDestroyed: this.eventCollection.videoElementDestroyed, videoElementDestroyed: this.eventCollection.videoElementDestroyed,
streamPlaying: this.eventCollection.streamPlaying streamPlaying: this.eventCollection.streamPlaying,
streamPropertyChanged: this.eventCollection.streamPropertyChanged
}; };
const dialogRef = this.dialog.open(EventsDialogComponent, { const dialogRef = this.dialog.open(EventsDialogComponent, {
data: { data: {
@ -501,7 +537,8 @@ export class VideoComponent implements OnInit, OnDestroy {
accessDialogOpened: this.eventCollection.accessDialogOpened, accessDialogOpened: this.eventCollection.accessDialogOpened,
accessDialogClosed: this.eventCollection.accessDialogClosed, accessDialogClosed: this.eventCollection.accessDialogClosed,
streamCreated: this.eventCollection.streamCreated, streamCreated: this.eventCollection.streamCreated,
streamDestroyed: this.eventCollection.streamDestroyed streamDestroyed: this.eventCollection.streamDestroyed,
streamPropertyChanged: this.eventCollection.streamPropertyChanged
}; };
const dialogRef = this.dialog.open(EventsDialogComponent, { const dialogRef = this.dialog.open(EventsDialogComponent, {
data: { data: {