2018-05-31 13:08:34 +02:00
|
|
|
import { Component, Inject } from '@angular/core';
|
2018-08-01 15:12:34 +02:00
|
|
|
import { MatDialogRef, MAT_CHECKBOX_CLICK_ACTION, MAT_DIALOG_DATA } from '@angular/material';
|
2018-05-31 13:08:34 +02:00
|
|
|
|
2018-08-01 15:12:34 +02:00
|
|
|
import { PublisherProperties, OpenVidu, Filter } from 'openvidu-browser';
|
2018-05-31 13:08:34 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-publisher-properties-dialog',
|
|
|
|
templateUrl: './publisher-properties-dialog.component.html',
|
|
|
|
styleUrls: ['./publisher-properties-dialog.component.css'],
|
|
|
|
providers: [
|
|
|
|
{ provide: MAT_CHECKBOX_CLICK_ACTION, useValue: 'noop' }
|
|
|
|
]
|
|
|
|
})
|
|
|
|
export class PublisherPropertiesDialogComponent {
|
|
|
|
|
|
|
|
OV: OpenVidu;
|
|
|
|
publisherProperties: PublisherProperties;
|
|
|
|
initValue: PublisherProperties;
|
|
|
|
|
|
|
|
audioSource;
|
|
|
|
videoSource;
|
|
|
|
|
|
|
|
audioSourceAux;
|
|
|
|
videoSourceAux;
|
|
|
|
|
|
|
|
audioDevices = [];
|
|
|
|
videoDevices = [];
|
|
|
|
|
2021-10-22 12:11:09 +02:00
|
|
|
filter = { type: undefined, options: undefined };
|
2021-10-21 19:35:02 +02:00
|
|
|
stringOptions: string;
|
2018-08-01 15:12:34 +02:00
|
|
|
|
2018-05-31 13:08:34 +02:00
|
|
|
constructor(public dialogRef: MatDialogRef<PublisherPropertiesDialogComponent>,
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data: PublisherProperties) {
|
|
|
|
this.publisherProperties = data;
|
2021-10-21 19:35:02 +02:00
|
|
|
if (this.publisherProperties.filter === null) {
|
|
|
|
console.log('Filter deleted');
|
|
|
|
} else {
|
|
|
|
if (!!this.publisherProperties.filter && !!this.publisherProperties.filter.type) {
|
|
|
|
this.filter['type'] = this.publisherProperties.filter.type;
|
|
|
|
} else {
|
|
|
|
this.filter['type'] = 'GStreamerFilter';
|
|
|
|
}
|
|
|
|
if (!!this.publisherProperties.filter && !!this.publisherProperties.filter.options) {
|
|
|
|
this.stringOptions = JSON.stringify(this.publisherProperties.filter.options);
|
|
|
|
this.filter['options'] = this.publisherProperties.filter.options;
|
|
|
|
} else {
|
|
|
|
this.stringOptions = '{"command":"videobalance saturation=0.0"}';
|
|
|
|
this.filter['options'] = JSON.parse(this.stringOptions);
|
|
|
|
}
|
|
|
|
}
|
2018-05-31 13:08:34 +02:00
|
|
|
this.OV = new OpenVidu();
|
|
|
|
this.initValue = Object.assign({}, this.publisherProperties);
|
|
|
|
this.audioSource = typeof this.publisherProperties.audioSource === 'string' ? this.publisherProperties.audioSource : undefined;
|
|
|
|
this.videoSource = typeof this.publisherProperties.videoSource === 'string' ? this.publisherProperties.videoSource : undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleAudio(): void {
|
|
|
|
if (this.publisherProperties.audioSource === false) {
|
|
|
|
this.publisherProperties.audioSource = this.audioSource;
|
|
|
|
this.audioSource = this.audioSourceAux;
|
|
|
|
} else {
|
|
|
|
this.audioSourceAux = this.audioSource;
|
|
|
|
this.audioSource = undefined;
|
|
|
|
this.publisherProperties.audioSource = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleVideo(): void {
|
|
|
|
if (this.publisherProperties.videoSource === false) {
|
|
|
|
this.publisherProperties.videoSource = this.videoSource;
|
|
|
|
this.videoSource = this.videoSourceAux;
|
|
|
|
} else {
|
|
|
|
this.videoSourceAux = this.videoSource;
|
|
|
|
this.videoSource = undefined;
|
|
|
|
this.publisherProperties.videoSource = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setCloseValue(): PublisherProperties {
|
|
|
|
if (typeof this.audioSource === 'string') {
|
|
|
|
if (!!this.audioSource) {
|
|
|
|
this.publisherProperties.audioSource = this.audioSource;
|
|
|
|
} else {
|
|
|
|
this.publisherProperties.audioSource = undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (typeof this.videoSource === 'string') {
|
|
|
|
if (!!this.videoSource) {
|
|
|
|
this.publisherProperties.videoSource = this.videoSource;
|
|
|
|
} else {
|
|
|
|
this.publisherProperties.videoSource = undefined;
|
|
|
|
}
|
|
|
|
}
|
2018-08-01 15:12:34 +02:00
|
|
|
try {
|
2021-10-21 19:35:02 +02:00
|
|
|
this.filter['options'] = JSON.parse(this.stringOptions);
|
2018-08-01 15:12:34 +02:00
|
|
|
} catch (e) {
|
|
|
|
}
|
2021-10-22 12:11:09 +02:00
|
|
|
if (this.filter['type'] == null || this.filter['type'] == '') {
|
2021-10-21 19:35:02 +02:00
|
|
|
this.publisherProperties.filter = null;
|
2018-08-03 15:00:12 +02:00
|
|
|
} else {
|
2021-10-21 19:35:02 +02:00
|
|
|
this.publisherProperties.filter = new Filter(this.filter['type'], this.filter['options']);
|
2018-08-03 15:00:12 +02:00
|
|
|
}
|
2018-05-31 13:08:34 +02:00
|
|
|
return this.publisherProperties;
|
|
|
|
}
|
|
|
|
|
|
|
|
listAudioDevices() {
|
|
|
|
this.audioDevices = [];
|
|
|
|
this.OV.getDevices().then(devices => {
|
|
|
|
devices.forEach(device => {
|
|
|
|
if (device.kind === 'audioinput') {
|
|
|
|
this.audioDevices.push(device);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
listVideoDevices() {
|
|
|
|
this.videoDevices = [];
|
|
|
|
this.OV.getDevices().then(devices => {
|
|
|
|
devices.forEach(device => {
|
|
|
|
if (device.kind === 'videoinput') {
|
|
|
|
this.videoDevices.push(device);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|