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

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

Issue 2703373006: Injectable audio encoders: voice_engine/channel changes. (Closed)
Patch Set: Added checks, made mock use pointer, elaborated on why I make up a CodecInst Created 3 years, 9 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 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 if (_rtpRtcpModule->SetSendingStatus(false) == -1) { 1195 if (_rtpRtcpModule->SetSendingStatus(false) == -1) {
1196 _engineStatisticsPtr->SetLastError( 1196 _engineStatisticsPtr->SetLastError(
1197 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, 1197 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning,
1198 "StartSend() RTP/RTCP failed to stop sending"); 1198 "StartSend() RTP/RTCP failed to stop sending");
1199 } 1199 }
1200 _rtpRtcpModule->SetSendingMediaStatus(false); 1200 _rtpRtcpModule->SetSendingMediaStatus(false);
1201 1201
1202 return 0; 1202 return 0;
1203 } 1203 }
1204 1204
1205 bool Channel::SetEncoder(int payload_type,
1206 std::unique_ptr<AudioEncoder> encoder) {
1207 RTC_DCHECK_GE(payload_type, 0);
1208 RTC_DCHECK_LE(payload_type, 127);
1209 // TODO(ossu): Make a CodecInst up for now. It seems like very little of this
1210 // information is actually used, possibly only payload type and clock rate.
1211 CodecInst lies;
1212 lies.pltype = payload_type;
1213 strncpy(lies.plname, "audio", sizeof(lies.plname));
1214 lies.plname[sizeof(lies.plname) - 1] = 0;
1215 // Seems unclear if it should be clock rate or sample rate. CodecInst
1216 // supposedly carries the sample rate, but only clock rate seems sensible to
1217 // send to the RTP/RTCP module.
1218 lies.plfreq = encoder->RtpTimestampRateHz();
1219 lies.pacsize = 0;
1220 lies.channels = encoder->NumChannels();
1221 lies.rate = 0;
1222
1223 if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) {
1224 _rtpRtcpModule->DeRegisterSendPayload(payload_type);
1225 if (_rtpRtcpModule->RegisterSendPayload(lies) != 0) {
1226 WEBRTC_TRACE(
1227 kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1228 "SetEncoder() failed to register codec to RTP/RTCP module");
1229 return false;
1230 }
1231 }
1232
1233 audio_coding_->SetEncoder(std::move(encoder));
1234 return true;
1235 }
1236
1205 int32_t Channel::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) { 1237 int32_t Channel::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) {
1206 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1238 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1207 "Channel::RegisterVoiceEngineObserver()"); 1239 "Channel::RegisterVoiceEngineObserver()");
1208 rtc::CritScope cs(&_callbackCritSect); 1240 rtc::CritScope cs(&_callbackCritSect);
1209 1241
1210 if (_voiceEngineObserverPtr) { 1242 if (_voiceEngineObserverPtr) {
1211 _engineStatisticsPtr->SetLastError( 1243 _engineStatisticsPtr->SetLastError(
1212 VE_INVALID_OPERATION, kTraceError, 1244 VE_INVALID_OPERATION, kTraceError,
1213 "RegisterVoiceEngineObserver() observer already enabled"); 1245 "RegisterVoiceEngineObserver() observer already enabled");
1214 return -1; 1246 return -1;
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 int64_t min_rtt = 0; 3043 int64_t min_rtt = 0;
3012 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3044 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3013 0) { 3045 0) {
3014 return 0; 3046 return 0;
3015 } 3047 }
3016 return rtt; 3048 return rtt;
3017 } 3049 }
3018 3050
3019 } // namespace voe 3051 } // namespace voe
3020 } // namespace webrtc 3052 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698