| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 <memory> | |
| 12 | |
| 13 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 11 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
| 14 | 12 |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "webrtc/base/scoped_ptr.h" |
| 17 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 16 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 19 #include "webrtc/modules/rtp_rtcp/source/mock/mock_rtp_payload_strategy.h" | 18 #include "webrtc/modules/rtp_rtcp/source/mock/mock_rtp_payload_strategy.h" |
| 20 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 21 | 20 |
| 22 namespace webrtc { | 21 namespace webrtc { |
| 23 | 22 |
| 24 using ::testing::Eq; | 23 using ::testing::Eq; |
| 25 using ::testing::Return; | 24 using ::testing::Return; |
| 26 using ::testing::_; | 25 using ::testing::_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 52 // of the created object. | 51 // of the created object. |
| 53 RtpUtility::Payload* returned_payload_on_heap = | 52 RtpUtility::Payload* returned_payload_on_heap = |
| 54 new RtpUtility::Payload(returned_payload); | 53 new RtpUtility::Payload(returned_payload); |
| 55 EXPECT_CALL(*mock_payload_strategy_, | 54 EXPECT_CALL(*mock_payload_strategy_, |
| 56 CreatePayloadType(kTypicalPayloadName, payload_type, | 55 CreatePayloadType(kTypicalPayloadName, payload_type, |
| 57 kTypicalFrequency, kTypicalChannels, rate)) | 56 kTypicalFrequency, kTypicalChannels, rate)) |
| 58 .WillOnce(Return(returned_payload_on_heap)); | 57 .WillOnce(Return(returned_payload_on_heap)); |
| 59 return returned_payload_on_heap; | 58 return returned_payload_on_heap; |
| 60 } | 59 } |
| 61 | 60 |
| 62 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_; | 61 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
| 63 testing::NiceMock<MockRTPPayloadStrategy>* mock_payload_strategy_; | 62 testing::NiceMock<MockRTPPayloadStrategy>* mock_payload_strategy_; |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 TEST_F(RtpPayloadRegistryTest, RegistersAndRemembersPayloadsUntilDeregistered) { | 65 TEST_F(RtpPayloadRegistryTest, RegistersAndRemembersPayloadsUntilDeregistered) { |
| 67 uint8_t payload_type = 97; | 66 uint8_t payload_type = 97; |
| 68 RtpUtility::Payload* returned_payload_on_heap = | 67 RtpUtility::Payload* returned_payload_on_heap = |
| 69 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); | 68 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); |
| 70 | 69 |
| 71 bool new_payload_created = false; | 70 bool new_payload_created = false; |
| 72 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 71 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 289 |
| 291 RTPHeader header; | 290 RTPHeader header; |
| 292 header.ssrc = 1000; | 291 header.ssrc = 1000; |
| 293 header.sequenceNumber = 100; | 292 header.sequenceNumber = 100; |
| 294 header.payloadType = rtx_payload_type; | 293 header.payloadType = rtx_payload_type; |
| 295 header.headerLength = header_length; | 294 header.headerLength = header_length; |
| 296 | 295 |
| 297 uint16_t original_sequence_number = 1234; | 296 uint16_t original_sequence_number = 1234; |
| 298 uint32_t original_ssrc = 500; | 297 uint32_t original_ssrc = 500; |
| 299 | 298 |
| 300 std::unique_ptr<const uint8_t[]> packet(GenerateRtxPacket( | 299 rtc::scoped_ptr<const uint8_t[]> packet(GenerateRtxPacket( |
| 301 header_length, payload_length, original_sequence_number)); | 300 header_length, payload_length, original_sequence_number)); |
| 302 std::unique_ptr<uint8_t[]> restored_packet( | 301 rtc::scoped_ptr<uint8_t[]> restored_packet( |
| 303 new uint8_t[header_length + payload_length]); | 302 new uint8_t[header_length + payload_length]); |
| 304 size_t length = original_length; | 303 size_t length = original_length; |
| 305 bool success = rtp_payload_registry->RestoreOriginalPacket( | 304 bool success = rtp_payload_registry->RestoreOriginalPacket( |
| 306 restored_packet.get(), packet.get(), &length, original_ssrc, header); | 305 restored_packet.get(), packet.get(), &length, original_ssrc, header); |
| 307 EXPECT_EQ(should_succeed, success) | 306 EXPECT_EQ(should_succeed, success) |
| 308 << "Test success should match should_succeed."; | 307 << "Test success should match should_succeed."; |
| 309 if (!success) { | 308 if (!success) { |
| 310 return; | 309 return; |
| 311 } | 310 } |
| 312 | 311 |
| 313 EXPECT_EQ(original_length - kRtxHeaderSize, length) | 312 EXPECT_EQ(original_length - kRtxHeaderSize, length) |
| 314 << "The restored packet should be exactly kRtxHeaderSize smaller."; | 313 << "The restored packet should be exactly kRtxHeaderSize smaller."; |
| 315 | 314 |
| 316 std::unique_ptr<RtpHeaderParser> header_parser(RtpHeaderParser::Create()); | 315 rtc::scoped_ptr<RtpHeaderParser> header_parser(RtpHeaderParser::Create()); |
| 317 RTPHeader restored_header; | 316 RTPHeader restored_header; |
| 318 ASSERT_TRUE( | 317 ASSERT_TRUE( |
| 319 header_parser->Parse(restored_packet.get(), length, &restored_header)); | 318 header_parser->Parse(restored_packet.get(), length, &restored_header)); |
| 320 EXPECT_EQ(original_sequence_number, restored_header.sequenceNumber) | 319 EXPECT_EQ(original_sequence_number, restored_header.sequenceNumber) |
| 321 << "The restored packet should have the original sequence number " | 320 << "The restored packet should have the original sequence number " |
| 322 << "in the correct location in the RTP header."; | 321 << "in the correct location in the RTP header."; |
| 323 EXPECT_EQ(expected_payload_type, restored_header.payloadType) | 322 EXPECT_EQ(expected_payload_type, restored_header.payloadType) |
| 324 << "The restored packet should have the correct payload type."; | 323 << "The restored packet should have the correct payload type."; |
| 325 EXPECT_EQ(original_ssrc, restored_header.ssrc) | 324 EXPECT_EQ(original_ssrc, restored_header.ssrc) |
| 326 << "The restored packet should have the correct ssrc."; | 325 << "The restored packet should have the correct ssrc."; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // Now that red is configured we expect to get the red payload type back on | 368 // Now that red is configured we expect to get the red payload type back on |
| 370 // recovery because of the workaround to always recover red when configured. | 369 // recovery because of the workaround to always recover red when configured. |
| 371 TestRtxPacket(rtp_payload_registry_.get(), 105, header.payloadType, true); | 370 TestRtxPacket(rtp_payload_registry_.get(), 105, header.payloadType, true); |
| 372 } | 371 } |
| 373 | 372 |
| 374 INSTANTIATE_TEST_CASE_P(TestDynamicRange, | 373 INSTANTIATE_TEST_CASE_P(TestDynamicRange, |
| 375 RtpPayloadRegistryGenericTest, | 374 RtpPayloadRegistryGenericTest, |
| 376 testing::Range(96, 127 + 1)); | 375 testing::Range(96, 127 + 1)); |
| 377 | 376 |
| 378 } // namespace webrtc | 377 } // namespace webrtc |
| OLD | NEW |