Revert of AcmReceiver::DecoderByPayloadType: Ask NetEq for decoder (patchset #1 id:1 of https://codereview.webrtc.org/2341283002/ )

Reason for revert:
Seems to have broken Chromium tests.

Original issue's description:
> AcmReceiver::DecoderByPayloadType: Ask NetEq for decoder
>
> Instead of looking in AcmReceiver::decoders_, which we're trying to
> get rid of.
>
> BUG=webrtc:5801
>
> Committed: https://crrev.com/07772e4738ef8007280f97a0245eef34b9ca9391
> Cr-Commit-Position: refs/heads/master@{#14276}

TBR=ossu@webrtc.org,henrik.lundin@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5801

Review-Url: https://codereview.webrtc.org/2346173002
Cr-Commit-Position: refs/heads/master@{#14277}
This commit is contained in:
kwiberg
2016-09-18 05:32:10 -07:00
committed by Commit bot
parent 07772e4738
commit f62b82e95f
2 changed files with 18 additions and 15 deletions

View File

@ -314,15 +314,19 @@ void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) {
int AcmReceiver::DecoderByPayloadType(uint8_t payload_type,
CodecInst* codec) const {
rtc::CritScope lock(&crit_sect_);
const rtc::Optional<CodecInst> ci = neteq_->GetDecoder(payload_type);
if (ci) {
*codec = *ci;
return 0;
} else {
auto it = decoders_.find(payload_type);
if (it == decoders_.end()) {
LOG(LERROR) << "AcmReceiver::DecoderByPayloadType "
<< static_cast<int>(payload_type);
return -1;
}
const Decoder& decoder = it->second;
*codec = *RentACodec::CodecInstById(
*RentACodec::CodecIdFromIndex(decoder.acm_codec_id));
codec->pltype = decoder.payload_type;
codec->channels = decoder.channels;
codec->plfreq = decoder.sample_rate_hz;
return 0;
}
int AcmReceiver::EnableNack(size_t max_nack_list_size) {

View File

@ -174,11 +174,10 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecGetCodec) {
// Add codec.
for (size_t n = 0; n < codecs_.size(); ++n) {
if (n & 0x1) { // Just add codecs with odd index.
EXPECT_EQ(
0, receiver_->AddCodec(n, codecs_[n].pltype, codecs_[n].channels,
codecs_[n].plfreq, NULL, codecs_[n].plname));
}
if (n & 0x1) // Just add codecs with odd index.
EXPECT_EQ(0,
receiver_->AddCodec(n, codecs_[n].pltype, codecs_[n].channels,
codecs_[n].plfreq, NULL, ""));
}
// Get codec and compare.
for (size_t n = 0; n < codecs_.size(); ++n) {
@ -210,9 +209,9 @@ TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecChangePayloadType) {
// Register the same codec with different payloads.
EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype,
codec1.inst.channels, codec1.inst.plfreq,
nullptr, codec1.inst.plname));
nullptr, ""));
EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec2.pltype, codec2.channels,
codec2.plfreq, NULL, codec2.plname));
codec2.plfreq, NULL, ""));
// Both payload types should exist.
EXPECT_EQ(0,
@ -236,10 +235,10 @@ TEST_F(AcmReceiverTestOldApi, AddCodecChangeCodecId) {
// Register the same payload type with different codec ID.
EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype,
codec1.inst.channels, codec1.inst.plfreq,
nullptr, codec1.inst.plname));
nullptr, ""));
EXPECT_EQ(0, receiver_->AddCodec(codec2.id, codec2.inst.pltype,
codec2.inst.channels, codec2.inst.plfreq,
nullptr, codec2.inst.plname));
nullptr, ""));
// Make sure that the last codec is used.
EXPECT_EQ(0,
@ -257,7 +256,7 @@ TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecRemoveCodec) {
const int payload_type = codec.inst.pltype;
EXPECT_EQ(
0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels,
codec.inst.plfreq, nullptr, codec.inst.plname));
codec.inst.plfreq, nullptr, ""));
// Remove non-existing codec should not fail. ACM1 legacy.
EXPECT_EQ(0, receiver_->RemoveCodec(payload_type + 1));