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
This commit is contained in:
pbos@webrtc.org
2015-02-27 08:56:14 +00:00
parent 3aca0b0b31
commit ea89495786
5 changed files with 7 additions and 96 deletions

View File

@@ -174,8 +174,6 @@ VideoAdapter::VideoAdapter()
adaption_changes_(0), adaption_changes_(0),
previous_width_(0), previous_width_(0),
previous_height_(0), previous_height_(0),
black_output_(false),
is_black_(false),
interval_next_frame_(0) { interval_next_frame_(0) {
} }
@@ -250,16 +248,6 @@ const VideoFormat& VideoAdapter::output_format() {
return 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 // Constrain output resolution to this many pixels overall
void VideoAdapter::SetOutputNumPixels(int num_pixels) { void VideoAdapter::SetOutputNumPixels(int num_pixels) {
output_num_pixels_ = num_pixels; output_num_pixels_ = num_pixels;
@@ -377,8 +365,7 @@ bool VideoAdapter::AdaptFrame(VideoFrame* in_frame, VideoFrame** out_frame) {
return true; return true;
} }
if (!black_output_ && if (in_frame->GetWidth() == static_cast<size_t>(adapted_format.width) &&
in_frame->GetWidth() == static_cast<size_t>(adapted_format.width) &&
in_frame->GetHeight() == static_cast<size_t>(adapted_format.height)) { in_frame->GetHeight() == static_cast<size_t>(adapted_format.height)) {
// The dimensions are correct and we aren't muting, so use the input frame. // The dimensions are correct and we aren't muting, so use the input frame.
*out_frame = in_frame; *out_frame = in_frame;
@@ -419,25 +406,14 @@ bool VideoAdapter::StretchToOutputFrame(const VideoFrame* in_frame) {
return false; return false;
} }
stretched = true; stretched = true;
is_black_ = false;
} }
if (!black_output_) {
if (!stretched) { if (!stretched) {
// The output frame does not need to be blacken and has not been 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 // from the input frame yet, stretch the input frame. This is the most
// common case. // common case.
in_frame->StretchToFrame(output_frame_.get(), true, true); 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());
}
return true; return true;
} }

View File

@@ -56,9 +56,6 @@ class VideoAdapter {
// Returns true if the adapter is dropping frames in calls to AdaptFrame. // Returns true if the adapter is dropping frames in calls to AdaptFrame.
bool drops_all_frames() const; bool drops_all_frames() const;
const VideoFormat& output_format(); 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 // Return the adapted resolution given the input resolution. The returned
// resolution will be 0x0 if the frame should be dropped. // 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. int adaption_changes_; // Number of changes in scale factor.
size_t previous_width_; // Previous adapter output width. size_t previous_width_; // Previous adapter output width.
size_t previous_height_; // Previous adapter output height. 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_; int64 interval_next_frame_;
rtc::scoped_ptr<VideoFrame> output_frame_; rtc::scoped_ptr<VideoFrame> output_frame_;
// The critical section to protect the above variables. // The critical section to protect the above variables.

View File

@@ -412,65 +412,6 @@ TEST_F(VideoAdapterTest, AdaptResolutionOnTheFly) {
listener_->GetStats(), request_format.width, request_format.height); 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<const VideoFrame> 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. // Drop all frames.
TEST_F(VideoAdapterTest, DropAllFrames) { TEST_F(VideoAdapterTest, DropAllFrames) {
VideoFormat format; // with resolution 0x0. VideoFormat format; // with resolution 0x0.

View File

@@ -570,7 +570,7 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
++effect_frame_drops_; ++effect_frame_drops_;
return; return;
} }
if (muted_ || (enable_video_adapter_ && video_adapter_.IsBlackOutput())) { if (muted_) {
// TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead. // TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead.
adapted_frame->SetToBlack(); adapted_frame->SetToBlack();
} }

View File

@@ -749,7 +749,6 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
} }
void set_muted(bool on) { void set_muted(bool on) {
// TODO(asapersson): add support. // TODO(asapersson): add support.
// video_adapter_.SetBlackOutput(on);
muted_ = on; muted_ = on;
} }
bool muted() {return muted_; } bool muted() {return muted_; }