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

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

Issue 2471613005: [Mojo Video Capture] Use actual factory instances implementing media::VideoCaptureDeviceFactory (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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SERVICES_VIDEO_CAPTURE_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_
6 #define SERVICES_VIDEO_CAPTURE_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_
7
8 #include <map>
9
10 #include "media/capture/video/video_capture_device_client.h"
11 #include "media/capture/video/video_capture_device_factory.h"
12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h"
14
15 namespace video_capture {
16
17 class VideoCaptureDeviceProxyImpl;
18
19 // Wraps a media::VideoCaptureDeviceFactory and exposes its functionality
20 // through the mojom::VideoCaptureDeviceFactory interface.
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
23 // media::VideoCaptureDevice at the same time.
24 class DeviceFactoryMediaToMojoAdapter
25 : public mojom::VideoCaptureDeviceFactory {
26 public:
27 DeviceFactoryMediaToMojoAdapter(
28 std::unique_ptr<media::VideoCaptureDeviceFactory> device_factory,
29 const media::VideoCaptureJpegDecoderFactoryCB&
30 jpeg_decoder_factory_callback);
31 ~DeviceFactoryMediaToMojoAdapter() override;
32
33 // mojom::VideoCaptureDeviceFactory:
34 void EnumerateDeviceDescriptors(
35 const EnumerateDeviceDescriptorsCallback& callback) override;
36 void GetSupportedFormats(
37 const media::VideoCaptureDeviceDescriptor& device_descriptor,
38 const GetSupportedFormatsCallback& callback) override;
39 void CreateDeviceProxy(
40 const media::VideoCaptureDeviceDescriptor& device_descriptor,
41 mojom::VideoCaptureDeviceProxyRequest proxy_request,
42 const CreateDeviceProxyCallback& callback) override;
43
44 private:
45 struct ActiveDeviceEntry {
46 ActiveDeviceEntry();
47 ~ActiveDeviceEntry();
48 ActiveDeviceEntry(ActiveDeviceEntry&& other);
49 ActiveDeviceEntry& operator=(ActiveDeviceEntry&& other);
50
51 std::unique_ptr<VideoCaptureDeviceProxyImpl> device_proxy;
52 // TODO(chfremer) Use mojo::Binding<> directly instead of unique_ptr<> when
53 // mojo::Binding<> supports move operators.
54 // https://crbug.com/644314
55 std::unique_ptr<mojo::Binding<mojom::VideoCaptureDeviceProxy>> binding;
56 };
57
58 void OnClientConnectionErrorOrClose(
59 const media::VideoCaptureDeviceDescriptor& descriptor);
60
61 const std::unique_ptr<media::VideoCaptureDeviceFactory> device_factory_;
62 const media::VideoCaptureJpegDecoderFactoryCB jpeg_decoder_factory_callback_;
63 std::map<media::VideoCaptureDeviceDescriptor, ActiveDeviceEntry>
64 active_devices_;
65 };
66
67 } // namespace video_capture
68
69 #endif // SERVICES_VIDEO_CAPTURE_DEVICE_FACTORY_MEDIA_TO_MOJO_ADAPTER_H_
OLDNEW
« no previous file with comments | « services/video_capture/BUILD.gn ('k') | services/video_capture/device_factory_media_to_mojo_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698