Chromium Code Reviews| Index: webrtc/voice_engine/channel.cc |
| diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc |
| index 006e3db69bf55d754eec187c52793b4a5f66e54c..b2e25838ea6bddadc524bf75f6c754043569da00 100644 |
| --- a/webrtc/voice_engine/channel.cc |
| +++ b/webrtc/voice_engine/channel.cc |
| @@ -1202,6 +1202,48 @@ int32_t Channel::StopSend() { |
| return 0; |
| } |
| +bool Channel::SetSendFormat(int payload_type, |
| + const SdpAudioFormat& format, |
| + AudioEncoderFactory* factory) { |
| + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| + "Channel::SetSendFormat()"); |
| + |
| + auto encoder = factory->MakeAudioEncoder(payload_type, format); |
| + if (!encoder) { |
| + WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
| + "SetSendFormat() failed to create encoder"); |
| + return false; |
| + } |
| + |
| + // TODO(ossu): Make a CodecInst up for now. |
|
the sun
2017/02/22 14:08:38
You need to explain why we should accept your lies
ossu
2017/02/22 14:24:41
Alright. I'll elaborate and give it a less offensi
|
| + CodecInst lies; |
| + lies.pltype = payload_type; |
| + strncpy(lies.plname, format.name.c_str(), sizeof(lies.plname)); |
| + lies.plname[sizeof(lies.plname) - 1] = 0; |
| + // Seems unclear if it should be clock rate or sample rate. CodecInst |
| + // supposedly carries the sample rate, but only clock rate seems sensible to |
| + // send to the RTP/RTCP module. |
| + lies.plfreq = format.clockrate_hz; |
| + //lies.plfreq = encoder->SampleRateHz(); |
| + lies.pacsize = 0; |
| + lies.channels = encoder->NumChannels(); |
| + lies.rate = 0; |
| + |
| + if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) { |
| + _rtpRtcpModule->DeRegisterSendPayload(payload_type); |
| + if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) { |
| + WEBRTC_TRACE( |
| + kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
| + "SetSendFormat() failed to register codec to RTP/RTCP module"); |
| + return false; |
| + } |
| + } |
| + |
| + audio_coding_->SetEncoder(std::move(encoder)); |
| + |
| + return true; |
| +} |
| + |
| int32_t Channel::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) { |
| WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| "Channel::RegisterVoiceEngineObserver()"); |