| 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/interface/rtp_payload_registry.h" | 11 #include "webrtc/modules/rtp_rtcp/interface/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/source/mock/mock_rtp_payload_strategy.h" | 16 #include "webrtc/modules/rtp_rtcp/source/mock/mock_rtp_payload_strategy.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 18 | 18 |
| 19 namespace webrtc { | 19 namespace webrtc { |
| 20 | 20 |
| 21 using ::testing::Eq; | 21 using ::testing::Eq; |
| 22 using ::testing::Return; | 22 using ::testing::Return; |
| 23 using ::testing::_; | 23 using ::testing::_; |
| 24 | 24 |
| 25 static const char* kTypicalPayloadName = "name"; | 25 static const char* kTypicalPayloadName = "name"; |
| 26 static const uint8_t kTypicalChannels = 1; | 26 static const size_t kTypicalChannels = 1; |
| 27 static const int kTypicalFrequency = 44000; | 27 static const int kTypicalFrequency = 44000; |
| 28 static const int kTypicalRate = 32 * 1024; | 28 static const int kTypicalRate = 32 * 1024; |
| 29 | 29 |
| 30 class RtpPayloadRegistryTest : public ::testing::Test { | 30 class RtpPayloadRegistryTest : public ::testing::Test { |
| 31 public: | 31 public: |
| 32 void SetUp() { | 32 void SetUp() { |
| 33 // Note: the payload registry takes ownership of the strategy. | 33 // Note: the payload registry takes ownership of the strategy. |
| 34 mock_payload_strategy_ = new testing::NiceMock<MockRTPPayloadStrategy>(); | 34 mock_payload_strategy_ = new testing::NiceMock<MockRTPPayloadStrategy>(); |
| 35 rtp_payload_registry_.reset(new RTPPayloadRegistry(mock_payload_strategy_)); | 35 rtp_payload_registry_.reset(new RTPPayloadRegistry(mock_payload_strategy_)); |
| 36 } | 36 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 // Now forget about it and verify it's gone. | 84 // Now forget about it and verify it's gone. |
| 85 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type)); | 85 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type)); |
| 86 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload( | 86 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload( |
| 87 payload_type, retrieved_payload)); | 87 payload_type, retrieved_payload)); |
| 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(new RTPPayloadRegistry( | 97 rtp_payload_registry_.reset(new RTPPayloadRegistry( |
| 98 RTPPayloadStrategy::CreateStrategy(true))); | 98 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, kRedBitRate, | 102 "red", kRedPayloadType, kRedSampleRate, kRedChannels, kRedBitRate, |
| 103 &new_payload_created)); | 103 &new_payload_created)); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload("generic-codec", | 255 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload("generic-codec", |
| 256 static_cast<int8_t>(payload_type), | 256 static_cast<int8_t>(payload_type), |
| 257 19, 1, 17, &ignored)); // dummy values, except for payload_type | 257 19, 1, 17, &ignored)); // dummy values, except for payload_type |
| 258 } | 258 } |
| 259 | 259 |
| 260 INSTANTIATE_TEST_CASE_P(TestDynamicRange, RtpPayloadRegistryGenericTest, | 260 INSTANTIATE_TEST_CASE_P(TestDynamicRange, RtpPayloadRegistryGenericTest, |
| 261 testing::Range(96, 127+1)); | 261 testing::Range(96, 127+1)); |
| 262 | 262 |
| 263 } // namespace webrtc | 263 } // namespace webrtc |
| OLD | NEW |