Skip to content

Commit

Permalink
feat(RTC) drop PERMISSION_PROMPT_IS_SHOWN event (#2609)
Browse files Browse the repository at this point in the history
* feat(RTC) drop PERMISSION_PROMPT_IS_SHOWN event

It was never accurate since browsers have changed their behavior over
time and can be implemented in the application more reliably.

* squash: Update JitsiMeetJS.ts

* squash: Update hand-crafted JitsiMeetJS.d.ts

---------

Co-authored-by: Дамян Минков <[email protected]>
  • Loading branch information
saghul and damencho authored Dec 13, 2024
1 parent 1ab4ae5 commit d7dc753
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 31 deletions.
14 changes: 2 additions & 12 deletions JitsiMeetJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ function getAnalyticsAttributesFromOptions(options) {
interface ICreateLocalTrackOptions {
cameraDeviceId?: string;
devices?: any[];
firePermissionPromptIsShownEvent?: boolean;
fireSlowPromiseEvent?: boolean;
micDeviceId?: string;
resolution?: string;
Expand Down Expand Up @@ -273,8 +272,6 @@ export default {
* which should be created. should be created or some additional
* configurations about resolution for example.
* @param {Array} options.effects optional effects array for the track
* @param {boolean} options.firePermissionPromptIsShownEvent - if event
* JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN should be fired
* @param {Array} options.devices the devices that will be requested
* @param {string} options.resolution resolution constraints
* @param {string} options.cameraDeviceId
Expand All @@ -285,13 +282,6 @@ export default {
* JitsiConferenceError if rejected.
*/
createLocalTracks(options: ICreateLocalTrackOptions = {}) {
const { firePermissionPromptIsShownEvent, ...restOptions } = options;

if (firePermissionPromptIsShownEvent && !RTC.arePermissionsGrantedForAvailableDevices()) {
// @ts-ignore
JitsiMediaDevices.emit(JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN, browser.getName());
}

let isFirstGUM = false;
let startTS = window.performance.now();

Expand All @@ -306,7 +296,7 @@ export default {
}
window.connectionTimes['obtainPermissions.start'] = startTS;

return RTC.obtainAudioAndVideoPermissions(restOptions)
return RTC.obtainAudioAndVideoPermissions(options)
.then(tracks => {
let endTS = window.performance.now();

Expand All @@ -319,7 +309,7 @@ export default {
Statistics.sendAnalytics(
createGetUserMediaEvent(
'success',
getAnalyticsAttributesFromOptions(restOptions)));
getAnalyticsAttributesFromOptions(options)));

if (this.isCollectingLocalStats()) {
for (let i = 0; i < tracks.length; i++) {
Expand Down
8 changes: 0 additions & 8 deletions modules/RTC/RTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,6 @@ export default class RTC extends Listenable {
return RTCUtils.getCurrentlyAvailableMediaDevices();
}

/**
* Returns whether available devices have permissions granted
* @returns {Boolean}
*/
static arePermissionsGrantedForAvailableDevices() {
return RTCUtils.arePermissionsGrantedForAvailableDevices();
}

/**
* Returns event data for device to be reported to stats.
* @returns {MediaDeviceInfo} device.
Expand Down
8 changes: 0 additions & 8 deletions modules/RTC/RTCUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,14 +827,6 @@ class RTCUtils extends Listenable {
return availableDevices;
}

/**
* Returns whether available devices have permissions granted
* @returns {Boolean}
*/
arePermissionsGrantedForAvailableDevices() {
return availableDevices.some(device => Boolean(device.label));
}

/**
* Returns event data for device to be reported to stats.
* @returns {MediaDeviceInfo} device.
Expand Down
2 changes: 1 addition & 1 deletion types/hand-crafted/JitsiMeetJS.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export type JitsiMeetJSType = {

setGlobalLogOptions: ( options: unknown ) => void; // TODO:

createLocalTracks: ( options: CreateLocalTracksOptions, firePermissionPromptIsShownEvent?: boolean, originalOptions?: CreateLocalTracksOptions ) => Promise<Array<JitsiLocalTrack> | JitsiConferenceErrors>; // TODO:
createLocalTracks: ( options: CreateLocalTracksOptions, originalOptions?: CreateLocalTracksOptions ) => Promise<Array<JitsiLocalTrack> | JitsiConferenceErrors>; // TODO:

createTrackVADEmitter: ( localAudioDeviceId: string, sampleRate: 256 | 512 | 1024 | 4096 | 8192 | 16384, vadProcessor: VADProcessor ) => Promise<TrackVADEmitter>;

Expand Down
1 change: 0 additions & 1 deletion types/hand-crafted/modules/RTC/RTC.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ export default class RTC extends Listenable {
isInForwardedSources: ( sourceName: string ) => boolean;
setReceiverVideoConstraints: ( constraints: unknown ) => void; // TODO:
setVideoMute: ( value: unknown ) => Promise<unknown>; // TODO:
arePermissionsGrantedForAvailableDevices: () => boolean;
sendEndpointStatsMessage: ( payload: unknown ) => void; // TODO:
}
1 change: 0 additions & 1 deletion types/hand-crafted/modules/RTC/RTCUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ declare class RTCUtils extends Listenable {
getAudioOutputDevice: () => string;
getCurrentlyAvailableMediaDevices: () => unknown[]; // TODO:
getEventDataForActiveDevice: ( device: MediaDeviceInfo ) => unknown; // TODO:
arePermissionsGrantedForAvailableDevices: () => boolean;
isUserStreamById: ( streamId: string ) => boolean;
}

Expand Down

0 comments on commit d7dc753

Please sign in to comment.