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

Unified Diff: webrtc/voice_engine/channel.cc

Issue 2703373006: Injectable audio encoders: voice_engine/channel changes. (Closed)
Patch Set: Removed builtin_audio_encoder_factory from voice_engine/BUILD.gn. Size check using sizeof(). Fixed … Created 3 years, 10 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
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()");

Powered by Google App Engine
This is Rietveld 408576698