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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 const uint16_t kFirstSequenceNumber = 0x1234; | 252 const uint16_t kFirstSequenceNumber = 0x1234; |
253 const uint32_t kFirstTimestamp = 0x12345678; | 253 const uint32_t kFirstTimestamp = 0x12345678; |
254 const uint32_t kSsrc = 0x87654321; | 254 const uint32_t kSsrc = 0x87654321; |
255 const uint32_t kFirstReceiveTime = 17; | 255 const uint32_t kFirstReceiveTime = 17; |
256 uint8_t payload[kPayloadLength] = {0}; | 256 uint8_t payload[kPayloadLength] = {0}; |
257 WebRtcRTPHeader rtp_header; | 257 WebRtcRTPHeader rtp_header; |
258 rtp_header.header.payloadType = kPayloadType; | 258 rtp_header.header.payloadType = kPayloadType; |
259 rtp_header.header.sequenceNumber = kFirstSequenceNumber; | 259 rtp_header.header.sequenceNumber = kFirstSequenceNumber; |
260 rtp_header.header.timestamp = kFirstTimestamp; | 260 rtp_header.header.timestamp = kFirstTimestamp; |
261 rtp_header.header.ssrc = kSsrc; | 261 rtp_header.header.ssrc = kSsrc; |
| 262 Packet fake_packet; |
| 263 fake_packet.payload_type = kPayloadType; |
| 264 fake_packet.sequence_number = kFirstSequenceNumber; |
| 265 fake_packet.timestamp = kFirstTimestamp; |
262 | 266 |
263 rtc::scoped_refptr<MockAudioDecoderFactory> mock_decoder_factory( | 267 rtc::scoped_refptr<MockAudioDecoderFactory> mock_decoder_factory( |
264 new rtc::RefCountedObject<MockAudioDecoderFactory>); | 268 new rtc::RefCountedObject<MockAudioDecoderFactory>); |
265 EXPECT_CALL(*mock_decoder_factory, MakeAudioDecoderMock(_, _)) | 269 EXPECT_CALL(*mock_decoder_factory, MakeAudioDecoderMock(_, _)) |
266 .WillOnce(Invoke([kPayloadLength, kFirstSequenceNumber, kFirstTimestamp, | 270 .WillOnce(Invoke([kPayloadLength, kFirstSequenceNumber, kFirstTimestamp, |
267 kFirstReceiveTime](const SdpAudioFormat& format, | 271 kFirstReceiveTime](const SdpAudioFormat& format, |
268 std::unique_ptr<AudioDecoder>* dec) { | 272 std::unique_ptr<AudioDecoder>* dec) { |
269 EXPECT_EQ("pcmu", format.name); | 273 EXPECT_EQ("pcmu", format.name); |
270 | 274 |
271 std::unique_ptr<MockAudioDecoder> mock_decoder(new MockAudioDecoder); | 275 std::unique_ptr<MockAudioDecoder> mock_decoder(new MockAudioDecoder); |
(...skipping 30 matching lines...) Expand all Loading... |
302 .Times(1); | 306 .Times(1); |
303 EXPECT_CALL(*mock_packet_buffer_, InsertPacketList(_, _, _, _)) | 307 EXPECT_CALL(*mock_packet_buffer_, InsertPacketList(_, _, _, _)) |
304 .Times(2) | 308 .Times(2) |
305 .WillRepeatedly( | 309 .WillRepeatedly( |
306 DoAll(SetArgPointee<2>(rtc::Optional<uint8_t>(kPayloadType)), | 310 DoAll(SetArgPointee<2>(rtc::Optional<uint8_t>(kPayloadType)), |
307 WithArg<0>(Invoke(DeletePacketsAndReturnOk)))); | 311 WithArg<0>(Invoke(DeletePacketsAndReturnOk)))); |
308 // SetArgPointee<2>(kPayloadType) means that the third argument (zero-based | 312 // SetArgPointee<2>(kPayloadType) means that the third argument (zero-based |
309 // index) is a pointer, and the variable pointed to is set to kPayloadType. | 313 // index) is a pointer, and the variable pointed to is set to kPayloadType. |
310 // Also invoke the function DeletePacketsAndReturnOk to properly delete all | 314 // Also invoke the function DeletePacketsAndReturnOk to properly delete all |
311 // packets in the list (to avoid memory leaks in the test). | 315 // packets in the list (to avoid memory leaks in the test). |
312 EXPECT_CALL(*mock_packet_buffer_, NextRtpHeader()) | 316 EXPECT_CALL(*mock_packet_buffer_, PeekNextPacket()) |
313 .Times(1) | 317 .Times(1) |
314 .WillOnce(Return(&rtp_header.header)); | 318 .WillOnce(Return(&fake_packet)); |
315 | 319 |
316 // Expectations for DTMF buffer. | 320 // Expectations for DTMF buffer. |
317 EXPECT_CALL(*mock_dtmf_buffer_, Flush()) | 321 EXPECT_CALL(*mock_dtmf_buffer_, Flush()) |
318 .Times(1); | 322 .Times(1); |
319 | 323 |
320 // Expectations for delay manager. | 324 // Expectations for delay manager. |
321 { | 325 { |
322 // All expectations within this block must be called in this specific order. | 326 // All expectations within this block must be called in this specific order. |
323 InSequence sequence; // Dummy variable. | 327 InSequence sequence; // Dummy variable. |
324 // Expectations when the first packet is inserted. | 328 // Expectations when the first packet is inserted. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 rtp_header.header.timestamp += kPayloadLengthSamples; | 373 rtp_header.header.timestamp += kPayloadLengthSamples; |
370 rtp_header.header.sequenceNumber += 1; | 374 rtp_header.header.sequenceNumber += 1; |
371 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); | 375 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); |
372 } | 376 } |
373 | 377 |
374 // Insert one more packet and make sure the buffer got flushed. That is, it | 378 // Insert one more packet and make sure the buffer got flushed. That is, it |
375 // should only hold one single packet. | 379 // should only hold one single packet. |
376 EXPECT_EQ(NetEq::kOK, | 380 EXPECT_EQ(NetEq::kOK, |
377 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 381 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
378 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); | 382 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); |
379 const RTPHeader* test_header = packet_buffer_->NextRtpHeader(); | 383 const Packet* test_packet = packet_buffer_->PeekNextPacket(); |
380 EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp); | 384 EXPECT_EQ(rtp_header.header.timestamp, test_packet->timestamp); |
381 EXPECT_EQ(rtp_header.header.sequenceNumber, test_header->sequenceNumber); | 385 EXPECT_EQ(rtp_header.header.sequenceNumber, test_packet->sequence_number); |
382 } | 386 } |
383 | 387 |
384 // This test verifies that timestamps propagate from the incoming packets | 388 // This test verifies that timestamps propagate from the incoming packets |
385 // through to the sync buffer and to the playout timestamp. | 389 // through to the sync buffer and to the playout timestamp. |
386 TEST_F(NetEqImplTest, VerifyTimestampPropagation) { | 390 TEST_F(NetEqImplTest, VerifyTimestampPropagation) { |
387 UseNoMocks(); | 391 UseNoMocks(); |
388 CreateInstance(); | 392 CreateInstance(); |
389 | 393 |
390 const uint8_t kPayloadType = 17; // Just an arbitrary number. | 394 const uint8_t kPayloadType = 17; // Just an arbitrary number. |
391 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. | 395 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1429 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
1426 .Times(1) | 1430 .Times(1) |
1427 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); | 1431 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); |
1428 | 1432 |
1429 bool muted; | 1433 bool muted; |
1430 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); | 1434 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
1431 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); | 1435 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); |
1432 } | 1436 } |
1433 | 1437 |
1434 }// namespace webrtc | 1438 }// namespace webrtc |
OLD | NEW |