openvidu-browser 2.27.0 → 2.28.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/OpenVidu/OpenVidu.js +16 -20
- package/lib/OpenVidu/OpenVidu.js.map +1 -1
- package/lib/OpenVidu/Session.js +3 -2
- package/lib/OpenVidu/Session.js.map +1 -1
- package/lib/OpenViduInternal/Utils/Platform.d.ts +4 -0
- package/lib/OpenViduInternal/Utils/Platform.js +11 -1
- package/lib/OpenViduInternal/Utils/Platform.js.map +1 -1
- package/openvidu-browser-2.28.0-beta1.tgz +0 -0
- package/package.json +1 -1
- package/src/OpenVidu/OpenVidu.ts +91 -92
- package/src/OpenVidu/Session.ts +2 -2
- package/src/OpenViduInternal/Utils/Platform.ts +13 -1
- package/static/js/.scannerwork/.sonar_lock +0 -0
- package/static/js/.scannerwork/report-task.txt +6 -0
- package/static/js/openvidu-browser-dev.js +14129 -0
- package/static/js/openvidu-browser-dev.min.js +1 -0
- package/static/js/openvidu-browser-dev.min.js.map +1 -0
- package/ts4.4/lib/OpenViduInternal/Utils/Platform.d.ts +4 -0
- package/static/js/openvidu-browser-2.27.0.js +0 -14128
- package/static/js/openvidu-browser-2.27.0.min.js +0 -1
- package/static/js/openvidu-browser-2.27.0.min.js.map +0 -1
package/src/OpenVidu/OpenVidu.ts
CHANGED
|
@@ -348,7 +348,9 @@ export class OpenVidu {
|
|
|
348
348
|
platform.isSafariBrowser() ||
|
|
349
349
|
platform.isAndroidBrowser() || // Android WebView & Ionic apps for Android
|
|
350
350
|
platform.isElectron() ||
|
|
351
|
-
platform.isNodeJs()
|
|
351
|
+
platform.isNodeJs() ||
|
|
352
|
+
// TODO: remove when updating platform detection library
|
|
353
|
+
platform.isMotorolaEdgeDevice()
|
|
352
354
|
);
|
|
353
355
|
}
|
|
354
356
|
|
|
@@ -512,107 +514,104 @@ export class OpenVidu {
|
|
|
512
514
|
* });
|
|
513
515
|
* ```
|
|
514
516
|
*/
|
|
515
|
-
getUserMedia(options: PublisherProperties): Promise<MediaStream> {
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
const constraintsAux: MediaStreamConstraints = { audio: definedAudioConstraint, video: false };
|
|
520
|
-
try {
|
|
521
|
-
const audioOnlyStream = await navigator.mediaDevices.getUserMedia(constraintsAux);
|
|
522
|
-
previousMediaStream.addTrack(audioOnlyStream.getAudioTracks()[0]);
|
|
523
|
-
return resolve(previousMediaStream);
|
|
524
|
-
} catch (error) {
|
|
525
|
-
previousMediaStream.getAudioTracks().forEach((track) => {
|
|
526
|
-
track.stop();
|
|
527
|
-
});
|
|
528
|
-
previousMediaStream.getVideoTracks().forEach((track) => {
|
|
529
|
-
track.stop();
|
|
530
|
-
});
|
|
531
|
-
return reject(this.generateAudioDeviceError(error, constraintsAux));
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
|
|
517
|
+
async getUserMedia(options: PublisherProperties): Promise<MediaStream> {
|
|
518
|
+
const askForAudioStreamOnly = async (previousMediaStream: MediaStream, constraints: MediaStreamConstraints) => {
|
|
519
|
+
const definedAudioConstraint = constraints.audio === undefined ? true : constraints.audio;
|
|
520
|
+
const constraintsAux: MediaStreamConstraints = { audio: definedAudioConstraint, video: false };
|
|
535
521
|
try {
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
522
|
+
const audioOnlyStream = await navigator.mediaDevices.getUserMedia(constraintsAux);
|
|
523
|
+
previousMediaStream.addTrack(audioOnlyStream.getAudioTracks()[0]);
|
|
524
|
+
return previousMediaStream;
|
|
525
|
+
} catch (error) {
|
|
526
|
+
previousMediaStream.getAudioTracks().forEach((track) => {
|
|
527
|
+
track.stop();
|
|
528
|
+
});
|
|
529
|
+
previousMediaStream.getVideoTracks().forEach((track) => {
|
|
530
|
+
track.stop();
|
|
531
|
+
});
|
|
532
|
+
throw this.generateAudioDeviceError(error, constraintsAux);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
546
535
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
536
|
+
try {
|
|
537
|
+
const myConstraints = await this.generateMediaConstraints(options);
|
|
538
|
+
if (
|
|
539
|
+
(!!myConstraints.videoTrack && !!myConstraints.audioTrack) ||
|
|
540
|
+
(!!myConstraints.audioTrack && myConstraints.constraints?.video === false) ||
|
|
541
|
+
(!!myConstraints.videoTrack && myConstraints.constraints?.audio === false)
|
|
542
|
+
) {
|
|
543
|
+
// No need to call getUserMedia at all. Both tracks provided, or only AUDIO track provided or only VIDEO track provided
|
|
544
|
+
return this.addAlreadyProvidedTracks(myConstraints, new MediaStream());
|
|
545
|
+
} else {
|
|
546
|
+
// getUserMedia must be called. AUDIO or VIDEO are requesting a new track
|
|
554
547
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
return
|
|
548
|
+
// Delete already provided constraints for audio or video
|
|
549
|
+
if (!!myConstraints.videoTrack) {
|
|
550
|
+
delete myConstraints.constraints!.video;
|
|
551
|
+
}
|
|
552
|
+
if (!!myConstraints.audioTrack) {
|
|
553
|
+
delete myConstraints.constraints!.audio;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
let mustAskForAudioTrackLater = false;
|
|
557
|
+
if (typeof options.videoSource === 'string') {
|
|
558
|
+
// Video is deviceId or screen sharing
|
|
559
|
+
if (
|
|
560
|
+
options.videoSource === 'screen' ||
|
|
561
|
+
options.videoSource === 'window' ||
|
|
562
|
+
(platform.isElectron() && options.videoSource.startsWith('screen:'))
|
|
563
|
+
) {
|
|
564
|
+
// Video is screen sharing
|
|
565
|
+
mustAskForAudioTrackLater =
|
|
566
|
+
!myConstraints.audioTrack && options.audioSource !== null && options.audioSource !== false;
|
|
567
|
+
if (navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
|
|
568
|
+
// getDisplayMedia supported
|
|
569
|
+
try {
|
|
570
|
+
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true });
|
|
571
|
+
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
|
|
572
|
+
if (mustAskForAudioTrackLater) {
|
|
573
|
+
return await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
|
|
574
|
+
} else {
|
|
575
|
+
return mediaStream;
|
|
581
576
|
}
|
|
582
|
-
}
|
|
583
|
-
|
|
577
|
+
} catch (error) {
|
|
578
|
+
let errorName: OpenViduErrorName = OpenViduErrorName.SCREEN_CAPTURE_DENIED;
|
|
579
|
+
const errorMessage = error.toString();
|
|
580
|
+
throw new OpenViduError(errorName, errorMessage);
|
|
584
581
|
}
|
|
585
582
|
} else {
|
|
586
|
-
//
|
|
583
|
+
// getDisplayMedia NOT supported. Can perform getUserMedia below with already calculated constraints
|
|
587
584
|
}
|
|
585
|
+
} else {
|
|
586
|
+
// Video is deviceId. Can perform getUserMedia below with already calculated constraints
|
|
588
587
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
} catch (error) {
|
|
602
|
-
let errorName: OpenViduErrorName;
|
|
603
|
-
const errorMessage = error.toString();
|
|
604
|
-
if (!(options.videoSource === 'screen')) {
|
|
605
|
-
errorName = OpenViduErrorName.DEVICE_ACCESS_DENIED;
|
|
606
|
-
} else {
|
|
607
|
-
errorName = OpenViduErrorName.SCREEN_CAPTURE_DENIED;
|
|
608
|
-
}
|
|
609
|
-
return reject(new OpenViduError(errorName, errorMessage));
|
|
588
|
+
}
|
|
589
|
+
// Use already calculated constraints
|
|
590
|
+
const constraintsAux = mustAskForAudioTrackLater
|
|
591
|
+
? { video: myConstraints.constraints!.video }
|
|
592
|
+
: myConstraints.constraints;
|
|
593
|
+
try {
|
|
594
|
+
const mediaStream = await navigator.mediaDevices.getUserMedia(constraintsAux);
|
|
595
|
+
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
|
|
596
|
+
if (mustAskForAudioTrackLater) {
|
|
597
|
+
return await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
|
|
598
|
+
} else {
|
|
599
|
+
return mediaStream;
|
|
610
600
|
}
|
|
601
|
+
} catch (error) {
|
|
602
|
+
let errorName: OpenViduErrorName;
|
|
603
|
+
const errorMessage = error.toString();
|
|
604
|
+
if (!(options.videoSource === 'screen')) {
|
|
605
|
+
errorName = OpenViduErrorName.DEVICE_ACCESS_DENIED;
|
|
606
|
+
} else {
|
|
607
|
+
errorName = OpenViduErrorName.SCREEN_CAPTURE_DENIED;
|
|
608
|
+
}
|
|
609
|
+
throw new OpenViduError(errorName, errorMessage);
|
|
611
610
|
}
|
|
612
|
-
} catch (error) {
|
|
613
|
-
reject(error);
|
|
614
611
|
}
|
|
615
|
-
})
|
|
612
|
+
} catch (error) {
|
|
613
|
+
throw error;
|
|
614
|
+
}
|
|
616
615
|
}
|
|
617
616
|
|
|
618
617
|
/* tslint:disable:no-empty */
|
|
@@ -990,7 +989,7 @@ export class OpenVidu {
|
|
|
990
989
|
/**
|
|
991
990
|
* @hidden
|
|
992
991
|
*/
|
|
993
|
-
addAlreadyProvidedTracks(myConstraints: CustomMediaStreamConstraints, mediaStream: MediaStream, stream?: Stream) {
|
|
992
|
+
addAlreadyProvidedTracks(myConstraints: CustomMediaStreamConstraints, mediaStream: MediaStream, stream?: Stream): MediaStream {
|
|
994
993
|
if (!!myConstraints.videoTrack) {
|
|
995
994
|
mediaStream.addTrack(myConstraints.videoTrack);
|
|
996
995
|
if (!!stream) {
|
package/src/OpenVidu/Session.ts
CHANGED
|
@@ -992,8 +992,8 @@ export class Session extends EventDispatcher {
|
|
|
992
992
|
oldValue = stream.videoActive;
|
|
993
993
|
event.newValue = event.newValue === 'true';
|
|
994
994
|
stream.videoActive = event.newValue;
|
|
995
|
-
const videoTrack = stream
|
|
996
|
-
if(!videoTrack.enabled && stream.videoActive){
|
|
995
|
+
const videoTrack = stream?.getMediaStream()?.getVideoTracks()?.[0];
|
|
996
|
+
if(videoTrack && !videoTrack.enabled && stream.videoActive){
|
|
997
997
|
videoTrack.enabled = true;
|
|
998
998
|
}
|
|
999
999
|
break;
|
|
@@ -101,6 +101,14 @@ export class PlatformUtils {
|
|
|
101
101
|
return platform.name === 'Samsung Internet Mobile' || platform.name === 'Samsung Internet';
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
// TODO: This method exists to overcome bug https://github.com/bestiejs/platform.js/issues/184
|
|
105
|
+
/**
|
|
106
|
+
* @hidden
|
|
107
|
+
*/
|
|
108
|
+
public isMotorolaEdgeDevice(): boolean {
|
|
109
|
+
return platform.product?.toLowerCase().includes('motorola edge') || false;
|
|
110
|
+
}
|
|
111
|
+
|
|
104
112
|
/**
|
|
105
113
|
* @hidden
|
|
106
114
|
*/
|
|
@@ -168,10 +176,14 @@ export class PlatformUtils {
|
|
|
168
176
|
this.isSamsungBrowser() ||
|
|
169
177
|
this.isIonicAndroid() ||
|
|
170
178
|
this.isIonicIos() ||
|
|
171
|
-
this.isElectron()
|
|
179
|
+
this.isElectron() ||
|
|
180
|
+
// TODO: remove when possible
|
|
181
|
+
this.isMotorolaEdgeDevice()
|
|
172
182
|
);
|
|
173
183
|
}
|
|
174
184
|
|
|
185
|
+
|
|
186
|
+
|
|
175
187
|
/**
|
|
176
188
|
* @hidden
|
|
177
189
|
*/
|
|
File without changes
|