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