| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 EXPECT_EQ(internal_timestamp, | 276 EXPECT_EQ(internal_timestamp, |
| 277 scaler.ToInternal(external_timestamp, kRtpPayloadType)); | 277 scaler.ToInternal(external_timestamp, kRtpPayloadType)); |
| 278 // Scale back. | 278 // Scale back. |
| 279 EXPECT_EQ(external_timestamp, scaler.ToExternal(internal_timestamp)); | 279 EXPECT_EQ(external_timestamp, scaler.ToExternal(internal_timestamp)); |
| 280 internal_timestamp += kStep; | 280 internal_timestamp += kStep; |
| 281 } | 281 } |
| 282 | 282 |
| 283 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 283 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 284 } | 284 } |
| 285 | 285 |
| 286 TEST(TimestampScaler, TestIsacFbLargeStep) { | |
| 287 MockDecoderDatabase db; | |
| 288 DecoderDatabase::DecoderInfo info; | |
| 289 info.codec_type = kDecoderISACfb; | |
| 290 static const uint8_t kRtpPayloadType = 17; | |
| 291 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | |
| 292 .WillRepeatedly(Return(&info)); | |
| 293 | |
| 294 TimestampScaler scaler(db); | |
| 295 // Test both sides of the timestamp wrap-around. | |
| 296 static const uint32_t kStep = 960; | |
| 297 uint32_t external_timestamp = 0; | |
| 298 // |external_timestamp| will be a large positive value. | |
| 299 external_timestamp = external_timestamp - 5 * kStep; | |
| 300 uint32_t internal_timestamp = external_timestamp; | |
| 301 for (; external_timestamp != 5 * kStep; external_timestamp += kStep) { | |
| 302 // Scale to internal timestamp. | |
| 303 EXPECT_EQ(internal_timestamp, | |
| 304 scaler.ToInternal(external_timestamp, kRtpPayloadType)); | |
| 305 // Scale back. | |
| 306 EXPECT_EQ(external_timestamp, scaler.ToExternal(internal_timestamp)); | |
| 307 // Internal timestamp should be incremented with two-thirds the step. | |
| 308 internal_timestamp += 2 * kStep / 3; | |
| 309 } | |
| 310 | |
| 311 EXPECT_CALL(db, Die()); // Called when database object is deleted. | |
| 312 } | |
| 313 | |
| 314 TEST(TimestampScaler, Failures) { | 286 TEST(TimestampScaler, Failures) { |
| 315 static const uint8_t kRtpPayloadType = 17; | 287 static const uint8_t kRtpPayloadType = 17; |
| 316 MockDecoderDatabase db; | 288 MockDecoderDatabase db; |
| 317 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 289 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 318 .WillOnce(ReturnNull()); // Return NULL to indicate unknown payload type. | 290 .WillOnce(ReturnNull()); // Return NULL to indicate unknown payload type. |
| 319 | 291 |
| 320 TimestampScaler scaler(db); | 292 TimestampScaler scaler(db); |
| 321 uint32_t timestamp = 4711; // Some number. | 293 uint32_t timestamp = 4711; // Some number. |
| 322 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); | 294 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); |
| 323 | 295 |
| 324 Packet* packet = NULL; | 296 Packet* packet = NULL; |
| 325 scaler.ToInternal(packet); // Should not crash. That's all we can test. | 297 scaler.ToInternal(packet); // Should not crash. That's all we can test. |
| 326 | 298 |
| 327 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 299 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 328 } | 300 } |
| 329 | 301 |
| 330 } // namespace webrtc | 302 } // namespace webrtc |
| OLD | NEW |