Skip to content

Commit

Permalink
ref(RTC): Use TS enum for RTC consts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jallamsetty1 committed Feb 5, 2024
1 parent 178f9bb commit d07cfd4
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 90 deletions.
4 changes: 2 additions & 2 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import {
FEATURE_JIGASI,
JITSI_MEET_MUC_TYPE
} from './modules/xmpp/xmpp';
import BridgeVideoType from './service/RTC/BridgeVideoType';
import CodecMimeType from './service/RTC/CodecMimeType';
import { BridgeVideoType } from './service/RTC/BridgeVideoType';
import { CodecMimeType } from './service/RTC/CodecMimeType';
import { MediaType } from './service/RTC/MediaType';
import RTCEvents from './service/RTC/RTCEvents';
import { SignalingEvents } from './service/RTC/SignalingEvents';
Expand Down
2 changes: 1 addition & 1 deletion modules/RTC/CodecSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { getLogger } from '@jitsi/logger';

import * as JitsiConferenceEvents from '../../JitsiConferenceEvents';
import CodecMimeType from '../../service/RTC/CodecMimeType';
import { CodecMimeType } from '../../service/RTC/CodecMimeType';
import { MediaType } from '../../service/RTC/MediaType';
import browser from '../browser';

Expand Down
2 changes: 1 addition & 1 deletion modules/RTC/JitsiLocalTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
NO_DATA_FROM_SOURCE,
TRACK_MUTE_CHANGED
} from '../../JitsiTrackEvents';
import CameraFacingMode from '../../service/RTC/CameraFacingMode';
import { CameraFacingMode } from '../../service/RTC/CameraFacingMode';
import { MediaType } from '../../service/RTC/MediaType';
import RTCEvents from '../../service/RTC/RTCEvents';
import { VideoType } from '../../service/RTC/VideoType';
Expand Down
2 changes: 1 addition & 1 deletion modules/RTC/RTCUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'webrtc-adapter';

import JitsiTrackError from '../../JitsiTrackError';
import * as JitsiTrackErrors from '../../JitsiTrackErrors';
import CameraFacingMode from '../../service/RTC/CameraFacingMode';
import { CameraFacingMode } from '../../service/RTC/CameraFacingMode';
import RTCEvents from '../../service/RTC/RTCEvents';
import Resolutions from '../../service/RTC/Resolutions';
import { VideoType } from '../../service/RTC/VideoType';
Expand Down
4 changes: 2 additions & 2 deletions modules/RTC/TPCUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getLogger } from '@jitsi/logger';
import clonedeep from 'lodash.clonedeep';
import transform from 'sdp-transform';

import CodecMimeType from '../../service/RTC/CodecMimeType';
import { CodecMimeType } from '../../service/RTC/CodecMimeType';
import { MediaDirection } from '../../service/RTC/MediaDirection';
import { MediaType } from '../../service/RTC/MediaType';
import { getSourceIndexFromSourceName } from '../../service/RTC/SignalingLayer';
Expand All @@ -12,7 +12,7 @@ import {
VIDEO_QUALITY_LEVELS,
VIDEO_QUALITY_SETTINGS
} from '../../service/RTC/StandardVideoSettings';
import VideoEncoderScalabilityMode from '../../service/RTC/VideoEncoderScalabilityMode';
import { VideoEncoderScalabilityMode } from '../../service/RTC/VideoEncoderScalabilityMode';
import { VideoType } from '../../service/RTC/VideoType';
import browser from '../browser';

Expand Down
4 changes: 2 additions & 2 deletions modules/RTC/TPCUtils.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-len */
import CodecMimeType from '../../service/RTC/CodecMimeType';
import VideoEncoderScalabilityMode from '../../service/RTC/VideoEncoderScalabilityMode';
import { CodecMimeType } from '../../service/RTC/CodecMimeType';
import { VideoEncoderScalabilityMode } from '../../service/RTC/VideoEncoderScalabilityMode';

import { MockJitsiLocalTrack, MockPeerConnection } from './MockClasses';
import { TPCUtils } from './TPCUtils';
Expand Down
2 changes: 1 addition & 1 deletion modules/RTC/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getLogger } from '@jitsi/logger';
import { Interop } from '@jitsi/sdp-interop';
import transform from 'sdp-transform';

import CodecMimeType from '../../service/RTC/CodecMimeType';
import { CodecMimeType } from '../../service/RTC/CodecMimeType';
import { MediaDirection } from '../../service/RTC/MediaDirection';
import { MediaType } from '../../service/RTC/MediaType';
import RTCEvents from '../../service/RTC/RTCEvents';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdp/SDPUtil.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getLogger } from '@jitsi/logger';
const logger = getLogger(__filename);

import CodecMimeType from '../../service/RTC/CodecMimeType';
import { CodecMimeType } from '../../service/RTC/CodecMimeType';
import { MediaDirection } from '../../service/RTC/MediaDirection';
import browser from '../browser';
import RandomUtil from '../util/RandomUtil';
Expand Down
22 changes: 7 additions & 15 deletions service/RTC/BridgeVideoType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,17 @@ import * as exported from "./BridgeVideoType";

describe( "/service/RTC/BridgeVideoType members", () => {
const {
CAMERA,
DESKTOP,
DESKTOP_HIGH_FPS,
NONE,
BridgeVideoType,
...others
} = exported as any; // TODO: remove cast after typescript conversion
} = exported;

it( "known members", () => {
expect( CAMERA ).toBe( 'camera' );
expect( DESKTOP ).toBe( 'desktop' );
expect( DESKTOP_HIGH_FPS ).toBe( 'desktop_high_fps' );
expect( NONE ).toBe( 'none' );
if ( BridgeVideoType ) {
expect( BridgeVideoType.CAMERA ).toBe( 'camera' );
expect( BridgeVideoType.DESKTOP ).toBe( 'desktop' );
expect( BridgeVideoType.DESKTOP_HIGH_FPS ).toBe( 'desktop_high_fps' );
expect( BridgeVideoType.NONE ).toBe( 'none' );
}
expect( BridgeVideoType ).toBeDefined();

expect( BridgeVideoType.CAMERA ).toBe( 'camera' );
expect( BridgeVideoType.DESKTOP ).toBe( 'desktop' );
expect( BridgeVideoType.DESKTOP_HIGH_FPS ).toBe( 'desktop_high_fps' );
expect( BridgeVideoType.NONE ).toBe( 'none' );
} );

it( "unknown members", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@
* Enumeration of the video types that are signaled to the bridge
* @type {{CAMERA: string, DESKTOP: string, DESKTOP_HIGH_FPS: string, NONE: string}}
*/
const BridgeVideoType = {
export enum BridgeVideoType {
/**
* The camera video type.
*/
CAMERA: 'camera',
CAMERA = 'camera',

/**
* The low fps desktop video type.
*/
DESKTOP: 'desktop',
DESKTOP = 'desktop',

/**
* The high fps desktop video type.
*/
DESKTOP_HIGH_FPS: 'desktop_high_fps',
DESKTOP_HIGH_FPS = 'desktop_high_fps',

/**
* Video type when no local source is present.
*/
NONE: 'none'
};

module.exports = BridgeVideoType;
NONE = 'none'
}
14 changes: 5 additions & 9 deletions service/RTC/CameraFacingMode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ import * as exported from "./CameraFacingMode";

describe( "/service/RTC/CameraFacingMode members", () => {
const {
ENVIRONMENT,
USER,
CameraFacingMode,
...others
} = exported as any; // TODO: remove cast after typescript conversion
} = exported;

it( "known members", () => {
expect( ENVIRONMENT ).toBe( 'environment' );
expect( USER ).toBe( 'user' );
if ( CameraFacingMode ) {
expect( CameraFacingMode.ENVIRONMENT ).toBe( 'environment' );
expect( CameraFacingMode.USER ).toBe( 'user' );
}
expect( CameraFacingMode ).toBeDefined();

expect( CameraFacingMode.ENVIRONMENT ).toBe( 'environment' );
expect( CameraFacingMode.USER ).toBe( 'user' );
} );

it( "unknown members", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
*
* @enum {string}
*/
const CameraFacingMode = {
export enum CameraFacingMode {
/**
* The mode which specifies the environment-facing camera.
*/
ENVIRONMENT: 'environment',
ENVIRONMENT = 'environment',

/**
* The mode which specifies the user-facing camera.
*/
USER: 'user'
};

module.exports = CameraFacingMode;
USER = 'user'
}
17 changes: 1 addition & 16 deletions service/RTC/CodecMimeType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,11 @@ import * as exported from "./CodecMimeType";

describe( "/service/RTC/CodecMimeType members", () => {
const {
default: {
AV1,
H264,
OPUS,
ULPFEC,
VP8,
VP9,
},
CodecMimeType,
...others
} = exported as any; // TODO: remove cast after typescript conversion
} = exported;

it( "known members", () => {
expect( AV1 ).toBe( 'av1' );
expect( H264 ).toBe( 'h264' );
expect( OPUS ).toBe( 'opus' );
expect( ULPFEC ).toBe( 'ulpfec' );
expect( VP8 ).toBe( 'vp8' );
expect( VP9 ).toBe( 'vp9' );

expect( CodecMimeType ).toBeDefined();

expect( CodecMimeType.AV1 ).toBe( 'av1' );
Expand Down
20 changes: 9 additions & 11 deletions service/RTC/CodecMimeType.js → service/RTC/CodecMimeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,39 @@
* Enumeration of the codec mime types
* @type {{AV1: string, H264: string, OPUS: string, RED: string, ULPFEC: string, VP8: string, VP9: string}}
*/
export const CodecMimeType = {
export enum CodecMimeType {
/**
* AV1 codec mime type.
*/
AV1: 'av1',
AV1 = 'av1',

/**
* The h264 codec mime type.
*/
H264: 'h264',
H264 = 'h264',

/**
* The opus codec mime type.
*/
OPUS: 'opus',
OPUS = 'opus',

/**
* The red codec mime type.
*/
RED: 'red',
RED = 'red',

/**
* The ulpfec codec mime type.
*/
ULPFEC: 'ulpfec',
ULPFEC = 'ulpfec',

/**
* The vp8 codec mime type.
*/
VP8: 'vp8',
VP8 = 'vp8',

/**
* The vp9 codec mime type.
*/
VP9: 'vp9'
};

export default CodecMimeType;
VP9 = 'vp9'
}
2 changes: 1 addition & 1 deletion service/RTC/MediaDirection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export enum MediaDirection {
* Media is sent and received.
*/
SENDRECV = 'sendrecv'
};
}
2 changes: 1 addition & 1 deletion service/RTC/RTCEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export enum RTCEvents {
* new remote sources.
*/
AUDIO_SSRCS_REMAPPED = 'rtc.audio_ssrcs_remapped'
};
}

export const CREATE_ANSWER_FAILED = RTCEvents.CREATE_ANSWER_FAILED;
export const CREATE_OFFER_FAILED = RTCEvents.CREATE_OFFER_FAILED;
Expand Down
2 changes: 1 addition & 1 deletion service/RTC/StandardVideoSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ export enum VIDEO_QUALITY_SETTINGS {

// When the camera is turned off.
NONE = 'none'
};
}
18 changes: 8 additions & 10 deletions service/RTC/VideoEncoderScalabilityMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@
* Enumeration of the scalability modes supported by the video encoders.
* For more information, check https://www.w3.org/TR/webrtc-svc/#dependencydiagrams*
*
* const VideoEncoderScalabilityMode: {
* enum VideoEncoderScalabilityMode {
* L1T3: string;
* L2T3: string;
* L2T3_KEY: string;
* L3T3: string;
* L3T3_KEY: string;
* }
*/
export const VideoEncoderScalabilityMode = {
export enum VideoEncoderScalabilityMode {
/**
* L1T3 mode: 1-layer spatial and 3-layer temporal scalabilty encoding.
*/
L1T3: 'L1T3',
L1T3 = 'L1T3',

/**
* L2T2 mode: 2-layer spatial and 3-layer temporal scalability encoding.
*/
L2T3: 'L2T3',
L2T3 = 'L2T3',

/**
* L2T3_KEY mode: 2-layer spatial and 3-layer temporal scalability K-SVC encoding.
*/
L2T3_KEY: 'L2T3_KEY',
L2T3_KEY = 'L2T3_KEY',

/**
* L3T3 mode: -layer spatial and 3-layer temporal scalability encoding.
*/
L3T3: 'L3T3',
L3T3 = 'L3T3',

/**
* L3T3_Key mode: 3-layer spatial and 3-layer temporal scalability K-SVC encoding.
*/
L3T3_KEY: 'L3T3_KEY'
};

export default VideoEncoderScalabilityMode;
L3T3_KEY = 'L3T3_KEY'
}
2 changes: 1 addition & 1 deletion service/RTC/VideoType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export enum VideoType {
* The desktop video type.
*/
DESKTOP = 'desktop'
};
}

0 comments on commit d07cfd4

Please sign in to comment.