| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 | 912 |
| 913 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { | 913 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { |
| 914 size_t num_streams = fake_call_->GetVideoReceiveStreams().size(); | 914 size_t num_streams = fake_call_->GetVideoReceiveStreams().size(); |
| 915 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 915 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
| 916 std::vector<FakeVideoReceiveStream*> streams = | 916 std::vector<FakeVideoReceiveStream*> streams = |
| 917 fake_call_->GetVideoReceiveStreams(); | 917 fake_call_->GetVideoReceiveStreams(); |
| 918 EXPECT_EQ(num_streams + 1, streams.size()); | 918 EXPECT_EQ(num_streams + 1, streams.size()); |
| 919 return streams[streams.size() - 1]; | 919 return streams[streams.size() - 1]; |
| 920 } | 920 } |
| 921 | 921 |
| 922 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate_kbps, | 922 void SetSendCodecsShouldWorkForBitrates( |
| 923 int expected_min_bitrate_bps, | 923 const char* min_bitrate_kbps, |
| 924 const char* start_bitrate_kbps, | 924 int expected_min_bitrate_bps, |
| 925 int expected_start_bitrate_bps, | 925 const char* start_bitrate_kbps, |
| 926 const char* max_bitrate_kbps, | 926 int expected_start_bitrate_bps, |
| 927 int expected_max_bitrate_bps) { | 927 const char* max_bitrate_kbps, |
| 928 rtc::Optional<int> expected_max_bitrate_bps) { |
| 928 auto& codecs = send_parameters_.codecs; | 929 auto& codecs = send_parameters_.codecs; |
| 929 codecs.clear(); | 930 codecs.clear(); |
| 930 codecs.push_back(kVp8Codec); | 931 codecs.push_back(kVp8Codec); |
| 931 codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; | 932 codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; |
| 932 codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; | 933 codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; |
| 933 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; | 934 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; |
| 934 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 935 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 935 | 936 |
| 936 EXPECT_EQ(expected_min_bitrate_bps, | 937 EXPECT_EQ(expected_min_bitrate_bps, |
| 937 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); | 938 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 fake_call_->GetVideoSendStreams(); | 1088 fake_call_->GetVideoSendStreams(); |
| 1088 EXPECT_TRUE(streams.size() > 0); | 1089 EXPECT_TRUE(streams.size() > 0); |
| 1089 FakeVideoSendStream* stream = streams[streams.size() - 1]; | 1090 FakeVideoSendStream* stream = streams[streams.size() - 1]; |
| 1090 | 1091 |
| 1091 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig(); | 1092 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig(); |
| 1092 EXPECT_EQ(1, encoder_config.streams.size()); | 1093 EXPECT_EQ(1, encoder_config.streams.size()); |
| 1093 return encoder_config.streams[0].max_bitrate_bps; | 1094 return encoder_config.streams[0].max_bitrate_bps; |
| 1094 } | 1095 } |
| 1095 | 1096 |
| 1096 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer, | 1097 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer, |
| 1097 int global_max, | 1098 rtc::Optional<int> global_max, |
| 1098 int stream_max, | 1099 rtc::Optional<int> stream_max, |
| 1099 int expected_encoder_bitrate) { | 1100 int expected_encoder_bitrate) { |
| 1100 VideoSendParameters limited_send_params = send_parameters_; | 1101 VideoSendParameters limited_send_params = send_parameters_; |
| 1101 limited_send_params.max_bandwidth_bps = global_max; | 1102 limited_send_params.max_bitrate_bps = global_max; |
| 1102 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params)); | 1103 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params)); |
| 1103 webrtc::RtpParameters parameters = channel_->GetRtpParameters(last_ssrc_); | 1104 webrtc::RtpParameters parameters = channel_->GetRtpParameters(last_ssrc_); |
| 1104 EXPECT_EQ(1UL, parameters.encodings.size()); | 1105 EXPECT_EQ(1UL, parameters.encodings.size()); |
| 1105 parameters.encodings[0].max_bitrate_bps = stream_max; | 1106 parameters.encodings[0].max_bitrate_bps = stream_max; |
| 1106 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); | 1107 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); |
| 1107 // Read back the parameteres and verify they have the correct value | 1108 // Read back the parameteres and verify they have the correct value |
| 1108 parameters = channel_->GetRtpParameters(last_ssrc_); | 1109 parameters = channel_->GetRtpParameters(last_ssrc_); |
| 1109 EXPECT_EQ(1UL, parameters.encodings.size()); | 1110 EXPECT_EQ(1UL, parameters.encodings.size()); |
| 1110 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps); | 1111 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps); |
| 1111 // Verify that the new value propagated down to the encoder | 1112 // Verify that the new value propagated down to the encoder |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2186 parameters.codecs.push_back(kVp8Codec360p); | 2187 parameters.codecs.push_back(kVp8Codec360p); |
| 2187 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2188 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 2188 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); | 2189 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); |
| 2189 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); | 2190 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); |
| 2190 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); | 2191 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); |
| 2191 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 2192 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
| 2192 } | 2193 } |
| 2193 | 2194 |
| 2194 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { | 2195 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { |
| 2195 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 2196 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
| 2196 200000); | 2197 rtc::Optional<int>(200000)); |
| 2197 } | 2198 } |
| 2198 | 2199 |
| 2199 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { | 2200 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { |
| 2200 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); | 2201 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", |
| 2202 rtc::Optional<int>(10000000)); |
| 2201 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); | 2203 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); |
| 2202 ASSERT_EQ(1u, streams.size()); | 2204 ASSERT_EQ(1u, streams.size()); |
| 2203 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); | 2205 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); |
| 2204 } | 2206 } |
| 2205 | 2207 |
| 2206 TEST_F(WebRtcVideoChannel2Test, | 2208 TEST_F(WebRtcVideoChannel2Test, |
| 2207 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { | 2209 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { |
| 2208 SetSendCodecsShouldWorkForBitrates( | 2210 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "", rtc::Optional<int>()); |
| 2209 "", 0, "", -1, "", -1); | |
| 2210 } | 2211 } |
| 2211 | 2212 |
| 2212 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { | 2213 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { |
| 2213 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1); | 2214 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", |
| 2215 rtc::Optional<int>()); |
| 2214 } | 2216 } |
| 2215 | 2217 |
| 2216 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { | 2218 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { |
| 2217 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; | 2219 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; |
| 2218 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; | 2220 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; |
| 2219 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); | 2221 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
| 2220 } | 2222 } |
| 2221 | 2223 |
| 2222 TEST_F(WebRtcVideoChannel2Test, | 2224 TEST_F(WebRtcVideoChannel2Test, |
| 2223 SetMaxSendBandwidthShouldPreserveOtherBitrates) { | 2225 SetMaxSendBandwidthShouldPreserveOtherBitrates) { |
| 2224 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 2226 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
| 2225 200000); | 2227 rtc::Optional<int>(200000)); |
| 2226 send_parameters_.max_bandwidth_bps = 300000; | 2228 send_parameters_.max_bitrate_bps = rtc::Optional<int>(300000); |
| 2227 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2229 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2228 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) | 2230 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) |
| 2229 << "Setting max bitrate should keep previous min bitrate."; | 2231 << "Setting max bitrate should keep previous min bitrate."; |
| 2230 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) | 2232 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) |
| 2231 << "Setting max bitrate should not reset start bitrate."; | 2233 << "Setting max bitrate should not reset start bitrate."; |
| 2232 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2234 EXPECT_EQ(rtc::Optional<int>(300000), |
| 2235 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
| 2233 } | 2236 } |
| 2234 | 2237 |
| 2235 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { | 2238 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { |
| 2236 send_parameters_.max_bandwidth_bps = 300000; | 2239 send_parameters_.max_bitrate_bps = rtc::Optional<int>(300000); |
| 2237 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2240 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2238 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2241 EXPECT_EQ(rtc::Optional<int>(300000), |
| 2239 // <= 0 means disable (infinite) max bitrate. | 2242 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
| 2240 send_parameters_.max_bandwidth_bps = 0; | 2243 // <not set> means disable (infinite) max bitrate. |
| 2244 send_parameters_.max_bitrate_bps = rtc::Optional<int>(); |
| 2241 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2245 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2242 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps) | 2246 EXPECT_EQ(rtc::Optional<int>(), |
| 2247 fake_call_->GetConfig().bitrate_config.max_bitrate_bps) |
| 2243 << "Setting zero max bitrate did not reset start bitrate."; | 2248 << "Setting zero max bitrate did not reset start bitrate."; |
| 2244 } | 2249 } |
| 2245 | 2250 |
| 2246 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { | 2251 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { |
| 2247 cricket::VideoSendParameters parameters; | 2252 cricket::VideoSendParameters parameters; |
| 2248 parameters.codecs.push_back(kVp8Codec720p); | 2253 parameters.codecs.push_back(kVp8Codec720p); |
| 2249 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2254 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 2250 channel_->SetSend(true); | 2255 channel_->SetSend(true); |
| 2251 | 2256 |
| 2252 FakeVideoSendStream* stream = AddSendStream(); | 2257 FakeVideoSendStream* stream = AddSendStream(); |
| 2253 | 2258 |
| 2254 cricket::FakeVideoCapturer capturer; | 2259 cricket::FakeVideoCapturer capturer; |
| 2255 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 2260 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 2256 EXPECT_EQ(cricket::CS_RUNNING, | 2261 EXPECT_EQ(cricket::CS_RUNNING, |
| 2257 capturer.Start(capturer.GetSupportedFormats()->front())); | 2262 capturer.Start(capturer.GetSupportedFormats()->front())); |
| 2258 | 2263 |
| 2259 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2264 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
| 2260 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; | 2265 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; |
| 2261 EXPECT_GT(initial_max_bitrate_bps, 0); | 2266 EXPECT_GT(initial_max_bitrate_bps, 0); |
| 2262 | 2267 |
| 2263 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; | 2268 parameters.max_bitrate_bps = rtc::Optional<int>(initial_max_bitrate_bps * 2); |
| 2264 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 2269 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
| 2265 // Insert a frame to update the encoder config. | 2270 // Insert a frame to update the encoder config. |
| 2266 EXPECT_TRUE(capturer.CaptureFrame()); | 2271 EXPECT_TRUE(capturer.CaptureFrame()); |
| 2267 streams = stream->GetVideoStreams(); | 2272 streams = stream->GetVideoStreams(); |
| 2268 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); | 2273 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); |
| 2269 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); | 2274 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); |
| 2270 } | 2275 } |
| 2271 | 2276 |
| 2272 TEST_F(WebRtcVideoChannel2Test, | 2277 TEST_F(WebRtcVideoChannel2Test, |
| 2273 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { | 2278 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2285 EXPECT_EQ(cricket::CS_RUNNING, | 2290 EXPECT_EQ(cricket::CS_RUNNING, |
| 2286 capturer.Start(capturer.GetSupportedFormats()->front())); | 2291 capturer.Start(capturer.GetSupportedFormats()->front())); |
| 2287 EXPECT_TRUE(capturer.CaptureFrame()); | 2292 EXPECT_TRUE(capturer.CaptureFrame()); |
| 2288 | 2293 |
| 2289 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2294 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
| 2290 ASSERT_GT(streams.size(), 1u) | 2295 ASSERT_GT(streams.size(), 1u) |
| 2291 << "Without simulcast this test doesn't make sense."; | 2296 << "Without simulcast this test doesn't make sense."; |
| 2292 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams); | 2297 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams); |
| 2293 EXPECT_GT(initial_max_bitrate_bps, 0); | 2298 EXPECT_GT(initial_max_bitrate_bps, 0); |
| 2294 | 2299 |
| 2295 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; | 2300 parameters.max_bitrate_bps = rtc::Optional<int>(initial_max_bitrate_bps * 2); |
| 2296 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 2301 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
| 2297 // Insert a frame to update the encoder config. | 2302 // Insert a frame to update the encoder config. |
| 2298 EXPECT_TRUE(capturer.CaptureFrame()); | 2303 EXPECT_TRUE(capturer.CaptureFrame()); |
| 2299 streams = stream->GetVideoStreams(); | 2304 streams = stream->GetVideoStreams(); |
| 2300 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams); | 2305 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams); |
| 2301 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); | 2306 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); |
| 2302 | 2307 |
| 2303 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr)); | 2308 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr)); |
| 2304 } | 2309 } |
| 2305 | 2310 |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3138 } | 3143 } |
| 3139 | 3144 |
| 3140 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { | 3145 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { |
| 3141 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); | 3146 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); |
| 3142 } | 3147 } |
| 3143 | 3148 |
| 3144 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { | 3149 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { |
| 3145 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); | 3150 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); |
| 3146 } | 3151 } |
| 3147 | 3152 |
| 3148 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) { | 3153 TEST_F(WebRtcVideoChannel2Test, CanSetMaxBitrateForExistingStream) { |
| 3149 AddSendStream(); | 3154 AddSendStream(); |
| 3150 | 3155 |
| 3151 cricket::FakeVideoCapturer capturer; | 3156 cricket::FakeVideoCapturer capturer; |
| 3152 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 3157 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 3153 cricket::VideoFormat capture_format_hd = | 3158 cricket::VideoFormat capture_format_hd = |
| 3154 capturer.GetSupportedFormats()->front(); | 3159 capturer.GetSupportedFormats()->front(); |
| 3155 EXPECT_EQ(1280, capture_format_hd.width); | 3160 EXPECT_EQ(1280, capture_format_hd.width); |
| 3156 EXPECT_EQ(720, capture_format_hd.height); | 3161 EXPECT_EQ(720, capture_format_hd.height); |
| 3157 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); | 3162 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); |
| 3158 EXPECT_TRUE(channel_->SetSend(true)); | 3163 EXPECT_TRUE(channel_->SetSend(true)); |
| 3159 | 3164 |
| 3160 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer); | 3165 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer); |
| 3161 EXPECT_TRUE(default_encoder_bitrate > 1000); | 3166 EXPECT_TRUE(default_encoder_bitrate > 1000); |
| 3162 | 3167 |
| 3163 // TODO(skvlad): Resolve the inconsistency between the interpretation | 3168 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(1000), |
| 3164 // of the global bitrate limit for audio and video: | 3169 rtc::Optional<int>(), 1000); |
| 3165 // - Audio: max_bandwidth_bps = 0 - fail the operation, | 3170 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(1000), |
| 3166 // max_bandwidth_bps = -1 - remove the bandwidth limit | 3171 rtc::Optional<int>(800), 800); |
| 3167 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, | 3172 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(600), |
| 3168 // max_bandwidth_bps = -1 - do not change the previously set | 3173 rtc::Optional<int>(800), 600); |
| 3169 // limit. | 3174 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(), |
| 3170 | 3175 rtc::Optional<int>(800), 800); |
| 3171 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000); | 3176 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(), rtc::Optional<int>(), |
| 3172 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); | 3177 default_encoder_bitrate); |
| 3173 SetAndExpectMaxBitrate(capturer, 600, 800, 600); | |
| 3174 SetAndExpectMaxBitrate(capturer, 0, 800, 800); | |
| 3175 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); | |
| 3176 | 3178 |
| 3177 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 3179 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
| 3178 } | 3180 } |
| 3179 | 3181 |
| 3182 TEST_F(WebRtcVideoChannel2Test, CannotSetNegativeOrZeroMaxBitrate) { |
| 3183 AddSendStream(); |
| 3184 webrtc::RtpParameters bad_parameters; |
| 3185 bad_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); |
| 3186 |
| 3187 bad_parameters.encodings[0].max_bitrate_bps = rtc::Optional<int>(0); |
| 3188 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, bad_parameters)); |
| 3189 bad_parameters.encodings[0].max_bitrate_bps = rtc::Optional<int>(-1); |
| 3190 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, bad_parameters)); |
| 3191 } |
| 3192 |
| 3180 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { | 3193 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { |
| 3181 webrtc::RtpParameters nonexistent_parameters = | 3194 webrtc::RtpParameters nonexistent_parameters = |
| 3182 channel_->GetRtpParameters(last_ssrc_); | 3195 channel_->GetRtpParameters(last_ssrc_); |
| 3183 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); | 3196 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); |
| 3184 | 3197 |
| 3185 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); | 3198 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); |
| 3186 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters)); | 3199 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters)); |
| 3187 } | 3200 } |
| 3188 | 3201 |
| 3189 TEST_F(WebRtcVideoChannel2Test, | 3202 TEST_F(WebRtcVideoChannel2Test, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3290 codec.width, codec.height, | 3303 codec.width, codec.height, |
| 3291 cricket::VideoFormat::FpsToInterval(30), | 3304 cricket::VideoFormat::FpsToInterval(30), |
| 3292 cricket::FOURCC_I420))); | 3305 cricket::FOURCC_I420))); |
| 3293 channel_->SetSend(true); | 3306 channel_->SetSend(true); |
| 3294 EXPECT_TRUE(capturer.CaptureFrame()); | 3307 EXPECT_TRUE(capturer.CaptureFrame()); |
| 3295 | 3308 |
| 3296 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); | 3309 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 3297 ASSERT_EQ(expected_num_streams, video_streams.size()); | 3310 ASSERT_EQ(expected_num_streams, video_streams.size()); |
| 3298 | 3311 |
| 3299 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( | 3312 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( |
| 3300 num_configured_streams, codec.width, codec.height, 0, kDefaultQpMax, | 3313 num_configured_streams, codec.width, codec.height, rtc::Optional<int>(), |
| 3314 kDefaultQpMax, |
| 3301 codec.framerate != 0 ? codec.framerate : kDefaultFramerate); | 3315 codec.framerate != 0 ? codec.framerate : kDefaultFramerate); |
| 3302 | 3316 |
| 3303 ASSERT_EQ(expected_streams.size(), video_streams.size()); | 3317 ASSERT_EQ(expected_streams.size(), video_streams.size()); |
| 3304 | 3318 |
| 3305 size_t num_streams = video_streams.size(); | 3319 size_t num_streams = video_streams.size(); |
| 3306 int total_max_bitrate_bps = 0; | 3320 int total_max_bitrate_bps = 0; |
| 3307 for (size_t i = 0; i < num_streams; ++i) { | 3321 for (size_t i = 0; i < num_streams; ++i) { |
| 3308 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); | 3322 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); |
| 3309 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); | 3323 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); |
| 3310 | 3324 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3392 } | 3406 } |
| 3393 | 3407 |
| 3394 // Test that we normalize send codec format size in simulcast. | 3408 // Test that we normalize send codec format size in simulcast. |
| 3395 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3409 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
| 3396 cricket::VideoCodec codec(kVp8Codec270p); | 3410 cricket::VideoCodec codec(kVp8Codec270p); |
| 3397 codec.width += 1; | 3411 codec.width += 1; |
| 3398 codec.height += 1; | 3412 codec.height += 1; |
| 3399 VerifySimulcastSettings(codec, 2, 2); | 3413 VerifySimulcastSettings(codec, 2, 2); |
| 3400 } | 3414 } |
| 3401 } // namespace cricket | 3415 } // namespace cricket |
| OLD | NEW |