| OLD | NEW |
| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Converts |rtp_timestamp| to the NTP time base using the NTP and RTP timestamp | 91 // Converts |rtp_timestamp| to the NTP time base using the NTP and RTP timestamp |
| 92 // pairs in |rtcp|. The converted timestamp is returned in | 92 // pairs in |rtcp|. The converted timestamp is returned in |
| 93 // |rtp_timestamp_in_ms|. This function compensates for wrap arounds in RTP | 93 // |rtp_timestamp_in_ms|. This function compensates for wrap arounds in RTP |
| 94 // timestamps and returns false if it can't do the conversion due to reordering. | 94 // timestamps and returns false if it can't do the conversion due to reordering. |
| 95 bool RtpToNtpMs(int64_t rtp_timestamp, | 95 bool RtpToNtpMs(int64_t rtp_timestamp, |
| 96 const RtcpList& rtcp, | 96 const RtcpList& rtcp, |
| 97 int64_t* rtp_timestamp_in_ms) { | 97 int64_t* rtp_timestamp_in_ms) { |
| 98 assert(rtcp.size() == 2); | 98 if (rtcp.size() != 2) |
| 99 return false; |
| 100 |
| 99 int64_t rtcp_ntp_ms_new = Clock::NtpToMs(rtcp.front().ntp_secs, | 101 int64_t rtcp_ntp_ms_new = Clock::NtpToMs(rtcp.front().ntp_secs, |
| 100 rtcp.front().ntp_frac); | 102 rtcp.front().ntp_frac); |
| 101 int64_t rtcp_ntp_ms_old = Clock::NtpToMs(rtcp.back().ntp_secs, | 103 int64_t rtcp_ntp_ms_old = Clock::NtpToMs(rtcp.back().ntp_secs, |
| 102 rtcp.back().ntp_frac); | 104 rtcp.back().ntp_frac); |
| 103 int64_t rtcp_timestamp_new = rtcp.front().rtp_timestamp; | 105 int64_t rtcp_timestamp_new = rtcp.front().rtp_timestamp; |
| 104 int64_t rtcp_timestamp_old = rtcp.back().rtp_timestamp; | 106 int64_t rtcp_timestamp_old = rtcp.back().rtp_timestamp; |
| 105 if (!CompensateForWrapAround(rtcp_timestamp_new, | 107 if (!CompensateForWrapAround(rtcp_timestamp_new, |
| 106 rtcp_timestamp_old, | 108 rtcp_timestamp_old, |
| 107 &rtcp_timestamp_new)) { | 109 &rtcp_timestamp_new)) { |
| 108 return false; | 110 return false; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 143 } |
| 142 } else if (static_cast<int32_t>(old_timestamp - new_timestamp) > 0) { | 144 } else if (static_cast<int32_t>(old_timestamp - new_timestamp) > 0) { |
| 143 // This difference should be less than -2^31 if we have had a backward wrap | 145 // This difference should be less than -2^31 if we have had a backward wrap |
| 144 // around. Since it is cast to a int32_t, it should be positive. | 146 // around. Since it is cast to a int32_t, it should be positive. |
| 145 return -1; | 147 return -1; |
| 146 } | 148 } |
| 147 return 0; | 149 return 0; |
| 148 } | 150 } |
| 149 | 151 |
| 150 } // namespace webrtc | 152 } // namespace webrtc |
| OLD | NEW |