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

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

Issue 2531383002: Wire up BitrateAllocation to be sent as RTCP TargetBitrate (Closed)
Patch Set: Undo crit removal Created 4 years 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, 43 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type,
44 encoded_image._timeStamp, 44 encoded_image._timeStamp,
45 encoded_image.capture_time_ms_, &payload, 45 encoded_image.capture_time_ms_, &payload,
46 encoded_image._length, nullptr, _, _)) 46 encoded_image._length, nullptr, _, _))
47 .Times(0); 47 .Times(0);
48 EXPECT_NE( 48 EXPECT_NE(
49 EncodedImageCallback::Result::OK, 49 EncodedImageCallback::Result::OK,
50 payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error); 50 payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error);
51 51
52 payload_router.set_active(true); 52 payload_router.SetActive(true);
53 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, 53 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type,
54 encoded_image._timeStamp, 54 encoded_image._timeStamp,
55 encoded_image.capture_time_ms_, &payload, 55 encoded_image.capture_time_ms_, &payload,
56 encoded_image._length, nullptr, _, _)) 56 encoded_image._length, nullptr, _, _))
57 .Times(1) 57 .Times(1)
58 .WillOnce(Return(true)); 58 .WillOnce(Return(true));
59 EXPECT_EQ( 59 EXPECT_EQ(
60 EncodedImageCallback::Result::OK, 60 EncodedImageCallback::Result::OK,
61 payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error); 61 payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error);
62 62
63 payload_router.set_active(false); 63 payload_router.SetActive(false);
64 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, 64 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type,
65 encoded_image._timeStamp, 65 encoded_image._timeStamp,
66 encoded_image.capture_time_ms_, &payload, 66 encoded_image.capture_time_ms_, &payload,
67 encoded_image._length, nullptr, _, _)) 67 encoded_image._length, nullptr, _, _))
68 .Times(0); 68 .Times(0);
69 EXPECT_NE( 69 EXPECT_NE(
70 EncodedImageCallback::Result::OK, 70 EncodedImageCallback::Result::OK,
71 payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error); 71 payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error);
72 72
73 payload_router.set_active(true); 73 payload_router.SetActive(true);
74 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type, 74 EXPECT_CALL(rtp, SendOutgoingData(encoded_image._frameType, payload_type,
75 encoded_image._timeStamp, 75 encoded_image._timeStamp,
76 encoded_image.capture_time_ms_, &payload, 76 encoded_image.capture_time_ms_, &payload,
77 encoded_image._length, nullptr, _, _)) 77 encoded_image._length, nullptr, _, _))
78 .Times(1) 78 .Times(1)
79 .WillOnce(Return(true)); 79 .WillOnce(Return(true));
80 EXPECT_EQ( 80 EXPECT_EQ(
81 EncodedImageCallback::Result::OK, 81 EncodedImageCallback::Result::OK,
82 payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error); 82 payload_router.OnEncodedImage(encoded_image, nullptr, nullptr).error);
83 } 83 }
(...skipping 15 matching lines...) Expand all
99 encoded_image._buffer = &payload; 99 encoded_image._buffer = &payload;
100 encoded_image._length = 1; 100 encoded_image._length = 1;
101 101
102 PayloadRouter payload_router(modules, payload_type); 102 PayloadRouter payload_router(modules, payload_type);
103 103
104 CodecSpecificInfo codec_info_1; 104 CodecSpecificInfo codec_info_1;
105 memset(&codec_info_1, 0, sizeof(CodecSpecificInfo)); 105 memset(&codec_info_1, 0, sizeof(CodecSpecificInfo));
106 codec_info_1.codecType = kVideoCodecVP8; 106 codec_info_1.codecType = kVideoCodecVP8;
107 codec_info_1.codecSpecific.VP8.simulcastIdx = 0; 107 codec_info_1.codecSpecific.VP8.simulcastIdx = 0;
108 108
109 payload_router.set_active(true); 109 payload_router.SetActive(true);
110 EXPECT_CALL(rtp_1, SendOutgoingData(encoded_image._frameType, payload_type, 110 EXPECT_CALL(rtp_1, SendOutgoingData(encoded_image._frameType, payload_type,
111 encoded_image._timeStamp, 111 encoded_image._timeStamp,
112 encoded_image.capture_time_ms_, &payload, 112 encoded_image.capture_time_ms_, &payload,
113 encoded_image._length, nullptr, _, _)) 113 encoded_image._length, nullptr, _, _))
114 .Times(1) 114 .Times(1)
115 .WillOnce(Return(true)); 115 .WillOnce(Return(true));
116 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0); 116 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)).Times(0);
117 EXPECT_EQ(EncodedImageCallback::Result::OK, 117 EXPECT_EQ(EncodedImageCallback::Result::OK,
118 payload_router.OnEncodedImage(encoded_image, &codec_info_1, nullptr) 118 payload_router.OnEncodedImage(encoded_image, &codec_info_1, nullptr)
119 .error); 119 .error);
120 120
121 CodecSpecificInfo codec_info_2; 121 CodecSpecificInfo codec_info_2;
122 memset(&codec_info_2, 0, sizeof(CodecSpecificInfo)); 122 memset(&codec_info_2, 0, sizeof(CodecSpecificInfo));
123 codec_info_2.codecType = kVideoCodecVP8; 123 codec_info_2.codecType = kVideoCodecVP8;
124 codec_info_2.codecSpecific.VP8.simulcastIdx = 1; 124 codec_info_2.codecSpecific.VP8.simulcastIdx = 1;
125 125
126 EXPECT_CALL(rtp_2, SendOutgoingData(encoded_image._frameType, payload_type, 126 EXPECT_CALL(rtp_2, SendOutgoingData(encoded_image._frameType, payload_type,
127 encoded_image._timeStamp, 127 encoded_image._timeStamp,
128 encoded_image.capture_time_ms_, &payload, 128 encoded_image.capture_time_ms_, &payload,
129 encoded_image._length, nullptr, _, _)) 129 encoded_image._length, nullptr, _, _))
130 .Times(1) 130 .Times(1)
131 .WillOnce(Return(true)); 131 .WillOnce(Return(true));
132 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) 132 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _))
133 .Times(0); 133 .Times(0);
134 EXPECT_EQ(EncodedImageCallback::Result::OK, 134 EXPECT_EQ(EncodedImageCallback::Result::OK,
135 payload_router.OnEncodedImage(encoded_image, &codec_info_2, nullptr) 135 payload_router.OnEncodedImage(encoded_image, &codec_info_2, nullptr)
136 .error); 136 .error);
137 137
138 // Inactive. 138 // Inactive.
139 payload_router.set_active(false); 139 payload_router.SetActive(false);
140 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _)) 140 EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _, _))
141 .Times(0); 141 .Times(0);
142 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _)) 142 EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _, _))
143 .Times(0); 143 .Times(0);
144 EXPECT_NE(EncodedImageCallback::Result::OK, 144 EXPECT_NE(EncodedImageCallback::Result::OK,
145 payload_router.OnEncodedImage(encoded_image, &codec_info_1, nullptr) 145 payload_router.OnEncodedImage(encoded_image, &codec_info_1, nullptr)
146 .error); 146 .error);
147 EXPECT_NE(EncodedImageCallback::Result::OK, 147 EXPECT_NE(EncodedImageCallback::Result::OK,
148 payload_router.OnEncodedImage(encoded_image, &codec_info_2, nullptr) 148 payload_router.OnEncodedImage(encoded_image, &codec_info_2, nullptr)
149 .error); 149 .error);
(...skipping 25 matching lines...) Expand all
175 // The modules return a value lower than default. 175 // The modules return a value lower than default.
176 const size_t kTestMinPayloadLength = 1001; 176 const size_t kTestMinPayloadLength = 1001;
177 EXPECT_CALL(rtp_1, MaxDataPayloadLength()) 177 EXPECT_CALL(rtp_1, MaxDataPayloadLength())
178 .Times(1) 178 .Times(1)
179 .WillOnce(Return(kTestMinPayloadLength + 10)); 179 .WillOnce(Return(kTestMinPayloadLength + 10));
180 EXPECT_CALL(rtp_2, MaxDataPayloadLength()) 180 EXPECT_CALL(rtp_2, MaxDataPayloadLength())
181 .Times(1) 181 .Times(1)
182 .WillOnce(Return(kTestMinPayloadLength)); 182 .WillOnce(Return(kTestMinPayloadLength));
183 EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength()); 183 EXPECT_EQ(kTestMinPayloadLength, payload_router.MaxPayloadLength());
184 } 184 }
185
186 TEST(PayloadRouterTest, SimulcastTargetBitrate) {
187 NiceMock<MockRtpRtcp> rtp_1;
188 NiceMock<MockRtpRtcp> rtp_2;
189 std::vector<RtpRtcp*> modules;
190 modules.push_back(&rtp_1);
191 modules.push_back(&rtp_2);
192 PayloadRouter payload_router(modules, 42);
193 payload_router.SetActive(true);
194
195 BitrateAllocation bitrate;
196 bitrate.SetBitrate(0, 0, 10000);
197 bitrate.SetBitrate(0, 1, 20000);
198 bitrate.SetBitrate(1, 0, 40000);
199 bitrate.SetBitrate(1, 1, 80000);
200
201 BitrateAllocation layer0_bitrate;
202 layer0_bitrate.SetBitrate(0, 0, 10000);
203 layer0_bitrate.SetBitrate(0, 1, 20000);
204
205 BitrateAllocation layer1_bitrate;
206 layer1_bitrate.SetBitrate(0, 0, 40000);
207 layer1_bitrate.SetBitrate(0, 1, 80000);
208
209 EXPECT_CALL(rtp_1, SetVideoBitrateAllocation(layer0_bitrate)).Times(1);
210 EXPECT_CALL(rtp_2, SetVideoBitrateAllocation(layer1_bitrate)).Times(1);
211
212 payload_router.OnBitrateAllocationUpdated(bitrate);
213 }
214
215 TEST(PayloadRouterTest, SvcTargetBitrate) {
216 NiceMock<MockRtpRtcp> rtp_1;
217 std::vector<RtpRtcp*> modules;
218 modules.push_back(&rtp_1);
219 PayloadRouter payload_router(modules, 42);
220 payload_router.SetActive(true);
221
222 BitrateAllocation bitrate;
223 bitrate.SetBitrate(0, 0, 10000);
224 bitrate.SetBitrate(0, 1, 20000);
225 bitrate.SetBitrate(1, 0, 40000);
226 bitrate.SetBitrate(1, 1, 80000);
227
228 EXPECT_CALL(rtp_1, SetVideoBitrateAllocation(bitrate)).Times(1);
229
230 payload_router.OnBitrateAllocationUpdated(bitrate);
231 }
232
185 } // namespace webrtc 233 } // 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