Chromium Code Reviews| 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 bool new_sr; | |
| 42 uint32_t ntp_sec = 0; | 43 uint32_t ntp_sec = 0; |
| 43 uint32_t ntp_frac = 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; |
| 56 bool new_sr; | |
| 59 uint32_t ntp_sec = 0; | 57 uint32_t ntp_sec = 0; |
| 60 uint32_t ntp_frac = 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_in_ms = -1; |
| 67 EXPECT_TRUE(RtpToNtpMs(rtcp.back().rtp_timestamp, rtcp, ×tamp_in_ms)); | 65 EXPECT_TRUE( |
| 66 RtpToNtpMs(rtcp.list.back().rtp_timestamp, rtcp, ×tamp_in_ms)); | |
| 68 // Since this RTP packet has the same timestamp as the RTCP packet constructed | 67 // 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. | 68 // at time 0 it should be mapped to 0 as well. |
| 70 EXPECT_EQ(0, timestamp_in_ms); | 69 EXPECT_EQ(0, timestamp_in_ms); |
| 71 } | 70 } |
| 72 | 71 |
| 73 TEST(WrapAroundTests, RtpWrapped) { | 72 TEST(WrapAroundTests, RtpWrapped) { |
| 74 RtcpList rtcp; | 73 RtcpMeasurements rtcp; |
| 74 bool new_sr; | |
| 75 uint32_t ntp_sec = 0; | 75 uint32_t ntp_sec = 0; |
| 76 uint32_t ntp_frac = 0; | 76 uint32_t ntp_frac = 1; |
| 77 uint32_t timestamp = 0xFFFFFFFF - 2 * kTimestampTicksPerMs; | 77 uint32_t timestamp = 0xFFFFFFFF - 2 * kTimestampTicksPerMs; |
| 78 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 78 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 79 ntp_frac += kOneMsInNtpFrac; | 79 ntp_frac += kOneMsInNtpFrac; |
| 80 timestamp += kTimestampTicksPerMs; | 80 timestamp += kTimestampTicksPerMs; |
| 81 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 81 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 82 ntp_frac += kOneMsInNtpFrac; | 82 |
| 83 timestamp += kTimestampTicksPerMs; | 83 int64_t timestamp_ms = -1; |
| 84 int64_t timestamp_in_ms = -1; | 84 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 | 85 // 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. | 86 // at time 0 it should be mapped to 0 as well. |
| 88 EXPECT_EQ(2, timestamp_in_ms); | 87 EXPECT_EQ(0, timestamp_ms); |
| 88 // Two kTimestampTicksPerMs advanced. | |
| 89 timestamp += kTimestampTicksPerMs; | |
| 90 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_ms)); | |
| 91 EXPECT_EQ(2, timestamp_ms); | |
| 92 // Wrapped rtp. | |
| 93 timestamp += kTimestampTicksPerMs; | |
| 94 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_ms)); | |
| 95 EXPECT_EQ(3, timestamp_ms); | |
| 89 } | 96 } |
| 90 | 97 |
| 91 TEST(WrapAroundTests, OldRtp_RtcpsWrapped) { | 98 TEST(WrapAroundTests, OldRtp_RtcpsWrapped) { |
| 92 RtcpList rtcp; | 99 RtcpMeasurements rtcp; |
| 100 bool new_sr; | |
| 93 uint32_t ntp_sec = 0; | 101 uint32_t ntp_sec = 0; |
| 94 uint32_t ntp_frac = 0; | 102 uint32_t ntp_frac = 1; |
| 95 uint32_t timestamp = 0; | 103 uint32_t timestamp = 0; |
| 96 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 104 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 97 ntp_frac += kOneMsInNtpFrac; | 105 ntp_frac += kOneMsInNtpFrac; |
| 98 timestamp += kTimestampTicksPerMs; | 106 timestamp += kTimestampTicksPerMs; |
| 99 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 107 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 100 ntp_frac += kOneMsInNtpFrac; | 108 ntp_frac += kOneMsInNtpFrac; |
| 101 timestamp -= 2*kTimestampTicksPerMs; | 109 timestamp -= 2*kTimestampTicksPerMs; |
| 102 int64_t timestamp_in_ms = -1; | 110 int64_t timestamp_in_ms = -1; |
| 103 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); | 111 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); |
| 104 } | 112 } |
| 105 | 113 |
| 106 TEST(WrapAroundTests, OldRtp_NewRtcpWrapped) { | 114 TEST(WrapAroundTests, OldRtp_NewRtcpWrapped) { |
| 107 RtcpList rtcp; | 115 RtcpMeasurements rtcp; |
| 116 bool new_sr; | |
| 108 uint32_t ntp_sec = 0; | 117 uint32_t ntp_sec = 0; |
| 109 uint32_t ntp_frac = 0; | 118 uint32_t ntp_frac = 1; |
| 110 uint32_t timestamp = 0xFFFFFFFF; | 119 uint32_t timestamp = 0xFFFFFFFF; |
| 111 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 120 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 112 ntp_frac += kOneMsInNtpFrac; | 121 ntp_frac += kOneMsInNtpFrac; |
| 113 timestamp += kTimestampTicksPerMs; | 122 timestamp += kTimestampTicksPerMs; |
| 114 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | 123 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 115 ntp_frac += kOneMsInNtpFrac; | 124 ntp_frac += kOneMsInNtpFrac; |
| 116 timestamp -= kTimestampTicksPerMs; | 125 timestamp -= kTimestampTicksPerMs; |
| 117 int64_t timestamp_in_ms = -1; | 126 int64_t timestamp_in_ms = -1; |
| 118 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); | 127 EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); |
| 119 // Constructed at the same time as the first RTCP and should therefore be | 128 // Constructed at the same time as the first RTCP and should therefore be |
| 120 // mapped to zero. | 129 // mapped to zero. |
| 121 EXPECT_EQ(0, timestamp_in_ms); | 130 EXPECT_EQ(0, timestamp_in_ms); |
| 122 } | 131 } |
| 123 | 132 |
| 124 TEST(WrapAroundTests, OldRtp_OldRtcpWrapped) { | 133 TEST(UpdateRtcpListTests, InjectRtcpSr) { |
| 125 RtcpList rtcp; | 134 const uint32_t kNtpSec = 10; |
| 135 const uint32_t kNtpFrac = 12345; | |
| 136 const uint32_t kTs = 0x12345678; | |
| 137 bool new_sr; | |
| 138 RtcpMeasurements rtcp; | |
| 139 EXPECT_TRUE(UpdateRtcpList(kNtpSec, kNtpFrac, kTs, &rtcp, &new_sr)); | |
| 140 EXPECT_TRUE(new_sr); | |
| 141 EXPECT_EQ(1u, rtcp.list.size()); | |
| 142 EXPECT_EQ(kNtpSec, rtcp.list.front().ntp_secs); | |
| 143 EXPECT_EQ(kNtpFrac, rtcp.list.front().ntp_frac); | |
| 144 EXPECT_EQ(kTs, rtcp.list.front().rtp_timestamp); | |
| 145 // Add second report. | |
| 146 EXPECT_TRUE(UpdateRtcpList(kNtpSec, kNtpFrac + kOneMsInNtpFrac, kTs + 1, | |
| 147 &rtcp, &new_sr)); | |
| 148 EXPECT_EQ(2u, rtcp.list.size()); | |
| 149 EXPECT_EQ(kTs + 1, rtcp.list.front().rtp_timestamp); | |
| 150 EXPECT_EQ(kTs + 0, rtcp.list.back().rtp_timestamp); | |
| 151 // List contains last two reports. | |
| 152 EXPECT_TRUE(UpdateRtcpList(kNtpSec, kNtpFrac + 2 * kOneMsInNtpFrac, kTs + 2, | |
| 153 &rtcp, &new_sr)); | |
| 154 EXPECT_EQ(2u, rtcp.list.size()); | |
| 155 EXPECT_EQ(kTs + 2, rtcp.list.front().rtp_timestamp); | |
| 156 EXPECT_EQ(kTs + 1, rtcp.list.back().rtp_timestamp); | |
| 157 } | |
| 158 | |
| 159 TEST(UpdateRtcpListTests, FailsForZeroNtp) { | |
|
stefan-webrtc
2016/10/18 23:38:27
Could you comment on why we decide to fail on zero
åsapersson
2016/10/19 14:35:28
Done. Added comment.
| |
| 160 RtcpMeasurements rtcp; | |
| 126 uint32_t ntp_sec = 0; | 161 uint32_t ntp_sec = 0; |
| 127 uint32_t ntp_frac = 0; | 162 uint32_t ntp_frac = 0; |
| 128 uint32_t timestamp = 0; | |
| 129 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | |
| 130 ntp_frac += kOneMsInNtpFrac; | |
| 131 timestamp -= kTimestampTicksPerMs; | |
| 132 rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp)); | |
| 133 ntp_frac += kOneMsInNtpFrac; | |
| 134 timestamp += 2*kTimestampTicksPerMs; | |
| 135 int64_t timestamp_in_ms = -1; | |
| 136 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_in_ms)); | |
| 137 } | |
| 138 | |
| 139 TEST(RtpToNtpTests, FailsForDecreasingRtpTimestamp) { | |
| 140 const uint32_t kNtpSec1 = 3683354930; | |
| 141 const uint32_t kNtpFrac1 = 699925050; | |
| 142 const uint32_t kTimestamp1 = 2192705742; | |
| 143 const uint32_t kNtpSec2 = kNtpSec1; | |
| 144 const uint32_t kNtpFrac2 = kNtpFrac1 + kOneMsInNtpFrac; | |
| 145 const uint32_t kTimestamp2 = kTimestamp1 - kTimestampTicksPerMs; | |
| 146 RtcpList rtcp; | |
| 147 rtcp.push_front(RtcpMeasurement(kNtpSec1, kNtpFrac1, kTimestamp1)); | |
| 148 rtcp.push_front(RtcpMeasurement(kNtpSec2, kNtpFrac2, kTimestamp2)); | |
| 149 int64_t timestamp_in_ms = -1; | |
| 150 EXPECT_FALSE(RtpToNtpMs(kTimestamp1, rtcp, ×tamp_in_ms)); | |
| 151 } | |
| 152 | |
| 153 TEST(UpdateRtcpListTests, InjectRtcpSrWithEqualNtp) { | |
| 154 RtcpList rtcp; | |
| 155 uint32_t ntp_sec = 0; | |
| 156 uint32_t ntp_frac = 2; | |
| 157 uint32_t timestamp = 0x12345678; | 163 uint32_t timestamp = 0x12345678; |
| 158 | 164 |
| 159 bool new_sr; | 165 bool new_sr; |
| 166 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 167 EXPECT_FALSE(new_sr); | |
| 168 EXPECT_EQ(0u, rtcp.list.size()); | |
| 169 } | |
| 170 | |
| 171 TEST(UpdateRtcpListTests, FailsForEqualNtp) { | |
| 172 RtcpMeasurements rtcp; | |
| 173 uint32_t ntp_sec = 0; | |
| 174 uint32_t ntp_frac = 699925050; | |
| 175 uint32_t timestamp = 0x12345678; | |
| 176 | |
| 177 bool new_sr; | |
| 160 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | 178 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 161 EXPECT_TRUE(new_sr); | 179 EXPECT_TRUE(new_sr); |
| 162 | 180 |
| 163 ++timestamp; | 181 ++timestamp; |
| 164 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | 182 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 165 EXPECT_FALSE(new_sr); | 183 EXPECT_FALSE(new_sr); |
| 184 EXPECT_EQ(1u, rtcp.list.size()); | |
| 166 } | 185 } |
| 167 | 186 |
| 168 TEST(UpdateRtcpListTests, InjectRtcpSrWithEqualTimestamp) { | 187 TEST(UpdateRtcpListTests, FailsForOldNtp) { |
| 169 RtcpList rtcp; | 188 RtcpMeasurements rtcp; |
| 189 uint32_t ntp_sec = 1; | |
| 190 uint32_t ntp_frac = 699925050; | |
| 191 uint32_t timestamp = 0x12345678; | |
| 192 | |
| 193 bool new_sr; | |
| 194 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 195 EXPECT_TRUE(new_sr); | |
| 196 | |
| 197 ntp_frac -= kOneMsInNtpFrac; | |
| 198 timestamp += kTimestampTicksPerMs; | |
| 199 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 200 EXPECT_EQ(1u, rtcp.list.size()); | |
| 201 } | |
| 202 | |
| 203 TEST(UpdateRtcpListTests, FailsForEqualTimestamp) { | |
| 204 RtcpMeasurements rtcp; | |
| 170 uint32_t ntp_sec = 0; | 205 uint32_t ntp_sec = 0; |
| 171 uint32_t ntp_frac = 2; | 206 uint32_t ntp_frac = 2; |
| 172 uint32_t timestamp = 0x12345678; | 207 uint32_t timestamp = 0x12345678; |
| 173 | 208 |
| 174 bool new_sr; | 209 bool new_sr; |
| 175 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | 210 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 176 EXPECT_TRUE(new_sr); | 211 EXPECT_TRUE(new_sr); |
| 177 | 212 |
| 178 ++ntp_frac; | 213 ++ntp_frac; |
| 179 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | 214 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 180 EXPECT_FALSE(new_sr); | 215 EXPECT_FALSE(new_sr); |
| 216 EXPECT_EQ(1u, rtcp.list.size()); | |
| 181 } | 217 } |
| 182 | 218 |
| 183 TEST(UpdateRtcpListTests, InjectRtcpSrWithZeroNtpFails) { | 219 TEST(UpdateRtcpListTests, FailsForOldRtpTimestamp) { |
| 184 RtcpList rtcp; | 220 RtcpMeasurements rtcp; |
| 185 uint32_t ntp_sec = 0; | 221 uint32_t ntp_sec = 0; |
| 186 uint32_t ntp_frac = 0; | 222 uint32_t ntp_frac = 2; |
| 187 uint32_t timestamp = 0x12345678; | 223 uint32_t timestamp = 0x12345678; |
| 188 | 224 |
| 189 bool new_sr; | 225 bool new_sr; |
| 226 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 227 EXPECT_TRUE(new_sr); | |
| 228 | |
| 229 ntp_frac += kOneMsInNtpFrac; | |
| 230 timestamp -= kTimestampTicksPerMs; | |
| 190 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | 231 EXPECT_FALSE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); |
| 232 EXPECT_FALSE(new_sr); | |
| 233 EXPECT_EQ(1u, rtcp.list.size()); | |
| 191 } | 234 } |
| 235 | |
| 236 TEST(UpdateRtcpListTests, VerifyParameters) { | |
| 237 RtcpMeasurements rtcp; | |
| 238 uint32_t ntp_sec = 1; | |
| 239 uint32_t ntp_frac = 2; | |
| 240 uint32_t timestamp = 0x12345678; | |
| 241 | |
| 242 bool new_sr; | |
| 243 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 244 EXPECT_TRUE(new_sr); | |
| 245 EXPECT_FALSE(rtcp.params.calculated); | |
| 246 | |
| 247 ntp_frac += kOneMsInNtpFrac; | |
| 248 timestamp += kTimestampTicksPerMs; | |
| 249 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 250 EXPECT_TRUE(rtcp.params.calculated); | |
| 251 EXPECT_DOUBLE_EQ(90.0, rtcp.params.frequency_khz); | |
| 252 EXPECT_NE(0.0, rtcp.params.offset_ms); | |
| 253 } | |
| 254 | |
| 255 TEST(RtpToNtpTests, FailsForEmptyList) { | |
| 256 RtcpMeasurements rtcp; | |
| 257 rtcp.params.calculated = true; | |
| 258 | |
| 259 int64_t timestamp_ms = -1; | |
| 260 EXPECT_EQ(0u, rtcp.list.size()); | |
| 261 EXPECT_FALSE(RtpToNtpMs(0, rtcp, ×tamp_ms)); | |
| 262 } | |
| 263 | |
| 264 TEST(RtpToNtpTests, FailsForNoParameters) { | |
| 265 RtcpMeasurements rtcp; | |
| 266 uint32_t ntp_sec = 1; | |
| 267 uint32_t ntp_frac = 2; | |
| 268 uint32_t timestamp = 0x12345678; | |
| 269 bool new_sr; | |
| 270 EXPECT_TRUE(UpdateRtcpList(ntp_sec, ntp_frac, timestamp, &rtcp, &new_sr)); | |
| 271 | |
| 272 int64_t timestamp_ms = -1; | |
| 273 EXPECT_EQ(1u, rtcp.list.size()); | |
| 274 EXPECT_FALSE(rtcp.params.calculated); | |
| 275 EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, ×tamp_ms)); | |
| 276 } | |
| 277 | |
| 192 }; // namespace webrtc | 278 }; // namespace webrtc |
| OLD | NEW |