Skip to content

Commit 819cdfb

Browse files
authored
fix(SDP) Remove redundant types. (#2917)
1 parent 46c8622 commit 819cdfb

File tree

10 files changed

+69
-124
lines changed

10 files changed

+69
-124
lines changed

modules/RTC/SourceInfo.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

modules/RTC/TPCUtils.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getLogger } from '@jitsi/logger';
22
import { cloneDeep } from 'lodash-es';
3-
import transform from 'sdp-transform';
3+
import transform, { type SessionDescription } from 'sdp-transform';
44

55
import { CodecMimeType } from '../../service/RTC/CodecMimeType';
66
import { MediaDirection } from '../../service/RTC/MediaDirection';
@@ -179,11 +179,11 @@ export class TPCUtils {
179179
/**
180180
* Returns the codecs in the current order of preference in the SDP provided.
181181
*
182-
* @param {transform.SessionDescription} parsedSdp the parsed SDP object.
182+
* @param {SessionDescription} parsedSdp the parsed SDP object.
183183
* @returns {Array<CodecMimeType>}
184184
* @private
185185
*/
186-
private _getConfiguredVideoCodecsImpl(parsedSdp: transform.SessionDescription): CodecMimeType[] {
186+
private _getConfiguredVideoCodecsImpl(parsedSdp: SessionDescription): CodecMimeType[] {
187187
const mLine = parsedSdp.media.find(m => m.type === MediaType.VIDEO);
188188
const codecs = new Set(mLine.rtp
189189
.filter(pt => pt.codec.toLowerCase() !== 'rtx')
@@ -775,11 +775,11 @@ export class TPCUtils {
775775
/**
776776
* Munges the session description to ensure that the codec order is as per the preferred codec settings.
777777
*
778-
* @param {transform.SessionDescription} parsedSdp that needs to be munged
779-
* @returns {transform.SessionDescription} the munged SDP.
778+
* @param {SessionDescription} parsedSdp that needs to be munged
779+
* @returns {SessionDescription} the munged SDP.
780780
* @internal
781781
*/
782-
mungeCodecOrder(parsedSdp: transform.SessionDescription): transform.SessionDescription {
782+
mungeCodecOrder(parsedSdp: SessionDescription): SessionDescription {
783783
const codecSettings = this.pc.codecSettings;
784784

785785
if (!codecSettings) {
@@ -827,11 +827,11 @@ export class TPCUtils {
827827
* Munges the stereo flag as well as the opusMaxAverageBitrate in the SDP, based on values set through config.js,
828828
* if present.
829829
*
830-
* @param {transform.SessionDescription} parsedSdp that needs to be munged.
831-
* @returns {transform.SessionDescription} the munged SDP.
830+
* @param {SessionDescription} parsedSdp that needs to be munged.
831+
* @returns {SessionDescription} the munged SDP.
832832
* @internal
833833
*/
834-
mungeOpus(parsedSdp: transform.SessionDescription): transform.SessionDescription {
834+
mungeOpus(parsedSdp: SessionDescription): SessionDescription {
835835
const { audioQuality } = this.options;
836836

837837
if (!audioQuality?.enableOpusDtx && !audioQuality?.stereo && !audioQuality?.opusMaxAverageBitrate) {
@@ -897,12 +897,12 @@ export class TPCUtils {
897897
/**
898898
* Munges the session SDP by setting the max bitrates on the video m-lines when VP9 K-SVC codec is in use.
899899
*
900-
* @param {transform.SessionDescription} parsedSdp that needs to be munged.
900+
* @param {SessionDescription} parsedSdp that needs to be munged.
901901
* @param {boolean} isLocalSdp - Whether the max bitrate (via b=AS line in SDP) is set on local SDP.
902-
* @returns {transform.SessionDescription} The munged SDP.
902+
* @returns {SessionDescription} The munged SDP.
903903
* @internal
904904
*/
905-
setMaxBitrates(parsedSdp: transform.SessionDescription, isLocalSdp = false): transform.SessionDescription {
905+
setMaxBitrates(parsedSdp: SessionDescription, isLocalSdp = false): SessionDescription {
906906
const pcCodecSettings = this.pc.codecSettings;
907907

908908
if (!pcCodecSettings) {

modules/RTC/TraceablePeerConnection.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ import JitsiRemoteTrack from './JitsiRemoteTrack';
3030
import RTC from './RTC';
3131
import RTCUtils from './RTCUtils';
3232
import { SS_DEFAULT_FRAME_RATE } from './ScreenObtainer';
33-
import { ITPCSourceInfo } from './SourceInfo';
3433
import { ICodecConfig, TPCUtils } from './TPCUtils';
3534

36-
3735
const logger = getLogger('modules/RTC/TraceablePeerConnection');
3836
const DEGRADATION_PREFERENCE_CAMERA = 'maintain-framerate';
3937
const DEGRADATION_PREFERENCE_DESKTOP = 'maintain-resolution';
@@ -84,6 +82,13 @@ export interface ITPCOptions {
8482
videoQuality: IVideoQuality;
8583
}
8684

85+
interface ITPCSourceInfo {
86+
groups: ISsrcGroupInfo;
87+
mediaType?: MediaType;
88+
msid: string;
89+
ssrcList?: Array<string>;
90+
videoType?: VideoType;
91+
}
8792
export interface IAudioQuality {
8893
enableOpusDtx?: boolean;
8994
opusMaxAverageBitrate?: number;
@@ -1313,7 +1318,7 @@ export default class TraceablePeerConnection {
13131318
const ssrcGroup = this.isSpatialScalabilityOn() ? SSRC_GROUP_SEMANTICS.SIM : SSRC_GROUP_SEMANTICS.FID;
13141319

13151320
return this.localSSRCs.get(localTrack.rtcId)
1316-
?.groups?.find(group => group.semantics === ssrcGroup)?.ssrcs || ssrcs;
1321+
?.groups?.find(group => group.semantics === ssrcGroup)?.ssrcs || ssrcs;
13171322
}
13181323

13191324
/**
@@ -1777,7 +1782,7 @@ export default class TraceablePeerConnection {
17771782

17781783
if (ssrcGroups?.length) {
17791784
for (const group of ssrcGroups) {
1780-
const parsedGroup: ISsrcGroupInfo = {
1785+
const parsedGroup = {
17811786
semantics: group.semantics,
17821787
ssrcs: group.ssrcs.split(' ').map(ssrcStr => parseInt(ssrcStr, 10))
17831788
};

modules/sdp/RtxModifier.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* eslint-disable max-len*/
21
import * as transform from 'sdp-transform';
32

43
import RtxModifier from './RtxModifier.js';
5-
import SDPUtil from './SDPUtil.js';
4+
import SDPUtil from './SDPUtil';
65
import { default as SampleSdpStrings } from './SampleSdpStrings';
76

87
/**

modules/sdp/SDPUtil.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { getLogger } from '@jitsi/logger';
2-
const logger = getLogger('modules/sdp/SDPUtil');
2+
import type { MediaDescription } from 'sdp-transform';
33

44
import { CodecMimeType } from '../../service/RTC/CodecMimeType';
55
import { MediaDirection } from '../../service/RTC/MediaDirection';
66
import { SSRC_GROUP_SEMANTICS } from '../../service/RTC/StandardVideoQualitySettings';
77
import browser from '../browser';
88
import RandomUtil from '../util/RandomUtil';
99

10-
import { ICryptoData, IExtmapData, IFingerprintData, IFmtpParameter, IICECandidate, IICEParams, IMLine, IMediaDescription, IMediaLine, IRTCPFBData, IRTPMapData, ISDPObject, ISSRCGroupData, ISsrcGroups } from './constants';
10+
import { ICryptoData, IExtmapData, IFingerprintData, IFmtpParameter, IICECandidate, IICEParams, IMediaLine, IRTCPFBData, IRTPMapData, ISSRCGroupData } from './constants';
1111

12+
const logger = getLogger('modules/sdp/SDPUtil');
1213

1314
const SDPUtil = {
1415
/**
@@ -326,26 +327,15 @@ const SDPUtil = {
326327
return RandomUtil.randomInt(1, 0xffffffff);
327328
},
328329

329-
/**
330-
* Gets the media description for a specific media type from the SDP.
331-
*
332-
* @param {ISDPObject} sdp - The SDP object.
333-
* @param {string} type - The media type to search for (e.g., "audio", "video").
334-
* @returns {Nullable<IMediaDescription>} - The media description object or null if not found.
335-
*/
336-
getMedia(sdp: ISDPObject, type: string): Nullable<IMediaDescription> {
337-
return sdp.media.find(m => m.type === type);
338-
},
339-
340330
/**
341331
* Gets the SSRC attribute value from the media line.
342332
*
343-
* @param {IMLine} mLine - The media line object.
333+
* @param {MediaDescription} mLine - The media line object.
344334
* @param {number} ssrc - The SSRC value to search for.
345335
* @param {string} attributeName - The attribute name to search for.
346336
* @returns {string|null} - The attribute value or null if not found.
347337
*/
348-
getSsrcAttribute(mLine: IMLine, ssrc: number, attributeName: string): Nullable<string> {
338+
getSsrcAttribute(mLine: MediaDescription, ssrc: number, attributeName: string): Nullable<string> {
349339
for (let i = 0; i < mLine.ssrcs.length; ++i) {
350340
const ssrcLine = mLine.ssrcs[i];
351341

@@ -493,10 +483,10 @@ const SDPUtil = {
493483
/**
494484
* Parses the SSRCs from a group description.
495485
*
496-
* @param {ISsrcGroups} ssrcGroup - The SSRC group object.
486+
* @param {MediaDescription['ssrcGroups'][number]} ssrcGroup - The SSRC group object.
497487
* @returns {number[]} - The list of SSRCs in the group.
498488
*/
499-
parseGroupSsrcs(ssrcGroup: ISsrcGroups): number[] {
489+
parseGroupSsrcs(ssrcGroup: MediaDescription['ssrcGroups'][number]): number[] {
500490
return ssrcGroup
501491
.ssrcs
502492
.split(' ')
@@ -623,10 +613,10 @@ const SDPUtil = {
623613

624614
/**
625615
* Parse the 'most' primary video ssrc from the given m line
626-
* @param {IMLine} videoMLine object as parsed from transform.parse
616+
* @param {MediaDescription} videoMLine object as parsed from transform.parse
627617
* @return {Optional<number>} the primary video ssrc from the given m line
628618
*/
629-
parsePrimaryVideoSsrc(videoMLine: IMLine): Optional<number> {
619+
parsePrimaryVideoSsrc(videoMLine: MediaDescription): Optional<number> {
630620
const numSsrcs = (videoMLine.ssrcs)
631621
.map(ssrcInfo => ssrcInfo.id)
632622
.filter((ssrc, index, array) => array.indexOf(ssrc) === index)
@@ -804,11 +794,11 @@ const SDPUtil = {
804794
* Sets the given codecName as the preferred codec by moving it to the beginning
805795
* of the payload types list (modifies the given mline in place). All instances
806796
* of the codec are moved up.
807-
* @param {IMLine} mLine the mline object from an sdp as parsed by transform.parse.
797+
* @param {MediaDescription} mLine the mline object from an sdp as parsed by transform.parse.
808798
* @param {string} codecName the name of the preferred codec.
809799
* @param {boolean} sortPayloadTypes whether the payloadtypes need to be sorted for a given codec.
810800
*/
811-
preferCodec(mline: IMLine, codecName: string, sortPayloadTypes: boolean = false): void {
801+
preferCodec(mline: MediaDescription, codecName: string, sortPayloadTypes: boolean = false): void {
812802
if (!mline || !codecName) {
813803
return;
814804
}
@@ -865,12 +855,12 @@ const SDPUtil = {
865855
* types are also stripped. If the resulting mline would have no codecs,
866856
* it's disabled.
867857
*
868-
* @param {IMLine} mLine the mline object from an sdp as parsed by transform.parse.
858+
* @param {MediaDescription} mLine the mline object from an sdp as parsed by transform.parse.
869859
* @param {string} codecName the name of the codec which will be stripped.
870860
* @param {boolean} highProfile determines if only the high profile codec needs to be stripped from the sdp for a
871861
* given codec type.
872862
*/
873-
stripCodec(mLine: IMLine, codecName: string, highProfile: boolean = false): void {
863+
stripCodec(mLine: MediaDescription, codecName: string, highProfile: boolean = false): void {
874864
if (!mLine || !codecName) {
875865
return;
876866
}
@@ -937,7 +927,7 @@ const SDPUtil = {
937927
item => keepPts.indexOf(item.payload) !== -1);
938928
if (mLine.rtcpFb) {
939929
mLine.rtcpFb = mLine.rtcpFb.filter(
940-
item => keepPts.indexOf(item.payload) !== -1);
930+
item => keepPts.indexOf(Number(item.payload)) !== -1);
941931
}
942932
}
943933
}

0 commit comments

Comments
 (0)