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

Side by Side Diff: content/browser/renderer_host/media/video_capture_provider.h

Issue 2803483003: [Mojo Video Capture] Split interface BuildableVideoCaptureDevice (Closed)
Patch Set: Remove fallback mechanism. Created 3 years, 8 months 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
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "content/common/content_export.h"
10 #include "content/public/common/media_stream_request.h" 11 #include "content/public/common/media_stream_request.h"
11 #include "media/capture/video/video_capture_device.h" 12 #include "media/capture/video/video_capture_device.h"
12 #include "media/capture/video/video_capture_device_info.h" 13 #include "media/capture/video/video_capture_device_info.h"
14 #include "media/capture/video/video_frame_receiver.h"
13 #include "media/capture/video_capture_types.h" 15 #include "media/capture/video_capture_types.h"
14 16
15 namespace content { 17 namespace content {
16 18
17 class VideoCaptureController; 19 class LaunchedVideoCaptureDevice;
18 20
19 // Abstraction for a video capture device that must be "built" before it can be 21 // Asynchronously launches video capture devices. After a call to
20 // operated and must be "stopped", before it can be released. Typical operation 22 // LaunchDeviceAsync() it is illegal to call LaunchDeviceAsync() again until
21 // is that a newly created instance initially reports IsDeviceAlive() == false. 23 // |callbacks| has been notified about the outcome of the asynchronous launch.
22 // Clients call CreateAndStartDeviceAsync(), which kicks off the asynchronous 24 class CONTENT_EXPORT VideoCaptureDeviceLauncher {
23 // building of the device. The outcome of the device building is reported to an
24 // instance of Callbacks. Once the device has been built successfully, the
25 // "Device operation methods", are allowed to be called. ReleaseDeviceAsync()
26 // must be called in order to release the device if it has before been built
27 // successfully. After calling ReleaseDeviceAsync(), it is legal to call
28 // CreateAndStartDeviceAsync() to rebuild and start the device again.
29 class CONTENT_EXPORT BuildableVideoCaptureDevice {
30 public: 25 public:
31 class CONTENT_EXPORT Callbacks { 26 class CONTENT_EXPORT Callbacks {
32 public: 27 public:
33 virtual ~Callbacks() {} 28 virtual ~Callbacks() {}
34 virtual void OnDeviceStarted(VideoCaptureController* controller) = 0; 29 virtual void OnDeviceLaunched(
35 virtual void OnDeviceStartFailed(VideoCaptureController* controller) = 0; 30 std::unique_ptr<LaunchedVideoCaptureDevice> device) = 0;
36 virtual void OnDeviceStartAborted() = 0; 31 virtual void OnDeviceLaunchFailed() = 0;
32 virtual void OnDeviceLaunchAborted() = 0;
37 }; 33 };
38 34
39 virtual ~BuildableVideoCaptureDevice() {} 35 virtual ~VideoCaptureDeviceLauncher() {}
40 36
41 // Device management methods. 37 // The passed-in |done_cb| must guarantee that the context relevant
42 virtual void CreateAndStartDeviceAsync( 38 // during the asynchronous processing stays alive.
43 VideoCaptureController* controller, 39 virtual void LaunchDeviceAsync(
40 const std::string& device_id,
41 MediaStreamType stream_type,
44 const media::VideoCaptureParams& params, 42 const media::VideoCaptureParams& params,
43 base::WeakPtr<media::VideoFrameReceiver> receiver,
45 Callbacks* callbacks, 44 Callbacks* callbacks,
46 base::OnceClosure done_cb) = 0; 45 base::OnceClosure done_cb) = 0;
47 virtual void ReleaseDeviceAsync(VideoCaptureController* controller,
48 base::OnceClosure done_cb) = 0;
49 virtual bool IsDeviceAlive() const = 0;
50 46
47 virtual void AbortLaunch() = 0;
48 };
49
50 class LaunchedVideoCaptureDevice
51 : public media::VideoFrameConsumerFeedbackObserver {
52 public:
51 // Device operation methods. 53 // Device operation methods.
52 virtual void GetPhotoCapabilities( 54 virtual void GetPhotoCapabilities(
53 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) 55 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback)
54 const = 0; 56 const = 0;
55 virtual void SetPhotoOptions( 57 virtual void SetPhotoOptions(
56 media::mojom::PhotoSettingsPtr settings, 58 media::mojom::PhotoSettingsPtr settings,
57 media::VideoCaptureDevice::SetPhotoOptionsCallback callback) = 0; 59 media::VideoCaptureDevice::SetPhotoOptionsCallback callback) = 0;
58 virtual void TakePhoto( 60 virtual void TakePhoto(
59 media::VideoCaptureDevice::TakePhotoCallback callback) = 0; 61 media::VideoCaptureDevice::TakePhotoCallback callback) = 0;
60 virtual void MaybeSuspendDevice() = 0; 62 virtual void MaybeSuspendDevice() = 0;
61 virtual void ResumeDevice() = 0; 63 virtual void ResumeDevice() = 0;
62 virtual void RequestRefreshFrame() = 0; 64 virtual void RequestRefreshFrame() = 0;
63 65
64 // Methods for specific types of devices. 66 // Methods for specific types of devices.
65 virtual void SetDesktopCaptureWindowIdAsync(gfx::NativeViewId window_id, 67 virtual void SetDesktopCaptureWindowIdAsync(gfx::NativeViewId window_id,
66 base::OnceClosure done_cb) = 0; 68 base::OnceClosure done_cb) = 0;
67 }; 69 };
68 70
69 class CONTENT_EXPORT VideoCaptureProvider { 71 class CONTENT_EXPORT VideoCaptureProvider {
70 public: 72 public:
71 virtual ~VideoCaptureProvider() {} 73 virtual ~VideoCaptureProvider() {}
72 74
73 // The passed-in |result_callback| must guarantee that the called 75 // The passed-in |result_callback| must guarantee that the called
74 // instance stays alive until |result_callback| is invoked. 76 // instance stays alive until |result_callback| is invoked.
75 virtual void GetDeviceInfosAsync( 77 virtual void GetDeviceInfosAsync(
76 const base::Callback< 78 const base::Callback<
77 void(const std::vector<media::VideoCaptureDeviceInfo>&)>& 79 void(const std::vector<media::VideoCaptureDeviceInfo>&)>&
78 result_callback) = 0; 80 result_callback) = 0;
79 81
80 virtual std::unique_ptr<BuildableVideoCaptureDevice> CreateBuildableDevice( 82 virtual std::unique_ptr<VideoCaptureDeviceLauncher>
81 const std::string& device_id, 83 CreateDeviceLauncher() = 0;
82 MediaStreamType stream_type) = 0;
83 }; 84 };
84 85
85 } // namespace content 86 } // namespace content
86 87
87 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ 88 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698