Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Unified Diff: webrtc/voice_engine/channel.cc

Issue 2924363004: Fix Channel::GetSendCodec when used together with SetEncoder. (Closed)
Patch Set: Remove RTC_DCHECK(false) used for debugging. :) Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/channel.cc
diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc
index b0bae4e4ceb0e05cd1ca421efdbc5943cf640e19..35412ce41cec091b09f282e0ecf817cbe7d30d69 100644
--- a/webrtc/voice_engine/channel.cc
+++ b/webrtc/voice_engine/channel.cc
@@ -1288,10 +1288,16 @@ bool Channel::SetEncoder(int payload_type,
// supposedly carries the sample rate, but only clock rate seems sensible to
// send to the RTP/RTCP module.
lies.plfreq = encoder->RtpTimestampRateHz();
- lies.pacsize = 0;
+ lies.pacsize = rtc::CheckedDivExact(
+ static_cast<int>(encoder->Max10MsFramesInAPacket() * lies.plfreq), 100);
lies.channels = encoder->NumChannels();
lies.rate = 0;
+ // Store a similarily made-up CodecInst for GetSendCodec to return.
henrika_webrtc 2017/06/09 13:50:04 Similar to what?
ossu 2017/06/09 13:54:00 On line 1281 I explain that I'm making a CodecInst
+ CodecInst send_codec = lies;
+ send_codec.plfreq = encoder->SampleRateHz();
+ cached_send_codec_.emplace(send_codec);
+
if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) {
_rtpRtcpModule->DeRegisterSendPayload(payload_type);
if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) {
@@ -1343,18 +1349,16 @@ int32_t Channel::DeRegisterVoiceEngineObserver() {
}
int32_t Channel::GetSendCodec(CodecInst& codec) {
- {
+ if (cached_send_codec_) {
+ codec = *cached_send_codec_;
+ return 0;
+ } else {
const CodecInst* send_codec = codec_manager_.GetCodecInst();
if (send_codec) {
codec = *send_codec;
return 0;
}
}
- rtc::Optional<CodecInst> acm_send_codec = audio_coding_->SendCodec();
- if (acm_send_codec) {
- codec = *acm_send_codec;
- return 0;
- }
return -1;
}
@@ -1383,6 +1387,8 @@ int32_t Channel::SetSendCodec(const CodecInst& codec) {
}
}
+ cached_send_codec_.reset();
+
return 0;
}
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698