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; |
} |