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 <string.h> | 11 #include <string.h> |
12 | 12 |
13 #include <list> | 13 #include <list> |
14 #include <memory> | |
15 | 14 |
16 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "webrtc/base/scoped_ptr.h" |
18 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h" | 18 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 19 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
20 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" | 20 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" |
21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
22 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h" | 22 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h" |
23 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" | 23 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" |
24 | 24 |
25 using ::testing::_; | 25 using ::testing::_; |
26 using ::testing::Args; | 26 using ::testing::Args; |
27 using ::testing::ElementsAreArray; | 27 using ::testing::ElementsAreArray; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 red_packet->length, kFecPayloadType)); | 85 red_packet->length, kFecPayloadType)); |
86 delete red_packet; | 86 delete red_packet; |
87 } | 87 } |
88 | 88 |
89 void InjectGarbagePacketLength(size_t fec_garbage_offset); | 89 void InjectGarbagePacketLength(size_t fec_garbage_offset); |
90 static void SurvivesMaliciousPacket(const uint8_t* data, | 90 static void SurvivesMaliciousPacket(const uint8_t* data, |
91 size_t length, | 91 size_t length, |
92 uint8_t ulpfec_payload_type); | 92 uint8_t ulpfec_payload_type); |
93 | 93 |
94 MockRtpData rtp_data_callback_; | 94 MockRtpData rtp_data_callback_; |
95 std::unique_ptr<ForwardErrorCorrection> fec_; | 95 rtc::scoped_ptr<ForwardErrorCorrection> fec_; |
96 std::unique_ptr<FecReceiver> receiver_fec_; | 96 rtc::scoped_ptr<FecReceiver> receiver_fec_; |
97 std::unique_ptr<FrameGenerator> generator_; | 97 rtc::scoped_ptr<FrameGenerator> generator_; |
98 }; | 98 }; |
99 | 99 |
100 void DeletePackets(std::list<Packet*>* packets) { | 100 void DeletePackets(std::list<Packet*>* packets) { |
101 while (!packets->empty()) { | 101 while (!packets->empty()) { |
102 delete packets->front(); | 102 delete packets->front(); |
103 packets->pop_front(); | 103 packets->pop_front(); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 TEST_F(ReceiverFecTest, TwoMediaOneFec) { | 107 TEST_F(ReceiverFecTest, TwoMediaOneFec) { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 .Times(1).WillRepeatedly(Return(true)); | 408 .Times(1).WillRepeatedly(Return(true)); |
409 EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); | 409 EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); |
410 | 410 |
411 DeletePackets(&media_packets); | 411 DeletePackets(&media_packets); |
412 } | 412 } |
413 | 413 |
414 void ReceiverFecTest::SurvivesMaliciousPacket(const uint8_t* data, | 414 void ReceiverFecTest::SurvivesMaliciousPacket(const uint8_t* data, |
415 size_t length, | 415 size_t length, |
416 uint8_t ulpfec_payload_type) { | 416 uint8_t ulpfec_payload_type) { |
417 webrtc::RTPHeader header; | 417 webrtc::RTPHeader header; |
418 std::unique_ptr<webrtc::RtpHeaderParser> parser( | 418 rtc::scoped_ptr<webrtc::RtpHeaderParser> parser( |
419 webrtc::RtpHeaderParser::Create()); | 419 webrtc::RtpHeaderParser::Create()); |
420 ASSERT_TRUE(parser->Parse(data, length, &header)); | 420 ASSERT_TRUE(parser->Parse(data, length, &header)); |
421 | 421 |
422 webrtc::NullRtpData null_callback; | 422 webrtc::NullRtpData null_callback; |
423 std::unique_ptr<webrtc::FecReceiver> receiver_fec( | 423 rtc::scoped_ptr<webrtc::FecReceiver> receiver_fec( |
424 webrtc::FecReceiver::Create(&null_callback)); | 424 webrtc::FecReceiver::Create(&null_callback)); |
425 | 425 |
426 receiver_fec->AddReceivedRedPacket(header, data, length, ulpfec_payload_type); | 426 receiver_fec->AddReceivedRedPacket(header, data, length, ulpfec_payload_type); |
427 } | 427 } |
428 | 428 |
429 TEST_F(ReceiverFecTest, TruncatedPacketWithFBitSet) { | 429 TEST_F(ReceiverFecTest, TruncatedPacketWithFBitSet) { |
430 const uint8_t kTruncatedPacket[] = {0x80, | 430 const uint8_t kTruncatedPacket[] = {0x80, |
431 0x2a, | 431 0x2a, |
432 0x68, | 432 0x68, |
433 0x71, | 433 0x71, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 0x27, | 533 0x27, |
534 0xc4, | 534 0xc4, |
535 0x2a, | 535 0x2a, |
536 0x21, | 536 0x21, |
537 0x2a, | 537 0x2a, |
538 0x28}; | 538 0x28}; |
539 SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100); | 539 SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100); |
540 } | 540 } |
541 | 541 |
542 } // namespace webrtc | 542 } // namespace webrtc |
OLD | NEW |