2017-04-12 00:54:35 +02:00
|
|
|
/*
|
|
|
|
* options: name: XXX data: true (Maybe this is based on webrtc) audio: true,
|
|
|
|
* video: true, url: "file:///..." > Player screen: true > Desktop (implicit
|
|
|
|
* video:true, audio:false) audio: true, video: true > Webcam
|
|
|
|
*
|
|
|
|
* stream.hasAudio(); stream.hasVideo(); stream.hasData();
|
|
|
|
*/
|
|
|
|
import { Stream, StreamOptions, VideoOptions } from '../OpenVidu/Stream';
|
|
|
|
import { OpenViduTokBox } from './OpenViduTokBox';
|
|
|
|
import { SessionTokBox } from './SessionTokBox';
|
|
|
|
|
2017-04-17 20:28:05 +02:00
|
|
|
import EventEmitter = require('wolfy87-eventemitter');
|
|
|
|
|
2017-04-12 00:54:35 +02:00
|
|
|
export class PublisherTokBox {
|
|
|
|
|
2017-04-17 20:28:05 +02:00
|
|
|
private ee = new EventEmitter();
|
|
|
|
|
|
|
|
accessAllowed = false;
|
|
|
|
element: Element;
|
|
|
|
id: string;
|
2017-04-12 00:54:35 +02:00
|
|
|
stream: Stream;
|
2017-04-17 20:28:05 +02:00
|
|
|
session: SessionTokBox;
|
|
|
|
|
|
|
|
constructor(stream: Stream, parentId: string) {
|
|
|
|
this.accessAllowed = false;
|
|
|
|
|
|
|
|
this.ee.on('camera-access-changed', (event) => {
|
|
|
|
this.accessAllowed = event.accessAllowed;
|
|
|
|
if (this.accessAllowed) {
|
|
|
|
this.ee.emitEvent('accessAllowed');
|
|
|
|
} else {
|
|
|
|
this.ee.emitEvent('accessDenied');
|
|
|
|
}
|
|
|
|
});
|
2017-04-12 00:54:35 +02:00
|
|
|
|
|
|
|
this.stream = stream;
|
2017-04-17 20:28:05 +02:00
|
|
|
if (document.getElementById(parentId) != null) {
|
|
|
|
this.element = document.getElementById(parentId)!!;
|
|
|
|
}
|
2017-04-12 00:54:35 +02:00
|
|
|
}
|
|
|
|
|
2017-04-12 11:45:08 +02:00
|
|
|
publishAudio(value: boolean) {
|
|
|
|
this.stream.getWebRtcPeer().audioEnabled = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
publishVideo(value: boolean) {
|
2017-04-17 20:28:05 +02:00
|
|
|
this.stream.getWebRtcPeer().videoEnabled = value;
|
2017-04-12 11:45:08 +02:00
|
|
|
}
|
2017-04-17 20:28:05 +02:00
|
|
|
|
2017-04-12 00:54:35 +02:00
|
|
|
}
|