Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: webrtc/video/payload_router_unittest.cc

Issue 1600973002: Initialize VideoEncoder objects asynchronously. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rename new_codec_settings Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/payload_router.cc ('k') | webrtc/video/video_capture_input.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 #include <vector>
12 #include <list>
13 12
14 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/base/scoped_ptr.h" 15 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
18 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" 17 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h"
19 #include "webrtc/video/payload_router.h" 18 #include "webrtc/video/payload_router.h"
20 19
21 using ::testing::_; 20 using ::testing::_;
22 using ::testing::AnyNumber; 21 using ::testing::AnyNumber;
23 using ::testing::NiceMock; 22 using ::testing::NiceMock;
24 using ::testing::Return; 23 using ::testing::Return;
25 24
26 namespace webrtc { 25 namespace webrtc {
27 26
28 class PayloadRouterTest : public ::testing::Test { 27 class PayloadRouterTest : public ::testing::Test {
29 protected: 28 protected:
30 virtual void SetUp() { 29 virtual void SetUp() {
31 payload_router_.reset(new PayloadRouter()); 30 payload_router_.reset(new PayloadRouter());
32 } 31 }
33 rtc::scoped_ptr<PayloadRouter> payload_router_; 32 rtc::scoped_ptr<PayloadRouter> payload_router_;
34 }; 33 };
35 34
36 TEST_F(PayloadRouterTest, SendOnOneModule) { 35 TEST_F(PayloadRouterTest, SendOnOneModule) {
37 MockRtpRtcp rtp; 36 MockRtpRtcp rtp;
38 std::list<RtpRtcp*> modules(1, &rtp); 37 std::vector<RtpRtcp*> modules(1, &rtp);
39 38
40 payload_router_->SetSendingRtpModules(modules); 39 payload_router_->SetSendingRtpModules(modules);
41 40
42 uint8_t payload = 'a'; 41 uint8_t payload = 'a';
43 FrameType frame_type = kVideoFrameKey; 42 FrameType frame_type = kVideoFrameKey;
44 int8_t payload_type = 96; 43 int8_t payload_type = 96;
45 44
46 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, 45 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL,
47 NULL)) 46 NULL))
48 .Times(0); 47 .Times(0);
(...skipping 26 matching lines...) Expand all
75 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, 74 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL,
76 NULL)) 75 NULL))
77 .Times(0); 76 .Times(0);
78 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, 77 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0,
79 &payload, 1, NULL, NULL)); 78 &payload, 1, NULL, NULL));
80 } 79 }
81 80
82 TEST_F(PayloadRouterTest, SendSimulcast) { 81 TEST_F(PayloadRouterTest, SendSimulcast) {
83 MockRtpRtcp rtp_1; 82 MockRtpRtcp rtp_1;
84 MockRtpRtcp rtp_2; 83 MockRtpRtcp rtp_2;
85 std::list<RtpRtcp*> modules; 84 std::vector<RtpRtcp*> modules;
86 modules.push_back(&rtp_1); 85 modules.push_back(&rtp_1);
87 modules.push_back(&rtp_2); 86 modules.push_back(&rtp_2);
88 87
89 payload_router_->SetSendingRtpModules(modules); 88 payload_router_->SetSendingRtpModules(modules);
90 89
91 uint8_t payload_1 = 'a'; 90 uint8_t payload_1 = 'a';
92 FrameType frame_type_1 = kVideoFrameKey; 91 FrameType frame_type_1 = kVideoFrameKey;
93 int8_t payload_type_1 = 96; 92 int8_t payload_type_1 = 96;
94 RTPVideoHeader rtp_hdr_1; 93 RTPVideoHeader rtp_hdr_1;
95 rtp_hdr_1.simulcastIdx = 0; 94 rtp_hdr_1.simulcastIdx = 0;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 139
141 TEST_F(PayloadRouterTest, MaxPayloadLength) { 140 TEST_F(PayloadRouterTest, MaxPayloadLength) {
142 // Without any limitations from the modules, verify we get the max payload 141 // Without any limitations from the modules, verify we get the max payload
143 // length for IP/UDP/SRTP with a MTU of 150 bytes. 142 // length for IP/UDP/SRTP with a MTU of 150 bytes.
144 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; 143 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4;
145 EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength()); 144 EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength());
146 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); 145 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength());
147 146
148 MockRtpRtcp rtp_1; 147 MockRtpRtcp rtp_1;
149 MockRtpRtcp rtp_2; 148 MockRtpRtcp rtp_2;
150 std::list<RtpRtcp*> modules; 149 std::vector<RtpRtcp*> modules;
151 modules.push_back(&rtp_1); 150 modules.push_back(&rtp_1);
152 modules.push_back(&rtp_2); 151 modules.push_back(&rtp_2);
153 payload_router_->SetSendingRtpModules(modules); 152 payload_router_->SetSendingRtpModules(modules);
154 153
155 // Modules return a higher length than the default value. 154 // Modules return a higher length than the default value.
156 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) 155 EXPECT_CALL(rtp_1, MaxDataPayloadLength())
157 .Times(1) 156 .Times(1)
158 .WillOnce(Return(kDefaultMaxLength + 10)); 157 .WillOnce(Return(kDefaultMaxLength + 10));
159 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) 158 EXPECT_CALL(rtp_2, MaxDataPayloadLength())
160 .Times(1) 159 .Times(1)
161 .WillOnce(Return(kDefaultMaxLength + 10)); 160 .WillOnce(Return(kDefaultMaxLength + 10));
162 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); 161 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength());
163 162
164 // The modules return a value lower than default. 163 // The modules return a value lower than default.
165 const size_t kTestMinPayloadLength = 1001; 164 const size_t kTestMinPayloadLength = 1001;
166 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) 165 EXPECT_CALL(rtp_1, MaxDataPayloadLength())
167 .Times(1) 166 .Times(1)
168 .WillOnce(Return(kTestMinPayloadLength + 10)); 167 .WillOnce(Return(kTestMinPayloadLength + 10));
169 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) 168 EXPECT_CALL(rtp_2, MaxDataPayloadLength())
170 .Times(1) 169 .Times(1)
171 .WillOnce(Return(kTestMinPayloadLength)); 170 .WillOnce(Return(kTestMinPayloadLength));
172 EXPECT_EQ(kTestMinPayloadLength, payload_router_->MaxPayloadLength()); 171 EXPECT_EQ(kTestMinPayloadLength, payload_router_->MaxPayloadLength());
173 } 172 }
174 173
175 TEST_F(PayloadRouterTest, SetTargetSendBitrates) { 174 TEST_F(PayloadRouterTest, SetTargetSendBitrates) {
176 MockRtpRtcp rtp_1; 175 MockRtpRtcp rtp_1;
177 MockRtpRtcp rtp_2; 176 MockRtpRtcp rtp_2;
178 std::list<RtpRtcp*> modules; 177 std::vector<RtpRtcp*> modules;
179 modules.push_back(&rtp_1); 178 modules.push_back(&rtp_1);
180 modules.push_back(&rtp_2); 179 modules.push_back(&rtp_2);
181 payload_router_->SetSendingRtpModules(modules); 180 payload_router_->SetSendingRtpModules(modules);
182 181
183 const uint32_t bitrate_1 = 10000; 182 const uint32_t bitrate_1 = 10000;
184 const uint32_t bitrate_2 = 76543; 183 const uint32_t bitrate_2 = 76543;
185 std::vector<uint32_t> bitrates(2, bitrate_1); 184 std::vector<uint32_t> bitrates(2, bitrate_1);
186 bitrates[1] = bitrate_2; 185 bitrates[1] = bitrate_2;
187 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) 186 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1))
188 .Times(1); 187 .Times(1);
(...skipping 11 matching lines...) Expand all
200 bitrates.resize(3); 199 bitrates.resize(3);
201 bitrates[1] = bitrate_2; 200 bitrates[1] = bitrate_2;
202 bitrates[2] = bitrate_1 + bitrate_2; 201 bitrates[2] = bitrate_1 + bitrate_2;
203 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) 202 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1))
204 .Times(1); 203 .Times(1);
205 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) 204 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2))
206 .Times(1); 205 .Times(1);
207 payload_router_->SetTargetSendBitrates(bitrates); 206 payload_router_->SetTargetSendBitrates(bitrates);
208 } 207 }
209 } // namespace webrtc 208 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/payload_router.cc ('k') | webrtc/video/video_capture_input.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698