diff --git a/openvidu-browser/src/OpenVidu/OpenVidu.ts b/openvidu-browser/src/OpenVidu/OpenVidu.ts index 3d2263ba..ddd81e1f 100644 --- a/openvidu-browser/src/OpenVidu/OpenVidu.ts +++ b/openvidu-browser/src/OpenVidu/OpenVidu.ts @@ -717,9 +717,10 @@ export class OpenVidu { /** * @hidden */ - sendTrackChangedEvent(publisher: Publisher, reason: string, oldLabel: string, newLabel: string, propertyType: string) { + sendTrackChangedEvent(publisher: Publisher, oldLabel: string, newLabel: string, propertyType: string) { const oldValue = { label: oldLabel }; const newValue = { label: newLabel }; + const reason = 'trackReplaced'; if (publisher.stream.isLocalStreamPublished) { this.sendRequest( @@ -727,7 +728,7 @@ export class OpenVidu { { streamId: publisher.stream.streamId, property: propertyType, - newValue: JSON.stringify({ newLabel }), + newValue: newValue, reason }, (error, response) => { diff --git a/openvidu-browser/src/OpenVidu/Publisher.ts b/openvidu-browser/src/OpenVidu/Publisher.ts index 5ddc7f24..c4bec311 100644 --- a/openvidu-browser/src/OpenVidu/Publisher.ts +++ b/openvidu-browser/src/OpenVidu/Publisher.ts @@ -811,12 +811,12 @@ export class Publisher extends StreamManager { }; if (track.kind === 'video' && updateLastConstraints) { this.openvidu.sendNewVideoDimensionsIfRequired(this, 'trackReplaced', 50, 30); - this.openvidu.sendTrackChangedEvent(this, 'trackReplaced', trackInfo.oldLabel, trackInfo.newLabel, 'videoActive'); + this.openvidu.sendTrackChangedEvent(this, trackInfo.oldLabel, trackInfo.newLabel, 'videoTrack'); if (this.stream.isLocalStreamPublished) { this.session.sendVideoData(this.stream.streamManager, 5, true, 5); } } else if (track.kind === 'audio' && updateLastConstraints) { - this.openvidu.sendTrackChangedEvent(this, 'trackReplaced', trackInfo.oldLabel, trackInfo.newLabel, 'audioActive'); + this.openvidu.sendTrackChangedEvent(this, trackInfo.oldLabel, trackInfo.newLabel, 'audioTrack'); } if (track.kind === 'audio') { this.stream.disableHarkSpeakingEvent(false); diff --git a/openvidu-browser/src/OpenVidu/Session.ts b/openvidu-browser/src/OpenVidu/Session.ts index ec05ab7d..71d6537e 100644 --- a/openvidu-browser/src/OpenVidu/Session.ts +++ b/openvidu-browser/src/OpenVidu/Session.ts @@ -649,7 +649,7 @@ export class Session extends EventDispatcher { * when speech is detected in its audio track. * * @param stream - The Stream for which you want to start receiving [[SpeechToTextEvent]]. - * @þaram lang - The language of the Stream's audio track. It must be a valid [BCP-47](https://tools.ietf.org/html/bcp47) language tag like "en-US" or "es-ES". + * @param lang - The language of the Stream's audio track. It must be a valid [BCP-47](https://tools.ietf.org/html/bcp47) language tag like "en-US" or "es-ES". * * @returns A Promise (to which you can optionally subscribe to) that is resolved if the speech-to-text subscription * was successful and rejected with an Error object if not. @@ -990,6 +990,12 @@ export class Session extends EventDispatcher { event.newValue = event.newValue === 'true'; stream.videoActive = event.newValue; break; + case 'videoTrack': + event.newValue = JSON.parse(event.newValue); + break; + case 'audioTrack': + event.newValue = JSON.parse(event.newValue); + break; case 'videoDimensions': oldValue = stream.videoDimensions; event.newValue = JSON.parse(JSON.parse(event.newValue)); diff --git a/openvidu-browser/src/OpenViduInternal/Events/StreamPropertyChangedEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/StreamPropertyChangedEvent.ts index fa262058..cc72227f 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/StreamPropertyChangedEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/StreamPropertyChangedEvent.ts @@ -30,7 +30,7 @@ export class StreamPropertyChangedEvent extends Event { stream: Stream; /** - * The property of the stream that changed. This value is either `"videoActive"`, `"audioActive"`, `"videoDimensions"` or `"filter"` + * The property of the stream that changed. This value is either `"videoActive"`, `"audioActive"`, `"videoTrack"`, `"audioTrack"`, `"videoDimensions"` or `"filter"` */ changedProperty: string; @@ -38,6 +38,8 @@ export class StreamPropertyChangedEvent extends Event { * Cause of the change on the stream's property: * - For `videoActive`: `"publishVideo"` * - For `audioActive`: `"publishAudio"` + * - For `videoTrack`: `"trackReplaced"` + * - For `audioTrack`: `"trackReplaced"` * - For `videoDimensions`: `"deviceRotated"`, `"screenResized"` or `"trackReplaced"` * - For `filter`: `"applyFilter"`, `"execFilterMethod"` or `"removeFilter"` */