AudioCodingModule: Specify decoders using SdpAudioFormat
NetEq already uses SdpAudioFormat internally; this CL adds an AudioCodingModule::RegisterReceiveCodec overload that accepts SdpAudioFormat, and propagates it through AcmReceiver into NetEq. The intention is to get rid of the other ways to specify decoders and always use SdpAudioFormat. (And eventually to do the same for encoders too.) NOTRY=true BUG=5801 Review-Url: https://codereview.webrtc.org/2365653004 Cr-Commit-Position: refs/heads/master@{#14506}
This commit is contained in:
@ -85,7 +85,12 @@ bool DecoderDatabase::DecoderInfo::IsType(const std::string& name) const {
|
||||
rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>
|
||||
DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) {
|
||||
if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) {
|
||||
return rtc::Optional<CngDecoder>({format.clockrate_hz});
|
||||
// CN has a 1:1 RTP clock rate to sample rate ratio.
|
||||
const int sample_rate_hz = format.clockrate_hz;
|
||||
RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
|
||||
sample_rate_hz == 32000 || sample_rate_hz == 48000);
|
||||
return rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>(
|
||||
{sample_rate_hz});
|
||||
} else {
|
||||
return rtc::Optional<CngDecoder>();
|
||||
}
|
||||
@ -141,6 +146,20 @@ int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type,
|
||||
return kOK;
|
||||
}
|
||||
|
||||
int DecoderDatabase::RegisterPayload(int rtp_payload_type,
|
||||
const SdpAudioFormat& audio_format) {
|
||||
if (rtp_payload_type < 0 || rtp_payload_type > 0x7f) {
|
||||
return kInvalidRtpPayloadType;
|
||||
}
|
||||
const auto ret = decoders_.insert(std::make_pair(
|
||||
rtp_payload_type, DecoderInfo(audio_format, decoder_factory_.get())));
|
||||
if (ret.second == false) {
|
||||
// Database already contains a decoder with type |rtp_payload_type|.
|
||||
return kDecoderExists;
|
||||
}
|
||||
return kOK;
|
||||
}
|
||||
|
||||
int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type,
|
||||
NetEqDecoder codec_type,
|
||||
const std::string& codec_name,
|
||||
|
||||
Reference in New Issue
Block a user