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

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

Issue 1814763002: Cleanup of webrtc::VideoRenderer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Use a more specific DEPS rule. Created 4 years, 9 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> 10 #include <algorithm>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 static const int kHeight = 240; 120 static const int kHeight = 240;
121 // This constant is chosen to be higher than the timeout in the video_render 121 // This constant is chosen to be higher than the timeout in the video_render
122 // module. This makes sure that frames aren't dropped if there are no other 122 // module. This makes sure that frames aren't dropped if there are no other
123 // frames in the queue. 123 // frames in the queue.
124 static const int kDelayRenderCallbackMs = 1000; 124 static const int kDelayRenderCallbackMs = 1000;
125 125
126 class Renderer : public VideoRenderer { 126 class Renderer : public VideoRenderer {
127 public: 127 public:
128 Renderer() : event_(false, false) {} 128 Renderer() : event_(false, false) {}
129 129
130 void RenderFrame(const VideoFrame& video_frame, 130 void OnFrame(const VideoFrame& video_frame) override { event_.Set(); }
131 int /*time_to_render_ms*/) override {
132 event_.Set();
133 }
134
135 bool IsTextureSupported() const override { return false; }
136 131
137 bool Wait() { return event_.Wait(kDefaultTimeoutMs); } 132 bool Wait() { return event_.Wait(kDefaultTimeoutMs); }
138 133
139 rtc::Event event_; 134 rtc::Event event_;
140 } renderer; 135 } renderer;
141 136
142 class TestFrameCallback : public I420FrameCallback { 137 class TestFrameCallback : public I420FrameCallback {
143 public: 138 public:
144 TestFrameCallback() : event_(false, false) {} 139 TestFrameCallback() : event_(false, false) {}
145 140
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 receiver_transport.StopSending(); 183 receiver_transport.StopSending();
189 184
190 DestroyStreams(); 185 DestroyStreams();
191 } 186 }
192 187
193 TEST_F(EndToEndTest, TransmitsFirstFrame) { 188 TEST_F(EndToEndTest, TransmitsFirstFrame) {
194 class Renderer : public VideoRenderer { 189 class Renderer : public VideoRenderer {
195 public: 190 public:
196 Renderer() : event_(false, false) {} 191 Renderer() : event_(false, false) {}
197 192
198 void RenderFrame(const VideoFrame& video_frame, 193 void OnFrame(const VideoFrame& video_frame) override { event_.Set(); }
199 int /*time_to_render_ms*/) override {
200 event_.Set();
201 }
202 bool IsTextureSupported() const override { return false; }
203 194
204 bool Wait() { return event_.Wait(kDefaultTimeoutMs); } 195 bool Wait() { return event_.Wait(kDefaultTimeoutMs); }
205 196
206 rtc::Event event_; 197 rtc::Event event_;
207 } renderer; 198 } renderer;
208 199
209 CreateCalls(Call::Config(), Call::Config()); 200 CreateCalls(Call::Config(), Call::Config());
210 201
211 test::DirectTransport sender_transport(sender_call_.get()); 202 test::DirectTransport sender_transport(sender_call_.get());
212 test::DirectTransport receiver_transport(receiver_call_.get()); 203 test::DirectTransport receiver_transport(receiver_call_.get());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 256
266 (*receive_configs)[0].renderer = this; 257 (*receive_configs)[0].renderer = this;
267 (*receive_configs)[0].decoders.resize(1); 258 (*receive_configs)[0].decoders.resize(1);
268 (*receive_configs)[0].decoders[0].payload_type = 259 (*receive_configs)[0].decoders[0].payload_type =
269 send_config->encoder_settings.payload_type; 260 send_config->encoder_settings.payload_type;
270 (*receive_configs)[0].decoders[0].payload_name = 261 (*receive_configs)[0].decoders[0].payload_name =
271 send_config->encoder_settings.payload_name; 262 send_config->encoder_settings.payload_name;
272 (*receive_configs)[0].decoders[0].decoder = decoder_.get(); 263 (*receive_configs)[0].decoders[0].decoder = decoder_.get();
273 } 264 }
274 265
275 void RenderFrame(const VideoFrame& video_frame, 266 void OnFrame(const VideoFrame& video_frame) override {
276 int time_to_render_ms) override {
277 const int kRequiredFrames = 500; 267 const int kRequiredFrames = 500;
278 if (++frame_counter_ == kRequiredFrames) 268 if (++frame_counter_ == kRequiredFrames)
279 observation_complete_.Set(); 269 observation_complete_.Set();
280 } 270 }
281 271
282 bool IsTextureSupported() const override { return false; }
283
284 private: 272 private:
285 std::unique_ptr<webrtc::VideoEncoder> encoder_; 273 std::unique_ptr<webrtc::VideoEncoder> encoder_;
286 std::unique_ptr<webrtc::VideoDecoder> decoder_; 274 std::unique_ptr<webrtc::VideoDecoder> decoder_;
287 int frame_counter_; 275 int frame_counter_;
288 } test; 276 } test;
289 277
290 RunBaseTest(&test); 278 RunBaseTest(&test);
291 } 279 }
292 280
293 #if defined(WEBRTC_END_TO_END_H264_TESTS) 281 #if defined(WEBRTC_END_TO_END_H264_TESTS)
(...skipping 27 matching lines...) Expand all
321 309
322 (*receive_configs)[0].renderer = this; 310 (*receive_configs)[0].renderer = this;
323 (*receive_configs)[0].decoders.resize(1); 311 (*receive_configs)[0].decoders.resize(1);
324 (*receive_configs)[0].decoders[0].payload_type = 312 (*receive_configs)[0].decoders[0].payload_type =
325 send_config->encoder_settings.payload_type; 313 send_config->encoder_settings.payload_type;
326 (*receive_configs)[0].decoders[0].payload_name = 314 (*receive_configs)[0].decoders[0].payload_name =
327 send_config->encoder_settings.payload_name; 315 send_config->encoder_settings.payload_name;
328 (*receive_configs)[0].decoders[0].decoder = decoder_.get(); 316 (*receive_configs)[0].decoders[0].decoder = decoder_.get();
329 } 317 }
330 318
331 void RenderFrame(const VideoFrame& video_frame, 319 void OnFrame(const VideoFrame& video_frame) override {
332 int time_to_render_ms) override {
333 const int kRequiredFrames = 500; 320 const int kRequiredFrames = 500;
334 if (++frame_counter_ == kRequiredFrames) 321 if (++frame_counter_ == kRequiredFrames)
335 observation_complete_.Set(); 322 observation_complete_.Set();
336 } 323 }
337 324
338 bool IsTextureSupported() const override { return false; }
339
340 private: 325 private:
341 std::unique_ptr<webrtc::VideoEncoder> encoder_; 326 std::unique_ptr<webrtc::VideoEncoder> encoder_;
342 std::unique_ptr<webrtc::VideoDecoder> decoder_; 327 std::unique_ptr<webrtc::VideoDecoder> decoder_;
343 int frame_counter_; 328 int frame_counter_;
344 } test; 329 } test;
345 330
346 RunBaseTest(&test); 331 RunBaseTest(&test);
347 } 332 }
348 333
349 #endif // defined(WEBRTC_END_TO_END_H264_TESTS) 334 #endif // defined(WEBRTC_END_TO_END_H264_TESTS)
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 protected_timestamps_.insert(header.timestamp); 499 protected_timestamps_.insert(header.timestamp);
515 state_ = kDropEveryOtherPacketUntilFec; 500 state_ = kDropEveryOtherPacketUntilFec;
516 return DROP_PACKET; 501 return DROP_PACKET;
517 } 502 }
518 break; 503 break;
519 } 504 }
520 505
521 return SEND_PACKET; 506 return SEND_PACKET;
522 } 507 }
523 508
524 void RenderFrame(const VideoFrame& video_frame, 509 void OnFrame(const VideoFrame& video_frame) override {
525 int time_to_render_ms) override {
526 rtc::CritScope lock(&crit_); 510 rtc::CritScope lock(&crit_);
527 // Rendering frame with timestamp of packet that was dropped -> FEC 511 // Rendering frame with timestamp of packet that was dropped -> FEC
528 // protection worked. 512 // protection worked.
529 if (protected_timestamps_.count(video_frame.timestamp()) != 0) 513 if (protected_timestamps_.count(video_frame.timestamp()) != 0)
530 observation_complete_.Set(); 514 observation_complete_.Set();
531 } 515 }
532 516
533 bool IsTextureSupported() const override { return false; }
534
535 enum { 517 enum {
536 kFirstPacket, 518 kFirstPacket,
537 kDropEveryOtherPacketUntilFec, 519 kDropEveryOtherPacketUntilFec,
538 kDropNextMediaPacket, 520 kDropNextMediaPacket,
539 } state_; 521 } state_;
540 522
541 void ModifyVideoConfigs( 523 void ModifyVideoConfigs(
542 VideoSendStream::Config* send_config, 524 VideoSendStream::Config* send_config,
543 std::vector<VideoReceiveStream::Config>* receive_configs, 525 std::vector<VideoReceiveStream::Config>* receive_configs,
544 VideoEncoderConfig* encoder_config) override { 526 VideoEncoderConfig* encoder_config) override {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 825 }
844 826
845 TEST_F(EndToEndTest, UsesFrameCallbacks) { 827 TEST_F(EndToEndTest, UsesFrameCallbacks) {
846 static const int kWidth = 320; 828 static const int kWidth = 320;
847 static const int kHeight = 240; 829 static const int kHeight = 240;
848 830
849 class Renderer : public VideoRenderer { 831 class Renderer : public VideoRenderer {
850 public: 832 public:
851 Renderer() : event_(false, false) {} 833 Renderer() : event_(false, false) {}
852 834
853 void RenderFrame(const VideoFrame& video_frame, 835 void OnFrame(const VideoFrame& video_frame) override {
854 int /*time_to_render_ms*/) override {
855 EXPECT_EQ(0, *video_frame.buffer(kYPlane)) 836 EXPECT_EQ(0, *video_frame.buffer(kYPlane))
856 << "Rendered frame should have zero luma which is applied by the " 837 << "Rendered frame should have zero luma which is applied by the "
857 "pre-render callback."; 838 "pre-render callback.";
858 event_.Set(); 839 event_.Set();
859 } 840 }
860 841
861 bool IsTextureSupported() const override { return false; }
862
863 bool Wait() { return event_.Wait(kDefaultTimeoutMs); } 842 bool Wait() { return event_.Wait(kDefaultTimeoutMs); }
864 rtc::Event event_; 843 rtc::Event event_;
865 } renderer; 844 } renderer;
866 845
867 class TestFrameCallback : public I420FrameCallback { 846 class TestFrameCallback : public I420FrameCallback {
868 public: 847 public:
869 TestFrameCallback(int expected_luma_byte, int next_luma_byte) 848 TestFrameCallback(int expected_luma_byte, int next_luma_byte)
870 : event_(false, false), 849 : event_(false, false),
871 expected_luma_byte_(expected_luma_byte), 850 expected_luma_byte_(expected_luma_byte),
872 next_luma_byte_(next_luma_byte) {} 851 next_luma_byte_(next_luma_byte) {}
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 EXPECT_NE(packet_type, RTCPUtility::RTCPPacketTypes::kRtpfbNack); 969 EXPECT_NE(packet_type, RTCPUtility::RTCPPacketTypes::kRtpfbNack);
991 970
992 if (packet_type == RTCPUtility::RTCPPacketTypes::kPsfbPli) { 971 if (packet_type == RTCPUtility::RTCPPacketTypes::kPsfbPli) {
993 received_pli_ = true; 972 received_pli_ = true;
994 break; 973 break;
995 } 974 }
996 } 975 }
997 return SEND_PACKET; 976 return SEND_PACKET;
998 } 977 }
999 978
1000 void RenderFrame(const VideoFrame& video_frame, 979 void OnFrame(const VideoFrame& video_frame) override {
1001 int time_to_render_ms) override {
1002 rtc::CritScope lock(&crit_); 980 rtc::CritScope lock(&crit_);
1003 if (received_pli_ && 981 if (received_pli_ &&
1004 video_frame.timestamp() > highest_dropped_timestamp_) { 982 video_frame.timestamp() > highest_dropped_timestamp_) {
1005 observation_complete_.Set(); 983 observation_complete_.Set();
1006 } 984 }
1007 if (!received_pli_) 985 if (!received_pli_)
1008 frames_to_drop_ = kPacketsToDrop; 986 frames_to_drop_ = kPacketsToDrop;
1009 } 987 }
1010 988
1011 bool IsTextureSupported() const override { return false; }
1012
1013 void ModifyVideoConfigs( 989 void ModifyVideoConfigs(
1014 VideoSendStream::Config* send_config, 990 VideoSendStream::Config* send_config,
1015 std::vector<VideoReceiveStream::Config>* receive_configs, 991 std::vector<VideoReceiveStream::Config>* receive_configs,
1016 VideoEncoderConfig* encoder_config) override { 992 VideoEncoderConfig* encoder_config) override {
1017 send_config->rtp.nack.rtp_history_ms = rtp_history_ms_; 993 send_config->rtp.nack.rtp_history_ms = rtp_history_ms_;
1018 (*receive_configs)[0].rtp.nack.rtp_history_ms = rtp_history_ms_; 994 (*receive_configs)[0].rtp.nack.rtp_history_ms = rtp_history_ms_;
1019 (*receive_configs)[0].renderer = this; 995 (*receive_configs)[0].renderer = this;
1020 } 996 }
1021 997
1022 void PerformTest() override { 998 void PerformTest() override {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 class VideoOutputObserver : public VideoRenderer { 1292 class VideoOutputObserver : public VideoRenderer {
1317 public: 1293 public:
1318 VideoOutputObserver(const MultiStreamTest::CodecSettings& settings, 1294 VideoOutputObserver(const MultiStreamTest::CodecSettings& settings,
1319 uint32_t ssrc, 1295 uint32_t ssrc,
1320 test::FrameGeneratorCapturer** frame_generator) 1296 test::FrameGeneratorCapturer** frame_generator)
1321 : settings_(settings), 1297 : settings_(settings),
1322 ssrc_(ssrc), 1298 ssrc_(ssrc),
1323 frame_generator_(frame_generator), 1299 frame_generator_(frame_generator),
1324 done_(false, false) {} 1300 done_(false, false) {}
1325 1301
1326 void RenderFrame(const VideoFrame& video_frame, 1302 void OnFrame(const VideoFrame& video_frame) override {
1327 int time_to_render_ms) override {
1328 EXPECT_EQ(settings_.width, video_frame.width()); 1303 EXPECT_EQ(settings_.width, video_frame.width());
1329 EXPECT_EQ(settings_.height, video_frame.height()); 1304 EXPECT_EQ(settings_.height, video_frame.height());
1330 (*frame_generator_)->Stop(); 1305 (*frame_generator_)->Stop();
1331 done_.Set(); 1306 done_.Set();
1332 } 1307 }
1333 1308
1334 uint32_t Ssrc() { return ssrc_; } 1309 uint32_t Ssrc() { return ssrc_; }
1335 1310
1336 bool IsTextureSupported() const override { return false; }
1337
1338 bool Wait() { return done_.Wait(kDefaultTimeoutMs); } 1311 bool Wait() { return done_.Wait(kDefaultTimeoutMs); }
1339 1312
1340 private: 1313 private:
1341 const MultiStreamTest::CodecSettings& settings_; 1314 const MultiStreamTest::CodecSettings& settings_;
1342 const uint32_t ssrc_; 1315 const uint32_t ssrc_;
1343 test::FrameGeneratorCapturer** const frame_generator_; 1316 test::FrameGeneratorCapturer** const frame_generator_;
1344 rtc::Event done_; 1317 rtc::Event done_;
1345 }; 1318 };
1346 1319
1347 class Tester : public MultiStreamTest { 1320 class Tester : public MultiStreamTest {
(...skipping 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3527 private: 3500 private:
3528 bool video_observed_; 3501 bool video_observed_;
3529 bool audio_observed_; 3502 bool audio_observed_;
3530 SequenceNumberUnwrapper unwrapper_; 3503 SequenceNumberUnwrapper unwrapper_;
3531 std::set<int64_t> received_packet_ids_; 3504 std::set<int64_t> received_packet_ids_;
3532 } test; 3505 } test;
3533 3506
3534 RunBaseTest(&test); 3507 RunBaseTest(&test);
3535 } 3508 }
3536 } // namespace webrtc 3509 } // namespace webrtc
OLDNEW
« webrtc/DEPS ('K') | « webrtc/test/win/d3d_renderer.cc ('k') | webrtc/video/replay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698