New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openvidu-browser

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openvidu-browser - npm Package Compare versions

Comparing version 2.27.0 to 2.28.0-beta1

openvidu-browser-2.28.0-beta1.tgz

36

lib/OpenVidu/OpenVidu.js

@@ -303,3 +303,5 @@ "use strict";

platform.isElectron() ||
platform.isNodeJs());
platform.isNodeJs() ||
// TODO: remove when updating platform detection library
platform.isMotorolaEdgeDevice());
};

@@ -471,7 +473,6 @@ /**

OpenVidu.prototype.getUserMedia = function (options) {
var _this = this;
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var askForAudioStreamOnly, myConstraints, mustAskForAudioTrackLater, mediaStream, error_1, errorName, errorMessage, constraintsAux, mediaStream, error_2, errorName, errorMessage, error_3;
var _this = this;
var _a, _b;
return __generator(this, function (_c) {

@@ -494,3 +495,3 @@ switch (_c.label) {

previousMediaStream.addTrack(audioOnlyStream.getAudioTracks()[0]);
return [2 /*return*/, resolve(previousMediaStream)];
return [2 /*return*/, previousMediaStream];
case 3:

@@ -504,3 +505,3 @@ error_4 = _a.sent();

});
return [2 /*return*/, reject(this.generateAudioDeviceError(error_4, constraintsAux))];
throw this.generateAudioDeviceError(error_4, constraintsAux);
case 4: return [2 /*return*/];

@@ -520,3 +521,3 @@ }

// No need to call getUserMedia at all. Both tracks provided, or only AUDIO track provided or only VIDEO track provided
return [2 /*return*/, resolve(this.addAlreadyProvidedTracks(myConstraints, new MediaStream()))];
return [2 /*return*/, this.addAlreadyProvidedTracks(myConstraints, new MediaStream())];
case 3:

@@ -549,6 +550,4 @@ // getUserMedia must be called. AUDIO or VIDEO are requesting a new track

return [4 /*yield*/, askForAudioStreamOnly(mediaStream, myConstraints.constraints)];
case 6:
_c.sent();
return [2 /*return*/];
case 7: return [2 /*return*/, resolve(mediaStream)];
case 6: return [2 /*return*/, _c.sent()];
case 7: return [2 /*return*/, mediaStream];
case 8: return [3 /*break*/, 10];

@@ -559,3 +558,3 @@ case 9:

errorMessage = error_1.toString();
return [2 /*return*/, reject(new OpenViduError_1.OpenViduError(errorName, errorMessage))];
throw new OpenViduError_1.OpenViduError(errorName, errorMessage);
case 10: return [3 /*break*/, 11];

@@ -576,6 +575,4 @@ case 11: return [3 /*break*/, 12];

return [4 /*yield*/, askForAudioStreamOnly(mediaStream, myConstraints.constraints)];
case 15:
_c.sent();
return [3 /*break*/, 17];
case 16: return [2 /*return*/, resolve(mediaStream)];
case 15: return [2 /*return*/, _c.sent()];
case 16: return [2 /*return*/, mediaStream];
case 17: return [3 /*break*/, 19];

@@ -592,12 +589,11 @@ case 18:

}
return [2 /*return*/, reject(new OpenViduError_1.OpenViduError(errorName, errorMessage))];
throw new OpenViduError_1.OpenViduError(errorName, errorMessage);
case 19: return [3 /*break*/, 21];
case 20:
error_3 = _c.sent();
reject(error_3);
return [3 /*break*/, 21];
throw error_3;
case 21: return [2 /*return*/];
}
});
}); });
});
};

@@ -604,0 +600,0 @@ /* tslint:disable:no-empty */

@@ -57,2 +57,6 @@ export declare class PlatformUtils {

*/
isMotorolaEdgeDevice(): boolean;
/**
* @hidden
*/
isIPhoneOrIPad(): boolean;

@@ -59,0 +63,0 @@ /**

@@ -92,5 +92,13 @@ "use strict";

};
// TODO: This method exists to overcome bug https://github.com/bestiejs/platform.js/issues/184
/**
* @hidden
*/
PlatformUtils.prototype.isMotorolaEdgeDevice = function () {
var _a;
return ((_a = platform.product) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('motorola edge')) || false;
};
/**
* @hidden
*/
PlatformUtils.prototype.isIPhoneOrIPad = function () {

@@ -151,3 +159,5 @@ var userAgent = !!platform.ua ? platform.ua : navigator.userAgent;

this.isIonicIos() ||
this.isElectron());
this.isElectron() ||
// TODO: remove when possible
this.isMotorolaEdgeDevice());
};

@@ -154,0 +164,0 @@ /**

@@ -56,3 +56,3 @@ {

},
"version": "2.27.0"
"version": "2.28.0-beta1"
}

@@ -351,3 +351,5 @@ /*

platform.isElectron() ||
platform.isNodeJs()
platform.isNodeJs() ||
// TODO: remove when updating platform detection library
platform.isMotorolaEdgeDevice()
);

@@ -516,103 +518,100 @@ }

*/
getUserMedia(options: PublisherProperties): Promise<MediaStream> {
return new Promise<MediaStream>(async (resolve, reject) => {
const askForAudioStreamOnly = async (previousMediaStream: MediaStream, constraints: MediaStreamConstraints) => {
const definedAudioConstraint = constraints.audio === undefined ? true : constraints.audio;
const constraintsAux: MediaStreamConstraints = { audio: definedAudioConstraint, video: false };
try {
const audioOnlyStream = await navigator.mediaDevices.getUserMedia(constraintsAux);
previousMediaStream.addTrack(audioOnlyStream.getAudioTracks()[0]);
return resolve(previousMediaStream);
} catch (error) {
previousMediaStream.getAudioTracks().forEach((track) => {
track.stop();
});
previousMediaStream.getVideoTracks().forEach((track) => {
track.stop();
});
return reject(this.generateAudioDeviceError(error, constraintsAux));
}
};
async getUserMedia(options: PublisherProperties): Promise<MediaStream> {
const askForAudioStreamOnly = async (previousMediaStream: MediaStream, constraints: MediaStreamConstraints) => {
const definedAudioConstraint = constraints.audio === undefined ? true : constraints.audio;
const constraintsAux: MediaStreamConstraints = { audio: definedAudioConstraint, video: false };
try {
const myConstraints = await this.generateMediaConstraints(options);
if (
(!!myConstraints.videoTrack && !!myConstraints.audioTrack) ||
(!!myConstraints.audioTrack && myConstraints.constraints?.video === false) ||
(!!myConstraints.videoTrack && myConstraints.constraints?.audio === false)
) {
// No need to call getUserMedia at all. Both tracks provided, or only AUDIO track provided or only VIDEO track provided
return resolve(this.addAlreadyProvidedTracks(myConstraints, new MediaStream()));
} else {
// getUserMedia must be called. AUDIO or VIDEO are requesting a new track
const audioOnlyStream = await navigator.mediaDevices.getUserMedia(constraintsAux);
previousMediaStream.addTrack(audioOnlyStream.getAudioTracks()[0]);
return previousMediaStream;
} catch (error) {
previousMediaStream.getAudioTracks().forEach((track) => {
track.stop();
});
previousMediaStream.getVideoTracks().forEach((track) => {
track.stop();
});
throw this.generateAudioDeviceError(error, constraintsAux);
}
};
// Delete already provided constraints for audio or video
if (!!myConstraints.videoTrack) {
delete myConstraints.constraints!.video;
}
if (!!myConstraints.audioTrack) {
delete myConstraints.constraints!.audio;
}
try {
const myConstraints = await this.generateMediaConstraints(options);
if (
(!!myConstraints.videoTrack && !!myConstraints.audioTrack) ||
(!!myConstraints.audioTrack && myConstraints.constraints?.video === false) ||
(!!myConstraints.videoTrack && myConstraints.constraints?.audio === false)
) {
// No need to call getUserMedia at all. Both tracks provided, or only AUDIO track provided or only VIDEO track provided
return this.addAlreadyProvidedTracks(myConstraints, new MediaStream());
} else {
// getUserMedia must be called. AUDIO or VIDEO are requesting a new track
let mustAskForAudioTrackLater = false;
if (typeof options.videoSource === 'string') {
// Video is deviceId or screen sharing
if (
options.videoSource === 'screen' ||
options.videoSource === 'window' ||
(platform.isElectron() && options.videoSource.startsWith('screen:'))
) {
// Video is screen sharing
mustAskForAudioTrackLater =
!myConstraints.audioTrack && options.audioSource !== null && options.audioSource !== false;
if (navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
// getDisplayMedia supported
try {
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true });
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
if (mustAskForAudioTrackLater) {
await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
return;
} else {
return resolve(mediaStream);
}
} catch (error) {
let errorName: OpenViduErrorName = OpenViduErrorName.SCREEN_CAPTURE_DENIED;
const errorMessage = error.toString();
return reject(new OpenViduError(errorName, errorMessage));
// Delete already provided constraints for audio or video
if (!!myConstraints.videoTrack) {
delete myConstraints.constraints!.video;
}
if (!!myConstraints.audioTrack) {
delete myConstraints.constraints!.audio;
}
let mustAskForAudioTrackLater = false;
if (typeof options.videoSource === 'string') {
// Video is deviceId or screen sharing
if (
options.videoSource === 'screen' ||
options.videoSource === 'window' ||
(platform.isElectron() && options.videoSource.startsWith('screen:'))
) {
// Video is screen sharing
mustAskForAudioTrackLater =
!myConstraints.audioTrack && options.audioSource !== null && options.audioSource !== false;
if (navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
// getDisplayMedia supported
try {
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true });
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
if (mustAskForAudioTrackLater) {
return await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
} else {
return mediaStream;
}
} else {
// getDisplayMedia NOT supported. Can perform getUserMedia below with already calculated constraints
} catch (error) {
let errorName: OpenViduErrorName = OpenViduErrorName.SCREEN_CAPTURE_DENIED;
const errorMessage = error.toString();
throw new OpenViduError(errorName, errorMessage);
}
} else {
// Video is deviceId. Can perform getUserMedia below with already calculated constraints
// getDisplayMedia NOT supported. Can perform getUserMedia below with already calculated constraints
}
} else {
// Video is deviceId. Can perform getUserMedia below with already calculated constraints
}
// Use already calculated constraints
const constraintsAux = mustAskForAudioTrackLater
? { video: myConstraints.constraints!.video }
: myConstraints.constraints;
try {
const mediaStream = await navigator.mediaDevices.getUserMedia(constraintsAux);
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
if (mustAskForAudioTrackLater) {
await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
} else {
return resolve(mediaStream);
}
} catch (error) {
let errorName: OpenViduErrorName;
const errorMessage = error.toString();
if (!(options.videoSource === 'screen')) {
errorName = OpenViduErrorName.DEVICE_ACCESS_DENIED;
} else {
errorName = OpenViduErrorName.SCREEN_CAPTURE_DENIED;
}
return reject(new OpenViduError(errorName, errorMessage));
}
// Use already calculated constraints
const constraintsAux = mustAskForAudioTrackLater
? { video: myConstraints.constraints!.video }
: myConstraints.constraints;
try {
const mediaStream = await navigator.mediaDevices.getUserMedia(constraintsAux);
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
if (mustAskForAudioTrackLater) {
return await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
} else {
return mediaStream;
}
} catch (error) {
let errorName: OpenViduErrorName;
const errorMessage = error.toString();
if (!(options.videoSource === 'screen')) {
errorName = OpenViduErrorName.DEVICE_ACCESS_DENIED;
} else {
errorName = OpenViduErrorName.SCREEN_CAPTURE_DENIED;
}
throw new OpenViduError(errorName, errorMessage);
}
} catch (error) {
reject(error);
}
});
} catch (error) {
throw error;
}
}

@@ -995,3 +994,3 @@

*/
addAlreadyProvidedTracks(myConstraints: CustomMediaStreamConstraints, mediaStream: MediaStream, stream?: Stream) {
addAlreadyProvidedTracks(myConstraints: CustomMediaStreamConstraints, mediaStream: MediaStream, stream?: Stream): MediaStream {
if (!!myConstraints.videoTrack) {

@@ -998,0 +997,0 @@ mediaStream.addTrack(myConstraints.videoTrack);

@@ -104,5 +104,13 @@ import platform = require('platform');

// TODO: This method exists to overcome bug https://github.com/bestiejs/platform.js/issues/184
/**
* @hidden
*/
public isMotorolaEdgeDevice(): boolean {
return platform.product?.toLowerCase().includes('motorola edge') || false;
}
/**
* @hidden
*/
public isIPhoneOrIPad(): boolean {

@@ -172,6 +180,10 @@ const userAgent = !!platform.ua ? platform.ua : navigator.userAgent;

this.isIonicIos() ||
this.isElectron()
this.isElectron() ||
// TODO: remove when possible
this.isMotorolaEdgeDevice()
);
}
/**

@@ -178,0 +190,0 @@ * @hidden

@@ -57,2 +57,6 @@ export declare class PlatformUtils {

*/
isMotorolaEdgeDevice(): boolean;
/**
* @hidden
*/
isIPhoneOrIPad(): boolean;

@@ -59,0 +63,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc