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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); | 174 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); |
175 static const uint8_t kRtpPayloadType = 17; | 175 static const uint8_t kRtpPayloadType = 17; |
176 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 176 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
177 .WillRepeatedly(Return(&info)); | 177 .WillRepeatedly(Return(&info)); |
178 | 178 |
179 TimestampScaler scaler(db); | 179 TimestampScaler scaler(db); |
180 // Test both sides of the timestamp wrap-around. | 180 // Test both sides of the timestamp wrap-around. |
181 uint32_t external_timestamp = 0xFFFFFFFF - 5; | 181 uint32_t external_timestamp = 0xFFFFFFFF - 5; |
182 uint32_t internal_timestamp = external_timestamp; | 182 uint32_t internal_timestamp = external_timestamp; |
183 Packet packet; | 183 Packet packet; |
184 packet.header.payloadType = kRtpPayloadType; | 184 packet.payloadType = kRtpPayloadType; |
185 for (; external_timestamp != 5; ++external_timestamp) { | 185 for (; external_timestamp != 5; ++external_timestamp) { |
186 packet.header.timestamp = external_timestamp; | 186 packet.timestamp = external_timestamp; |
187 // Scale to internal timestamp. | 187 // Scale to internal timestamp. |
188 scaler.ToInternal(&packet); | 188 scaler.ToInternal(&packet); |
189 EXPECT_EQ(internal_timestamp, packet.header.timestamp); | 189 EXPECT_EQ(internal_timestamp, packet.timestamp); |
190 internal_timestamp += 2; | 190 internal_timestamp += 2; |
191 } | 191 } |
192 | 192 |
193 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 193 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
194 } | 194 } |
195 | 195 |
196 // 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 |
197 // correctly. Since it is simply calling the ToInternal(Packet* packet) method, | 197 // correctly. Since it is simply calling the ToInternal(Packet* packet) method, |
198 // we are not doing as many tests here. | 198 // we are not doing as many tests here. |
199 TEST(TimestampScaler, TestG722PacketList) { | 199 TEST(TimestampScaler, TestG722PacketList) { |
200 MockDecoderDatabase db; | 200 MockDecoderDatabase db; |
201 auto factory = CreateBuiltinAudioDecoderFactory(); | 201 auto factory = CreateBuiltinAudioDecoderFactory(); |
202 // Use G722, which has a factor 2 scaling. | 202 // Use G722, which has a factor 2 scaling. |
203 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); | 203 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); |
204 static const uint8_t kRtpPayloadType = 17; | 204 static const uint8_t kRtpPayloadType = 17; |
205 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) | 205 EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) |
206 .WillRepeatedly(Return(&info)); | 206 .WillRepeatedly(Return(&info)); |
207 | 207 |
208 TimestampScaler scaler(db); | 208 TimestampScaler scaler(db); |
209 // Test both sides of the timestamp wrap-around. | 209 // Test both sides of the timestamp wrap-around. |
210 uint32_t external_timestamp = 0xFFFFFFFF - 5; | 210 uint32_t external_timestamp = 0xFFFFFFFF - 5; |
211 uint32_t internal_timestamp = external_timestamp; | 211 uint32_t internal_timestamp = external_timestamp; |
212 Packet packet1; | 212 Packet packet1; |
213 packet1.header.payloadType = kRtpPayloadType; | 213 packet1.payloadType = kRtpPayloadType; |
214 packet1.header.timestamp = external_timestamp; | 214 packet1.timestamp = external_timestamp; |
215 Packet packet2; | 215 Packet packet2; |
216 packet2.header.payloadType = kRtpPayloadType; | 216 packet2.payloadType = kRtpPayloadType; |
217 packet2.header.timestamp = external_timestamp + 10; | 217 packet2.timestamp = external_timestamp + 10; |
218 PacketList packet_list; | 218 PacketList packet_list; |
219 packet_list.push_back(&packet1); | 219 packet_list.push_back(&packet1); |
220 packet_list.push_back(&packet2); | 220 packet_list.push_back(&packet2); |
221 | 221 |
222 scaler.ToInternal(&packet_list); | 222 scaler.ToInternal(&packet_list); |
223 EXPECT_EQ(internal_timestamp, packet1.header.timestamp); | 223 EXPECT_EQ(internal_timestamp, packet1.timestamp); |
224 EXPECT_EQ(internal_timestamp + 20, packet2.header.timestamp); | 224 EXPECT_EQ(internal_timestamp + 20, packet2.timestamp); |
225 | 225 |
226 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 226 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
227 } | 227 } |
228 | 228 |
229 TEST(TimestampScaler, TestG722Reset) { | 229 TEST(TimestampScaler, TestG722Reset) { |
230 MockDecoderDatabase db; | 230 MockDecoderDatabase db; |
231 auto factory = CreateBuiltinAudioDecoderFactory(); | 231 auto factory = CreateBuiltinAudioDecoderFactory(); |
232 // Use G722, which has a factor 2 scaling. | 232 // Use G722, which has a factor 2 scaling. |
233 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); | 233 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722, factory); |
234 static const uint8_t kRtpPayloadType = 17; | 234 static const uint8_t kRtpPayloadType = 17; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 uint32_t timestamp = 4711; // Some number. | 304 uint32_t timestamp = 4711; // Some number. |
305 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); | 305 EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); |
306 | 306 |
307 Packet* packet = NULL; | 307 Packet* packet = NULL; |
308 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. |
309 | 309 |
310 EXPECT_CALL(db, Die()); // Called when database object is deleted. | 310 EXPECT_CALL(db, Die()); // Called when database object is deleted. |
311 } | 311 } |
312 | 312 |
313 } // namespace webrtc | 313 } // namespace webrtc |
OLD | NEW |