| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 | |
| 12 #include <list> | |
| 13 | |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webrtc/base/scoped_ptr.h" | 13 #include "webrtc/base/scoped_ptr.h" |
| 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 14 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 18 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" | 15 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" |
| 19 #include "webrtc/video/payload_router.h" | 16 #include "webrtc/video/payload_router.h" |
| 20 | 17 |
| 21 using ::testing::_; | 18 using ::testing::_; |
| 22 using ::testing::AnyNumber; | 19 using ::testing::AnyNumber; |
| 23 using ::testing::NiceMock; | 20 using ::testing::NiceMock; |
| 24 using ::testing::Return; | 21 using ::testing::Return; |
| 25 | 22 |
| 26 namespace webrtc { | 23 namespace webrtc { |
| 27 | 24 |
| 28 class PayloadRouterTest : public ::testing::Test { | 25 class PayloadRouterTest : public ::testing::Test { |
| 29 protected: | 26 protected: |
| 30 virtual void SetUp() { | 27 virtual void SetUp() { |
| 31 payload_router_.reset(new PayloadRouter()); | 28 payload_router_.reset(new PayloadRouter()); |
| 32 } | 29 } |
| 33 rtc::scoped_ptr<PayloadRouter> payload_router_; | 30 rtc::scoped_ptr<PayloadRouter> payload_router_; |
| 34 }; | 31 }; |
| 35 | 32 |
| 36 TEST_F(PayloadRouterTest, SendOnOneModule) { | 33 TEST_F(PayloadRouterTest, SendOnOneModule) { |
| 37 MockRtpRtcp rtp; | 34 MockRtpRtcp rtp; |
| 38 std::list<RtpRtcp*> modules(1, &rtp); | 35 std::vector<RtpRtcp*> modules(1, &rtp); |
| 39 | 36 |
| 40 payload_router_->SetSendingRtpModules(modules); | 37 payload_router_->SetSendingRtpModules(modules); |
| 41 | 38 |
| 42 uint8_t payload = 'a'; | 39 uint8_t payload = 'a'; |
| 43 FrameType frame_type = kVideoFrameKey; | 40 FrameType frame_type = kVideoFrameKey; |
| 44 int8_t payload_type = 96; | 41 int8_t payload_type = 96; |
| 45 | 42 |
| 46 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, | 43 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, |
| 47 NULL)) | 44 NULL)) |
| 48 .Times(0); | 45 .Times(0); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 75 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, | 72 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, |
| 76 NULL)) | 73 NULL)) |
| 77 .Times(0); | 74 .Times(0); |
| 78 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, | 75 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, |
| 79 &payload, 1, NULL, NULL)); | 76 &payload, 1, NULL, NULL)); |
| 80 } | 77 } |
| 81 | 78 |
| 82 TEST_F(PayloadRouterTest, SendSimulcast) { | 79 TEST_F(PayloadRouterTest, SendSimulcast) { |
| 83 MockRtpRtcp rtp_1; | 80 MockRtpRtcp rtp_1; |
| 84 MockRtpRtcp rtp_2; | 81 MockRtpRtcp rtp_2; |
| 85 std::list<RtpRtcp*> modules; | 82 std::vector<RtpRtcp*> modules; |
| 86 modules.push_back(&rtp_1); | 83 modules.push_back(&rtp_1); |
| 87 modules.push_back(&rtp_2); | 84 modules.push_back(&rtp_2); |
| 88 | 85 |
| 89 payload_router_->SetSendingRtpModules(modules); | 86 payload_router_->SetSendingRtpModules(modules); |
| 90 | 87 |
| 91 uint8_t payload_1 = 'a'; | 88 uint8_t payload_1 = 'a'; |
| 92 FrameType frame_type_1 = kVideoFrameKey; | 89 FrameType frame_type_1 = kVideoFrameKey; |
| 93 int8_t payload_type_1 = 96; | 90 int8_t payload_type_1 = 96; |
| 94 RTPVideoHeader rtp_hdr_1; | 91 RTPVideoHeader rtp_hdr_1; |
| 95 rtp_hdr_1.simulcastIdx = 0; | 92 rtp_hdr_1.simulcastIdx = 0; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 137 |
| 141 TEST_F(PayloadRouterTest, MaxPayloadLength) { | 138 TEST_F(PayloadRouterTest, MaxPayloadLength) { |
| 142 // Without any limitations from the modules, verify we get the max payload | 139 // Without any limitations from the modules, verify we get the max payload |
| 143 // length for IP/UDP/SRTP with a MTU of 150 bytes. | 140 // length for IP/UDP/SRTP with a MTU of 150 bytes. |
| 144 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; | 141 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; |
| 145 EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength()); | 142 EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength()); |
| 146 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); | 143 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); |
| 147 | 144 |
| 148 MockRtpRtcp rtp_1; | 145 MockRtpRtcp rtp_1; |
| 149 MockRtpRtcp rtp_2; | 146 MockRtpRtcp rtp_2; |
| 150 std::list<RtpRtcp*> modules; | 147 std::vector<RtpRtcp*> modules; |
| 151 modules.push_back(&rtp_1); | 148 modules.push_back(&rtp_1); |
| 152 modules.push_back(&rtp_2); | 149 modules.push_back(&rtp_2); |
| 153 payload_router_->SetSendingRtpModules(modules); | 150 payload_router_->SetSendingRtpModules(modules); |
| 154 | 151 |
| 155 // Modules return a higher length than the default value. | 152 // Modules return a higher length than the default value. |
| 156 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) | 153 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) |
| 157 .Times(1) | 154 .Times(1) |
| 158 .WillOnce(Return(kDefaultMaxLength + 10)); | 155 .WillOnce(Return(kDefaultMaxLength + 10)); |
| 159 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) | 156 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) |
| 160 .Times(1) | 157 .Times(1) |
| 161 .WillOnce(Return(kDefaultMaxLength + 10)); | 158 .WillOnce(Return(kDefaultMaxLength + 10)); |
| 162 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); | 159 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); |
| 163 | 160 |
| 164 // The modules return a value lower than default. | 161 // The modules return a value lower than default. |
| 165 const size_t kTestMinPayloadLength = 1001; | 162 const size_t kTestMinPayloadLength = 1001; |
| 166 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) | 163 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) |
| 167 .Times(1) | 164 .Times(1) |
| 168 .WillOnce(Return(kTestMinPayloadLength + 10)); | 165 .WillOnce(Return(kTestMinPayloadLength + 10)); |
| 169 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) | 166 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) |
| 170 .Times(1) | 167 .Times(1) |
| 171 .WillOnce(Return(kTestMinPayloadLength)); | 168 .WillOnce(Return(kTestMinPayloadLength)); |
| 172 EXPECT_EQ(kTestMinPayloadLength, payload_router_->MaxPayloadLength()); | 169 EXPECT_EQ(kTestMinPayloadLength, payload_router_->MaxPayloadLength()); |
| 173 } | 170 } |
| 174 | 171 |
| 175 TEST_F(PayloadRouterTest, SetTargetSendBitrates) { | 172 TEST_F(PayloadRouterTest, SetTargetSendBitrates) { |
| 176 MockRtpRtcp rtp_1; | 173 MockRtpRtcp rtp_1; |
| 177 MockRtpRtcp rtp_2; | 174 MockRtpRtcp rtp_2; |
| 178 std::list<RtpRtcp*> modules; | 175 std::vector<RtpRtcp*> modules; |
| 179 modules.push_back(&rtp_1); | 176 modules.push_back(&rtp_1); |
| 180 modules.push_back(&rtp_2); | 177 modules.push_back(&rtp_2); |
| 181 payload_router_->SetSendingRtpModules(modules); | 178 payload_router_->SetSendingRtpModules(modules); |
| 182 | 179 |
| 183 const uint32_t bitrate_1 = 10000; | 180 const uint32_t bitrate_1 = 10000; |
| 184 const uint32_t bitrate_2 = 76543; | 181 const uint32_t bitrate_2 = 76543; |
| 185 std::vector<uint32_t> bitrates(2, bitrate_1); | 182 std::vector<uint32_t> bitrates(2, bitrate_1); |
| 186 bitrates[1] = bitrate_2; | 183 bitrates[1] = bitrate_2; |
| 187 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) | 184 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) |
| 188 .Times(1); | 185 .Times(1); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 200 bitrates.resize(3); | 197 bitrates.resize(3); |
| 201 bitrates[1] = bitrate_2; | 198 bitrates[1] = bitrate_2; |
| 202 bitrates[2] = bitrate_1 + bitrate_2; | 199 bitrates[2] = bitrate_1 + bitrate_2; |
| 203 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) | 200 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) |
| 204 .Times(1); | 201 .Times(1); |
| 205 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) | 202 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) |
| 206 .Times(1); | 203 .Times(1); |
| 207 payload_router_->SetTargetSendBitrates(bitrates); | 204 payload_router_->SetTargetSendBitrates(bitrates); |
| 208 } | 205 } |
| 209 } // namespace webrtc | 206 } // namespace webrtc |
| OLD | NEW |