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

Side by Side Diff: webrtc/base/macasyncsocket.cc

Issue 1944683002: Read recv timestamps from socket (posix only). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 7 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/base/macasyncsocket.h ('k') | webrtc/base/nat_unittest.cc » ('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 2010 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2010 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 reinterpret_cast<sockaddr*>(&saddr), len); 181 reinterpret_cast<sockaddr*>(&saddr), len);
182 182
183 if (sent == SOCKET_ERROR) { 183 if (sent == SOCKET_ERROR) {
184 error_ = errno; 184 error_ = errno;
185 } 185 }
186 186
187 return sent; 187 return sent;
188 } 188 }
189 189
190 // Read data received from the remote end we're connected to. 190 // Read data received from the remote end we're connected to.
191 int MacAsyncSocket::Recv(void* buffer, size_t length) { 191 int MacAsyncSocket::Recv(void* buffer, size_t length, int64_t* timestamp) {
192 if (timestamp) {
193 *timestamp = -1;
194 }
192 int received = ::recv(native_socket_, reinterpret_cast<char*>(buffer), 195 int received = ::recv(native_socket_, reinterpret_cast<char*>(buffer),
193 length, 0); 196 length, 0);
194 if (received == SOCKET_ERROR) error_ = errno; 197 if (received == SOCKET_ERROR) error_ = errno;
195 198
196 // Recv should only be called when there is data to read 199 // Recv should only be called when there is data to read
197 ASSERT((received != 0) || (length == 0)); 200 ASSERT((received != 0) || (length == 0));
198 return received; 201 return received;
199 } 202 }
200 203
201 // Read data received from any remote party 204 // Read data received from any remote party
202 int MacAsyncSocket::RecvFrom(void* buffer, size_t length, 205 int MacAsyncSocket::RecvFrom(void* buffer,
203 SocketAddress* out_addr) { 206 size_t length,
207 SocketAddress* out_addr,
208 int64_t* timestamp) {
209 if (timestamp) {
210 *timestamp = -1;
211 }
204 sockaddr_storage saddr; 212 sockaddr_storage saddr;
205 socklen_t addr_len = sizeof(saddr); 213 socklen_t addr_len = sizeof(saddr);
206 int received = ::recvfrom(native_socket_, reinterpret_cast<char*>(buffer), 214 int received = ::recvfrom(native_socket_, reinterpret_cast<char*>(buffer),
207 length, 0, reinterpret_cast<sockaddr*>(&saddr), 215 length, 0, reinterpret_cast<sockaddr*>(&saddr),
208 &addr_len); 216 &addr_len);
209 if (received >= 0 && out_addr != NULL) { 217 if (received >= 0 && out_addr != NULL) {
210 SocketAddressFromSockAddrStorage(saddr, out_addr); 218 SocketAddressFromSockAddrStorage(saddr, out_addr);
211 } else if (received == SOCKET_ERROR) { 219 } else if (received == SOCKET_ERROR) {
212 error_ = errno; 220 error_ = errno;
213 } 221 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 this_socket->current_callbacks_ &= ~kCFSocketWriteCallBack; 476 this_socket->current_callbacks_ &= ~kCFSocketWriteCallBack;
469 this_socket->SignalWriteEvent(this_socket); 477 this_socket->SignalWriteEvent(this_socket);
470 break; 478 break;
471 479
472 default: 480 default:
473 ASSERT(false && "Invalid callback type for socket"); 481 ASSERT(false && "Invalid callback type for socket");
474 } 482 }
475 } 483 }
476 484
477 } // namespace rtc 485 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/macasyncsocket.h ('k') | webrtc/base/nat_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698