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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "media/video/capture/fake_video_capture_device.h" | 10 #include "media/video/capture/fake_video_capture_device.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class MockClient : public media::VideoCaptureDevice::Client { | 22 class MockClient : public media::VideoCaptureDevice::Client { |
23 public: | 23 public: |
24 MOCK_METHOD2(ReserveOutputBuffer, | 24 MOCK_METHOD2(ReserveOutputBuffer, |
25 scoped_refptr<Buffer>(media::VideoFrame::Format format, | 25 scoped_refptr<Buffer>(media::VideoFrame::Format format, |
26 const gfx::Size& dimensions)); | 26 const gfx::Size& dimensions)); |
27 MOCK_METHOD0(OnErr, void()); | 27 MOCK_METHOD0(OnErr, void()); |
28 | 28 |
29 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) | 29 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) |
30 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {} | 30 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {} |
31 | 31 |
32 virtual void OnError(const std::string& error_message) OVERRIDE { | 32 virtual void OnError(const std::string& error_message) override { |
33 OnErr(); | 33 OnErr(); |
34 } | 34 } |
35 | 35 |
36 virtual void OnIncomingCapturedData(const uint8* data, | 36 virtual void OnIncomingCapturedData(const uint8* data, |
37 int length, | 37 int length, |
38 const VideoCaptureFormat& format, | 38 const VideoCaptureFormat& format, |
39 int rotation, | 39 int rotation, |
40 base::TimeTicks timestamp) OVERRIDE { | 40 base::TimeTicks timestamp) override { |
41 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); | 41 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); |
42 } | 42 } |
43 | 43 |
44 virtual void OnIncomingCapturedVideoFrame( | 44 virtual void OnIncomingCapturedVideoFrame( |
45 const scoped_refptr<Buffer>& buffer, | 45 const scoped_refptr<Buffer>& buffer, |
46 const media::VideoCaptureFormat& buffer_format, | 46 const media::VideoCaptureFormat& buffer_format, |
47 const scoped_refptr<media::VideoFrame>& frame, | 47 const scoped_refptr<media::VideoFrame>& frame, |
48 base::TimeTicks timestamp) OVERRIDE { | 48 base::TimeTicks timestamp) override { |
49 NOTREACHED(); | 49 NOTREACHED(); |
50 } | 50 } |
51 | 51 |
52 private: | 52 private: |
53 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; | 53 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; |
54 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; | 54 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; |
55 }; | 55 }; |
56 | 56 |
57 class DeviceEnumerationListener : | 57 class DeviceEnumerationListener : |
58 public base::RefCounted<DeviceEnumerationListener> { | 58 public base::RefCounted<DeviceEnumerationListener> { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 // We set TimeWait to 200 action timeouts and this should be enough for at | 201 // We set TimeWait to 200 action timeouts and this should be enough for at |
202 // least action_count/kFakeCaptureCapabilityChangePeriod calls. | 202 // least action_count/kFakeCaptureCapabilityChangePeriod calls. |
203 for (int i = 0; i < action_count; ++i) { | 203 for (int i = 0; i < action_count; ++i) { |
204 WaitForCapturedFrame(); | 204 WaitForCapturedFrame(); |
205 } | 205 } |
206 device->StopAndDeAllocate(); | 206 device->StopAndDeAllocate(); |
207 } | 207 } |
208 | 208 |
209 }; // namespace media | 209 }; // namespace media |
OLD | NEW |