Dev dependencies updated. 'streamCreated' event restored for Publisher

pull/20/head
pabloFuente 2017-11-18 15:43:27 +01:00
parent 320595d40d
commit e83afb9994
5 changed files with 36 additions and 21 deletions

View File

@ -31,9 +31,9 @@
"sdp-translator": "0.1.24"
},
"devDependencies": {
"typescript": "2.5.2",
"browserify": "14.4.0",
"tsify": "3.0.1",
"uglify-js": "3.0.15"
"typescript": "2.6.1",
"browserify": "14.5.0",
"tsify": "3.0.3",
"uglify-js": "3.1.9"
}
}

View File

@ -105,13 +105,13 @@ function bufferizeCandidates(pc, onerror) {
switch (pc.signalingState) {
case 'closed':
callback(new Error('PeerConnection object is closed'))
break
callback(new Error('PeerConnection object is closed'));
break;
case 'stable':
if (pc.remoteDescription) {
pc.addIceCandidate(candidate, callback, callback)
break
pc.addIceCandidate(candidate, callback, callback);
}
break;
default:
candidatesQueue.push({
candidate: candidate,

View File

@ -60,14 +60,18 @@ export class OpenVidu {
if (this.checkSystemRequirements()) {
let publisher: Publisher;
if (cameraOptions != null) {
cameraOptions.audio = cameraOptions.audio != null ? cameraOptions.audio : true;
cameraOptions.video = cameraOptions.video != null ? cameraOptions.video : true;
if (!cameraOptions.screen) {
// Webcam and/or microphone is being requested
let cameraOptionsAux = {
sendAudio: cameraOptions.audio != null ? cameraOptions.audio : true,
sendVideo: cameraOptions.video != null ? cameraOptions.video : true,
activeAudio: cameraOptions.activeAudio != null ? cameraOptions.activeAudio : true,
activeVideo: cameraOptions.activeVideo != null ? cameraOptions.activeVideo : true,
activeAudio: cameraOptions.audioActive != null ? cameraOptions.audioActive : true,
activeVideo: cameraOptions.videoActive != null ? cameraOptions.videoActive : true,
data: true,
mediaConstraints: this.openVidu.generateMediaConstraints(cameraOptions)
};
@ -81,10 +85,10 @@ export class OpenVidu {
publisher = new Publisher(this.openVidu.initPublisherScreen(parentId, callback), parentId, true);
screenSharingAuto.getScreenId((error, sourceId, screenConstraints) => {
cameraOptions = {
sendAudio: cameraOptions.audio != null ? cameraOptions.audio : true,
sendVideo: cameraOptions.video != null ? cameraOptions.video : true,
activeAudio: cameraOptions.activeAudio != null ? cameraOptions.activeAudio : true,
activeVideo: cameraOptions.activeVideo != null ? cameraOptions.activeVideo : true,
sendAudio: cameraOptions.audio,
sendVideo: cameraOptions.video,
activeAudio: cameraOptions.audioActive != null ? cameraOptions.audioActive : true,
activeVideo: cameraOptions.videoActive != null ? cameraOptions.videoActive : true,
data: true,
mediaConstraints: {
video: screenConstraints.video,
@ -138,8 +142,8 @@ export class OpenVidu {
cameraOptions = {
sendAudio: cameraOptions.audio != null ? cameraOptions.audio : true,
sendVideo: cameraOptions.video != null ? cameraOptions.video : true,
activeAudio: cameraOptions.activeAudio != null ? cameraOptions.activeAudio : true,
activeVideo: cameraOptions.activeVideo != null ? cameraOptions.activeVideo : true,
activeAudio: cameraOptions.audioActive != null ? cameraOptions.audioActive : true,
activeVideo: cameraOptions.videoActive != null ? cameraOptions.videoActive : true,
data: true,
mediaConstraints: {
video: screenConstraints.video,

View File

@ -67,6 +67,16 @@ export class Publisher {
}
callback(event);
});
if (eventName == 'streamCreated') {
if (this.stream.isPublisherPublished) {
this.ee.emitEvent('streamCreated', [{ stream: this.stream }]);
} else {
this.stream.addEventListener('stream-created-by-publisher', () => {
console.warn('Publisher emitting streamCreated');
this.ee.emitEvent('streamCreated', [{ stream: this.stream }]);
});
}
}
if (eventName == 'videoElementCreated') {
if (this.stream.isVideoELementCreated) {
this.ee.emitEvent('videoElementCreated', [{

View File

@ -78,7 +78,8 @@ export class Stream {
private videoSrcObject: MediaStream | null;
private parentId: string;
public isReady: boolean = false;
public isReadyToPublish: boolean = false;
public isPublisherPublished: boolean = false;
public isVideoELementCreated: boolean = false;
public accessIsAllowed: boolean = false;
public accessIsDenied: boolean = false;
@ -253,8 +254,6 @@ export class Stream {
playOnlyVideo(parentElement, thumbnailId) {
// TO-DO: check somehow if the stream is audio only, so the element created is <audio> instead of <video>
this.video = document.createElement('video');
this.video.id = (this.local ? 'local-' : 'remote-') + 'video-' + this.getId();
@ -295,7 +294,7 @@ export class Stream {
this.video = parentElement.appendChild(this.video);
}
this.isReady = true;
this.isReadyToPublish = true;
return this.video;
}
@ -515,6 +514,8 @@ export class Stream {
this.wp.generateOffer(sdpOfferCallback.bind(this));
});
}
this.isPublisherPublished = true;
this.ee.emitEvent('stream-created-by-publisher');
} else {
let offerConstraints = {
audio: this.recvAudio,
@ -540,7 +541,7 @@ export class Stream {
publish() {
// FIXME: Throw error when stream is not local
if (this.isReady) {
if (this.isReadyToPublish) {
this.initWebRtcPeer(this.publishVideoCallback);
} else {
this.ee.once('stream-ready', streamEvent => {