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

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 2705093002: Injectable audio encoders: WebRtcVoiceEngine and company (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 void Channel::SetSink(std::unique_ptr<AudioSinkInterface> sink) { 1097 void Channel::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
1098 rtc::CritScope cs(&_callbackCritSect); 1098 rtc::CritScope cs(&_callbackCritSect);
1099 audio_sink_ = std::move(sink); 1099 audio_sink_ = std::move(sink);
1100 } 1100 }
1101 1101
1102 const rtc::scoped_refptr<AudioDecoderFactory>& 1102 const rtc::scoped_refptr<AudioDecoderFactory>&
1103 Channel::GetAudioDecoderFactory() const { 1103 Channel::GetAudioDecoderFactory() const {
1104 return decoder_factory_; 1104 return decoder_factory_;
1105 } 1105 }
1106 1106
1107 AudioCodingModule& Channel::GetAudioCodingModule() {
1108 return *audio_coding_;
1109 }
1110
1107 int32_t Channel::StartPlayout() { 1111 int32_t Channel::StartPlayout() {
1108 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1112 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1109 "Channel::StartPlayout()"); 1113 "Channel::StartPlayout()");
1110 if (channel_state_.Get().playing) { 1114 if (channel_state_.Get().playing) {
1111 return 0; 1115 return 0;
1112 } 1116 }
1113 1117
1114 // Add participant as candidates for mixing. 1118 // Add participant as candidates for mixing.
1115 if (_outputMixerPtr->SetMixabilityStatus(*this, true) != 0) { 1119 if (_outputMixerPtr->SetMixabilityStatus(*this, true) != 0) {
1116 _engineStatisticsPtr->SetLastError( 1120 _engineStatisticsPtr->SetLastError(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 if (_rtpRtcpModule->SetSendingStatus(false) == -1) { 1199 if (_rtpRtcpModule->SetSendingStatus(false) == -1) {
1196 _engineStatisticsPtr->SetLastError( 1200 _engineStatisticsPtr->SetLastError(
1197 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, 1201 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning,
1198 "StartSend() RTP/RTCP failed to stop sending"); 1202 "StartSend() RTP/RTCP failed to stop sending");
1199 } 1203 }
1200 _rtpRtcpModule->SetSendingMediaStatus(false); 1204 _rtpRtcpModule->SetSendingMediaStatus(false);
1201 1205
1202 return 0; 1206 return 0;
1203 } 1207 }
1204 1208
1209 bool Channel::SetSendFormat(int payload_type,
1210 const SdpAudioFormat& format,
1211 AudioEncoderFactory* factory) {
1212 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1213 "Channel::SetSendFormat()");
1214
1215 auto encoder = factory->MakeAudioEncoder(payload_type, format);
ossu 2017/02/22 10:24:23 I put the MakeAudioEncoder call here, rather than
kwiberg-webrtc 2017/02/22 10:42:06 We want RegisterSendPayload to not take a CodecIns
1216 if (!encoder) {
1217 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1218 "SetSendFormat() failed to create encoder");
1219 return false;
1220 }
1221
1222 // TODO(ossu): Make a CodecInst up for now.
1223 CodecInst lies;
1224 lies.pltype = payload_type;
1225 strncpy(lies.plname, format.name.c_str(), RTP_PAYLOAD_NAME_SIZE);
kwiberg-webrtc 2017/02/21 23:35:04 The length limiter should also involve sizeof(lies
ossu 2017/02/22 10:24:23 But sizeof(lies.plname) _is_ RTP_PAYLOAD_NAME_SIZE
kwiberg-webrtc 2017/02/22 10:42:06 You know that, and I know that (obviously!), but I
ossu 2017/02/22 10:47:07 You're right. I'll use the sizeof instead. I think
1226 lies.plname[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
1227 // Seems unclear if it should be clock rate or sample rate. CodecInst used to
1228 // carry sample rate, but only clock rate seems sensible to send to the
kwiberg-webrtc 2017/02/21 23:35:04 "CodecInst supposedly carries the sample rate,"
ossu 2017/02/22 10:24:23 Alright. I think this comment is more for the revi
kwiberg-webrtc 2017/02/22 10:42:06 Acknowledged.
1229 // RTP/RTCP module.
1230 // lies.plfreq = encoder->SampleRateHz();
1231 lies.plfreq = format.clockrate_hz;
1232 lies.pacsize = 0;
1233 lies.channels = encoder->NumChannels();
1234 lies.rate = 0;
1235
1236 if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) {
1237 _rtpRtcpModule->DeRegisterSendPayload(payload_type);
1238 if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) {
1239 WEBRTC_TRACE(
1240 kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1241 "SetSendFormat() failed to register codec to RTP/RTCP module");
1242 return false;
1243 }
1244 }
1245
1246 audio_coding_->SetEncoder(std::move(encoder));
1247
1248 return true;
1249 }
1250
1205 int32_t Channel::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) { 1251 int32_t Channel::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) {
1206 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1252 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1207 "Channel::RegisterVoiceEngineObserver()"); 1253 "Channel::RegisterVoiceEngineObserver()");
1208 rtc::CritScope cs(&_callbackCritSect); 1254 rtc::CritScope cs(&_callbackCritSect);
1209 1255
1210 if (_voiceEngineObserverPtr) { 1256 if (_voiceEngineObserverPtr) {
1211 _engineStatisticsPtr->SetLastError( 1257 _engineStatisticsPtr->SetLastError(
1212 VE_INVALID_OPERATION, kTraceError, 1258 VE_INVALID_OPERATION, kTraceError,
1213 "RegisterVoiceEngineObserver() observer already enabled"); 1259 "RegisterVoiceEngineObserver() observer already enabled");
1214 return -1; 1260 return -1;
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 int64_t min_rtt = 0; 3057 int64_t min_rtt = 0;
3012 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3058 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3013 0) { 3059 0) {
3014 return 0; 3060 return 0;
3015 } 3061 }
3016 return rtt; 3062 return rtt;
3017 } 3063 }
3018 3064
3019 } // namespace voe 3065 } // namespace voe
3020 } // namespace webrtc 3066 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698