webrtc: implement default clocks for assigned payload types

This commit is contained in:
Koushik Dutta
2025-04-15 07:53:28 -07:00
parent d1bfed3019
commit 1cb6212fc6
3 changed files with 14 additions and 4 deletions

View File

@@ -242,12 +242,22 @@ export function parseRtpMap(mline: ReturnType<typeof parseMLine>, rtpmap: string
}
}
// assigned payload types do not need to provide a clock, there is a default.
let clock = parseInt(match?.[3]);
if (!clock) {
clock = undefined;
if (codec === 'pcm_mulaw' || codec === 'pcm_alaw')
clock = 8000;
else if (codec === 'pcm_s16be')
clock = 16000;
}
return {
line: rtpmap,
codec,
ffmpegEncoder,
rawCodec: match?.[2],
clock: parseInt(match?.[3]),
clock,
channels: parseInt(match?.[5]) || undefined,
payloadType: parseInt(match?.[1]),
}