| 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 |
| 11 #include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h" | 11 #include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h" |
| 12 | 12 |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" | 15 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" |
| 16 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h" | 16 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h" |
| 17 #include "webrtc/modules/audio_coding/neteq/packet.h" | 17 #include "webrtc/modules/audio_coding/neteq/packet.h" |
| 18 | 18 |
| 19 using ::testing::Return; | 19 using ::testing::Return; |
| 20 using ::testing::ReturnNull; | 20 using ::testing::ReturnNull; |
| 21 using ::testing::_; | 21 using ::testing::_; |
| 22 | 22 |
| 23 namespace webrtc { | 23 namespace webrtc { |
| 24 | 24 |
| 25 TEST(TimestampScaler, TestNoScaling) { | 25 TEST(TimestampScaler, TestNoScaling) { |
| 26 MockDecoderDatabase db; | 26 MockDecoderDatabase db; |
| 27 auto factory = CreateBuiltinAudioDecoderFactory(); | 27 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 28 // Use PCMu, because it doesn't use scaled timestamps. | 28 // Use PCMu, because it doesn't use scaled timestamps. |
| 29 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, "", | 29 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, factory); |
| 30 factory); | |
| 31 static const uint8_t kRtpPayloadType = 0; | 30 static const uint8_t kRtpPayloadType = 0; |
| 32 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 31 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 33 .WillRepeatedly(Return(&info)); | 32 .WillRepeatedly(Return(&info)); |
| 34 | 33 |
| 35 TimestampScaler scaler(db); | 34 TimestampScaler scaler(db); |
| 36 // Test both sides of the timestamp wrap-around. | 35 // Test both sides of the timestamp wrap-around. |
| 37 for (uint32_t timestamp = 0xFFFFFFFF - 5; timestamp != 5; ++timestamp) { | 36 for (uint32_t timestamp = 0xFFFFFFFF - 5; timestamp != 5; ++timestamp) { |
| 38 // Scale to internal timestamp. | 37 // Scale to internal timestamp. |
| 39 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); | 38 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); |
| 40 // Scale back. | 39 // Scale back. |
| 41 EXPECT_EQ(timestamp, scaler.ToExternal(timestamp)); | 40 EXPECT_EQ(timestamp, scaler.ToExternal(timestamp)); |
| 42 } | 41 } |
| 43 | 42 |
| 44 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 43 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 45 } | 44 } |
| 46 | 45 |
| 47 TEST(TimestampScaler, TestNoScalingLargeStep) { | 46 TEST(TimestampScaler, TestNoScalingLargeStep) { |
| 48 MockDecoderDatabase db; | 47 MockDecoderDatabase db; |
| 49 auto factory = CreateBuiltinAudioDecoderFactory(); | 48 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 50 // Use PCMu, because it doesn't use scaled timestamps. | 49 // Use PCMu, because it doesn't use scaled timestamps. |
| 51 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, "", | 50 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, factory); |
| 52 factory); | |
| 53 static const uint8_t kRtpPayloadType = 0; | 51 static const uint8_t kRtpPayloadType = 0; |
| 54 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 52 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 55 .WillRepeatedly(Return(&info)); | 53 .WillRepeatedly(Return(&info)); |
| 56 | 54 |
| 57 TimestampScaler scaler(db); | 55 TimestampScaler scaler(db); |
| 58 // Test both sides of the timestamp wrap-around. | 56 // Test both sides of the timestamp wrap-around. |
| 59 static const uint32_t kStep = 160; | 57 static const uint32_t kStep = 160; |
| 60 uint32_t start_timestamp = 0; | 58 uint32_t start_timestamp = 0; |
| 61 // |external_timestamp| will be a large positive value. | 59 // |external_timestamp| will be a large positive value. |
| 62 start_timestamp = start_timestamp - 5 * kStep; | 60 start_timestamp = start_timestamp - 5 * kStep; |
| 63 for (uint32_t timestamp = start_timestamp; timestamp != 5 * kStep; | 61 for (uint32_t timestamp = start_timestamp; timestamp != 5 * kStep; |
| 64 timestamp += kStep) { | 62 timestamp += kStep) { |
| 65 // Scale to internal timestamp. | 63 // Scale to internal timestamp. |
| 66 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); | 64 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); |
| 67 // Scale back. | 65 // Scale back. |
| 68 EXPECT_EQ(timestamp, scaler.ToExternal(timestamp)); | 66 EXPECT_EQ(timestamp, scaler.ToExternal(timestamp)); |
| 69 } | 67 } |
| 70 | 68 |
| 71 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 69 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 72 } | 70 } |
| 73 | 71 |
| 74 TEST(TimestampScaler, TestG722) { | 72 TEST(TimestampScaler, TestG722) { |
| 75 MockDecoderDatabase db; | 73 MockDecoderDatabase db; |
| 76 auto factory = CreateBuiltinAudioDecoderFactory(); | 74 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 77 // Use G722, which has a factor 2 scaling. | 75 // Use G722, which has a factor 2 scaling. |
| 78 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, "", | 76 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); |
| 79 factory); | |
| 80 static const uint8_t kRtpPayloadType = 17; | 77 static const uint8_t kRtpPayloadType = 17; |
| 81 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 78 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 82 .WillRepeatedly(Return(&info)); | 79 .WillRepeatedly(Return(&info)); |
| 83 | 80 |
| 84 TimestampScaler scaler(db); | 81 TimestampScaler scaler(db); |
| 85 // Test both sides of the timestamp wrap-around. | 82 // Test both sides of the timestamp wrap-around. |
| 86 uint32_t external_timestamp = 0xFFFFFFFF - 5; | 83 uint32_t external_timestamp = 0xFFFFFFFF - 5; |
| 87 uint32_t internal_timestamp = external_timestamp; | 84 uint32_t internal_timestamp = external_timestamp; |
| 88 for (; external_timestamp != 5; ++external_timestamp) { | 85 for (; external_timestamp != 5; ++external_timestamp) { |
| 89 // Scale to internal timestamp. | 86 // Scale to internal timestamp. |
| 90 EXPECT_EQ(internal_timestamp, | 87 EXPECT_EQ(internal_timestamp, |
| 91 scaler.ToInternal(external_timestamp, kRtpPayloadType)); | 88 scaler.ToInternal(external_timestamp, kRtpPayloadType)); |
| 92 // Scale back. | 89 // Scale back. |
| 93 EXPECT_EQ(external_timestamp, scaler.ToExternal(internal_timestamp)); | 90 EXPECT_EQ(external_timestamp, scaler.ToExternal(internal_timestamp)); |
| 94 internal_timestamp += 2; | 91 internal_timestamp += 2; |
| 95 } | 92 } |
| 96 | 93 |
| 97 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 94 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 98 } | 95 } |
| 99 | 96 |
| 100 TEST(TimestampScaler, TestG722LargeStep) { | 97 TEST(TimestampScaler, TestG722LargeStep) { |
| 101 MockDecoderDatabase db; | 98 MockDecoderDatabase db; |
| 102 auto factory = CreateBuiltinAudioDecoderFactory(); | 99 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 103 // Use G722, which has a factor 2 scaling. | 100 // Use G722, which has a factor 2 scaling. |
| 104 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, "", | 101 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); |
| 105 factory); | |
| 106 static const uint8_t kRtpPayloadType = 17; | 102 static const uint8_t kRtpPayloadType = 17; |
| 107 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 103 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 108 .WillRepeatedly(Return(&info)); | 104 .WillRepeatedly(Return(&info)); |
| 109 | 105 |
| 110 TimestampScaler scaler(db); | 106 TimestampScaler scaler(db); |
| 111 // Test both sides of the timestamp wrap-around. | 107 // Test both sides of the timestamp wrap-around. |
| 112 static const uint32_t kStep = 320; | 108 static const uint32_t kStep = 320; |
| 113 uint32_t external_timestamp = 0; | 109 uint32_t external_timestamp = 0; |
| 114 // |external_timestamp| will be a large positive value. | 110 // |external_timestamp| will be a large positive value. |
| 115 external_timestamp = external_timestamp - 5 * kStep; | 111 external_timestamp = external_timestamp - 5 * kStep; |
| 116 uint32_t internal_timestamp = external_timestamp; | 112 uint32_t internal_timestamp = external_timestamp; |
| 117 for (; external_timestamp != 5 * kStep; external_timestamp += kStep) { | 113 for (; external_timestamp != 5 * kStep; external_timestamp += kStep) { |
| 118 // Scale to internal timestamp. | 114 // Scale to internal timestamp. |
| 119 EXPECT_EQ(internal_timestamp, | 115 EXPECT_EQ(internal_timestamp, |
| 120 scaler.ToInternal(external_timestamp, kRtpPayloadType)); | 116 scaler.ToInternal(external_timestamp, kRtpPayloadType)); |
| 121 // Scale back. | 117 // Scale back. |
| 122 EXPECT_EQ(external_timestamp, scaler.ToExternal(internal_timestamp)); | 118 EXPECT_EQ(external_timestamp, scaler.ToExternal(internal_timestamp)); |
| 123 // Internal timestamp should be incremented with twice the step. | 119 // Internal timestamp should be incremented with twice the step. |
| 124 internal_timestamp += 2 * kStep; | 120 internal_timestamp += 2 * kStep; |
| 125 } | 121 } |
| 126 | 122 |
| 127 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 123 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 128 } | 124 } |
| 129 | 125 |
| 130 TEST(TimestampScaler, TestG722WithCng) { | 126 TEST(TimestampScaler, TestG722WithCng) { |
| 131 MockDecoderDatabase db; | 127 MockDecoderDatabase db; |
| 132 auto factory = CreateBuiltinAudioDecoderFactory(); | 128 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 133 // Use G722, which has a factor 2 scaling. | 129 // Use G722, which has a factor 2 scaling. |
| 134 const DecoderDatabase::DecoderInfo info_g722(NetEqDecoder::kDecoderG722, "", | 130 const DecoderDatabase::DecoderInfo info_g722(NetEqDecoder::kDecoderG722, |
| 135 factory); | 131 factory); |
| 136 const DecoderDatabase::DecoderInfo info_cng(NetEqDecoder::kDecoderCNGwb, "", | 132 const DecoderDatabase::DecoderInfo info_cng(NetEqDecoder::kDecoderCNGwb, |
| 137 factory); | 133 factory); |
| 138 static const uint8_t kRtpPayloadTypeG722 = 17; | 134 static const uint8_t kRtpPayloadTypeG722 = 17; |
| 139 static const uint8_t kRtpPayloadTypeCng = 13; | 135 static const uint8_t kRtpPayloadTypeCng = 13; |
| 140 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadTypeG722)) | 136 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadTypeG722)) |
| 141 .WillRepeatedly(Return(&info_g722)); | 137 .WillRepeatedly(Return(&info_g722)); |
| 142 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadTypeCng)) | 138 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadTypeCng)) |
| 143 .WillRepeatedly(Return(&info_cng)); | 139 .WillRepeatedly(Return(&info_cng)); |
| 144 | 140 |
| 145 TimestampScaler scaler(db); | 141 TimestampScaler scaler(db); |
| 146 // Test both sides of the timestamp wrap-around. | 142 // Test both sides of the timestamp wrap-around. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 168 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 164 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 169 } | 165 } |
| 170 | 166 |
| 171 // Make sure that the method ToInternal(Packet* packet) is wired up correctly. | 167 // Make sure that the method ToInternal(Packet* packet) is wired up correctly. |
| 172 // Since it is simply calling the other ToInternal method, we are not doing | 168 // Since it is simply calling the other ToInternal method, we are not doing |
| 173 // as many tests here. | 169 // as many tests here. |
| 174 TEST(TimestampScaler, TestG722Packet) { | 170 TEST(TimestampScaler, TestG722Packet) { |
| 175 MockDecoderDatabase db; | 171 MockDecoderDatabase db; |
| 176 auto factory = CreateBuiltinAudioDecoderFactory(); | 172 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 177 // Use G722, which has a factor 2 scaling. | 173 // Use G722, which has a factor 2 scaling. |
| 178 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, "", | 174 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); |
| 179 factory); | |
| 180 static const uint8_t kRtpPayloadType = 17; | 175 static const uint8_t kRtpPayloadType = 17; |
| 181 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 176 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 182 .WillRepeatedly(Return(&info)); | 177 .WillRepeatedly(Return(&info)); |
| 183 | 178 |
| 184 TimestampScaler scaler(db); | 179 TimestampScaler scaler(db); |
| 185 // Test both sides of the timestamp wrap-around. | 180 // Test both sides of the timestamp wrap-around. |
| 186 uint32_t external_timestamp = 0xFFFFFFFF - 5; | 181 uint32_t external_timestamp = 0xFFFFFFFF - 5; |
| 187 uint32_t internal_timestamp = external_timestamp; | 182 uint32_t internal_timestamp = external_timestamp; |
| 188 Packet packet; | 183 Packet packet; |
| 189 packet.header.payloadType = kRtpPayloadType; | 184 packet.header.payloadType = kRtpPayloadType; |
| 190 for (; external_timestamp != 5; ++external_timestamp) { | 185 for (; external_timestamp != 5; ++external_timestamp) { |
| 191 packet.header.timestamp = external_timestamp; | 186 packet.header.timestamp = external_timestamp; |
| 192 // Scale to internal timestamp. | 187 // Scale to internal timestamp. |
| 193 scaler.ToInternal(&packet); | 188 scaler.ToInternal(&packet); |
| 194 EXPECT_EQ(internal_timestamp, packet.header.timestamp); | 189 EXPECT_EQ(internal_timestamp, packet.header.timestamp); |
| 195 internal_timestamp += 2; | 190 internal_timestamp += 2; |
| 196 } | 191 } |
| 197 | 192 |
| 198 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 193 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 199 } | 194 } |
| 200 | 195 |
| 201 // Make sure that the method ToInternal(PacketList* packet_list) is wired up | 196 // Make sure that the method ToInternal(PacketList* packet_list) is wired up |
| 202 // correctly. Since it is simply calling the ToInternal(Packet* packet) method, | 197 // correctly. Since it is simply calling the ToInternal(Packet* packet) method, |
| 203 // we are not doing as many tests here. | 198 // we are not doing as many tests here. |
| 204 TEST(TimestampScaler, TestG722PacketList) { | 199 TEST(TimestampScaler, TestG722PacketList) { |
| 205 MockDecoderDatabase db; | 200 MockDecoderDatabase db; |
| 206 auto factory = CreateBuiltinAudioDecoderFactory(); | 201 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 207 // Use G722, which has a factor 2 scaling. | 202 // Use G722, which has a factor 2 scaling. |
| 208 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, "", | 203 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); |
| 209 factory); | |
| 210 static const uint8_t kRtpPayloadType = 17; | 204 static const uint8_t kRtpPayloadType = 17; |
| 211 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 205 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 212 .WillRepeatedly(Return(&info)); | 206 .WillRepeatedly(Return(&info)); |
| 213 | 207 |
| 214 TimestampScaler scaler(db); | 208 TimestampScaler scaler(db); |
| 215 // Test both sides of the timestamp wrap-around. | 209 // Test both sides of the timestamp wrap-around. |
| 216 uint32_t external_timestamp = 0xFFFFFFFF - 5; | 210 uint32_t external_timestamp = 0xFFFFFFFF - 5; |
| 217 uint32_t internal_timestamp = external_timestamp; | 211 uint32_t internal_timestamp = external_timestamp; |
| 218 Packet packet1; | 212 Packet packet1; |
| 219 packet1.header.payloadType = kRtpPayloadType; | 213 packet1.header.payloadType = kRtpPayloadType; |
| 220 packet1.header.timestamp = external_timestamp; | 214 packet1.header.timestamp = external_timestamp; |
| 221 Packet packet2; | 215 Packet packet2; |
| 222 packet2.header.payloadType = kRtpPayloadType; | 216 packet2.header.payloadType = kRtpPayloadType; |
| 223 packet2.header.timestamp = external_timestamp + 10; | 217 packet2.header.timestamp = external_timestamp + 10; |
| 224 PacketList packet_list; | 218 PacketList packet_list; |
| 225 packet_list.push_back(&packet1); | 219 packet_list.push_back(&packet1); |
| 226 packet_list.push_back(&packet2); | 220 packet_list.push_back(&packet2); |
| 227 | 221 |
| 228 scaler.ToInternal(&packet_list); | 222 scaler.ToInternal(&packet_list); |
| 229 EXPECT_EQ(internal_timestamp, packet1.header.timestamp); | 223 EXPECT_EQ(internal_timestamp, packet1.header.timestamp); |
| 230 EXPECT_EQ(internal_timestamp + 20, packet2.header.timestamp); | 224 EXPECT_EQ(internal_timestamp + 20, packet2.header.timestamp); |
| 231 | 225 |
| 232 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 226 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 233 } | 227 } |
| 234 | 228 |
| 235 TEST(TimestampScaler, TestG722Reset) { | 229 TEST(TimestampScaler, TestG722Reset) { |
| 236 MockDecoderDatabase db; | 230 MockDecoderDatabase db; |
| 237 auto factory = CreateBuiltinAudioDecoderFactory(); | 231 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 238 // Use G722, which has a factor 2 scaling. | 232 // Use G722, which has a factor 2 scaling. |
| 239 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, "", | 233 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); |
| 240 factory); | |
| 241 static const uint8_t kRtpPayloadType = 17; | 234 static const uint8_t kRtpPayloadType = 17; |
| 242 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 235 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 243 .WillRepeatedly(Return(&info)); | 236 .WillRepeatedly(Return(&info)); |
| 244 | 237 |
| 245 TimestampScaler scaler(db); | 238 TimestampScaler scaler(db); |
| 246 // Test both sides of the timestamp wrap-around. | 239 // Test both sides of the timestamp wrap-around. |
| 247 uint32_t external_timestamp = 0xFFFFFFFF - 5; | 240 uint32_t external_timestamp = 0xFFFFFFFF - 5; |
| 248 uint32_t internal_timestamp = external_timestamp; | 241 uint32_t internal_timestamp = external_timestamp; |
| 249 for (; external_timestamp != 5; ++external_timestamp) { | 242 for (; external_timestamp != 5; ++external_timestamp) { |
| 250 // Scale to internal timestamp. | 243 // Scale to internal timestamp. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 270 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 263 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 271 } | 264 } |
| 272 | 265 |
| 273 // TODO(minyue): This test becomes trivial since Opus does not need a timestamp | 266 // TODO(minyue): This test becomes trivial since Opus does not need a timestamp |
| 274 // scaler. Therefore, this test may be removed in future. There is no harm to | 267 // scaler. Therefore, this test may be removed in future. There is no harm to |
| 275 // keep it, since it can be taken as a test case for the situation of a trivial | 268 // keep it, since it can be taken as a test case for the situation of a trivial |
| 276 // timestamp scaler. | 269 // timestamp scaler. |
| 277 TEST(TimestampScaler, TestOpusLargeStep) { | 270 TEST(TimestampScaler, TestOpusLargeStep) { |
| 278 MockDecoderDatabase db; | 271 MockDecoderDatabase db; |
| 279 auto factory = CreateBuiltinAudioDecoderFactory(); | 272 auto factory = CreateBuiltinAudioDecoderFactory(); |
| 280 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderOpus, "", | 273 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderOpus, factory); |
| 281 factory); | |
| 282 static const uint8_t kRtpPayloadType = 17; | 274 static const uint8_t kRtpPayloadType = 17; |
| 283 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 275 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
| 284 .WillRepeatedly(Return(&info)); | 276 .WillRepeatedly(Return(&info)); |
| 285 | 277 |
| 286 TimestampScaler scaler(db); | 278 TimestampScaler scaler(db); |
| 287 // Test both sides of the timestamp wrap-around. | 279 // Test both sides of the timestamp wrap-around. |
| 288 static const uint32_t kStep = 960; | 280 static const uint32_t kStep = 960; |
| 289 uint32_t external_timestamp = 0; | 281 uint32_t external_timestamp = 0; |
| 290 // |external_timestamp| will be a large positive value. | 282 // |external_timestamp| will be a large positive value. |
| 291 external_timestamp = external_timestamp - 5 * kStep; | 283 external_timestamp = external_timestamp - 5 * kStep; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 312 uint32_t timestamp = 4711; // Some number. | 304 uint32_t timestamp = 4711; // Some number. |
| 313 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); | 305 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); |
| 314 | 306 |
| 315 Packet* packet = NULL; | 307 Packet* packet = NULL; |
| 316 scaler.ToInternal(packet); // Should not crash. That's all we can test. | 308 scaler.ToInternal(packet); // Should not crash. That's all we can test. |
| 317 | 309 |
| 318 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 310 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
| 319 } | 311 } |
| 320 | 312 |
| 321 } // namespace webrtc | 313 } // namespace webrtc |
| OLD | NEW |