From 98e943c8b8d2bd753fefd129c8f972f65357d2ef Mon Sep 17 00:00:00 2001 From: marian Date: Mon, 19 Apr 2021 10:02:58 +0000 Subject: [PATCH] Added SDP support for stereo slin/alaw/mulaw. git-svn-id: http://voip.null.ro/svn/yate@6483 acf43c95-373e-0410-b603-e72c3f656dc1 --- conf.d/mgcpca.conf.sample | 12 ++++++++++++ conf.d/mgcpgw.conf.sample | 12 ++++++++++++ conf.d/ysipchan.conf.sample | 12 ++++++++++++ libs/ysdp/parser.cpp | 12 +++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/conf.d/mgcpca.conf.sample b/conf.d/mgcpca.conf.sample index 89532831..c365db67 100644 --- a/conf.d/mgcpca.conf.sample +++ b/conf.d/mgcpca.conf.sample @@ -66,6 +66,9 @@ ; default: bool: Enable all unlisted codecs by default if a transcoder exists ;default=enable +; default_stereo: bool: Enable all unlisted stereo audio codecs by default if a transcoder exists +;default_stereo=no + ; mulaw: bool: Companded-only G711 mu-law (PCMU/8000) ;mulaw=default @@ -107,6 +110,15 @@ ; NOTE: RFC 4867 (and older 3267) specifies the default is bandwidth efficient ;amr_octet=no +; 2*mulaw: bool: Stereo Companded-only G711 mu-law (PCMU/8000) +;2*mulaw=default_stereo + +; 2*alaw: bool: Stereo Companded-only G711 a-law (PCMU/8000) +;2*alaw=default_stereo + +; 2*slin: bool: Stereo Signed Linear 16-bit uncompressed (L16/8000) +;2*slin=default_stereo + [hacks] ; This section holds the dirty stuff required to work with some broken diff --git a/conf.d/mgcpgw.conf.sample b/conf.d/mgcpgw.conf.sample index 2cdfe235..19a7d0e5 100644 --- a/conf.d/mgcpgw.conf.sample +++ b/conf.d/mgcpgw.conf.sample @@ -47,6 +47,9 @@ ; default: bool: Enable all unlisted codecs by default if a transcoder exists ;default=enable +; default_stereo: bool: Enable all unlisted stereo audio codecs by default if a transcoder exists +;default_stereo=no + ; mulaw: bool: Companded-only G711 mu-law (PCMU/8000) ;mulaw=default @@ -88,6 +91,15 @@ ; NOTE: RFC 4867 (and older 3267) specifies the default is bandwidth efficient ;amr_octet=no +; 2*mulaw: bool: Stereo Companded-only G711 mu-law (PCMU/8000) +;2*mulaw=default_stereo + +; 2*alaw: bool: Stereo Companded-only G711 a-law (PCMU/8000) +;2*alaw=default_stereo + +; 2*slin: bool: Stereo Signed Linear 16-bit uncompressed (L16/8000) +;2*slin=default_stereo + [hacks] ; This section holds the dirty stuff required to work with some broken diff --git a/conf.d/ysipchan.conf.sample b/conf.d/ysipchan.conf.sample index 1812e489..5f2a5883 100644 --- a/conf.d/ysipchan.conf.sample +++ b/conf.d/ysipchan.conf.sample @@ -429,6 +429,9 @@ ; default: bool: Enable all unlisted codecs by default if a transcoder exists ;default=enable +; default_stereo: bool: Enable all unlisted stereo audio codecs by default if a transcoder exists +;default_stereo=no + ; mulaw: bool: Companded-only G711 mu-law (PCMU/8000) ;mulaw=default @@ -473,6 +476,15 @@ ; NOTE: RFC 4867 (and older 3267) specifies the default is bandwidth efficient ;amr_octet=no +; 2*mulaw: bool: Stereo Companded-only G711 mu-law (PCMU/8000) +;2*mulaw=default_stereo + +; 2*alaw: bool: Stereo Companded-only G711 a-law (PCMU/8000) +;2*alaw=default_stereo + +; 2*slin: bool: Stereo Signed Linear 16-bit uncompressed (L16/8000) +;2*slin=default_stereo + [methods] ; Use this section to allow server processing of various SIP methods by diff --git a/libs/ysdp/parser.cpp b/libs/ysdp/parser.cpp index e7529375..1b2e646a 100644 --- a/libs/ysdp/parser.cpp +++ b/libs/ysdp/parser.cpp @@ -32,6 +32,7 @@ const TokenDict SDPParser::s_payloads[] = { { "alaw", 8 }, { "gsm", 3 }, { "lpc10", 7 }, + { "2*slin", 10 }, { "slin", 11 }, { "g726", 2 }, { "g722/16000", 9 }, @@ -64,6 +65,9 @@ const TokenDict SDPParser::s_payloads[] = { { "mpv", 32 }, { "mp2t", 33 }, { "mp4v", 110 }, + // Stereo + { "2*mulaw", 117 }, + { "2*alaw", 118 }, { 0, 0 }, }; @@ -73,6 +77,7 @@ const TokenDict SDPParser::s_rtpmap[] = { { "PCMA/8000", 8 }, { "GSM/8000", 3 }, { "LPC/8000", 7 }, + { "L16/8000/2", 10 }, { "L16/8000", 11 }, { "G726-32/8000", 2 }, { "G722/8000", 9 }, @@ -101,6 +106,9 @@ const TokenDict SDPParser::s_rtpmap[] = { { "MPV/90000", 32 }, { "MP2T/90000", 33 }, { "MP4V-ES/90000", 110 }, + // Stereo, dynamic payloads + { "PCMU/8000/2", 117 }, + { "PCMA/8000/2", 118 }, { 0, 0 }, }; @@ -469,13 +477,15 @@ void SDPParser::initialize(const NamedList* codecs, const NamedList* hacks, cons if (hacks) m_hacks.copyParams(*hacks); bool defcodecs = m_codecs.getBoolValue("default",true); + bool stereo = m_codecs.getBoolValue("default_stereo"); m_audioFormats = ""; String audio = "audio"; for (const TokenDict* dict = s_payloads; dict->token; dict++) { DataFormat fmt(dict->token); const FormatInfo* info = fmt.getInfo(); if (info && (audio == info->type)) { - if (m_codecs.getBoolValue(fmt,defcodecs && DataTranslator::canConvert(fmt))) + bool defVal = (2 != info->numChannels) ? defcodecs : stereo; + if (m_codecs.getBoolValue(fmt,defVal && DataTranslator::canConvert(fmt))) m_audioFormats.append(fmt,","); } }