| 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_METHOD5(OnIncomingCapturedData, | 44 MOCK_METHOD6(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 const base::TimeTicks& timestamp)); | 49 base::TimeTicks reference_time, |
| 50 MOCK_METHOD9(OnIncomingCapturedYuvData, | 50 base::TimeDelta tiemstamp)); |
| 51 void(const uint8_t* y_data, | |
| 52 const uint8_t* u_data, | |
| 53 const uint8_t* v_data, | |
| 54 size_t y_stride, | |
| 55 size_t u_stride, | |
| 56 size_t v_stride, | |
| 57 const media::VideoCaptureFormat& frame_format, | |
| 58 int clockwise_rotation, | |
| 59 const base::TimeTicks& timestamp)); | |
| 60 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); | 51 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); |
| 61 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); | 52 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); |
| 62 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); | 53 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); |
| 63 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); | 54 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); |
| 64 MOCK_METHOD2(OnError, | 55 MOCK_METHOD2(OnError, |
| 65 void(const tracked_objects::Location& from_here, | 56 void(const tracked_objects::Location& from_here, |
| 66 const std::string& reason)); | 57 const std::string& reason)); |
| 67 | 58 |
| 68 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. | 59 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. |
| 69 std::unique_ptr<Buffer> ReserveOutputBuffer( | 60 std::unique_ptr<Buffer> ReserveOutputBuffer( |
| 70 const gfx::Size& dimensions, | 61 const gfx::Size& dimensions, |
| 71 media::VideoPixelFormat format, | 62 media::VideoPixelFormat format, |
| 72 media::VideoPixelStorage storage) override { | 63 media::VideoPixelStorage storage) override { |
| 73 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); | 64 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); |
| 74 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); | 65 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); |
| 75 DoReserveOutputBuffer(); | 66 DoReserveOutputBuffer(); |
| 76 return std::unique_ptr<Buffer>(); | 67 return std::unique_ptr<Buffer>(); |
| 77 } | 68 } |
| 78 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 69 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
| 79 const media::VideoCaptureFormat& frame_format, | 70 const media::VideoCaptureFormat& frame_format, |
| 80 const base::TimeTicks& timestamp) override { | 71 base::TimeTicks reference_time, |
| 72 base::TimeDelta timestamp) override { |
| 81 DoOnIncomingCapturedBuffer(); | 73 DoOnIncomingCapturedBuffer(); |
| 82 } | 74 } |
| 83 void OnIncomingCapturedVideoFrame( | 75 void OnIncomingCapturedVideoFrame( |
| 84 std::unique_ptr<Buffer> buffer, | 76 std::unique_ptr<Buffer> buffer, |
| 85 const scoped_refptr<media::VideoFrame>& frame, | 77 const scoped_refptr<media::VideoFrame>& frame, |
| 86 const base::TimeTicks& timestamp) override { | 78 base::TimeTicks reference_time) override { |
| 87 DoOnIncomingCapturedVideoFrame(); | 79 DoOnIncomingCapturedVideoFrame(); |
| 88 } | 80 } |
| 89 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( | 81 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( |
| 90 const gfx::Size& dimensions, | 82 const gfx::Size& dimensions, |
| 91 media::VideoPixelFormat format, | 83 media::VideoPixelFormat format, |
| 92 media::VideoPixelStorage storage) override { | 84 media::VideoPixelStorage storage) override { |
| 93 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); | 85 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); |
| 94 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); | 86 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); |
| 95 DoResurrectLastOutputBuffer(); | 87 DoResurrectLastOutputBuffer(); |
| 96 return std::unique_ptr<Buffer>(); | 88 return std::unique_ptr<Buffer>(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 media::VideoCaptureParams capture_params; | 154 media::VideoCaptureParams capture_params; |
| 163 capture_params.requested_format.frame_size.SetSize(640, 480); | 155 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 164 capture_params.requested_format.frame_rate = kFrameRate; | 156 capture_params.requested_format.frame_rate = kFrameRate; |
| 165 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; | 157 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; |
| 166 capture_device->AllocateAndStart(capture_params, std::move(client)); | 158 capture_device->AllocateAndStart(capture_params, std::move(client)); |
| 167 capture_device->StopAndDeAllocate(); | 159 capture_device->StopAndDeAllocate(); |
| 168 } | 160 } |
| 169 | 161 |
| 170 } // namespace | 162 } // namespace |
| 171 } // namespace content | 163 } // namespace content |
| OLD | NEW |