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