OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/video_capture/mock_device_factory.h" | 5 #include "services/video_capture/mock_device_factory.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "media/capture/video/fake_video_capture_device.h" | 11 #include "media/capture/video/fake_video_capture_device.h" |
12 #include "services/video_capture/device_mock_to_media_adapter.h" | 12 #include "services/video_capture/device_mojo_mock_to_media_adapter.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 // Report a single hard-coded supported format to clients. | 15 // Report a single hard-coded supported format to clients. |
16 media::VideoCaptureFormat kSupportedFormat(gfx::Size(), | 16 media::VideoCaptureFormat kSupportedFormat(gfx::Size(), |
17 25.0f, | 17 25.0f, |
18 media::PIXEL_FORMAT_I420, | 18 media::PIXEL_FORMAT_I420, |
19 media::PIXEL_STORAGE_CPU); | 19 media::PIXEL_STORAGE_CPU); |
20 } | 20 } |
21 | 21 |
22 namespace video_capture { | 22 namespace video_capture { |
23 | 23 |
24 MockDeviceFactory::MockDeviceFactory() = default; | 24 MockDeviceFactory::MockDeviceFactory() = default; |
25 | 25 |
26 MockDeviceFactory::~MockDeviceFactory() = default; | 26 MockDeviceFactory::~MockDeviceFactory() = default; |
27 | 27 |
28 void MockDeviceFactory::AddMockDevice( | 28 void MockDeviceFactory::AddMockDevice( |
29 mojom::MockVideoCaptureDevicePtr device, | 29 mojom::MockMediaDevicePtr device, |
30 const media::VideoCaptureDeviceDescriptor& descriptor) { | 30 const media::VideoCaptureDeviceDescriptor& descriptor) { |
31 devices_[descriptor] = std::move(device); | 31 devices_[descriptor] = std::move(device); |
32 } | 32 } |
33 | 33 |
34 std::unique_ptr<media::VideoCaptureDevice> MockDeviceFactory::CreateDevice( | 34 std::unique_ptr<media::VideoCaptureDevice> MockDeviceFactory::CreateDevice( |
35 const media::VideoCaptureDeviceDescriptor& device_descriptor) { | 35 const media::VideoCaptureDeviceDescriptor& device_descriptor) { |
36 mojom::MockVideoCaptureDevicePtr* device = &(devices_[device_descriptor]); | 36 mojom::MockMediaDevicePtr* device = &(devices_[device_descriptor]); |
37 if (device == nullptr) { | 37 if (device == nullptr) { |
38 return nullptr; | 38 return nullptr; |
39 } | 39 } |
40 return base::MakeUnique<DeviceMockToMediaAdapter>(device); | 40 return base::MakeUnique<DeviceMojoMockToMediaAdapter>(device); |
41 } | 41 } |
42 | 42 |
43 void MockDeviceFactory::GetDeviceDescriptors( | 43 void MockDeviceFactory::GetDeviceDescriptors( |
44 media::VideoCaptureDeviceDescriptors* device_descriptors) { | 44 media::VideoCaptureDeviceDescriptors* device_descriptors) { |
45 for (const auto& entry : devices_) | 45 for (const auto& entry : devices_) |
46 device_descriptors->push_back(entry.first); | 46 device_descriptors->push_back(entry.first); |
47 } | 47 } |
48 | 48 |
49 void MockDeviceFactory::GetSupportedFormats( | 49 void MockDeviceFactory::GetSupportedFormats( |
50 const media::VideoCaptureDeviceDescriptor& device_descriptor, | 50 const media::VideoCaptureDeviceDescriptor& device_descriptor, |
51 media::VideoCaptureFormats* supported_formats) { | 51 media::VideoCaptureFormats* supported_formats) { |
52 supported_formats->push_back(kSupportedFormat); | 52 supported_formats->push_back(kSupportedFormat); |
53 } | 53 } |
54 | 54 |
55 } // namespace video_capture | 55 } // namespace video_capture |
OLD | NEW |