mirror of https://github.com/OpenVidu/openvidu.git
Merge 0c354df6e0
into 56edac65ad
commit
4822c19797
|
@ -189,6 +189,7 @@ export class OpenVidu {
|
||||||
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: this.isMediaStreamTrack(properties.videoSource) ? undefined : ((typeof properties.resolution !== 'undefined') ? properties.resolution : '640x480'),
|
||||||
videoSource: (typeof properties.videoSource !== 'undefined') ? properties.videoSource : undefined,
|
videoSource: (typeof properties.videoSource !== 'undefined') ? properties.videoSource : undefined,
|
||||||
|
keepTracksOnDispose: (typeof properties.keepTracksOnDispose !== 'undefined') ? properties.keepTracksOnDispose : false,
|
||||||
filter: properties.filter
|
filter: properties.filter
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -113,6 +113,16 @@ export class Stream implements EventDispatcher {
|
||||||
*/
|
*/
|
||||||
filter: Filter;
|
filter: Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps tracks unstopped on disposal. Allows to keep tracks running if session is diposed
|
||||||
|
*
|
||||||
|
* This property may be useful if a publisher is started with a previously existing
|
||||||
|
* track which should keep running after disposal, e.g. if you start your webcam
|
||||||
|
* in a <video> element and want to keep it running after OpenVidu session closed
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
keepTracksOnDispose = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
|
@ -201,6 +211,9 @@ export class Stream implements EventDispatcher {
|
||||||
this.typeOfVideo = this.isSendScreen() ? 'SCREEN' : 'CAMERA';
|
this.typeOfVideo = this.isSendScreen() ? 'SCREEN' : 'CAMERA';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.keepTracksOnDispose = !!this.outboundStreamOpts.publisherProperties.keepTracksOnDispose;
|
||||||
|
|
||||||
if (!!this.outboundStreamOpts.publisherProperties.filter) {
|
if (!!this.outboundStreamOpts.publisherProperties.filter) {
|
||||||
this.filter = this.outboundStreamOpts.publisherProperties.filter;
|
this.filter = this.outboundStreamOpts.publisherProperties.filter;
|
||||||
}
|
}
|
||||||
|
@ -429,7 +442,7 @@ export class Stream implements EventDispatcher {
|
||||||
*/
|
*/
|
||||||
disposeWebRtcPeer(): void {
|
disposeWebRtcPeer(): void {
|
||||||
if (this.webRtcPeer) {
|
if (this.webRtcPeer) {
|
||||||
this.webRtcPeer.dispose();
|
this.webRtcPeer.dispose(this.keepTracksOnDispose);
|
||||||
}
|
}
|
||||||
if (this.speechEvent) {
|
if (this.speechEvent) {
|
||||||
this.speechEvent.stop();
|
this.speechEvent.stop();
|
||||||
|
@ -445,12 +458,14 @@ export class Stream implements EventDispatcher {
|
||||||
*/
|
*/
|
||||||
disposeMediaStream(): void {
|
disposeMediaStream(): void {
|
||||||
if (this.mediaStream) {
|
if (this.mediaStream) {
|
||||||
this.mediaStream.getAudioTracks().forEach((track) => {
|
if (!this.keepTracksOnDispose) {
|
||||||
track.stop();
|
this.mediaStream.getAudioTracks().forEach((track) => {
|
||||||
});
|
track.stop();
|
||||||
this.mediaStream.getVideoTracks().forEach((track) => {
|
});
|
||||||
track.stop();
|
this.mediaStream.getVideoTracks().forEach((track) => {
|
||||||
});
|
track.stop();
|
||||||
|
});
|
||||||
|
}
|
||||||
delete this.mediaStream;
|
delete this.mediaStream;
|
||||||
}
|
}
|
||||||
console.info((!!this.outboundStreamOpts ? 'Local ' : 'Remote ') + "MediaStream from 'Stream' with id [" + this.streamId + '] is now disposed');
|
console.info((!!this.outboundStreamOpts ? 'Local ' : 'Remote ') + "MediaStream from 'Stream' with id [" + this.streamId + '] is now disposed');
|
||||||
|
|
|
@ -88,4 +88,10 @@ export interface PublisherProperties {
|
||||||
*/
|
*/
|
||||||
filter?: Filter;
|
filter?: Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to stop the published video tracks after disposal or to keep them (useful if you set your own track as videoSource and you need to keep it aftger disposal)
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
keepTracksOnDispose? : boolean;
|
||||||
|
|
||||||
}
|
}
|
|
@ -101,7 +101,7 @@ export class WebRtcPeer {
|
||||||
/**
|
/**
|
||||||
* This method frees the resources used by WebRtcPeer
|
* This method frees the resources used by WebRtcPeer
|
||||||
*/
|
*/
|
||||||
dispose() {
|
dispose(keepTracksOnDispose = false) {
|
||||||
console.debug('Disposing WebRtcPeer');
|
console.debug('Disposing WebRtcPeer');
|
||||||
try {
|
try {
|
||||||
if (this.pc) {
|
if (this.pc) {
|
||||||
|
@ -112,7 +112,7 @@ export class WebRtcPeer {
|
||||||
this.localCandidatesQueue = [];
|
this.localCandidatesQueue = [];
|
||||||
|
|
||||||
this.pc.getLocalStreams().forEach(str => {
|
this.pc.getLocalStreams().forEach(str => {
|
||||||
this.streamStop(str);
|
this.streamStop(str, keepTracksOnDispose);
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME This is not yet implemented in firefox
|
// FIXME This is not yet implemented in firefox
|
||||||
|
@ -244,9 +244,11 @@ export class WebRtcPeer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private streamStop(stream: MediaStream): void {
|
private streamStop(stream: MediaStream, keepTracksOnDispose = false): void {
|
||||||
stream.getTracks().forEach(track => {
|
stream.getTracks().forEach(track => {
|
||||||
track.stop();
|
if (!keepTracksOnDispose) {
|
||||||
|
track.stop();
|
||||||
|
}
|
||||||
stream.removeTrack(track);
|
stream.removeTrack(track);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue