| 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 "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 11 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
| 12 | 12 |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "webrtc/base/scoped_ptr.h" | 15 #include "webrtc/base/scoped_ptr.h" |
| 16 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 16 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 18 #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" |
| 19 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 20 | 20 |
| 21 namespace webrtc { | 21 namespace webrtc { |
| 22 | 22 |
| 23 using ::testing::Eq; | 23 using ::testing::Eq; |
| 24 using ::testing::Return; | 24 using ::testing::Return; |
| 25 using ::testing::_; | 25 using ::testing::_; |
| 26 | 26 |
| 27 static const char* kTypicalPayloadName = "name"; | 27 static const char* kTypicalPayloadName = "name"; |
| 28 static const uint8_t kTypicalChannels = 1; | 28 static const size_t kTypicalChannels = 1; |
| 29 static const int kTypicalFrequency = 44000; | 29 static const int kTypicalFrequency = 44000; |
| 30 static const int kTypicalRate = 32 * 1024; | 30 static const int kTypicalRate = 32 * 1024; |
| 31 | 31 |
| 32 class RtpPayloadRegistryTest : public ::testing::Test { | 32 class RtpPayloadRegistryTest : public ::testing::Test { |
| 33 public: | 33 public: |
| 34 void SetUp() { | 34 void SetUp() { |
| 35 // Note: the payload registry takes ownership of the strategy. | 35 // Note: the payload registry takes ownership of the strategy. |
| 36 mock_payload_strategy_ = new testing::NiceMock<MockRTPPayloadStrategy>(); | 36 mock_payload_strategy_ = new testing::NiceMock<MockRTPPayloadStrategy>(); |
| 37 rtp_payload_registry_.reset(new RTPPayloadRegistry(mock_payload_strategy_)); | 37 rtp_payload_registry_.reset(new RTPPayloadRegistry(mock_payload_strategy_)); |
| 38 } | 38 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 EXPECT_EQ(returned_payload_on_heap, retrieved_payload); | 83 EXPECT_EQ(returned_payload_on_heap, retrieved_payload); |
| 84 | 84 |
| 85 // Now forget about it and verify it's gone. | 85 // Now forget about it and verify it's gone. |
| 86 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type)); | 86 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type)); |
| 87 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type)); | 87 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) { | 90 TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) { |
| 91 const uint8_t kRedPayloadType = 127; | 91 const uint8_t kRedPayloadType = 127; |
| 92 const int kRedSampleRate = 8000; | 92 const int kRedSampleRate = 8000; |
| 93 const int kRedChannels = 1; | 93 const size_t kRedChannels = 1; |
| 94 const int kRedBitRate = 0; | 94 const int kRedBitRate = 0; |
| 95 | 95 |
| 96 // This creates an audio RTP payload strategy. | 96 // This creates an audio RTP payload strategy. |
| 97 rtp_payload_registry_.reset( | 97 rtp_payload_registry_.reset( |
| 98 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))); | 98 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))); |
| 99 | 99 |
| 100 bool new_payload_created = false; | 100 bool new_payload_created = false; |
| 101 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 101 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( |
| 102 "red", kRedPayloadType, kRedSampleRate, kRedChannels, | 102 "red", kRedPayloadType, kRedSampleRate, kRedChannels, |
| 103 kRedBitRate, &new_payload_created)); | 103 kRedBitRate, &new_payload_created)); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true); | 387 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true); |
| 388 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true); | 388 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true); |
| 389 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false); | 389 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false); |
| 390 } | 390 } |
| 391 | 391 |
| 392 INSTANTIATE_TEST_CASE_P(TestDynamicRange, | 392 INSTANTIATE_TEST_CASE_P(TestDynamicRange, |
| 393 RtpPayloadRegistryGenericTest, | 393 RtpPayloadRegistryGenericTest, |
| 394 testing::Range(96, 127 + 1)); | 394 testing::Range(96, 127 + 1)); |
| 395 | 395 |
| 396 } // namespace webrtc | 396 } // namespace webrtc |
| OLD | NEW |