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

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

Issue 1369263002: Unify Transport and newapi::Transport interfaces. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: self-review Created 5 years, 2 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
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/include/voe_network.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 { 207 {
208 CriticalSectionScoped cs(&_callbackCritSect); 208 CriticalSectionScoped cs(&_callbackCritSect);
209 if (_rxVadObserverPtr) 209 if (_rxVadObserverPtr)
210 { 210 {
211 _rxVadObserverPtr->OnRxVad(_channelId, vadDecision); 211 _rxVadObserverPtr->OnRxVad(_channelId, vadDecision);
212 } 212 }
213 213
214 return 0; 214 return 0;
215 } 215 }
216 216
217 int 217 bool
218 Channel::SendPacket(const void *data, size_t len) 218 Channel::SendRtp(const uint8_t *data, size_t len)
219 { 219 {
220 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), 220 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId),
221 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len); 221 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len);
222 222
223 CriticalSectionScoped cs(&_callbackCritSect); 223 CriticalSectionScoped cs(&_callbackCritSect);
224 224
225 if (_transportPtr == NULL) 225 if (_transportPtr == NULL)
226 { 226 {
227 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), 227 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId),
228 "Channel::SendPacket() failed to send RTP packet due to" 228 "Channel::SendPacket() failed to send RTP packet due to"
229 " invalid transport object"); 229 " invalid transport object");
230 return -1; 230 return false;
231 } 231 }
232 232
233 uint8_t* bufferToSendPtr = (uint8_t*)data; 233 uint8_t* bufferToSendPtr = (uint8_t*)data;
234 size_t bufferLength = len; 234 size_t bufferLength = len;
235 235
236 int n = _transportPtr->SendPacket(bufferToSendPtr, bufferLength); 236 if (!_transportPtr->SendRtp(bufferToSendPtr, bufferLength)) {
237 if (n < 0) {
238 std::string transport_name = 237 std::string transport_name =
239 _externalTransport ? "external transport" : "WebRtc sockets"; 238 _externalTransport ? "external transport" : "WebRtc sockets";
240 WEBRTC_TRACE(kTraceError, kTraceVoice, 239 WEBRTC_TRACE(kTraceError, kTraceVoice,
241 VoEId(_instanceId,_channelId), 240 VoEId(_instanceId,_channelId),
242 "Channel::SendPacket() RTP transmission using %s failed", 241 "Channel::SendPacket() RTP transmission using %s failed",
243 transport_name.c_str()); 242 transport_name.c_str());
244 return -1; 243 return false;
245 } 244 }
246 return n; 245 return true;
247 } 246 }
248 247
249 int 248 bool
250 Channel::SendRTCPPacket(const void *data, size_t len) 249 Channel::SendRtcp(const uint8_t *data, size_t len)
251 { 250 {
252 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), 251 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId),
253 "Channel::SendRTCPPacket(len=%" PRIuS ")", len); 252 "Channel::SendRtcp(len=%" PRIuS ")", len);
254 253
255 CriticalSectionScoped cs(&_callbackCritSect); 254 CriticalSectionScoped cs(&_callbackCritSect);
256 if (_transportPtr == NULL) 255 if (_transportPtr == NULL)
257 { 256 {
258 WEBRTC_TRACE(kTraceError, kTraceVoice, 257 WEBRTC_TRACE(kTraceError, kTraceVoice,
259 VoEId(_instanceId,_channelId), 258 VoEId(_instanceId,_channelId),
260 "Channel::SendRTCPPacket() failed to send RTCP packet" 259 "Channel::SendRtcp() failed to send RTCP packet"
261 " due to invalid transport object"); 260 " due to invalid transport object");
262 return -1; 261 return false;
263 } 262 }
264 263
265 uint8_t* bufferToSendPtr = (uint8_t*)data; 264 uint8_t* bufferToSendPtr = (uint8_t*)data;
266 size_t bufferLength = len; 265 size_t bufferLength = len;
267 266
268 int n = _transportPtr->SendRTCPPacket(bufferToSendPtr, bufferLength); 267 int n = _transportPtr->SendRtcp(bufferToSendPtr, bufferLength);
269 if (n < 0) { 268 if (n < 0) {
270 std::string transport_name = 269 std::string transport_name =
271 _externalTransport ? "external transport" : "WebRtc sockets"; 270 _externalTransport ? "external transport" : "WebRtc sockets";
272 WEBRTC_TRACE(kTraceInfo, kTraceVoice, 271 WEBRTC_TRACE(kTraceInfo, kTraceVoice,
273 VoEId(_instanceId,_channelId), 272 VoEId(_instanceId,_channelId),
274 "Channel::SendRTCPPacket() transmission using %s failed", 273 "Channel::SendRtcp() transmission using %s failed",
275 transport_name.c_str()); 274 transport_name.c_str());
276 return -1; 275 return false;
277 } 276 }
278 return n; 277 return true;
279 } 278 }
280 279
281 void Channel::OnPlayTelephoneEvent(uint8_t event, 280 void Channel::OnPlayTelephoneEvent(uint8_t event,
282 uint16_t lengthMs, 281 uint16_t lengthMs,
283 uint8_t volume) { 282 uint8_t volume) {
284 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), 283 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId),
285 "Channel::OnPlayTelephoneEvent(event=%u, lengthMs=%u," 284 "Channel::OnPlayTelephoneEvent(event=%u, lengthMs=%u,"
286 " volume=%u)", event, lengthMs, volume); 285 " volume=%u)", event, lengthMs, volume);
287 286
288 if (!_playOutbandDtmfEvent || (event > 15)) 287 if (!_playOutbandDtmfEvent || (event > 15))
(...skipping 3412 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 3700
3702 assert(_audioFrame.samples_per_channel_ == toneSamples); 3701 assert(_audioFrame.samples_per_channel_ == toneSamples);
3703 } else 3702 } else
3704 { 3703 {
3705 // Add 10ms to "delay-since-last-tone" counter 3704 // Add 10ms to "delay-since-last-tone" counter
3706 _inbandDtmfGenerator.UpdateDelaySinceLastTone(); 3705 _inbandDtmfGenerator.UpdateDelaySinceLastTone();
3707 } 3706 }
3708 return 0; 3707 return 0;
3709 } 3708 }
3710 3709
3711 int32_t
3712 Channel::SendPacketRaw(const void *data, size_t len, bool RTCP)
3713 {
3714 CriticalSectionScoped cs(&_callbackCritSect);
3715 if (_transportPtr == NULL)
3716 {
3717 return -1;
3718 }
3719 if (!RTCP)
3720 {
3721 return _transportPtr->SendPacket(data, len);
3722 }
3723 else
3724 {
3725 return _transportPtr->SendRTCPPacket(data, len);
3726 }
3727 }
3728
3729 void Channel::UpdatePlayoutTimestamp(bool rtcp) { 3710 void Channel::UpdatePlayoutTimestamp(bool rtcp) {
3730 uint32_t playout_timestamp = 0; 3711 uint32_t playout_timestamp = 0;
3731 3712
3732 if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) { 3713 if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) {
3733 // This can happen if this channel has not been received any RTP packet. In 3714 // This can happen if this channel has not been received any RTP packet. In
3734 // this case, NetEq is not capable of computing playout timestamp. 3715 // this case, NetEq is not capable of computing playout timestamp.
3735 return; 3716 return;
3736 } 3717 }
3737 3718
3738 uint16_t delay_ms = 0; 3719 uint16_t delay_ms = 0;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3973 int64_t min_rtt = 0; 3954 int64_t min_rtt = 0;
3974 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) 3955 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt)
3975 != 0) { 3956 != 0) {
3976 return 0; 3957 return 0;
3977 } 3958 }
3978 return rtt; 3959 return rtt;
3979 } 3960 }
3980 3961
3981 } // namespace voe 3962 } // namespace voe
3982 } // namespace webrtc 3963 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/include/voe_network.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698