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

Side by Side Diff: content/browser/media/capture/web_contents_video_capture_device_unittest.cc

Issue 2582883002: Revert of [Mojo Video Capture] Replace method OnIncomingCapturedVideoFrame with OnIncomingCapturedBufferExt (Closed)
Patch Set: Created 4 years 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/media/capture/web_contents_video_capture_device.h" 5 #include "content/browser/media/capture/web_contents_video_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 370
371 // Trampoline method to workaround GMOCK problems with std::unique_ptr<>. 371 // Trampoline method to workaround GMOCK problems with std::unique_ptr<>.
372 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, 372 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer,
373 const media::VideoCaptureFormat& format, 373 const media::VideoCaptureFormat& format,
374 base::TimeTicks reference_time, 374 base::TimeTicks reference_time,
375 base::TimeDelta timestamp) override { 375 base::TimeDelta timestamp) override {
376 DoOnIncomingCapturedBuffer(); 376 DoOnIncomingCapturedBuffer();
377 } 377 }
378 378
379 void OnIncomingCapturedBufferExt( 379 void OnIncomingCapturedVideoFrame(
380 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, 380 std::unique_ptr<Buffer> buffer,
381 const media::VideoCaptureFormat& format, 381 scoped_refptr<media::VideoFrame> frame) override {
382 base::TimeTicks reference_time, 382 EXPECT_FALSE(frame->visible_rect().IsEmpty());
383 base::TimeDelta timestamp, 383 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame->format());
384 gfx::Rect visible_rect, 384 double frame_rate = 0;
385 const media::VideoFrameMetadata& additional_metadata) override { 385 EXPECT_TRUE(
386 EXPECT_FALSE(visible_rect.IsEmpty()); 386 frame->metadata()->GetDouble(media::VideoFrameMetadata::FRAME_RATE,
387 EXPECT_EQ(media::PIXEL_FORMAT_I420, format.pixel_format); 387 &frame_rate));
388 EXPECT_EQ(kTestFramesPerSecond, format.frame_rate); 388 EXPECT_EQ(kTestFramesPerSecond, frame_rate);
389 389
390 // TODO(miu): We just look at the center pixel presently, because if the 390 // TODO(miu): We just look at the center pixel presently, because if the
391 // analysis is too slow, the backlog of frames will grow without bound and 391 // analysis is too slow, the backlog of frames will grow without bound and
392 // trouble erupts. http://crbug.com/174519 392 // trouble erupts. http://crbug.com/174519
393 using media::VideoFrame; 393 using media::VideoFrame;
394 auto frame = VideoFrame::WrapExternalSharedMemory( 394 const gfx::Point center = frame->visible_rect().CenterPoint();
395 media::PIXEL_FORMAT_I420, format.frame_size, visible_rect,
396 format.frame_size, static_cast<uint8_t*>(buffer->data()),
397 buffer->mapped_size(), base::SharedMemory::NULLHandle(), 0u,
398 base::TimeDelta());
399 const gfx::Point center = visible_rect.CenterPoint();
400 const int center_offset_y = 395 const int center_offset_y =
401 (frame->stride(VideoFrame::kYPlane) * center.y()) + center.x(); 396 (frame->stride(VideoFrame::kYPlane) * center.y()) + center.x();
402 const int center_offset_uv = 397 const int center_offset_uv =
403 (frame->stride(VideoFrame::kUPlane) * (center.y() / 2)) + 398 (frame->stride(VideoFrame::kUPlane) * (center.y() / 2)) +
404 (center.x() / 2); 399 (center.x() / 2);
405 report_callback_.Run( 400 report_callback_.Run(
406 SkColorSetRGB(frame->data(VideoFrame::kYPlane)[center_offset_y], 401 SkColorSetRGB(frame->data(VideoFrame::kYPlane)[center_offset_y],
407 frame->data(VideoFrame::kUPlane)[center_offset_uv], 402 frame->data(VideoFrame::kUPlane)[center_offset_uv],
408 frame->data(VideoFrame::kVPlane)[center_offset_uv]), 403 frame->data(VideoFrame::kVPlane)[center_offset_uv]),
409 frame->visible_rect().size()); 404 frame->visible_rect().size());
410 } 405 }
411 406
412 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> 407 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer>
413 ResurrectLastOutputBuffer(const gfx::Size& dimensions, 408 ResurrectLastOutputBuffer(const gfx::Size& dimensions,
414 media::VideoPixelFormat format, 409 media::VideoPixelFormat format,
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 for (int i = 0; i < 3; ++i) { 1272 for (int i = 0; i < 3; ++i) {
1278 SimulateRefreshFrameRequest(); 1273 SimulateRefreshFrameRequest();
1279 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); 1274 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN));
1280 } 1275 }
1281 1276
1282 device()->StopAndDeAllocate(); 1277 device()->StopAndDeAllocate();
1283 } 1278 }
1284 1279
1285 } // namespace 1280 } // namespace
1286 } // namespace content 1281 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698