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