| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/capture/video/fake_video_capture_device.h" | 5 #include "media/capture/video/fake_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 <memory> | 10 #include <memory> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) | 70 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) |
| 71 : frame_cb_(frame_cb) {} | 71 : frame_cb_(frame_cb) {} |
| 72 | 72 |
| 73 // Client virtual methods for capturing using Device Buffers. | 73 // Client virtual methods for capturing using Device Buffers. |
| 74 void OnIncomingCapturedData(const uint8_t* data, | 74 void OnIncomingCapturedData(const uint8_t* data, |
| 75 int length, | 75 int length, |
| 76 const VideoCaptureFormat& format, | 76 const VideoCaptureFormat& format, |
| 77 int rotation, | 77 int rotation, |
| 78 base::TimeTicks reference_time, | 78 base::TimeTicks reference_time, |
| 79 base::TimeDelta timestamp) override { | 79 base::TimeDelta timestamp, |
| 80 int frame_id) override { |
| 80 frame_cb_.Run(format); | 81 frame_cb_.Run(format); |
| 81 } | 82 } |
| 82 // Virtual methods for capturing using Client's Buffers. | 83 // Virtual methods for capturing using Client's Buffers. |
| 83 std::unique_ptr<Buffer> ReserveOutputBuffer( | 84 std::unique_ptr<Buffer> ReserveOutputBuffer( |
| 84 const gfx::Size& dimensions, | 85 const gfx::Size& dimensions, |
| 85 media::VideoPixelFormat format, | 86 media::VideoPixelFormat format, |
| 86 media::VideoPixelStorage storage) { | 87 media::VideoPixelStorage storage) override { |
| 87 EXPECT_TRUE((format == media::PIXEL_FORMAT_ARGB && | 88 EXPECT_TRUE((format == media::PIXEL_FORMAT_ARGB && |
| 88 storage == media::PIXEL_STORAGE_CPU)); | 89 storage == media::PIXEL_STORAGE_CPU)); |
| 89 EXPECT_GT(dimensions.GetArea(), 0); | 90 EXPECT_GT(dimensions.GetArea(), 0); |
| 90 const VideoCaptureFormat frame_format(dimensions, 0.0, format); | 91 const VideoCaptureFormat frame_format(dimensions, 0.0, format); |
| 91 return base::MakeUnique<MockBuffer>(0, frame_format.ImageAllocationSize()); | 92 return base::MakeUnique<MockBuffer>(0, frame_format.ImageAllocationSize()); |
| 92 } | 93 } |
| 93 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 94 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
| 94 const VideoCaptureFormat& frame_format, | 95 const VideoCaptureFormat& format, |
| 95 base::TimeTicks reference_time, | 96 base::TimeTicks reference_time, |
| 96 base::TimeDelta timestamp) { | 97 base::TimeDelta timestamp, |
| 97 frame_cb_.Run(frame_format); | 98 int frame_id) override { |
| 99 frame_cb_.Run(format); |
| 98 } | 100 } |
| 99 void OnIncomingCapturedVideoFrame(std::unique_ptr<Buffer> buffer, | 101 void OnIncomingCapturedVideoFrame(std::unique_ptr<Buffer> buffer, |
| 100 scoped_refptr<media::VideoFrame> frame) { | 102 scoped_refptr<media::VideoFrame> frame, |
| 103 int frame_id) override { |
| 101 VideoCaptureFormat format(frame->natural_size(), 30.0, | 104 VideoCaptureFormat format(frame->natural_size(), 30.0, |
| 102 PIXEL_FORMAT_I420); | 105 PIXEL_FORMAT_I420); |
| 103 frame_cb_.Run(format); | 106 frame_cb_.Run(format); |
| 104 } | 107 } |
| 105 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( | 108 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( |
| 106 const gfx::Size& dimensions, | 109 const gfx::Size& dimensions, |
| 107 media::VideoPixelFormat format, | 110 media::VideoPixelFormat format, |
| 108 media::VideoPixelStorage storage) { | 111 media::VideoPixelStorage storage) override { |
| 109 return std::unique_ptr<Buffer>(); | 112 return std::unique_ptr<Buffer>(); |
| 110 } | 113 } |
| 111 double GetBufferPoolUtilization() const override { return 0.0; } | 114 double GetBufferPoolUtilization() const override { return 0.0; } |
| 112 | 115 |
| 113 private: | 116 private: |
| 114 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; | 117 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; |
| 115 }; | 118 }; |
| 116 | 119 |
| 117 class DeviceEnumerationListener | 120 class DeviceEnumerationListener |
| 118 : public base::RefCounted<DeviceEnumerationListener> { | 121 : public base::RefCounted<DeviceEnumerationListener> { |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 INSTANTIATE_TEST_CASE_P( | 470 INSTANTIATE_TEST_CASE_P( |
| 468 , | 471 , |
| 469 FakeVideoCaptureDeviceCommandLineTest, | 472 FakeVideoCaptureDeviceCommandLineTest, |
| 470 Values(CommandLineTestData{"fps=-1", 5, 1u}, | 473 Values(CommandLineTestData{"fps=-1", 5, 1u}, |
| 471 CommandLineTestData{"fps=29.97, device-count=1", 29.97f, 1u}, | 474 CommandLineTestData{"fps=29.97, device-count=1", 29.97f, 1u}, |
| 472 CommandLineTestData{"fps=60, device-count=2", 60, 2u}, | 475 CommandLineTestData{"fps=60, device-count=2", 60, 2u}, |
| 473 CommandLineTestData{"fps=1000, device-count=-1", 60, 1u}, | 476 CommandLineTestData{"fps=1000, device-count=-1", 60, 1u}, |
| 474 CommandLineTestData{"device-count=2", 20, 2u}, | 477 CommandLineTestData{"device-count=2", 20, 2u}, |
| 475 CommandLineTestData{"device-count=0", 20, 1u})); | 478 CommandLineTestData{"device-count=0", 20, 1u})); |
| 476 }; // namespace media | 479 }; // namespace media |
| OLD | NEW |