| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/desktop_capture_device_aura.h" | 5 #include "content/browser/media/capture/desktop_capture_device_aura.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class VideoFrame; | 34 class VideoFrame; |
| 35 } // namespace media | 35 } // namespace media |
| 36 | 36 |
| 37 namespace content { | 37 namespace content { |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 const int kFrameRate = 30; | 40 const int kFrameRate = 30; |
| 41 | 41 |
| 42 class MockDeviceClient : public media::VideoCaptureDevice::Client { | 42 class MockDeviceClient : public media::VideoCaptureDevice::Client { |
| 43 public: | 43 public: |
| 44 MOCK_METHOD6(OnIncomingCapturedData, | 44 MOCK_METHOD7(OnIncomingCapturedData, |
| 45 void(const uint8_t* data, | 45 void(const uint8_t* data, |
| 46 int length, | 46 int length, |
| 47 const media::VideoCaptureFormat& frame_format, | 47 const media::VideoCaptureFormat& frame_format, |
| 48 int rotation, | 48 int rotation, |
| 49 base::TimeTicks reference_time, | 49 base::TimeTicks reference_time, |
| 50 base::TimeDelta tiemstamp)); | 50 base::TimeDelta tiemstamp, |
| 51 int frame_feedback_id)); |
| 51 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); | 52 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); |
| 52 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); | 53 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); |
| 53 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); | 54 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); |
| 54 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); | 55 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); |
| 55 MOCK_METHOD2(OnError, | 56 MOCK_METHOD2(OnError, |
| 56 void(const tracked_objects::Location& from_here, | 57 void(const tracked_objects::Location& from_here, |
| 57 const std::string& reason)); | 58 const std::string& reason)); |
| 58 | 59 |
| 59 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. | 60 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. |
| 60 std::unique_ptr<Buffer> ReserveOutputBuffer( | 61 std::unique_ptr<Buffer> ReserveOutputBuffer(const gfx::Size& dimensions, |
| 61 const gfx::Size& dimensions, | 62 media::VideoPixelFormat format, |
| 62 media::VideoPixelFormat format, | 63 media::VideoPixelStorage storage, |
| 63 media::VideoPixelStorage storage) override { | 64 int frame_feedback_id) override { |
| 64 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); | 65 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); |
| 65 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); | 66 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); |
| 66 DoReserveOutputBuffer(); | 67 DoReserveOutputBuffer(); |
| 67 return std::unique_ptr<Buffer>(); | 68 return std::unique_ptr<Buffer>(); |
| 68 } | 69 } |
| 69 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 70 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
| 70 const media::VideoCaptureFormat& frame_format, | 71 const media::VideoCaptureFormat& frame_format, |
| 71 base::TimeTicks reference_time, | 72 base::TimeTicks reference_time, |
| 72 base::TimeDelta timestamp) override { | 73 base::TimeDelta timestamp) override { |
| 73 DoOnIncomingCapturedBuffer(); | 74 DoOnIncomingCapturedBuffer(); |
| 74 } | 75 } |
| 75 void OnIncomingCapturedVideoFrame( | 76 void OnIncomingCapturedVideoFrame( |
| 76 std::unique_ptr<Buffer> buffer, | 77 std::unique_ptr<Buffer> buffer, |
| 77 scoped_refptr<media::VideoFrame> frame) override { | 78 scoped_refptr<media::VideoFrame> frame) override { |
| 78 DoOnIncomingCapturedVideoFrame(); | 79 DoOnIncomingCapturedVideoFrame(); |
| 79 } | 80 } |
| 80 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( | 81 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( |
| 81 const gfx::Size& dimensions, | 82 const gfx::Size& dimensions, |
| 82 media::VideoPixelFormat format, | 83 media::VideoPixelFormat format, |
| 83 media::VideoPixelStorage storage) override { | 84 media::VideoPixelStorage storage, |
| 85 int frame_feedback_id) override { |
| 84 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); | 86 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); |
| 85 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); | 87 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); |
| 86 DoResurrectLastOutputBuffer(); | 88 DoResurrectLastOutputBuffer(); |
| 87 return std::unique_ptr<Buffer>(); | 89 return std::unique_ptr<Buffer>(); |
| 88 } | 90 } |
| 89 double GetBufferPoolUtilization() const override { return 0.0; } | 91 double GetBufferPoolUtilization() const override { return 0.0; } |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 // Test harness that sets up a minimal environment with necessary stubs. | 94 // Test harness that sets up a minimal environment with necessary stubs. |
| 93 class DesktopCaptureDeviceAuraTest : public testing::Test { | 95 class DesktopCaptureDeviceAuraTest : public testing::Test { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 media::VideoCaptureParams capture_params; | 154 media::VideoCaptureParams capture_params; |
| 153 capture_params.requested_format.frame_size.SetSize(640, 480); | 155 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 154 capture_params.requested_format.frame_rate = kFrameRate; | 156 capture_params.requested_format.frame_rate = kFrameRate; |
| 155 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; | 157 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; |
| 156 capture_device->AllocateAndStart(capture_params, std::move(client)); | 158 capture_device->AllocateAndStart(capture_params, std::move(client)); |
| 157 capture_device->StopAndDeAllocate(); | 159 capture_device->StopAndDeAllocate(); |
| 158 } | 160 } |
| 159 | 161 |
| 160 } // namespace | 162 } // namespace |
| 161 } // namespace content | 163 } // namespace content |
| OLD | NEW |