mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: do not generate media constraints if MediaStreamTracks provided
parent
a52c4feb71
commit
cf2c29db9a
|
@ -182,12 +182,12 @@ export class OpenVidu {
|
||||||
|
|
||||||
properties = {
|
properties = {
|
||||||
audioSource: (typeof properties.audioSource !== 'undefined') ? properties.audioSource : undefined,
|
audioSource: (typeof properties.audioSource !== 'undefined') ? properties.audioSource : undefined,
|
||||||
frameRate: this.isMediaStreamTrack(properties.videoSource) ? undefined : ((typeof properties.frameRate !== 'undefined') ? properties.frameRate : undefined),
|
frameRate: (properties.videoSource instanceof MediaStreamTrack) ? undefined : ((typeof properties.frameRate !== 'undefined') ? properties.frameRate : undefined),
|
||||||
insertMode: (typeof properties.insertMode !== 'undefined') ? ((typeof properties.insertMode === 'string') ? VideoInsertMode[properties.insertMode] : properties.insertMode) : VideoInsertMode.APPEND,
|
insertMode: (typeof properties.insertMode !== 'undefined') ? ((typeof properties.insertMode === 'string') ? VideoInsertMode[properties.insertMode] : properties.insertMode) : VideoInsertMode.APPEND,
|
||||||
mirror: (typeof properties.mirror !== 'undefined') ? properties.mirror : true,
|
mirror: (typeof properties.mirror !== 'undefined') ? properties.mirror : true,
|
||||||
publishAudio: (typeof properties.publishAudio !== 'undefined') ? properties.publishAudio : true,
|
publishAudio: (typeof properties.publishAudio !== 'undefined') ? properties.publishAudio : true,
|
||||||
publishVideo: (typeof properties.publishVideo !== 'undefined') ? properties.publishVideo : true,
|
publishVideo: (typeof properties.publishVideo !== 'undefined') ? properties.publishVideo : true,
|
||||||
resolution: this.isMediaStreamTrack(properties.videoSource) ? undefined : ((typeof properties.resolution !== 'undefined') ? properties.resolution : '640x480'),
|
resolution: (properties.videoSource instanceof MediaStreamTrack) ? undefined : ((typeof properties.resolution !== 'undefined') ? properties.resolution : '640x480'),
|
||||||
videoSource: (typeof properties.videoSource !== 'undefined') ? properties.videoSource : undefined,
|
videoSource: (typeof properties.videoSource !== 'undefined') ? properties.videoSource : undefined,
|
||||||
filter: properties.filter
|
filter: properties.filter
|
||||||
};
|
};
|
||||||
|
@ -605,20 +605,6 @@ export class OpenVidu {
|
||||||
this.jsonRpcClient.send(method, params, callback);
|
this.jsonRpcClient.send(method, params, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @hidden
|
|
||||||
*/
|
|
||||||
isMediaStreamTrack(mediaSource: any): boolean {
|
|
||||||
const is = (!!mediaSource &&
|
|
||||||
mediaSource.enabled !== undefined && typeof mediaSource.enabled === 'boolean' &&
|
|
||||||
mediaSource.id !== undefined && typeof mediaSource.id === 'string' &&
|
|
||||||
mediaSource.kind !== undefined && typeof mediaSource.kind === 'string' &&
|
|
||||||
mediaSource.label !== undefined && typeof mediaSource.label === 'string' &&
|
|
||||||
mediaSource.muted !== undefined && typeof mediaSource.muted === 'boolean' &&
|
|
||||||
mediaSource.readyState !== undefined && typeof mediaSource.readyState === 'string');
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -271,12 +271,12 @@ export class Publisher extends StreamManager {
|
||||||
this.accessAllowed = true;
|
this.accessAllowed = true;
|
||||||
this.accessDenied = false;
|
this.accessDenied = false;
|
||||||
|
|
||||||
if (this.openvidu.isMediaStreamTrack(this.properties.audioSource)) {
|
if (this.properties.audioSource instanceof MediaStreamTrack) {
|
||||||
mediaStream.removeTrack(mediaStream.getAudioTracks()[0]);
|
mediaStream.removeTrack(mediaStream.getAudioTracks()[0]);
|
||||||
mediaStream.addTrack((<MediaStreamTrack>this.properties.audioSource));
|
mediaStream.addTrack((<MediaStreamTrack>this.properties.audioSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.openvidu.isMediaStreamTrack(this.properties.videoSource)) {
|
if (this.properties.videoSource instanceof MediaStreamTrack) {
|
||||||
mediaStream.removeTrack(mediaStream.getVideoTracks()[0]);
|
mediaStream.removeTrack(mediaStream.getVideoTracks()[0]);
|
||||||
mediaStream.addTrack((<MediaStreamTrack>this.properties.videoSource));
|
mediaStream.addTrack((<MediaStreamTrack>this.properties.videoSource));
|
||||||
}
|
}
|
||||||
|
@ -374,6 +374,26 @@ export class Publisher extends StreamManager {
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Check if new constraints need to be generated. No constraints needed if
|
||||||
|
// - video track is given and no audio
|
||||||
|
// - audio track is given and no video
|
||||||
|
// - both video and audio tracks are given
|
||||||
|
if ((this.properties.videoSource instanceof MediaStreamTrack && !this.properties.audioSource)
|
||||||
|
|| (this.properties.audioSource instanceof MediaStreamTrack && !this.properties.videoSource)
|
||||||
|
|| (this.properties.videoSource instanceof MediaStreamTrack && this.properties.audioSource instanceof MediaStreamTrack)) {
|
||||||
|
const mediaStream = new MediaStream();
|
||||||
|
if (this.properties.videoSource instanceof MediaStreamTrack) {
|
||||||
|
mediaStream.addTrack((<MediaStreamTrack>this.properties.videoSource));
|
||||||
|
}
|
||||||
|
if (this.properties.audioSource instanceof MediaStreamTrack) {
|
||||||
|
mediaStream.addTrack((<MediaStreamTrack>this.properties.audioSource));
|
||||||
|
}
|
||||||
|
// MediaStreamTracks are handled within callback - just call callback with new MediaStream() and let it handle the sources
|
||||||
|
successCallback(mediaStream);
|
||||||
|
// Return as we do not need to process further
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.openvidu.generateMediaConstraints(this.properties)
|
this.openvidu.generateMediaConstraints(this.properties)
|
||||||
.then(constraints => {
|
.then(constraints => {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue