|
1 | 1 | import { getLogger } from '@jitsi/logger'; |
2 | | -const logger = getLogger('modules/sdp/SDPUtil'); |
| 2 | +import type { MediaDescription } from 'sdp-transform'; |
3 | 3 |
|
4 | 4 | import { CodecMimeType } from '../../service/RTC/CodecMimeType'; |
5 | 5 | import { MediaDirection } from '../../service/RTC/MediaDirection'; |
6 | 6 | import { SSRC_GROUP_SEMANTICS } from '../../service/RTC/StandardVideoQualitySettings'; |
7 | 7 | import browser from '../browser'; |
8 | 8 | import RandomUtil from '../util/RandomUtil'; |
9 | 9 |
|
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'; |
11 | 11 |
|
| 12 | +const logger = getLogger('modules/sdp/SDPUtil'); |
12 | 13 |
|
13 | 14 | const SDPUtil = { |
14 | 15 | /** |
@@ -326,26 +327,15 @@ const SDPUtil = { |
326 | 327 | return RandomUtil.randomInt(1, 0xffffffff); |
327 | 328 | }, |
328 | 329 |
|
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 | | - |
340 | 330 | /** |
341 | 331 | * Gets the SSRC attribute value from the media line. |
342 | 332 | * |
343 | | - * @param {IMLine} mLine - The media line object. |
| 333 | + * @param {MediaDescription} mLine - The media line object. |
344 | 334 | * @param {number} ssrc - The SSRC value to search for. |
345 | 335 | * @param {string} attributeName - The attribute name to search for. |
346 | 336 | * @returns {string|null} - The attribute value or null if not found. |
347 | 337 | */ |
348 | | - getSsrcAttribute(mLine: IMLine, ssrc: number, attributeName: string): Nullable<string> { |
| 338 | + getSsrcAttribute(mLine: MediaDescription, ssrc: number, attributeName: string): Nullable<string> { |
349 | 339 | for (let i = 0; i < mLine.ssrcs.length; ++i) { |
350 | 340 | const ssrcLine = mLine.ssrcs[i]; |
351 | 341 |
|
@@ -493,10 +483,10 @@ const SDPUtil = { |
493 | 483 | /** |
494 | 484 | * Parses the SSRCs from a group description. |
495 | 485 | * |
496 | | - * @param {ISsrcGroups} ssrcGroup - The SSRC group object. |
| 486 | + * @param {MediaDescription['ssrcGroups'][number]} ssrcGroup - The SSRC group object. |
497 | 487 | * @returns {number[]} - The list of SSRCs in the group. |
498 | 488 | */ |
499 | | - parseGroupSsrcs(ssrcGroup: ISsrcGroups): number[] { |
| 489 | + parseGroupSsrcs(ssrcGroup: MediaDescription['ssrcGroups'][number]): number[] { |
500 | 490 | return ssrcGroup |
501 | 491 | .ssrcs |
502 | 492 | .split(' ') |
@@ -623,10 +613,10 @@ const SDPUtil = { |
623 | 613 |
|
624 | 614 | /** |
625 | 615 | * 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 |
627 | 617 | * @return {Optional<number>} the primary video ssrc from the given m line |
628 | 618 | */ |
629 | | - parsePrimaryVideoSsrc(videoMLine: IMLine): Optional<number> { |
| 619 | + parsePrimaryVideoSsrc(videoMLine: MediaDescription): Optional<number> { |
630 | 620 | const numSsrcs = (videoMLine.ssrcs) |
631 | 621 | .map(ssrcInfo => ssrcInfo.id) |
632 | 622 | .filter((ssrc, index, array) => array.indexOf(ssrc) === index) |
@@ -804,11 +794,11 @@ const SDPUtil = { |
804 | 794 | * Sets the given codecName as the preferred codec by moving it to the beginning |
805 | 795 | * of the payload types list (modifies the given mline in place). All instances |
806 | 796 | * 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. |
808 | 798 | * @param {string} codecName the name of the preferred codec. |
809 | 799 | * @param {boolean} sortPayloadTypes whether the payloadtypes need to be sorted for a given codec. |
810 | 800 | */ |
811 | | - preferCodec(mline: IMLine, codecName: string, sortPayloadTypes: boolean = false): void { |
| 801 | + preferCodec(mline: MediaDescription, codecName: string, sortPayloadTypes: boolean = false): void { |
812 | 802 | if (!mline || !codecName) { |
813 | 803 | return; |
814 | 804 | } |
@@ -865,12 +855,12 @@ const SDPUtil = { |
865 | 855 | * types are also stripped. If the resulting mline would have no codecs, |
866 | 856 | * it's disabled. |
867 | 857 | * |
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. |
869 | 859 | * @param {string} codecName the name of the codec which will be stripped. |
870 | 860 | * @param {boolean} highProfile determines if only the high profile codec needs to be stripped from the sdp for a |
871 | 861 | * given codec type. |
872 | 862 | */ |
873 | | - stripCodec(mLine: IMLine, codecName: string, highProfile: boolean = false): void { |
| 863 | + stripCodec(mLine: MediaDescription, codecName: string, highProfile: boolean = false): void { |
874 | 864 | if (!mLine || !codecName) { |
875 | 865 | return; |
876 | 866 | } |
@@ -937,7 +927,7 @@ const SDPUtil = { |
937 | 927 | item => keepPts.indexOf(item.payload) !== -1); |
938 | 928 | if (mLine.rtcpFb) { |
939 | 929 | mLine.rtcpFb = mLine.rtcpFb.filter( |
940 | | - item => keepPts.indexOf(item.payload) !== -1); |
| 930 | + item => keepPts.indexOf(Number(item.payload)) !== -1); |
941 | 931 | } |
942 | 932 | } |
943 | 933 | } |
|
0 commit comments