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

Side by Side Diff: webrtc/system_wrappers/source/rtp_to_ntp.cc

Issue 2354843003: Add sanity check for decreasing RTP timestamp in RtpToNtpMs. (Closed)
Patch Set: remove {} Created 4 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 | « no previous file | webrtc/system_wrappers/source/rtp_to_ntp_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 (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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 rtcp.front().ntp_frac); 103 rtcp.front().ntp_frac);
104 int64_t rtcp_ntp_ms_old = Clock::NtpToMs(rtcp.back().ntp_secs, 104 int64_t rtcp_ntp_ms_old = Clock::NtpToMs(rtcp.back().ntp_secs,
105 rtcp.back().ntp_frac); 105 rtcp.back().ntp_frac);
106 int64_t rtcp_timestamp_new = rtcp.front().rtp_timestamp; 106 int64_t rtcp_timestamp_new = rtcp.front().rtp_timestamp;
107 int64_t rtcp_timestamp_old = rtcp.back().rtp_timestamp; 107 int64_t rtcp_timestamp_old = rtcp.back().rtp_timestamp;
108 if (!CompensateForWrapAround(rtcp_timestamp_new, 108 if (!CompensateForWrapAround(rtcp_timestamp_new,
109 rtcp_timestamp_old, 109 rtcp_timestamp_old,
110 &rtcp_timestamp_new)) { 110 &rtcp_timestamp_new)) {
111 return false; 111 return false;
112 } 112 }
113 if (rtcp_timestamp_new < rtcp_timestamp_old)
114 return false;
115
113 double freq_khz; 116 double freq_khz;
114 if (!CalculateFrequency(rtcp_ntp_ms_new, 117 if (!CalculateFrequency(rtcp_ntp_ms_new,
115 rtcp_timestamp_new, 118 rtcp_timestamp_new,
116 rtcp_ntp_ms_old, 119 rtcp_ntp_ms_old,
117 rtcp_timestamp_old, 120 rtcp_timestamp_old,
118 &freq_khz)) { 121 &freq_khz)) {
119 return false; 122 return false;
120 } 123 }
121 double offset = rtcp_timestamp_new - freq_khz * rtcp_ntp_ms_new; 124 double offset = rtcp_timestamp_new - freq_khz * rtcp_ntp_ms_new;
122 int64_t rtp_timestamp_unwrapped; 125 int64_t rtp_timestamp_unwrapped;
(...skipping 21 matching lines...) Expand all
144 } 147 }
145 } else if (static_cast<int32_t>(old_timestamp - new_timestamp) > 0) { 148 } else if (static_cast<int32_t>(old_timestamp - new_timestamp) > 0) {
146 // This difference should be less than -2^31 if we have had a backward wrap 149 // This difference should be less than -2^31 if we have had a backward wrap
147 // around. Since it is cast to a int32_t, it should be positive. 150 // around. Since it is cast to a int32_t, it should be positive.
148 return -1; 151 return -1;
149 } 152 }
150 return 0; 153 return 0;
151 } 154 }
152 155
153 } // namespace webrtc 156 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/system_wrappers/source/rtp_to_ntp_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698