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

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

Issue 2070343002: Remove ViEncoder::Pause / Start (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove from header file. Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include <algorithm> // max 10 #include <algorithm> // max
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 // New bitrate should be reconfigured above the previous max. As there's no 1186 // New bitrate should be reconfigured above the previous max. As there's no
1187 // network connection this shouldn't be flaky, as no bitrate should've been 1187 // network connection this shouldn't be flaky, as no bitrate should've been
1188 // reported in between. 1188 // reported in between.
1189 EXPECT_TRUE(encoder.WaitForStartBitrate()); 1189 EXPECT_TRUE(encoder.WaitForStartBitrate());
1190 EXPECT_EQ(bitrate_config.start_bitrate_bps / 1000, 1190 EXPECT_EQ(bitrate_config.start_bitrate_bps / 1000,
1191 encoder.GetStartBitrateKbps()); 1191 encoder.GetStartBitrateKbps());
1192 1192
1193 DestroyStreams(); 1193 DestroyStreams();
1194 } 1194 }
1195 1195
1196 // This test that if the encoder use an internal source, VideoEncoder::SetRates
1197 // will be called with zero bitrate during initialization and that
1198 // VideoSendStream::Stop also triggers VideoEncoder::SetRates Start to be called
1199 // with zero bitrate.
1200 TEST_F(VideoSendStreamTest, VideoSendStreamStopSetEncoderRateToZero) {
1201 class StartStopBitrateObserver : public test::FakeEncoder {
1202 public:
1203 StartStopBitrateObserver()
1204 : FakeEncoder(Clock::GetRealTimeClock()),
1205 bitrate_changed_(false, false),
1206 bitrate_kbps_(0) {}
1207 int32_t InitEncode(const VideoCodec* config,
1208 int32_t number_of_cores,
1209 size_t max_payload_size) override {
1210 rtc::CritScope lock(&crit_);
1211 bitrate_kbps_ = config->startBitrate;
1212 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size);
1213 }
1214
1215 int32_t SetRates(uint32_t new_target_bitrate, uint32_t framerate) override {
1216 rtc::CritScope lock(&crit_);
1217 bitrate_kbps_ = new_target_bitrate;
1218 bitrate_changed_.Set();
1219 return FakeEncoder::SetRates(new_target_bitrate, framerate);
1220 }
1221
1222 int GetBitrateKbps() const {
1223 rtc::CritScope lock(&crit_);
1224 return bitrate_kbps_;
1225 }
1226
1227 bool WaitBitrateChanged() {
1228 return bitrate_changed_.Wait(VideoSendStreamTest::kDefaultTimeoutMs);
1229 }
1230
1231 private:
1232 rtc::CriticalSection crit_;
1233 rtc::Event bitrate_changed_;
1234 int bitrate_kbps_ GUARDED_BY(crit_);
1235 };
1236
1237 CreateSenderCall(Call::Config());
1238
1239 test::NullTransport transport;
1240 CreateSendConfig(1, 0, &transport);
1241
1242 StartStopBitrateObserver encoder;
1243 video_send_config_.encoder_settings.encoder = &encoder;
1244 video_send_config_.encoder_settings.internal_source = true;
1245
1246 CreateVideoStreams();
1247
1248 EXPECT_TRUE(encoder.WaitBitrateChanged());
1249 EXPECT_EQ(0, encoder.GetBitrateKbps());
1250 video_send_stream_->Start();
1251 EXPECT_TRUE(encoder.WaitBitrateChanged());
1252 EXPECT_GT(encoder.GetBitrateKbps(), 0);
1253 video_send_stream_->Stop();
1254 EXPECT_TRUE(encoder.WaitBitrateChanged());
1255 EXPECT_EQ(0, encoder.GetBitrateKbps());
1256
1257 DestroyStreams();
1258 }
1259
1196 TEST_F(VideoSendStreamTest, CapturesTextureAndVideoFrames) { 1260 TEST_F(VideoSendStreamTest, CapturesTextureAndVideoFrames) {
1197 class FrameObserver : public rtc::VideoSinkInterface<VideoFrame> { 1261 class FrameObserver : public rtc::VideoSinkInterface<VideoFrame> {
1198 public: 1262 public:
1199 FrameObserver() : output_frame_event_(false, false) {} 1263 FrameObserver() : output_frame_event_(false, false) {}
1200 1264
1201 void OnFrame(const VideoFrame& video_frame) override { 1265 void OnFrame(const VideoFrame& video_frame) override {
1202 output_frames_.push_back(video_frame); 1266 output_frames_.push_back(video_frame);
1203 output_frame_event_.Set(); 1267 output_frame_event_.Set();
1204 } 1268 }
1205 1269
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 observation_complete_.Set(); 2367 observation_complete_.Set();
2304 } 2368 }
2305 } 2369 }
2306 } test; 2370 } test;
2307 2371
2308 RunBaseTest(&test); 2372 RunBaseTest(&test);
2309 } 2373 }
2310 #endif // !defined(RTC_DISABLE_VP9) 2374 #endif // !defined(RTC_DISABLE_VP9)
2311 2375
2312 } // namespace webrtc 2376 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698