mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: fixes for Publishers subscribed to remote
parent
c111ed20af
commit
3e5853227b
|
@ -117,7 +117,8 @@ export class Publisher extends StreamManager {
|
|||
*/
|
||||
publishAudio(value: boolean): void {
|
||||
if (this.stream.audioActive !== value) {
|
||||
this.stream.getMediaStream().getAudioTracks().forEach((track) => {
|
||||
const affectedMediaStream: MediaStream = this.stream.displayMyRemote() ? this.stream.localMediaStreamWhenSubscribedToRemote : this.stream.getMediaStream();
|
||||
affectedMediaStream.getAudioTracks().forEach((track) => {
|
||||
track.enabled = value;
|
||||
});
|
||||
if (!!this.session && !!this.stream.streamId) {
|
||||
|
@ -163,7 +164,8 @@ export class Publisher extends StreamManager {
|
|||
*/
|
||||
publishVideo(value: boolean): void {
|
||||
if (this.stream.videoActive !== value) {
|
||||
this.stream.getMediaStream().getVideoTracks().forEach((track) => {
|
||||
const affectedMediaStream: MediaStream = this.stream.displayMyRemote() ? this.stream.localMediaStreamWhenSubscribedToRemote : this.stream.getMediaStream();
|
||||
affectedMediaStream.getVideoTracks().forEach((track) => {
|
||||
track.enabled = value;
|
||||
});
|
||||
if (!!this.session && !!this.stream.streamId) {
|
||||
|
@ -305,15 +307,16 @@ export class Publisher extends StreamManager {
|
|||
reject(new Error('Unknown track kind ' + track.kind));
|
||||
}
|
||||
(<any>sender).replaceTrack(track).then(() => {
|
||||
const mediaStream: MediaStream = this.stream.displayMyRemote() ? this.stream.localMediaStreamWhenSubscribedToRemote : this.stream.getMediaStream();
|
||||
let removedTrack: MediaStreamTrack;
|
||||
if (track.kind === 'video') {
|
||||
removedTrack = this.stream.getMediaStream().getVideoTracks()[0];
|
||||
removedTrack = mediaStream.getVideoTracks()[0];
|
||||
} else {
|
||||
removedTrack = this.stream.getMediaStream().getAudioTracks()[0];
|
||||
removedTrack = mediaStream.getAudioTracks()[0];
|
||||
}
|
||||
this.stream.getMediaStream().removeTrack(removedTrack);
|
||||
mediaStream.removeTrack(removedTrack);
|
||||
removedTrack.stop();
|
||||
this.stream.getMediaStream().addTrack(track);
|
||||
mediaStream.addTrack(track);
|
||||
resolve();
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
|
|
|
@ -941,7 +941,6 @@ export class Session implements EventDispatcher {
|
|||
candidate: msg.candidate,
|
||||
component: msg.component,
|
||||
foundation: msg.foundation,
|
||||
ip: msg.ip,
|
||||
port: msg.port,
|
||||
priority: msg.priority,
|
||||
protocol: msg.protocol,
|
||||
|
|
|
@ -195,6 +195,10 @@ export class Stream implements EventDispatcher {
|
|||
* @hidden
|
||||
*/
|
||||
harkOptions;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
localMediaStreamWhenSubscribedToRemote: MediaStream;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -495,6 +499,16 @@ export class Stream implements EventDispatcher {
|
|||
});
|
||||
delete this.mediaStream;
|
||||
}
|
||||
// If subscribeToRemote local MediaStream must be stopped
|
||||
if (this.localMediaStreamWhenSubscribedToRemote) {
|
||||
this.localMediaStreamWhenSubscribedToRemote.getAudioTracks().forEach((track) => {
|
||||
track.stop();
|
||||
});
|
||||
this.localMediaStreamWhenSubscribedToRemote.getVideoTracks().forEach((track) => {
|
||||
track.stop();
|
||||
});
|
||||
delete this.localMediaStreamWhenSubscribedToRemote;
|
||||
}
|
||||
if (!!this.speechEvent) {
|
||||
if (!!this.speechEvent.stop) {
|
||||
this.speechEvent.stop();
|
||||
|
@ -863,6 +877,7 @@ export class Stream implements EventDispatcher {
|
|||
this.isLocalStreamPublished = true;
|
||||
this.publishedOnce = true;
|
||||
if (this.displayMyRemote()) {
|
||||
this.localMediaStreamWhenSubscribedToRemote = this.mediaStream;
|
||||
this.remotePeerSuccessfullyEstablished();
|
||||
}
|
||||
if (reconnect) {
|
||||
|
|
Loading…
Reference in New Issue