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

Unified Diff: webrtc/voice_engine/channel.cc

Issue 2703373006: Injectable audio encoders: voice_engine/channel changes. (Closed)
Patch Set: Removed 'virtual' from Channel::SetEncoder. Created 3 years, 8 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') | webrtc/voice_engine/channel_proxy.h » ('j') | 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 3a4a9704981c77287fa385dcd999d25f8780564b..a7a45e67a7b8f671296c8cd6af89941c18243e44 100644
--- a/webrtc/voice_engine/channel.cc
+++ b/webrtc/voice_engine/channel.cc
@@ -1274,6 +1274,38 @@ void Channel::StopSend() {
_rtpRtcpModule->SetSendingMediaStatus(false);
}
+bool Channel::SetEncoder(int payload_type,
+ std::unique_ptr<AudioEncoder> encoder) {
+ RTC_DCHECK_GE(payload_type, 0);
+ RTC_DCHECK_LE(payload_type, 127);
+ // TODO(ossu): Make a CodecInst up for now. It seems like very little of this
+ // information is actually used, possibly only payload type and clock rate.
+ CodecInst lies;
+ lies.pltype = payload_type;
+ strncpy(lies.plname, "audio", 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 = encoder->RtpTimestampRateHz();
+ 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),
+ "SetEncoder() 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()");
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698