Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: services/video_capture/video_capture_device_factory_impl.h

Issue 2468663003: [Mojo Video Capture] Add Mojo Typemap for VideoCaptureDeviceDescriptor (Closed)
Patch Set: dcheng's comments and formatting Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ 5 #ifndef SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_
6 #define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ 6 #define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "mojo/public/cpp/bindings/binding.h" 10 #include "mojo/public/cpp/bindings/binding.h"
11 #include "services/video_capture/public/interfaces/mock_video_capture_device.moj om.h" 11 #include "services/video_capture/public/interfaces/mock_video_capture_device.moj om.h"
12 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h" 12 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h"
13 #include "services/video_capture/video_capture_device_proxy_impl.h" 13 #include "services/video_capture/video_capture_device_proxy_impl.h"
14 14
15 namespace video_capture { 15 namespace video_capture {
16 16
17 class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory { 17 class VideoCaptureDeviceFactoryImpl : public mojom::VideoCaptureDeviceFactory {
18 public: 18 public:
19 VideoCaptureDeviceFactoryImpl(const media::VideoCaptureJpegDecoderFactoryCB& 19 VideoCaptureDeviceFactoryImpl(const media::VideoCaptureJpegDecoderFactoryCB&
20 jpeg_decoder_factory_callback); 20 jpeg_decoder_factory_callback);
21 ~VideoCaptureDeviceFactoryImpl() override; 21 ~VideoCaptureDeviceFactoryImpl() override;
22 22
23 void AddMojoDevice(std::unique_ptr<VideoCaptureDeviceProxyImpl> device, 23 void AddMojoDevice(std::unique_ptr<VideoCaptureDeviceProxyImpl> device,
24 mojom::VideoCaptureDeviceDescriptorPtr descriptor); 24 const media::VideoCaptureDeviceDescriptor& descriptor);
25 25
26 void AddMediaDevice(std::unique_ptr<media::VideoCaptureDevice> device, 26 void AddMediaDevice(std::unique_ptr<media::VideoCaptureDevice> device,
27 mojom::VideoCaptureDeviceDescriptorPtr descriptor); 27 const media::VideoCaptureDeviceDescriptor& descriptor);
28 28
29 void AddMockDevice(mojom::MockVideoCaptureDevicePtr device, 29 void AddMockDevice(mojom::MockVideoCaptureDevicePtr device,
30 mojom::VideoCaptureDeviceDescriptorPtr descriptor); 30 const media::VideoCaptureDeviceDescriptor& descriptor);
31 31
32 // mojom::VideoCaptureDeviceFactory: 32 // mojom::VideoCaptureDeviceFactory:
33 void EnumerateDeviceDescriptors( 33 void EnumerateDeviceDescriptors(
34 const EnumerateDeviceDescriptorsCallback& callback) override; 34 const EnumerateDeviceDescriptorsCallback& callback) override;
35 void GetSupportedFormats( 35 void GetSupportedFormats(
36 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, 36 const media::VideoCaptureDeviceDescriptor& device_descriptor,
37 const GetSupportedFormatsCallback& callback) override; 37 const GetSupportedFormatsCallback& callback) override;
38 void CreateDeviceProxy( 38 void CreateDeviceProxy(
39 mojom::VideoCaptureDeviceDescriptorPtr device_descriptor, 39 const media::VideoCaptureDeviceDescriptor& device_descriptor,
40 mojom::VideoCaptureDeviceProxyRequest proxy_request, 40 mojom::VideoCaptureDeviceProxyRequest proxy_request,
41 const CreateDeviceProxyCallback& callback) override; 41 const CreateDeviceProxyCallback& callback) override;
42 42
43 private: 43 private:
44 // We use a std::vector of structs with the |descriptor| field as a unique 44 // We use a std::vector of structs with the |descriptor| field as a unique
45 // keys. We do it this way instead of using a std::map because Mojo-generated 45 // keys. We do it this way instead of using a std::map because Mojo-generated
46 // structs (here VideoCaptureDeviceDescriptor) do not (yet) generate a 46 // structs (here VideoCaptureDeviceDescriptor) do not (yet) generate a
47 // comparison operator, and we do not want to provide a custom one. The 47 // comparison operator, and we do not want to provide a custom one. The
48 // performance penalty of linear-time lookup should be minimal assuming that 48 // performance penalty of linear-time lookup should be minimal assuming that
49 // the number of capture devices is typically small. 49 // the number of capture devices is typically small.
50 class DeviceEntry { 50 class DeviceEntry {
51 public: 51 public:
52 DeviceEntry(mojom::VideoCaptureDeviceDescriptorPtr descriptor, 52 DeviceEntry(const media::VideoCaptureDeviceDescriptor& descriptor,
53 std::unique_ptr<VideoCaptureDeviceProxyImpl> bindable_target); 53 std::unique_ptr<VideoCaptureDeviceProxyImpl> bindable_target);
54 ~DeviceEntry(); 54 ~DeviceEntry();
55 DeviceEntry(DeviceEntry&& other); 55 DeviceEntry(DeviceEntry&& other);
56 DeviceEntry& operator=(DeviceEntry&& other); 56 DeviceEntry& operator=(DeviceEntry&& other);
57 57
58 mojom::VideoCaptureDeviceDescriptorPtr MakeDescriptorCopy() const; 58 const media::VideoCaptureDeviceDescriptor& descriptor() const;
59 bool DescriptorEquals( 59 bool DescriptorEquals(
60 const mojom::VideoCaptureDeviceDescriptorPtr& other) const; 60 const media::VideoCaptureDeviceDescriptor& other) const;
61 bool is_bound() const; 61 bool is_bound() const;
62 void Bind(mojom::VideoCaptureDeviceProxyRequest request); 62 void Bind(mojom::VideoCaptureDeviceProxyRequest request);
63 void Unbind(); 63 void Unbind();
64 64
65 void OnConnectionErrorOrClose(); 65 void OnConnectionErrorOrClose();
66 66
67 private: 67 private:
68 mojom::VideoCaptureDeviceDescriptorPtr descriptor_; 68 media::VideoCaptureDeviceDescriptor descriptor_;
69 std::unique_ptr<VideoCaptureDeviceProxyImpl> device_proxy_; 69 std::unique_ptr<VideoCaptureDeviceProxyImpl> device_proxy_;
70 // TODO(chfremer) Use mojo::Binding<> directly instead of unique_ptr<> when 70 // TODO(chfremer) Use mojo::Binding<> directly instead of unique_ptr<> when
71 // mojo::Binding<> supports move operators. 71 // mojo::Binding<> supports move operators.
72 // https://crbug.com/644314 72 // https://crbug.com/644314
73 std::unique_ptr<mojo::Binding<mojom::VideoCaptureDeviceProxy>> binding_; 73 std::unique_ptr<mojo::Binding<mojom::VideoCaptureDeviceProxy>> binding_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(DeviceEntry); 75 DISALLOW_COPY_AND_ASSIGN(DeviceEntry);
76 }; 76 };
77 77
78 std::vector<DeviceEntry> devices_; 78 std::vector<DeviceEntry> devices_;
79 media::VideoCaptureJpegDecoderFactoryCB jpeg_decoder_factory_callback_; 79 media::VideoCaptureJpegDecoderFactoryCB jpeg_decoder_factory_callback_;
80 }; 80 };
81 81
82 } // namespace video_capture 82 } // namespace video_capture
83 83
84 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_ 84 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_FACTORY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698