| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Update extrapolator with the new arrival time. | 44 // Update extrapolator with the new arrival time. |
| 45 // The extrapolator assumes the TimeInMilliseconds time. | 45 // The extrapolator assumes the TimeInMilliseconds time. |
| 46 int64_t receiver_arrival_time_ms = clock_->TimeInMilliseconds(); | 46 int64_t receiver_arrival_time_ms = clock_->TimeInMilliseconds(); |
| 47 int64_t sender_send_time_ms = Clock::NtpToMs(ntp_secs, ntp_frac); | 47 int64_t sender_send_time_ms = Clock::NtpToMs(ntp_secs, ntp_frac); |
| 48 int64_t sender_arrival_time_90k = (sender_send_time_ms + rtt / 2) * 90; | 48 int64_t sender_arrival_time_90k = (sender_send_time_ms + rtt / 2) * 90; |
| 49 ts_extrapolator_->Update(receiver_arrival_time_ms, sender_arrival_time_90k); | 49 ts_extrapolator_->Update(receiver_arrival_time_ms, sender_arrival_time_90k); |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 | 52 |
| 53 int64_t RemoteNtpTimeEstimator::Estimate(uint32_t rtp_timestamp) { | 53 int64_t RemoteNtpTimeEstimator::Estimate(uint32_t rtp_timestamp) { |
| 54 if (rtcp_list_.size() < 2) { | |
| 55 // We need two RTCP SR reports to calculate NTP. | |
| 56 return -1; | |
| 57 } | |
| 58 int64_t sender_capture_ntp_ms = 0; | 54 int64_t sender_capture_ntp_ms = 0; |
| 59 if (!RtpToNtpMs(rtp_timestamp, rtcp_list_, &sender_capture_ntp_ms)) { | 55 if (!RtpToNtpMs(rtp_timestamp, rtcp_list_, &sender_capture_ntp_ms)) { |
| 60 return -1; | 56 return -1; |
| 61 } | 57 } |
| 62 uint32_t timestamp = sender_capture_ntp_ms * 90; | 58 uint32_t timestamp = sender_capture_ntp_ms * 90; |
| 63 int64_t receiver_capture_ms = | 59 int64_t receiver_capture_ms = |
| 64 ts_extrapolator_->ExtrapolateLocalTime(timestamp); | 60 ts_extrapolator_->ExtrapolateLocalTime(timestamp); |
| 65 int64_t ntp_offset = | 61 int64_t ntp_offset = |
| 66 clock_->CurrentNtpInMilliseconds() - clock_->TimeInMilliseconds(); | 62 clock_->CurrentNtpInMilliseconds() - clock_->TimeInMilliseconds(); |
| 67 int64_t receiver_capture_ntp_ms = receiver_capture_ms + ntp_offset; | 63 int64_t receiver_capture_ntp_ms = receiver_capture_ms + ntp_offset; |
| 68 int64_t now_ms = clock_->TimeInMilliseconds(); | 64 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 69 if (now_ms - last_timing_log_ms_ > kTimingLogIntervalMs) { | 65 if (now_ms - last_timing_log_ms_ > kTimingLogIntervalMs) { |
| 70 LOG(LS_INFO) << "RTP timestamp: " << rtp_timestamp | 66 LOG(LS_INFO) << "RTP timestamp: " << rtp_timestamp |
| 71 << " in NTP clock: " << sender_capture_ntp_ms | 67 << " in NTP clock: " << sender_capture_ntp_ms |
| 72 << " estimated time in receiver clock: " << receiver_capture_ms | 68 << " estimated time in receiver clock: " << receiver_capture_ms |
| 73 << " converted to NTP clock: " << receiver_capture_ntp_ms; | 69 << " converted to NTP clock: " << receiver_capture_ntp_ms; |
| 74 last_timing_log_ms_ = now_ms; | 70 last_timing_log_ms_ = now_ms; |
| 75 } | 71 } |
| 76 return receiver_capture_ntp_ms; | 72 return receiver_capture_ntp_ms; |
| 77 } | 73 } |
| 78 | 74 |
| 79 } // namespace webrtc | 75 } // namespace webrtc |
| OLD | NEW |