From 9359cb3e75c7100dab4c687f60dd28dc613280e4 Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Wed, 23 Jul 2014 15:44:48 +0000 Subject: [PATCH] Enable SendAndReceive tests. Also fixes a crash in ::SetCapturer which wasn't exposed by tests before. BUG=1788 R=wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/18019005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6765 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/media/webrtc/webrtcvideoengine2.cc | 24 ++++---- .../webrtc/webrtcvideoengine2_unittest.cc | 58 ++++++++++++------- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc index 28bd6f46a2..86c9acc16b 100644 --- a/talk/media/webrtc/webrtcvideoengine2.cc +++ b/talk/media/webrtc/webrtcvideoengine2.cc @@ -1402,18 +1402,20 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( { talk_base::CritScope cs(&lock_); - if (capturer == NULL && stream_ != NULL) { - LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; - webrtc::I420VideoFrame black_frame; + if (capturer == NULL) { + if (stream_ != NULL) { + LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; + webrtc::I420VideoFrame black_frame; - int width = format_.width; - int height = format_.height; - int half_width = (width + 1) / 2; - black_frame.CreateEmptyFrame( - width, height, width, half_width, half_width); - SetWebRtcFrameToBlack(&black_frame); - SetDimensions(width, height); - stream_->Input()->SwapFrame(&black_frame); + int width = format_.width; + int height = format_.height; + int half_width = (width + 1) / 2; + black_frame.CreateEmptyFrame( + width, height, width, half_width, half_width); + SetWebRtcFrameToBlack(&black_frame); + SetDimensions(width, height); + stream_->Input()->SwapFrame(&black_frame); + } capturer_ = NULL; return true; diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc index c6168ea169..94c18c71fc 100644 --- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc +++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc @@ -542,6 +542,18 @@ WEBRTC_BASE_TEST(SetSendStreamFormat0x0); // TODO(zhurunz): Fix the flakey test. WEBRTC_DISABLED_BASE_TEST(SetSendStreamFormat); +TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) { + SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); +} + +TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Qvga) { + SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30, 0)); +} + +TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8SvcQqvga) { + SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30, 0)); +} + TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) { Base::TwoStreamsSendAndReceive(kVp8Codec); } @@ -550,6 +562,32 @@ TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsReUseFirstStream) { Base::TwoStreamsReUseFirstStream(kVp8Codec); } +WEBRTC_BASE_TEST(SendManyResizeOnce); + +// TODO(pbos): Enable and figure out why this fails (or should work). +TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) { + EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); + EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); + channel_->UpdateAspectRatio(1280, 720); + video_capturer_.reset(new cricket::FakeVideoCapturer); + const std::vector* formats = + video_capturer_->GetSupportedFormats(); + cricket::VideoFormat capture_format_hd = (*formats)[0]; + EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format_hd)); + EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get())); + + // Capture format HD -> adapt (OnOutputFormatRequest VGA) -> VGA. + cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0); + EXPECT_TRUE(SetOneCodec(codec)); + codec.width /= 2; + codec.height /= 2; + EXPECT_TRUE(SetSend(true)); + EXPECT_TRUE(channel_->SetRender(true)); + EXPECT_EQ(0, renderer_.num_rendered_frames()); + EXPECT_TRUE(SendFrame()); + EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); +} + class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { public: virtual void SetUp() OVERRIDE { @@ -1494,26 +1532,6 @@ TEST_F(WebRtcVideoChannel2Test, SetSend) { << "Send stream created after SetSend(true) not sending initially."; } -TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveVp8Vga) { - FAIL() << "Not implemented."; // TODO(pbos): Implement. -} - -TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveVp8Qvga) { - FAIL() << "Not implemented."; // TODO(pbos): Implement. -} - -TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveH264SvcQqvga) { - FAIL() << "Not implemented."; // TODO(pbos): Implement. -} - -TEST_F(WebRtcVideoChannel2Test, DISABLED_SendManyResizeOnce) { - FAIL() << "Not implemented."; // TODO(pbos): Implement. -} - -TEST_F(WebRtcVideoChannel2Test, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) { - FAIL() << "Not implemented."; // TODO(pbos): Implement. -} - TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetDscpOptions) { FAIL() << "Not implemented."; // TODO(pbos): Implement. }