Skip to content

Commit

Permalink
feat(createLocalTracks) drop unused slow gUM event
Browse files Browse the repository at this point in the history
It's better handled by the application layer anyway.
  • Loading branch information
saghul committed May 7, 2024
1 parent ec98b02 commit 258e1db
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 29 deletions.
3 changes: 0 additions & 3 deletions JitsiMediaDevicesEvents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe( "/JitsiMediaDevicesEvents members", () => {
DEVICE_LIST_CHANGED,
PERMISSIONS_CHANGED,
PERMISSION_PROMPT_IS_SHOWN,
SLOW_GET_USER_MEDIA,
JitsiMediaDevicesEvents,
...others
} = exported;
Expand All @@ -16,14 +15,12 @@ describe( "/JitsiMediaDevicesEvents members", () => {
expect( DEVICE_LIST_CHANGED ).toBe( 'mediaDevices.devicechange' );
expect( PERMISSIONS_CHANGED ).toBe( 'rtc.permissions_changed' );
expect( PERMISSION_PROMPT_IS_SHOWN ).toBe( 'mediaDevices.permissionPromptIsShown' );
expect( SLOW_GET_USER_MEDIA ).toBe( 'mediaDevices.slowGetUserMedia' );

expect( JitsiMediaDevicesEvents ).toBeDefined();

expect( JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED ).toBe( 'mediaDevices.devicechange' );
expect( JitsiMediaDevicesEvents.PERMISSIONS_CHANGED ).toBe( 'rtc.permissions_changed' );
expect( JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN ).toBe( 'mediaDevices.permissionPromptIsShown' );
expect( JitsiMediaDevicesEvents.SLOW_GET_USER_MEDIA ).toBe( 'mediaDevices.slowGetUserMedia' );
} );

it( "unknown members", () => {
Expand Down
5 changes: 1 addition & 4 deletions JitsiMediaDevicesEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@ export enum JitsiMediaDevicesEvents {
* |'react-native'|'android'} environmentType - type of browser or
* other execution environment.
*/
PERMISSION_PROMPT_IS_SHOWN = 'mediaDevices.permissionPromptIsShown',

SLOW_GET_USER_MEDIA = 'mediaDevices.slowGetUserMedia'
PERMISSION_PROMPT_IS_SHOWN = 'mediaDevices.permissionPromptIsShown'
};

// exported for backward compatibility
export const DEVICE_LIST_CHANGED = JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED;
export const PERMISSIONS_CHANGED = JitsiMediaDevicesEvents.PERMISSIONS_CHANGED;
export const PERMISSION_PROMPT_IS_SHOWN = JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN;
export const SLOW_GET_USER_MEDIA = JitsiMediaDevicesEvents.SLOW_GET_USER_MEDIA;
21 changes: 1 addition & 20 deletions JitsiMeetJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ import { VideoType } from './service/RTC/VideoType';

const logger = Logger.getLogger(__filename);

/**
* The amount of time to wait until firing
* {@link JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN} event.
*/
const USER_MEDIA_SLOW_PROMISE_TIMEOUT = 1000;

/**
* Indicates whether GUM has been executed or not.
*/
Expand Down Expand Up @@ -278,8 +272,6 @@ export default {
* @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 {boolean} options.fireSlowPromiseEvent - if event
* JitsiMediaDevicesEvents.USER_MEDIA_SLOW_PROMISE_TIMEOUT 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 @@ -290,18 +282,11 @@ export default {
* JitsiConferenceError if rejected.
*/
createLocalTracks(options: ICreateLocalTrackOptions = {}) {
let promiseFulfilled = false;
const { firePermissionPromptIsShownEvent, fireSlowPromiseEvent, ...restOptions } = options;
const { firePermissionPromptIsShownEvent, ...restOptions } = options;

if (firePermissionPromptIsShownEvent && !RTC.arePermissionsGrantedForAvailableDevices()) {
// @ts-ignore
JitsiMediaDevices.emit(JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN, browser.getName());
} else if (fireSlowPromiseEvent) {
window.setTimeout(() => {
if (!promiseFulfilled) {
JitsiMediaDevices.emit(JitsiMediaDevicesEvents.SLOW_GET_USER_MEDIA);
}
}, USER_MEDIA_SLOW_PROMISE_TIMEOUT);
}

let isFirstGUM = false;
Expand All @@ -320,8 +305,6 @@ export default {

return RTC.obtainAudioAndVideoPermissions(restOptions)
.then(tracks => {
promiseFulfilled = true;

let endTS = window.performance.now();

window.connectionTimes['obtainPermissions.end'] = endTS;
Expand Down Expand Up @@ -362,8 +345,6 @@ export default {
return tracks;
})
.catch(error => {
promiseFulfilled = true;

if (error.name === JitsiTrackErrors.SCREENSHARING_USER_CANCELED) {
Statistics.sendAnalytics(
createGetUserMediaEvent(
Expand Down
3 changes: 1 addition & 2 deletions types/hand-crafted/JitsiMediaDevicesEvents.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export enum JitsiMediaDevicesEvents {
DEVICE_LIST_CHANGED = 'mediaDevices.devicechange',
PERMISSIONS_CHANGED = 'rtc.permissions_changed',
PERMISSION_PROMPT_IS_SHOWN = 'mediaDevices.permissionPromptIsShown',
SLOW_GET_USER_MEDIA = 'mediaDevices.slowGetUserMedia'
PERMISSION_PROMPT_IS_SHOWN = 'mediaDevices.permissionPromptIsShown'
}

0 comments on commit 258e1db

Please sign in to comment.