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

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

Issue 1725363003: Move RTP module activation into PayloadRouter. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nuke comment Created 4 years, 10 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_send_stream.cc » ('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
(...skipping 16 matching lines...) Expand all
27 virtual void SetUp() { 27 virtual void SetUp() {
28 payload_router_.reset(new PayloadRouter()); 28 payload_router_.reset(new PayloadRouter());
29 } 29 }
30 rtc::scoped_ptr<PayloadRouter> payload_router_; 30 rtc::scoped_ptr<PayloadRouter> payload_router_;
31 }; 31 };
32 32
33 TEST_F(PayloadRouterTest, SendOnOneModule) { 33 TEST_F(PayloadRouterTest, SendOnOneModule) {
34 MockRtpRtcp rtp; 34 MockRtpRtcp rtp;
35 std::vector<RtpRtcp*> modules(1, &rtp); 35 std::vector<RtpRtcp*> modules(1, &rtp);
36 36
37 payload_router_->SetSendingRtpModules(modules); 37 payload_router_->Init(modules);
38 payload_router_->SetSendingRtpModules(modules.size());
38 39
39 uint8_t payload = 'a'; 40 uint8_t payload = 'a';
40 FrameType frame_type = kVideoFrameKey; 41 FrameType frame_type = kVideoFrameKey;
41 int8_t payload_type = 96; 42 int8_t payload_type = 96;
42 43
43 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, 44 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL,
44 NULL)) 45 NULL))
45 .Times(0); 46 .Times(0);
46 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, 47 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0,
47 &payload, 1, NULL, NULL)); 48 &payload, 1, NULL, NULL));
(...skipping 12 matching lines...) Expand all
60 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, 61 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0,
61 &payload, 1, NULL, NULL)); 62 &payload, 1, NULL, NULL));
62 63
63 payload_router_->set_active(true); 64 payload_router_->set_active(true);
64 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL, 65 EXPECT_CALL(rtp, SendOutgoingData(frame_type, payload_type, 0, 0, _, 1, NULL,
65 NULL)) 66 NULL))
66 .Times(1); 67 .Times(1);
67 EXPECT_TRUE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, 68 EXPECT_TRUE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0,
68 &payload, 1, NULL, NULL)); 69 &payload, 1, NULL, NULL));
69 70
70 modules.clear(); 71 payload_router_->SetSendingRtpModules(0);
71 payload_router_->SetSendingRtpModules(modules);
72 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,
73 NULL)) 73 NULL))
74 .Times(0); 74 .Times(0);
75 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0, 75 EXPECT_FALSE(payload_router_->RoutePayload(frame_type, payload_type, 0, 0,
76 &payload, 1, NULL, NULL)); 76 &payload, 1, NULL, NULL));
77 } 77 }
78 78
79 TEST_F(PayloadRouterTest, SendSimulcast) { 79 TEST_F(PayloadRouterTest, SendSimulcast) {
80 MockRtpRtcp rtp_1; 80 MockRtpRtcp rtp_1;
81 MockRtpRtcp rtp_2; 81 MockRtpRtcp rtp_2;
82 std::vector<RtpRtcp*> modules; 82 std::vector<RtpRtcp*> modules;
83 modules.push_back(&rtp_1); 83 modules.push_back(&rtp_1);
84 modules.push_back(&rtp_2); 84 modules.push_back(&rtp_2);
85 85
86 payload_router_->SetSendingRtpModules(modules); 86 payload_router_->Init(modules);
87 payload_router_->SetSendingRtpModules(modules.size());
87 88
88 uint8_t payload_1 = 'a'; 89 uint8_t payload_1 = 'a';
89 FrameType frame_type_1 = kVideoFrameKey; 90 FrameType frame_type_1 = kVideoFrameKey;
90 int8_t payload_type_1 = 96; 91 int8_t payload_type_1 = 96;
91 RTPVideoHeader rtp_hdr_1; 92 RTPVideoHeader rtp_hdr_1;
92 rtp_hdr_1.simulcastIdx = 0; 93 rtp_hdr_1.simulcastIdx = 0;
93 94
94 payload_router_->set_active(true); 95 payload_router_->set_active(true);
95 EXPECT_CALL(rtp_1, SendOutgoingData(frame_type_1, payload_type_1, 0, 0, _, 1, 96 EXPECT_CALL(rtp_1, SendOutgoingData(frame_type_1, payload_type_1, 0, 0, _, 1,
96 NULL, &rtp_hdr_1)) 97 NULL, &rtp_hdr_1))
(...skipping 21 matching lines...) Expand all
118 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) 119 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _))
119 .Times(0); 120 .Times(0);
120 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) 121 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _))
121 .Times(0); 122 .Times(0);
122 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_1, payload_type_1, 0, 0, 123 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_1, payload_type_1, 0, 0,
123 &payload_1, 1, NULL, &rtp_hdr_1)); 124 &payload_1, 1, NULL, &rtp_hdr_1));
124 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_2, payload_type_2, 0, 0, 125 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_2, payload_type_2, 0, 0,
125 &payload_2, 1, NULL, &rtp_hdr_2)); 126 &payload_2, 1, NULL, &rtp_hdr_2));
126 127
127 // Invalid simulcast index. 128 // Invalid simulcast index.
129 payload_router_->SetSendingRtpModules(1);
128 payload_router_->set_active(true); 130 payload_router_->set_active(true);
129 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _)) 131 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _))
130 .Times(0); 132 .Times(0);
131 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _)) 133 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _))
132 .Times(0); 134 .Times(0);
133 rtp_hdr_1.simulcastIdx = 2; 135 rtp_hdr_1.simulcastIdx = 1;
134 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_1, payload_type_1, 0, 0, 136 EXPECT_FALSE(payload_router_->RoutePayload(frame_type_1, payload_type_1, 0, 0,
135 &payload_1, 1, NULL, &rtp_hdr_1)); 137 &payload_1, 1, NULL, &rtp_hdr_1));
136 } 138 }
137 139
138 TEST_F(PayloadRouterTest, MaxPayloadLength) { 140 TEST_F(PayloadRouterTest, MaxPayloadLength) {
139 // 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
140 // length for IP/UDP/SRTP with a MTU of 150 bytes. 142 // length for IP/UDP/SRTP with a MTU of 150 bytes.
141 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4; 143 const size_t kDefaultMaxLength = 1500 - 20 - 8 - 12 - 4;
142 EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength()); 144 EXPECT_EQ(kDefaultMaxLength, payload_router_->DefaultMaxPayloadLength());
143 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); 145 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength());
144 146
145 MockRtpRtcp rtp_1; 147 MockRtpRtcp rtp_1;
146 MockRtpRtcp rtp_2; 148 MockRtpRtcp rtp_2;
147 std::vector<RtpRtcp*> modules; 149 std::vector<RtpRtcp*> modules;
148 modules.push_back(&rtp_1); 150 modules.push_back(&rtp_1);
149 modules.push_back(&rtp_2); 151 modules.push_back(&rtp_2);
150 payload_router_->SetSendingRtpModules(modules); 152 payload_router_->Init(modules);
153 payload_router_->SetSendingRtpModules(modules.size());
151 154
152 // Modules return a higher length than the default value. 155 // Modules return a higher length than the default value.
153 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) 156 EXPECT_CALL(rtp_1, MaxDataPayloadLength())
154 .Times(1) 157 .Times(1)
155 .WillOnce(Return(kDefaultMaxLength + 10)); 158 .WillOnce(Return(kDefaultMaxLength + 10));
156 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) 159 EXPECT_CALL(rtp_2, MaxDataPayloadLength())
157 .Times(1) 160 .Times(1)
158 .WillOnce(Return(kDefaultMaxLength + 10)); 161 .WillOnce(Return(kDefaultMaxLength + 10));
159 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength()); 162 EXPECT_EQ(kDefaultMaxLength, payload_router_->MaxPayloadLength());
160 163
161 // The modules return a value lower than default. 164 // The modules return a value lower than default.
162 const size_t kTestMinPayloadLength = 1001; 165 const size_t kTestMinPayloadLength = 1001;
163 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) 166 EXPECT_CALL(rtp_1, MaxDataPayloadLength())
164 .Times(1) 167 .Times(1)
165 .WillOnce(Return(kTestMinPayloadLength + 10)); 168 .WillOnce(Return(kTestMinPayloadLength + 10));
166 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) 169 EXPECT_CALL(rtp_2, MaxDataPayloadLength())
167 .Times(1) 170 .Times(1)
168 .WillOnce(Return(kTestMinPayloadLength)); 171 .WillOnce(Return(kTestMinPayloadLength));
169 EXPECT_EQ(kTestMinPayloadLength, payload_router_->MaxPayloadLength()); 172 EXPECT_EQ(kTestMinPayloadLength, payload_router_->MaxPayloadLength());
170 } 173 }
171 174
172 TEST_F(PayloadRouterTest, SetTargetSendBitrates) { 175 TEST_F(PayloadRouterTest, SetTargetSendBitrates) {
173 MockRtpRtcp rtp_1; 176 MockRtpRtcp rtp_1;
174 MockRtpRtcp rtp_2; 177 MockRtpRtcp rtp_2;
175 std::vector<RtpRtcp*> modules; 178 std::vector<RtpRtcp*> modules;
176 modules.push_back(&rtp_1); 179 modules.push_back(&rtp_1);
177 modules.push_back(&rtp_2); 180 modules.push_back(&rtp_2);
178 payload_router_->SetSendingRtpModules(modules); 181 payload_router_->Init(modules);
182 payload_router_->SetSendingRtpModules(modules.size());
179 183
180 const uint32_t bitrate_1 = 10000; 184 const uint32_t bitrate_1 = 10000;
181 const uint32_t bitrate_2 = 76543; 185 const uint32_t bitrate_2 = 76543;
182 std::vector<uint32_t> bitrates(2, bitrate_1); 186 std::vector<uint32_t> bitrates(2, bitrate_1);
183 bitrates[1] = bitrate_2; 187 bitrates[1] = bitrate_2;
184 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) 188 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1))
185 .Times(1); 189 .Times(1);
186 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) 190 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2))
187 .Times(1); 191 .Times(1);
188 payload_router_->SetTargetSendBitrates(bitrates); 192 payload_router_->SetTargetSendBitrates(bitrates);
189 193
190 bitrates.resize(1); 194 bitrates.resize(1);
191 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1)) 195 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1))
192 .Times(0); 196 .Times(1);
193 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2)) 197 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2))
194 .Times(0); 198 .Times(0);
195 payload_router_->SetTargetSendBitrates(bitrates); 199 payload_router_->SetTargetSendBitrates(bitrates);
196
197 bitrates.resize(3);
198 bitrates[1] = bitrate_2;
199 bitrates[2] = bitrate_1 + bitrate_2;
200 EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1))
201 .Times(1);
202 EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2))
203 .Times(1);
204 payload_router_->SetTargetSendBitrates(bitrates);
205 } 200 }
206 } // namespace webrtc 201 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/payload_router.cc ('k') | webrtc/video/video_send_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698