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

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

Issue 2502483003: [Mojo Video Capture] Cleanup naming of classes/files in services/video_capture (Closed)
Patch Set: Rebase 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_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_ 5 #ifndef SERVICES_VIDEO_CAPTURE_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_
6 #define SERVICES_VIDEO_CAPTURE_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_ 6 #define SERVICES_VIDEO_CAPTURE_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "media/capture/video/video_capture_device_client.h" 10 #include "media/capture/video/video_capture_device_client.h"
11 #include "media/capture/video/video_capture_device_factory.h" 11 #include "media/capture/video/video_capture_device_factory.h"
12 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h" 13 #include "services/video_capture/public/interfaces/device_factory.mojom.h"
14 14
15 namespace video_capture { 15 namespace video_capture {
16 16
17 class VideoCaptureDeviceProxyImpl; 17 class DeviceMediaToMojoAdapter;
18 18
19 // Wraps a media::VideoCaptureDeviceFactory and exposes its functionality 19 // Wraps a media::VideoCaptureDeviceFactory and exposes its functionality
20 // through the mojom::VideoCaptureDeviceFactory interface. 20 // through the mojom::DeviceFactory interface.
21 // Keeps track of device instances that have been created to ensure that 21 // Keeps track of device instances that have been created to ensure that
22 // it does not create more than one instance of the same 22 // it does not create more than one instance of the same
23 // media::VideoCaptureDevice at the same time. 23 // media::VideoCaptureDevice at the same time.
24 class DeviceFactoryMediaToMojoAdapter 24 class DeviceFactoryMediaToMojoAdapter : public mojom::DeviceFactory {
25 : public mojom::VideoCaptureDeviceFactory {
26 public: 25 public:
27 DeviceFactoryMediaToMojoAdapter( 26 DeviceFactoryMediaToMojoAdapter(
28 std::unique_ptr<media::VideoCaptureDeviceFactory> device_factory, 27 std::unique_ptr<media::VideoCaptureDeviceFactory> device_factory,
29 const media::VideoCaptureJpegDecoderFactoryCB& 28 const media::VideoCaptureJpegDecoderFactoryCB&
30 jpeg_decoder_factory_callback); 29 jpeg_decoder_factory_callback);
31 ~DeviceFactoryMediaToMojoAdapter() override; 30 ~DeviceFactoryMediaToMojoAdapter() override;
32 31
33 // mojom::VideoCaptureDeviceFactory: 32 // mojom::DeviceFactory:
34 void EnumerateDeviceDescriptors( 33 void EnumerateDeviceDescriptors(
35 const EnumerateDeviceDescriptorsCallback& callback) override; 34 const EnumerateDeviceDescriptorsCallback& callback) override;
36 void GetSupportedFormats( 35 void GetSupportedFormats(
37 const std::string& device_id, 36 const std::string& device_id,
38 const GetSupportedFormatsCallback& callback) override; 37 const GetSupportedFormatsCallback& callback) override;
39 void CreateDeviceProxy(const std::string& device_id, 38 void CreateDevice(const std::string& device_id,
40 mojom::VideoCaptureDeviceProxyRequest proxy_request, 39 mojom::DeviceRequest device_request,
41 const CreateDeviceProxyCallback& callback) override; 40 const CreateDeviceCallback& callback) override;
42 41
43 private: 42 private:
44 struct ActiveDeviceEntry { 43 struct ActiveDeviceEntry {
45 ActiveDeviceEntry(); 44 ActiveDeviceEntry();
46 ~ActiveDeviceEntry(); 45 ~ActiveDeviceEntry();
47 ActiveDeviceEntry(ActiveDeviceEntry&& other); 46 ActiveDeviceEntry(ActiveDeviceEntry&& other);
48 ActiveDeviceEntry& operator=(ActiveDeviceEntry&& other); 47 ActiveDeviceEntry& operator=(ActiveDeviceEntry&& other);
49 48
50 std::unique_ptr<VideoCaptureDeviceProxyImpl> device_proxy; 49 std::unique_ptr<DeviceMediaToMojoAdapter> device;
51 // TODO(chfremer) Use mojo::Binding<> directly instead of unique_ptr<> when 50 // TODO(chfremer) Use mojo::Binding<> directly instead of unique_ptr<> when
52 // mojo::Binding<> supports move operators. 51 // mojo::Binding<> supports move operators.
53 // https://crbug.com/644314 52 // https://crbug.com/644314
54 std::unique_ptr<mojo::Binding<mojom::VideoCaptureDeviceProxy>> binding; 53 std::unique_ptr<mojo::Binding<mojom::Device>> binding;
55 }; 54 };
56 55
57 void OnClientConnectionErrorOrClose(const std::string& device_id); 56 void OnClientConnectionErrorOrClose(const std::string& device_id);
58 57
59 // Returns false if no descriptor found. 58 // Returns false if no descriptor found.
60 bool LookupDescriptorFromId(const std::string& device_id, 59 bool LookupDescriptorFromId(const std::string& device_id,
61 media::VideoCaptureDeviceDescriptor* descriptor); 60 media::VideoCaptureDeviceDescriptor* descriptor);
62 61
63 const std::unique_ptr<media::VideoCaptureDeviceFactory> device_factory_; 62 const std::unique_ptr<media::VideoCaptureDeviceFactory> device_factory_;
64 const media::VideoCaptureJpegDecoderFactoryCB jpeg_decoder_factory_callback_; 63 const media::VideoCaptureJpegDecoderFactoryCB jpeg_decoder_factory_callback_;
65 std::map<std::string, ActiveDeviceEntry> active_devices_by_id_; 64 std::map<std::string, ActiveDeviceEntry> active_devices_by_id_;
66 }; 65 };
67 66
68 } // namespace video_capture 67 } // namespace video_capture
69 68
70 #endif // SERVICES_VIDEO_CAPTURE_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_ 69 #endif // SERVICES_VIDEO_CAPTURE_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698