| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #include "rtc_base/socket.h" |
| 12 |
| 13 | #include <cstdint> |
| 14 |
| 15 | #include "rtc_base/buffer.h" |
| 16 |
| 17 | namespace rtc { |
| 18 |
| 19 | int Socket::RecvFrom(ReceiveBuffer& buffer) { |
| 20 | static constexpr int BUF_SIZE = 64 * 1024; |
| 21 | int64_t timestamp = -1; |
| 22 | buffer.payload.EnsureCapacity(BUF_SIZE); |
| 23 | int len = RecvFrom(buffer.payload.data(), buffer.payload.capacity(), |
| 24 | &buffer.source_address, ×tamp); |
| 25 | buffer.payload.SetSize(len > 0 ? len : 0); |
| 26 | if (len > 0 && timestamp != -1) { |
| 27 | buffer.arrival_time = webrtc::Timestamp::Micros(timestamp); |
| 28 | } |
| 29 |
| 30 | return len; |
| 31 | } |
| 32 |
| 33 | } // namespace rtc |
| 34 |