- fixes to parse EVS payload types with CMR & ToC
This commit is contained in:
parent
ed12569ad6
commit
328ae8d5b5
|
|
@ -32,7 +32,10 @@ CodecList::Settings::EvsSpec CodecList::Settings::EvsSpec::parse(const std::stri
|
||||||
auto parts = strx::split(spec, "-/");
|
auto parts = strx::split(spec, "-/");
|
||||||
if (parts.size() == 3)
|
if (parts.size() == 3)
|
||||||
{
|
{
|
||||||
|
// Payload type number
|
||||||
result.mPayloadType = strx::toInt(strx::trim(parts.front()).c_str(), -1);
|
result.mPayloadType = strx::toInt(strx::trim(parts.front()).c_str(), -1);
|
||||||
|
|
||||||
|
// Encoding
|
||||||
std::string& encoding_type = parts[1];
|
std::string& encoding_type = parts[1];
|
||||||
if (encoding_type == "mime")
|
if (encoding_type == "mime")
|
||||||
result.mEncodingType = Encoding_MIME;
|
result.mEncodingType = Encoding_MIME;
|
||||||
|
|
@ -42,6 +45,7 @@ CodecList::Settings::EvsSpec CodecList::Settings::EvsSpec::parse(const std::stri
|
||||||
else
|
else
|
||||||
throw std::logic_error("Bad EVS codec encoding type");
|
throw std::logic_error("Bad EVS codec encoding type");
|
||||||
|
|
||||||
|
// Bandwidth
|
||||||
std::string& bandwidth = parts.back();
|
std::string& bandwidth = parts.back();
|
||||||
if (bandwidth == "nb" || bandwidth == "NB")
|
if (bandwidth == "nb" || bandwidth == "NB")
|
||||||
result.mBandwidth = Bandwidth_NB;
|
result.mBandwidth = Bandwidth_NB;
|
||||||
|
|
|
||||||
|
|
@ -202,17 +202,35 @@ int EVSCodec::decode(const void* input, int input_length, void* output, int outp
|
||||||
|
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
|
|
||||||
/*if we have FixedPayload without ToC*/
|
// Check if we get payload with CMR
|
||||||
if (FixedPayload_EVSPrimary.find(input_length * 8) != FixedPayload_EVSPrimary.end())
|
auto payload_iter = FixedPayload_EVSPrimary.find((input_length - 2) * 8);
|
||||||
|
if (payload_iter == FixedPayload_EVSPrimary.end())
|
||||||
{
|
{
|
||||||
char c = evs::rate2EVSmode(FixedPayload_EVSPrimary.find(input_length * 8)->second);
|
// Check if we get payload with ToC and without CMR
|
||||||
|
payload_iter = FixedPayload_EVSPrimary.find((input_length - 1) * 8);
|
||||||
|
if (payload_iter == FixedPayload_EVSPrimary.end())
|
||||||
|
{
|
||||||
|
// Maybe there is no ToC ?
|
||||||
|
payload_iter = FixedPayload_EVSPrimary.find(input_length * 8);
|
||||||
|
if (payload_iter == FixedPayload_EVSPrimary.end())
|
||||||
|
{
|
||||||
|
// Bad payload size at all
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* Add ToC byte.
|
/* Add ToC byte.
|
||||||
* WARNING maybe it will be work incorrect with 56bit payload,
|
* WARNING maybe it will be work incorrect with 56bit payload,
|
||||||
* see 3GPP TS 26.445 Annex A, A.2.1.3 */
|
* see 3GPP TS 26.445 Annex A, A.2.1.3 */
|
||||||
|
char c = evs::rate2EVSmode(FixedPayload_EVSPrimary.find(input_length * 8)->second);
|
||||||
buffer += c;
|
buffer += c;
|
||||||
}
|
|
||||||
|
|
||||||
buffer += std::string(reinterpret_cast<const char*>(input), input_length);
|
buffer += std::string(reinterpret_cast<const char*>(input), input_length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
buffer = std::string(reinterpret_cast<const char*>(input), input_length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// Skip CMR byte
|
||||||
|
buffer = std::string(reinterpret_cast<const char*>(input) + 1, input_length);
|
||||||
|
|
||||||
|
|
||||||
// Output buffer for 48 KHz
|
// Output buffer for 48 KHz
|
||||||
float data[L_FRAME48k];
|
float data[L_FRAME48k];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue