| 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 19 matching lines...) Expand all Loading... |
| 30 EXPECT_EQ(1, CheckForWrapArounds(0x0000FFFF, 0xFFFF0000)); | 30 EXPECT_EQ(1, CheckForWrapArounds(0x0000FFFF, 0xFFFF0000)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 TEST(WrapAroundTests, BackwardWrap) { | 33 TEST(WrapAroundTests, BackwardWrap) { |
| 34 EXPECT_EQ(-1, CheckForWrapArounds(0xFFFFFFFF, 0)); | 34 EXPECT_EQ(-1, CheckForWrapArounds(0xFFFFFFFF, 0)); |
| 35 EXPECT_EQ(-1, CheckForWrapArounds(0xFFFF0000, 0)); | 35 EXPECT_EQ(-1, CheckForWrapArounds(0xFFFF0000, 0)); |
| 36 EXPECT_EQ(-1, CheckForWrapArounds(0xFFFFFFFF, 0x0000FFFF)); | 36 EXPECT_EQ(-1, CheckForWrapArounds(0xFFFFFFFF, 0x0000FFFF)); |
| 37 EXPECT_EQ(-1, CheckForWrapArounds(0xFFFF0000, 0x0000FFFF)); | 37 EXPECT_EQ(-1, CheckForWrapArounds(0xFFFF0000, 0x0000FFFF)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 TEST(WrapAroundTests, OldRtcpWrapped) { | 40 TEST(WrapAroundTests, OldRtcpWrapped_OldRtpTimestamp) { |
| 41 RtcpList rtcp; | 41 RtcpMeasurements rtcp; |
| 42 uint32_t ntp_sec = 0; | 42 bool new_sr; |
| 43 uint32_t ntp_frac = 0; | 43 uint32_t ntp_sec = 0; |
| 44 uint32_t ntp_frac = 1; |
| 44 uint32_t timestamp = 0; | 45 uint32_t timestamp = 0; |
| 45 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 46 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 46 ntp_frac += kOneMsInNtpFrac; | 47 ntp_frac += kOneMsInNtpFrac; |
| 47 timestamp -= kTimestampTicksPerMs; | 48 timestamp -= kTimestampTicksPerMs; |
| 48 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 49 // Expected to fail since the older RTCP has a smaller RTP timestamp than the |
| 49 ntp_frac += kOneMsInNtpFrac; | 50 // newer (old:0, new:4294967206). |
| 50 timestamp -= kTimestampTicksPerMs; | 51 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 51 int64_t timestamp_in_ms = -1; | |
| 52 // This expected to fail since it's highly unlikely that the older RTCP | |
| 53 // has a much smaller RTP timestamp than the newer. | |
| 54 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); | |
| 55 } | 52 } |
| 56 | 53 |
| 57 TEST(WrapAroundTests, NewRtcpWrapped) { | 54 TEST(WrapAroundTests, NewRtcpWrapped) { |
| 58 RtcpList rtcp; | 55 RtcpMeasurements rtcp; |
| 59 uint32_t ntp_sec = 0; | 56 bool new_sr; |
| 60 uint32_t ntp_frac = 0; | 57 uint32_t ntp_sec = 0; |
| 58 uint32_t ntp_frac = 1; |
| 61 uint32_t timestamp = 0xFFFFFFFF; | 59 uint32_t timestamp = 0xFFFFFFFF; |
| 62 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 60 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 63 ntp_frac += kOneMsInNtpFrac; | 61 ntp_frac += kOneMsInNtpFrac; |
| 64 timestamp += kTimestampTicksPerMs; | 62 timestamp += kTimestampTicksPerMs; |
| 65 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 63 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 66 int64_t timestamp_in_ms = -1; | 64 int64_t timestamp_ms = -1; |
| 67 EXPECT_TRUE(RtpToNtpMs(rtcp.back().rtp_timestamp, rtcp, ×tamp_in_ms)); | 65 EXPECT_TRUE(RtpToNtpMs(rtcp.list.back().rtp_timestamp, rtcp, ×tamp_ms)); |
| 68 // Since this RTP packet has the same timestamp as the RTCP packet constructed | 66 // Since this RTP packet has the same timestamp as the RTCP packet constructed |
| 69 // at time 0 it should be mapped to 0 as well. | 67 // at time 0 it should be mapped to 0 as well. |
| 70 EXPECT_EQ(0, timestamp_in_ms); | 68 EXPECT_EQ(0, timestamp_ms); |
| 71 } | 69 } |
| 72 | 70 |
| 73 TEST(WrapAroundTests, RtpWrapped) { | 71 TEST(WrapAroundTests, RtpWrapped) { |
| 74 RtcpList rtcp; | 72 RtcpMeasurements rtcp; |
| 75 uint32_t ntp_sec = 0; | 73 bool new_sr; |
| 76 uint32_t ntp_frac = 0; | 74 uint32_t ntp_sec = 0; |
| 75 uint32_t ntp_frac = 1; |
| 77 uint32_t timestamp = 0xFFFFFFFF - 2 * kTimestampTicksPerMs; | 76 uint32_t timestamp = 0xFFFFFFFF - 2 * kTimestampTicksPerMs; |
| 78 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 77 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 79 ntp_frac += kOneMsInNtpFrac; | 78 ntp_frac += kOneMsInNtpFrac; |
| 80 timestamp += kTimestampTicksPerMs; | 79 timestamp += kTimestampTicksPerMs; |
| 81 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 80 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 82 ntp_frac += kOneMsInNtpFrac; | 81 |
| 83 timestamp += kTimestampTicksPerMs; | 82 int64_t timestamp_ms = -1; |
| 84 int64_t timestamp_in_ms = -1; | 83 EXPECT_TRUE(RtpToNtpMs(rtcp.list.back().rtp_timestamp, rtcp, ×tamp_ms)); |
| 85 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); | |
| 86 // Since this RTP packet has the same timestamp as the RTCP packet constructed | 84 // Since this RTP packet has the same timestamp as the RTCP packet constructed |
| 87 // at time 0 it should be mapped to 0 as well. | 85 // at time 0 it should be mapped to 0 as well. |
| 88 EXPECT_EQ(2, timestamp_in_ms); | 86 EXPECT_EQ(0, timestamp_ms); |
| 87 // Two kTimestampTicksPerMs advanced. |
| 88 timestamp += kTimestampTicksPerMs; |
| 89 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_ms)); |
| 90 EXPECT_EQ(2, timestamp_ms); |
| 91 // Wrapped rtp. |
| 92 timestamp += kTimestampTicksPerMs; |
| 93 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_ms)); |
| 94 EXPECT_EQ(3, timestamp_ms); |
| 89 } | 95 } |
| 90 | 96 |
| 91 TEST(WrapAroundTests, OldRtp_RtcpsWrapped) { | 97 TEST(WrapAroundTests, OldRtp_RtcpsWrapped) { |
| 92 RtcpList rtcp; | 98 RtcpMeasurements rtcp; |
| 93 uint32_t ntp_sec = 0; | 99 bool new_sr; |
| 94 uint32_t ntp_frac = 0; | 100 uint32_t ntp_sec = 0; |
| 101 uint32_t ntp_frac = 1; |
| 95 uint32_t timestamp = 0; | 102 uint32_t timestamp = 0; |
| 96 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 103 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 97 ntp_frac += kOneMsInNtpFrac; | 104 ntp_frac += kOneMsInNtpFrac; |
| 98 timestamp += kTimestampTicksPerMs; | 105 timestamp += kTimestampTicksPerMs; |
| 99 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 106 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 100 ntp_frac += kOneMsInNtpFrac; | |
| 101 timestamp -= 2*kTimestampTicksPerMs; | 107 timestamp -= 2*kTimestampTicksPerMs; |
| 102 int64_t timestamp_in_ms = -1; | 108 int64_t timestamp_ms = -1; |
| 103 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); | 109 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_ms)); |
| 104 } | 110 } |
| 105 | 111 |
| 106 TEST(WrapAroundTests, OldRtp_NewRtcpWrapped) { | 112 TEST(WrapAroundTests, OldRtp_NewRtcpWrapped) { |
| 107 RtcpList rtcp; | 113 RtcpMeasurements rtcp; |
| 108 uint32_t ntp_sec = 0; | 114 bool new_sr; |
| 109 uint32_t ntp_frac = 0; | 115 uint32_t ntp_sec = 0; |
| 116 uint32_t ntp_frac = 1; |
| 110 uint32_t timestamp = 0xFFFFFFFF; | 117 uint32_t timestamp = 0xFFFFFFFF; |
| 111 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 118 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 112 ntp_frac += kOneMsInNtpFrac; | 119 ntp_frac += kOneMsInNtpFrac; |
| 113 timestamp += kTimestampTicksPerMs; | 120 timestamp += kTimestampTicksPerMs; |
| 114 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 121 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 115 ntp_frac += kOneMsInNtpFrac; | |
| 116 timestamp -= kTimestampTicksPerMs; | 122 timestamp -= kTimestampTicksPerMs; |
| 117 int64_t timestamp_in_ms = -1; | 123 int64_t timestamp_ms = -1; |
| 118 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); | 124 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_ms)); |
| 119 // Constructed at the same time as the first RTCP and should therefore be | 125 // Constructed at the same time as the first RTCP and should therefore be |
| 120 // mapped to zero. | 126 // mapped to zero. |
| 121 EXPECT_EQ(0, timestamp_in_ms); | 127 EXPECT_EQ(0, timestamp_ms); |
| 122 } | 128 } |
| 123 | 129 |
| 124 TEST(WrapAroundTests, OldRtp_OldRtcpWrapped) { | 130 TEST(UpdateRtcpListTests, InjectRtcpSr) { |
| 125 RtcpList rtcp; | 131 const uint32_t kNtpSec = 10; |
| 132 const uint32_t kNtpFrac = 12345; |
| 133 const uint32_t kTs = 0x12345678; |
| 134 bool new_sr; |
| 135 RtcpMeasurements rtcp; |
| 136 EXPECT_TRUE(UpdateRtcpList(kNtpSec, kNtpFrac, kTs, &rtcp, &new_sr)); |
| 137 EXPECT_TRUE(new_sr); |
| 138 EXPECT_EQ(1u, rtcp.list.size()); |
| 139 EXPECT_EQ(kNtpSec, rtcp.list.front().ntp_secs); |
| 140 EXPECT_EQ(kNtpFrac, rtcp.list.front().ntp_frac); |
| 141 EXPECT_EQ(kTs, rtcp.list.front().rtp_timestamp); |
| 142 // Add second report. |
| 143 EXPECT_TRUE(UpdateRtcpList(kNtpSec, kNtpFrac + kOneMsInNtpFrac, kTs + 1, |
| 144 &rtcp, &new_sr)); |
| 145 EXPECT_EQ(2u, rtcp.list.size()); |
| 146 EXPECT_EQ(kTs + 1, rtcp.list.front().rtp_timestamp); |
| 147 EXPECT_EQ(kTs + 0, rtcp.list.back().rtp_timestamp); |
| 148 // List should contain last two reports. |
| 149 EXPECT_TRUE(UpdateRtcpList(kNtpSec, kNtpFrac + 2 * kOneMsInNtpFrac, kTs + 2, |
| 150 &rtcp, &new_sr)); |
| 151 EXPECT_EQ(2u, rtcp.list.size()); |
| 152 EXPECT_EQ(kTs + 2, rtcp.list.front().rtp_timestamp); |
| 153 EXPECT_EQ(kTs + 1, rtcp.list.back().rtp_timestamp); |
| 154 } |
| 155 |
| 156 TEST(UpdateRtcpListTests, FailsForZeroNtp) { |
| 157 RtcpMeasurements rtcp; |
| 126 uint32_t ntp_sec = 0; | 158 uint32_t ntp_sec = 0; |
| 127 uint32_t ntp_frac = 0; | 159 uint32_t ntp_frac = 0; |
| 128 uint32_t timestamp = 0; | 160 uint32_t timestamp = 0x12345678; |
| 129 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 161 bool new_sr; |
| 162 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 163 EXPECT_FALSE(new_sr); |
| 164 EXPECT_EQ(0u, rtcp.list.size()); |
| 165 } |
| 166 |
| 167 TEST(UpdateRtcpListTests, FailsForEqualNtp) { |
| 168 RtcpMeasurements rtcp; |
| 169 uint32_t ntp_sec = 0; |
| 170 uint32_t ntp_frac = 699925050; |
| 171 uint32_t timestamp = 0x12345678; |
| 172 bool new_sr; |
| 173 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 174 EXPECT_TRUE(new_sr); |
| 175 EXPECT_EQ(1u, rtcp.list.size()); |
| 176 // Ntp time already added, list not updated. |
| 177 ++timestamp; |
| 178 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 179 EXPECT_FALSE(new_sr); |
| 180 EXPECT_EQ(1u, rtcp.list.size()); |
| 181 } |
| 182 |
| 183 TEST(UpdateRtcpListTests, FailsForOldNtp) { |
| 184 RtcpMeasurements rtcp; |
| 185 uint32_t ntp_sec = 1; |
| 186 uint32_t ntp_frac = 699925050; |
| 187 uint32_t timestamp = 0x12345678; |
| 188 bool new_sr; |
| 189 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 190 EXPECT_TRUE(new_sr); |
| 191 EXPECT_EQ(1u, rtcp.list.size()); |
| 192 // Old ntp time, list not updated. |
| 193 ntp_frac -= kOneMsInNtpFrac; |
| 194 timestamp += kTimestampTicksPerMs; |
| 195 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 196 EXPECT_EQ(1u, rtcp.list.size()); |
| 197 } |
| 198 |
| 199 TEST(UpdateRtcpListTests, FailsForEqualTimestamp) { |
| 200 RtcpMeasurements rtcp; |
| 201 uint32_t ntp_sec = 0; |
| 202 uint32_t ntp_frac = 2; |
| 203 uint32_t timestamp = 0x12345678; |
| 204 bool new_sr; |
| 205 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 206 EXPECT_TRUE(new_sr); |
| 207 EXPECT_EQ(1u, rtcp.list.size()); |
| 208 // Timestamp already added, list not updated. |
| 209 ++ntp_frac; |
| 210 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 211 EXPECT_FALSE(new_sr); |
| 212 EXPECT_EQ(1u, rtcp.list.size()); |
| 213 } |
| 214 |
| 215 TEST(UpdateRtcpListTests, FailsForOldRtpTimestamp) { |
| 216 RtcpMeasurements rtcp; |
| 217 uint32_t ntp_sec = 0; |
| 218 uint32_t ntp_frac = 2; |
| 219 uint32_t timestamp = 0x12345678; |
| 220 bool new_sr; |
| 221 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 222 EXPECT_TRUE(new_sr); |
| 223 EXPECT_EQ(1u, rtcp.list.size()); |
| 224 // Old timestamp, list not updated. |
| 130 ntp_frac += kOneMsInNtpFrac; | 225 ntp_frac += kOneMsInNtpFrac; |
| 131 timestamp -= kTimestampTicksPerMs; | 226 timestamp -= kTimestampTicksPerMs; |
| 132 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 227 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 133 ntp_frac += kOneMsInNtpFrac; | 228 EXPECT_FALSE(new_sr); |
| 134 timestamp += 2*kTimestampTicksPerMs; | 229 EXPECT_EQ(1u, rtcp.list.size()); |
| 135 int64_t timestamp_in_ms = -1; | 230 } |
| 136 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); | 231 |
| 137 } | 232 TEST(UpdateRtcpListTests, VerifyParameters) { |
| 138 | 233 RtcpMeasurements rtcp; |
| 139 TEST(RtpToNtpTests, FailsForDecreasingRtpTimestamp) { | 234 uint32_t ntp_sec = 1; |
| 140 const uint32_t kNtpSec1 = 3683354930; | 235 uint32_t ntp_frac = 2; |
| 141 const uint32_t kNtpFrac1 = 699925050; | 236 uint32_t timestamp = 0x12345678; |
| 142 const uint32_t kTimestamp1 = 2192705742; | 237 bool new_sr; |
| 143 const uint32_t kNtpSec2 = kNtpSec1; | 238 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 144 const uint32_t kNtpFrac2 = kNtpFrac1 + kOneMsInNtpFrac; | 239 EXPECT_TRUE(new_sr); |
| 145 const uint32_t kTimestamp2 = kTimestamp1 - kTimestampTicksPerMs; | 240 EXPECT_FALSE(rtcp.params.calculated); |
| 146 RtcpList rtcp; | 241 // Add second report, parameters should be calculated. |
| 147 rtcp.push_front(RtcpMeasurement(kNtpSec1, kNtpFrac1, kTimestamp1)); | 242 ntp_frac += kOneMsInNtpFrac; |
| 148 rtcp.push_front(RtcpMeasurement(kNtpSec2, kNtpFrac2, kTimestamp2)); | 243 timestamp += kTimestampTicksPerMs; |
| 149 int64_t timestamp_in_ms = -1; | 244 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 150 EXPECT_FALSE(RtpToNtpMs(kTimestamp1, rtcp, ×tamp_in_ms)); | 245 EXPECT_TRUE(rtcp.params.calculated); |
| 151 } | 246 EXPECT_DOUBLE_EQ(90.0, rtcp.params.frequency_khz); |
| 152 | 247 EXPECT_NE(0.0, rtcp.params.offset_ms); |
| 153 TEST(UpdateRtcpListTests, InjectRtcpSrWithEqualNtp) { | 248 } |
| 154 RtcpList rtcp; | 249 |
| 155 uint32_t ntp_sec = 0; | 250 TEST(RtpToNtpTests, FailsForEmptyList) { |
| 156 uint32_t ntp_frac = 2; | 251 RtcpMeasurements rtcp; |
| 157 uint32_t timestamp = 0x12345678; | 252 rtcp.params.calculated = true; |
| 158 | 253 // List is empty, conversion of RTP to NTP time should fail. |
| 159 bool new_sr; | 254 EXPECT_EQ(0u, rtcp.list.size()); |
| 160 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | 255 int64_t timestamp_ms = -1; |
| 161 EXPECT_TRUE(new_sr); | 256 EXPECT_FALSE(RtpToNtpMs(0, rtcp, ×tamp_ms)); |
| 162 | 257 } |
| 163 ++timestamp; | 258 |
| 164 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | 259 TEST(RtpToNtpTests, FailsForNoParameters) { |
| 165 EXPECT_FALSE(new_sr); | 260 RtcpMeasurements rtcp; |
| 166 } | 261 uint32_t ntp_sec = 1; |
| 167 | 262 uint32_t ntp_frac = 2; |
| 168 TEST(UpdateRtcpListTests, InjectRtcpSrWithEqualTimestamp) { | 263 uint32_t timestamp = 0x12345678; |
| 169 RtcpList rtcp; | 264 bool new_sr; |
| 170 uint32_t ntp_sec = 0; | 265 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 171 uint32_t ntp_frac = 2; | 266 EXPECT_EQ(1u, rtcp.list.size()); |
| 172 uint32_t timestamp = 0x12345678; | 267 // Parameters are not calculated, conversion of RTP to NTP time should fail. |
| 173 | 268 EXPECT_FALSE(rtcp.params.calculated); |
| 174 bool new_sr; | 269 int64_t timestamp_ms = -1; |
| 175 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | 270 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_ms)); |
| 176 EXPECT_TRUE(new_sr); | 271 } |
| 177 | 272 |
| 178 ++ntp_frac; | |
| 179 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 180 EXPECT_FALSE(new_sr); | |
| 181 } | |
| 182 | |
| 183 TEST(UpdateRtcpListTests, InjectRtcpSrWithZeroNtpFails) { | |
| 184 RtcpList rtcp; | |
| 185 uint32_t ntp_sec = 0; | |
| 186 uint32_t ntp_frac = 0; | |
| 187 uint32_t timestamp = 0x12345678; | |
| 188 | |
| 189 bool new_sr; | |
| 190 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 191 } | |
| 192 }; // namespace webrtc | 273 }; // namespace webrtc |
| OLD | NEW |