| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace media { | 25 namespace media { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // This class is a Client::Buffer that allocates and frees the requested |size|. | 29 // This class is a Client::Buffer that allocates and frees the requested |size|. |
| 30 class MockBuffer : public VideoCaptureDevice::Client::Buffer { | 30 class MockBuffer : public VideoCaptureDevice::Client::Buffer { |
| 31 public: | 31 public: |
| 32 MockBuffer(int buffer_id, size_t mapped_size) | 32 MockBuffer(int buffer_id, size_t mapped_size) |
| 33 : id_(buffer_id), | 33 : id_(buffer_id), |
| 34 mapped_size_(mapped_size), | 34 mapped_size_(mapped_size), |
| 35 data_(new uint8[mapped_size]) {} | 35 data_(new uint8_t[mapped_size]) {} |
| 36 ~MockBuffer() override { delete[] data_; } | 36 ~MockBuffer() override { delete[] data_; } |
| 37 | 37 |
| 38 int id() const override { return id_; } | 38 int id() const override { return id_; } |
| 39 gfx::Size dimensions() const override { return gfx::Size(); } | 39 gfx::Size dimensions() const override { return gfx::Size(); } |
| 40 size_t mapped_size() const override { return mapped_size_; } | 40 size_t mapped_size() const override { return mapped_size_; } |
| 41 void* data(int plane) override { return data_; } | 41 void* data(int plane) override { return data_; } |
| 42 ClientBuffer AsClientBuffer(int plane) override { return nullptr; } | 42 ClientBuffer AsClientBuffer(int plane) override { return nullptr; } |
| 43 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) | 43 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) |
| 44 base::FileDescriptor AsPlatformFile() override { | 44 base::FileDescriptor AsPlatformFile() override { |
| 45 return base::FileDescriptor(); | 45 return base::FileDescriptor(); |
| 46 } | 46 } |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 const int id_; | 50 const int id_; |
| 51 const size_t mapped_size_; | 51 const size_t mapped_size_; |
| 52 uint8* const data_; | 52 uint8_t* const data_; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class MockClient : public VideoCaptureDevice::Client { | 55 class MockClient : public VideoCaptureDevice::Client { |
| 56 public: | 56 public: |
| 57 MOCK_METHOD2(OnError, | 57 MOCK_METHOD2(OnError, |
| 58 void(const tracked_objects::Location& from_here, | 58 void(const tracked_objects::Location& from_here, |
| 59 const std::string& reason)); | 59 const std::string& reason)); |
| 60 | 60 |
| 61 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) | 61 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) |
| 62 : frame_cb_(frame_cb) {} | 62 : frame_cb_(frame_cb) {} |
| 63 | 63 |
| 64 // Client virtual methods for capturing using Device Buffers. | 64 // Client virtual methods for capturing using Device Buffers. |
| 65 void OnIncomingCapturedData(const uint8* data, | 65 void OnIncomingCapturedData(const uint8_t* data, |
| 66 int length, | 66 int length, |
| 67 const VideoCaptureFormat& format, | 67 const VideoCaptureFormat& format, |
| 68 int rotation, | 68 int rotation, |
| 69 const base::TimeTicks& timestamp) { | 69 const base::TimeTicks& timestamp) { |
| 70 frame_cb_.Run(format); | 70 frame_cb_.Run(format); |
| 71 } | 71 } |
| 72 void OnIncomingCapturedYuvData(const uint8* y_data, | 72 void OnIncomingCapturedYuvData(const uint8_t* y_data, |
| 73 const uint8* u_data, | 73 const uint8_t* u_data, |
| 74 const uint8* v_data, | 74 const uint8_t* v_data, |
| 75 size_t y_stride, | 75 size_t y_stride, |
| 76 size_t u_stride, | 76 size_t u_stride, |
| 77 size_t v_stride, | 77 size_t v_stride, |
| 78 const VideoCaptureFormat& frame_format, | 78 const VideoCaptureFormat& frame_format, |
| 79 int clockwise_rotation, | 79 int clockwise_rotation, |
| 80 const base::TimeTicks& timestamp) { | 80 const base::TimeTicks& timestamp) { |
| 81 frame_cb_.Run(frame_format); | 81 frame_cb_.Run(frame_format); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Virtual methods for capturing using Client's Buffers. | 84 // Virtual methods for capturing using Client's Buffers. |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 INSTANTIATE_TEST_CASE_P(, | 281 INSTANTIATE_TEST_CASE_P(, |
| 282 FakeVideoCaptureDeviceCommandLineTest, | 282 FakeVideoCaptureDeviceCommandLineTest, |
| 283 Values(CommandLineTestData{"fps=-1", 5}, | 283 Values(CommandLineTestData{"fps=-1", 5}, |
| 284 CommandLineTestData{"fps=29.97", 29.97f}, | 284 CommandLineTestData{"fps=29.97", 29.97f}, |
| 285 CommandLineTestData{"fps=60", 60}, | 285 CommandLineTestData{"fps=60", 60}, |
| 286 CommandLineTestData{"fps=1000", 60})); | 286 CommandLineTestData{"fps=1000", 60})); |
| 287 }; // namespace media | 287 }; // namespace media |
| OLD | NEW |