From ea89495786f29db5369e89a4c7ea59780e0c6787 Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Fri, 27 Feb 2015 08:56:14 +0000 Subject: [PATCH] Remove {Is,Set}BlackOutput from VideoAdapter. BUG= R=pthatcher@webrtc.org Review URL: https://webrtc-codereview.appspot.com/39309004 Cr-Commit-Position: refs/heads/master@{#8523} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8523 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/media/base/videoadapter.cc | 36 +++------------ talk/media/base/videoadapter.h | 5 -- talk/media/base/videoadapter_unittest.cc | 59 ------------------------ talk/media/base/videocapturer.cc | 2 +- talk/media/webrtc/webrtcvideoengine.cc | 1 - 5 files changed, 7 insertions(+), 96 deletions(-) diff --git a/talk/media/base/videoadapter.cc b/talk/media/base/videoadapter.cc index 9b437e4878..dae2f01405 100644 --- a/talk/media/base/videoadapter.cc +++ b/talk/media/base/videoadapter.cc @@ -174,8 +174,6 @@ VideoAdapter::VideoAdapter() adaption_changes_(0), previous_width_(0), previous_height_(0), - black_output_(false), - is_black_(false), interval_next_frame_(0) { } @@ -250,16 +248,6 @@ const VideoFormat& VideoAdapter::output_format() { return output_format_; } -void VideoAdapter::SetBlackOutput(bool black) { - rtc::CritScope cs(&critical_section_); - black_output_ = black; -} - -bool VideoAdapter::IsBlackOutput() { - rtc::CritScope cs(&critical_section_); - return black_output_; -} - // Constrain output resolution to this many pixels overall void VideoAdapter::SetOutputNumPixels(int num_pixels) { output_num_pixels_ = num_pixels; @@ -377,8 +365,7 @@ bool VideoAdapter::AdaptFrame(VideoFrame* in_frame, VideoFrame** out_frame) { return true; } - if (!black_output_ && - in_frame->GetWidth() == static_cast(adapted_format.width) && + if (in_frame->GetWidth() == static_cast(adapted_format.width) && in_frame->GetHeight() == static_cast(adapted_format.height)) { // The dimensions are correct and we aren't muting, so use the input frame. *out_frame = in_frame; @@ -419,24 +406,13 @@ bool VideoAdapter::StretchToOutputFrame(const VideoFrame* in_frame) { return false; } stretched = true; - is_black_ = false; } - if (!black_output_) { - if (!stretched) { - // The output frame does not need to be blacken and has not been stretched - // from the input frame yet, stretch the input frame. This is the most - // common case. - in_frame->StretchToFrame(output_frame_.get(), true, true); - } - is_black_ = false; - } else { - if (!is_black_) { - output_frame_->SetToBlack(); - is_black_ = true; - } - output_frame_->SetElapsedTime(in_frame->GetElapsedTime()); - output_frame_->SetTimeStamp(in_frame->GetTimeStamp()); + if (!stretched) { + // The output frame does not need to be blacken and has not been stretched + // from the input frame yet, stretch the input frame. This is the most + // common case. + in_frame->StretchToFrame(output_frame_.get(), true, true); } return true; diff --git a/talk/media/base/videoadapter.h b/talk/media/base/videoadapter.h index 2c6cb04f65..0be4ad7a55 100644 --- a/talk/media/base/videoadapter.h +++ b/talk/media/base/videoadapter.h @@ -56,9 +56,6 @@ class VideoAdapter { // Returns true if the adapter is dropping frames in calls to AdaptFrame. bool drops_all_frames() const; const VideoFormat& output_format(); - // If the parameter black is true, the adapted frames will be black. - void SetBlackOutput(bool black); - bool IsBlackOutput(); // Return the adapted resolution given the input resolution. The returned // resolution will be 0x0 if the frame should be dropped. @@ -103,8 +100,6 @@ class VideoAdapter { int adaption_changes_; // Number of changes in scale factor. size_t previous_width_; // Previous adapter output width. size_t previous_height_; // Previous adapter output height. - bool black_output_; // Flag to tell if we need to black output_frame_. - bool is_black_; // Flag to tell if output_frame_ is currently black. int64 interval_next_frame_; rtc::scoped_ptr output_frame_; // The critical section to protect the above variables. diff --git a/talk/media/base/videoadapter_unittest.cc b/talk/media/base/videoadapter_unittest.cc index 995660591e..76b1502dfc 100755 --- a/talk/media/base/videoadapter_unittest.cc +++ b/talk/media/base/videoadapter_unittest.cc @@ -412,65 +412,6 @@ TEST_F(VideoAdapterTest, AdaptResolutionOnTheFly) { listener_->GetStats(), request_format.width, request_format.height); } -// Black the output frame. -TEST_F(VideoAdapterTest, BlackOutput) { - adapter_->SetOutputFormat(capture_format_); - EXPECT_EQ(CS_RUNNING, capturer_->Start(capture_format_)); - EXPECT_TRUE_WAIT(!capturer_->IsRunning() || - listener_->GetStats().captured_frames >= 10, kWaitTimeout); - // Verify that the output frame is not black. - rtc::scoped_ptr adapted_frame( - listener_->CopyAdaptedFrame()); - EXPECT_NE(16, *adapted_frame->GetYPlane()); - EXPECT_NE(128, *adapted_frame->GetUPlane()); - EXPECT_NE(128, *adapted_frame->GetVPlane()); - - adapter_->SetBlackOutput(true); - int captured_frames = listener_->GetStats().captured_frames; - EXPECT_TRUE_WAIT( - !capturer_->IsRunning() || - listener_->GetStats().captured_frames >= captured_frames + 10, - kWaitTimeout); - // Verify that the output frame is black. - adapted_frame.reset(listener_->CopyAdaptedFrame()); - EXPECT_EQ(16, *adapted_frame->GetYPlane()); - EXPECT_EQ(128, *adapted_frame->GetUPlane()); - EXPECT_EQ(128, *adapted_frame->GetVPlane()); - - // Verify that the elapsed time and timestamp of the black frame increase. - int64 elapsed_time = adapted_frame->GetElapsedTime(); - int64 timestamp = adapted_frame->GetTimeStamp(); - captured_frames = listener_->GetStats().captured_frames; - EXPECT_TRUE_WAIT( - !capturer_->IsRunning() || - listener_->GetStats().captured_frames >= captured_frames + 10, - kWaitTimeout); - - adapted_frame.reset(listener_->CopyAdaptedFrame()); - EXPECT_GT(adapted_frame->GetElapsedTime(), elapsed_time); - EXPECT_GT(adapted_frame->GetTimeStamp(), timestamp); - - // Change the output size - VideoFormat request_format = capture_format_; - request_format.width /= 2; - request_format.height /= 2; - adapter_->SetOutputFormat(request_format); - captured_frames = listener_->GetStats().captured_frames; - EXPECT_TRUE_WAIT( - !capturer_->IsRunning() || - listener_->GetStats().captured_frames >= captured_frames + 10, - kWaitTimeout); - - // Verify resolution change after adaptation. - VerifyAdaptedResolution( - listener_->GetStats(), request_format.width, request_format.height); - // Verify that the output frame is black. - adapted_frame.reset(listener_->CopyAdaptedFrame()); - EXPECT_EQ(16, *adapted_frame->GetYPlane()); - EXPECT_EQ(128, *adapted_frame->GetUPlane()); - EXPECT_EQ(128, *adapted_frame->GetVPlane()); -} - // Drop all frames. TEST_F(VideoAdapterTest, DropAllFrames) { VideoFormat format; // with resolution 0x0. diff --git a/talk/media/base/videocapturer.cc b/talk/media/base/videocapturer.cc index f0bb80a5ac..bed3b0c616 100644 --- a/talk/media/base/videocapturer.cc +++ b/talk/media/base/videocapturer.cc @@ -570,7 +570,7 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*, ++effect_frame_drops_; return; } - if (muted_ || (enable_video_adapter_ && video_adapter_.IsBlackOutput())) { + if (muted_) { // TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead. adapted_frame->SetToBlack(); } diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc index 428676f9b6..2685252955 100644 --- a/talk/media/webrtc/webrtcvideoengine.cc +++ b/talk/media/webrtc/webrtcvideoengine.cc @@ -749,7 +749,6 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> { } void set_muted(bool on) { // TODO(asapersson): add support. - // video_adapter_.SetBlackOutput(on); muted_ = on; } bool muted() {return muted_; }