rebroadcast/webrtc: fixup pcm_ulaw handling

This commit is contained in:
Koushik Dutta
2023-05-03 14:11:17 -07:00
parent 957d27b8ef
commit 9ed850e327
8 changed files with 29 additions and 12 deletions

View File

@@ -269,7 +269,11 @@ export async function startParserSession<T extends string>(ffmpegInput: FFmpegIn
};
// tbh parsing stdout is super sketchy way of doing this.
parseAudioCodec(cp).then(result => inputAudioCodec = result);
parseAudioCodec(cp).then(result => {
inputAudioCodec = result;
if (inputAudioCodec === 'pcm_mulaw')
inputAudioCodec = 'pcm_ulaw';
});
parseResolution(cp).then(result => inputVideoResolution = result);
await parseVideoCodec(cp).then(result => inputVideoCodec = result);

View File

@@ -217,13 +217,26 @@ const acontrol = 'a=control:';
const artpmap = 'a=rtpmap:';
export function parseMSection(msection: string[]) {
const control = msection.find(line => line.startsWith(acontrol))?.substring(acontrol.length);
const rtpmapFirst = msection.find(line => line.startsWith(artpmap));
const mline = parseMLine(msection[0]);
let codec = parseRtpMap(mline.type, rtpmapFirst).codec;
const rtpmaps = msection.filter(line => line.startsWith(artpmap)).map(line => parseRtpMap(mline.type, line));
let codec: string;
const [rtpmapFirst] = rtpmaps;
if (rtpmapFirst) {
codec = rtpmapFirst.codec;
}
else {
// just guess
const [firstPayloadType ] = mline.payloadTypes;
if (firstPayloadType === 0)
codec = 'pcm_ulaw';
else if (firstPayloadType === 8)
codec = 'pcm_alaw';
else
codec = 'pcm_alaw';
}
let direction: string;
for (const checkDirection of ['sendonly', 'sendrecv', 'recvonly', 'inactive']) {
const found = msection.find(line => line === 'a=' + checkDirection);

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.9.84",
"version": "0.9.85",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/prebuffer-mixin",
"version": "0.9.84",
"version": "0.9.85",
"license": "Apache-2.0",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.9.84",
"version": "0.9.85",
"description": "Video Stream Rebroadcast, Prebuffer, and Management Plugin for Scrypted.",
"author": "Scrypted",
"license": "Apache-2.0",

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/webrtc",
"version": "0.1.44",
"version": "0.1.45",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/webrtc",
"version": "0.1.44",
"version": "0.1.45",
"dependencies": {
"@scrypted/common": "file:../../common",
"@scrypted/sdk": "file:../../sdk",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/webrtc",
"version": "0.1.44",
"version": "0.1.45",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",
"prescrypted-setup-project": "scrypted-package-json",

View File

@@ -109,7 +109,7 @@ export async function createTrackForwarder(options: {
if (!maximumCompatibilityMode) {
let found: RTCRtpCodecParameters;
if (mediaStreamOptions?.audio?.codec === 'pcm_mulaw') {
if (mediaStreamOptions?.audio?.codec === 'pcm_ulaw') {
found = audioTransceiver.codecs.find(codec => codec.mimeType === 'audio/PCMU')
}
else if (mediaStreamOptions?.audio?.codec === 'pcm_alaw') {

View File

@@ -50,7 +50,7 @@ export function getAudioCodec(outputCodecParameters: RTCRtpCodecParameters) {
}
if (outputCodecParameters.name === 'PCMU') {
return {
name: 'pcm_mulaw',
name: 'pcm_ulaw',
encoder: 'pcm_mulaw',
};
}