mirror of
https://github.com/koush/scrypted.git
synced 2026-02-12 01:54:27 +00:00
common: sdp parsing should handle default audio type
This commit is contained in:
@@ -9,7 +9,6 @@ import tls from 'tls';
|
||||
import { BASIC, DIGEST } from 'http-auth-utils/dist/index';
|
||||
import crypto from 'crypto';
|
||||
import { timeoutPromise } from './promise-utils';
|
||||
import { sleep } from './sleep';
|
||||
|
||||
export const RTSP_FRAME_MAGIC = 36;
|
||||
|
||||
@@ -617,7 +616,7 @@ export class RtspServer {
|
||||
control: msection.control,
|
||||
protocol: 'udp',
|
||||
destination: parseInt(rtp),
|
||||
codec: msection.codec || (msection.type === 'audio' ? 'pcm' : undefined),
|
||||
codec: msection.codec,
|
||||
}
|
||||
}
|
||||
else if (transport.includes('TCP')) {
|
||||
@@ -629,7 +628,7 @@ export class RtspServer {
|
||||
control: msection.control,
|
||||
protocol: 'tcp',
|
||||
destination: low,
|
||||
codec: msection.codec || (msection.type === 'audio' ? 'pcm' : undefined),
|
||||
codec: msection.codec,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,7 @@ const artpmap = 'a=rtpmap:';
|
||||
export function parseMSection(msection: string[]) {
|
||||
const control = msection.find(line => line.startsWith(acontrol))?.substring(acontrol.length);
|
||||
const rtpmap = msection.find(line => line.startsWith(artpmap))?.toLowerCase();
|
||||
const mline = parseMLine(msection[0]);
|
||||
|
||||
let codec: string;
|
||||
if (rtpmap?.includes('mpeg4')) {
|
||||
@@ -171,6 +172,12 @@ export function parseMSection(msection: string[]) {
|
||||
else if (rtpmap?.includes('opus')) {
|
||||
codec = 'opus';
|
||||
}
|
||||
else if (rtpmap?.includes('pcma')) {
|
||||
codec = 'pcm_alaw';
|
||||
}
|
||||
else if (rtpmap?.includes('pcmu')) {
|
||||
codec = 'pcm_ulaw';
|
||||
}
|
||||
else if (rtpmap?.includes('pcm')) {
|
||||
codec = 'pcm';
|
||||
}
|
||||
@@ -180,8 +187,13 @@ export function parseMSection(msection: string[]) {
|
||||
else if (rtpmap?.includes('h265')) {
|
||||
codec = 'h265';
|
||||
}
|
||||
else if (!rtpmap && mline.type === 'audio') {
|
||||
// ffmpeg seems to omit the rtpmap type for pcm alaw when creating sdp?
|
||||
// is this the default?
|
||||
codec = 'pcm_alaw';
|
||||
}
|
||||
|
||||
let direction: string;
|
||||
let direction: string;
|
||||
for (const checkDirection of ['sendonly', 'sendrecv', 'recvonly', 'inactive']) {
|
||||
const found = msection.find(line => line === 'a=' + checkDirection);
|
||||
if (found) {
|
||||
@@ -191,7 +203,7 @@ export function parseMSection(msection: string[]) {
|
||||
}
|
||||
|
||||
return {
|
||||
...parseMLine(msection[0]),
|
||||
...mline,
|
||||
fmtp: parseFmtp(msection),
|
||||
lines: msection,
|
||||
contents: msection.join('\r\n'),
|
||||
|
||||
Reference in New Issue
Block a user