Commit 21346db6 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Fix VideoCaptureDeviceFuchsia to report correct frame rate

Fixed the capturer to increment frame counter, so it reports frame rate.
Updated tests to verify that frame rate is set for all frames.

Also removed redundant line that was setting pixel format to the same
value that's sent one line avove.

Bug: 1116536
Change-Id: I74bc000a2bc9172768bb3153f01cdded7a3e911b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2357611
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Reviewed-by: default avatarFabrice de Gans-Riberi <fdegans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798956}
parent 939e2f7e
......@@ -374,12 +374,12 @@ void VideoCaptureDeviceFuchsia::ProcessNewFrame(
base::TimeDelta timestamp =
std::max(reference_time - start_time_, base::TimeDelta());
++frames_received_;
float frame_rate =
(timestamp > base::TimeDelta())
? static_cast<float>(frames_received_) / timestamp.InSecondsF()
: 0.0;
VideoCaptureFormat capture_format(output_size, frame_rate, PIXEL_FORMAT_I420);
capture_format.pixel_format = PIXEL_FORMAT_I420;
Client::Buffer buffer;
Client::ReserveResult result = client_->ReserveOutputBuffer(
......
......@@ -33,6 +33,7 @@ void ValidateReceivedFrame(const ReceivedFrame& frame,
(expected_size.height() + 1) & ~1);
ASSERT_EQ(frame.format.frame_size, coded_size);
EXPECT_EQ(frame.format.pixel_format, PIXEL_FORMAT_I420);
EXPECT_GT(frame.format.frame_rate, 0.0);
EXPECT_EQ(frame.visible_rect, gfx::Rect(expected_size));
EXPECT_EQ(frame.color_space, gfx::ColorSpace());
......@@ -293,11 +294,13 @@ TEST_F(VideoCaptureDeviceFuchsiaTest, MultipleFrames) {
EXPECT_TRUE(fake_device_watcher_.stream()->WaitBuffersAllocated());
auto start_timestamp = base::TimeTicks::Now();
for (size_t i = 0; i < 10; ++i) {
ASSERT_TRUE(fake_device_watcher_.stream()->WaitFreeBuffer());
auto frame_timestamp =
base::TimeTicks() + base::TimeDelta::FromMilliseconds(i * 16);
start_timestamp + base::TimeDelta::FromMilliseconds(i * 16);
fake_device_watcher_.stream()->ProduceFrame(frame_timestamp, i);
client_->WaitFrame();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment