Chromium Code Reviews| Index: content/browser/renderer_host/media/buildable_video_capture_device.h |
| diff --git a/content/browser/renderer_host/media/buildable_video_capture_device.h b/content/browser/renderer_host/media/buildable_video_capture_device.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..867fb7ee01c30847db225cf63b80a29d80c56af2 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/media/buildable_video_capture_device.h |
| @@ -0,0 +1,86 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ |
| + |
| +#include "base/memory/ptr_util.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "content/browser/renderer_host/media/ownership.h" |
| +#include "content/public/common/media_stream_request.h" |
| +#include "media/capture/video/video_capture_device.h" |
| +#include "media/capture/video_capture_types.h" |
| + |
| +namespace content { |
| + |
| +class VideoCaptureController; |
| +class VideoCaptureDeviceEntry; |
| + |
| +class CONTENT_EXPORT BuildableDeviceCallbacks { |
| + public: |
| + virtual ~BuildableDeviceCallbacks() {} |
| + // Returns false if no descriptor was found. |
| + virtual bool LookupDeviceDescriptor( |
| + const std::string& id, |
| + media::VideoCaptureDeviceDescriptor* descriptor) = 0; |
| + virtual void OnDeviceAboutToStart(media::VideoFacingMode facing_mode) = 0; |
|
miu
2017/03/11 01:13:21
I've seen a lot of similar code throughout Chromiu
chfremer
2017/03/13 22:02:02
I like those names when reading the calling code.
|
| + virtual void OnDeviceStarted(VideoCaptureDeviceEntry* entry) = 0; |
| + virtual void OnDeviceStartFailed(VideoCaptureDeviceEntry* entry) = 0; |
| +}; |
| + |
| +// Abstraction for a video capture device that must be "built" before it can be |
| +// operated and must be "stopped", before it can be released. Typical operation |
| +// is that a newly created instance initially reports HasDevice() == false. |
| +// Clients call CreateAndStartDeviceAsync(), which kicks off the asynchronous |
| +// building of the device. The outcome of the device building is typically |
| +// reported to an instance of BuildableDeviceCallbacks (see above). Once the |
| +// device has been built successfully, the "Device operation methods", are |
| +// allowed to be called. ReleaseDeviceAsync() must be called in order to |
| +// release the device if it has before been built successfully. After calling |
| +// ReleaseDeviceAsync(), it is legal to call CreateAndStartDeviceAsync() to |
| +// rebuild and start the device again. |
| +class BuildableVideoCaptureDevice { |
|
miu
2017/03/11 01:13:21
naming/description suggestion: It looks like this
chfremer
2017/03/13 22:02:03
Hmm, now that I think about it with a fresh mind a
miu
2017/03/16 00:01:35
Ack.
chfremer
2017/03/16 17:39:39
Sorry, yes, I meant the "launcher" part. I got ahe
|
| + public: |
| + virtual ~BuildableVideoCaptureDevice() {} |
| + |
| + // Device management methods. |
| + // The passed-in |context_reference| must guarantee that the context relevant |
|
miu
2017/03/11 01:13:21
I'm a little confused by this. If the BuildableVid
chfremer
2017/03/13 22:02:02
Your understanding is correct. The comment is conf
chfremer
2017/03/16 17:39:39
I still haven't found a better way of explaining |
miu
2017/03/17 21:18:15
That's because it should be a "done callback" to r
|
| + // during the asynchronous processing stays alive. |
| + virtual void CreateAndStartDeviceAsync( |
| + VideoCaptureDeviceEntry* entry, |
| + VideoCaptureController* controller, |
| + const media::VideoCaptureParams& params, |
| + BuildableDeviceCallbacks* callbacks, |
| + std::unique_ptr<Ownership> context_reference) = 0; |
| + // The passed-in |context_reference| must guarantee that the context relevant |
| + // during the asynchronous processing stays alive. |
| + virtual void ReleaseDeviceAsync( |
| + VideoCaptureController* controller, |
| + std::unique_ptr<Ownership> context_reference) = 0; |
| + virtual bool HasDevice() const = 0; |
|
miu
2017/03/11 01:13:21
naming suggestion: s/HasDevice/IsDeviceAlive/ They
chfremer
2017/03/13 22:02:02
Done.
|
| + |
| + // Device operation methods. |
| + virtual void GetPhotoCapabilities( |
| + media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) |
| + const = 0; |
| + virtual void SetPhotoOptions( |
| + media::mojom::PhotoSettingsPtr settings, |
| + media::VideoCaptureDevice::SetPhotoOptionsCallback callback) = 0; |
| + virtual void TakePhoto( |
| + media::VideoCaptureDevice::TakePhotoCallback callback) = 0; |
| + virtual void MaybeSuspendDevice() = 0; |
| + virtual void ResumeDevice() = 0; |
| + virtual void RequestRefreshFrame() = 0; |
| + |
| + // Methods for specific types of devices. |
| + // The passed-in |context_reference| must guarantee that the context relevant |
| + // during the asynchronous processing stays alive. |
| + virtual void SetDesktopCaptureWindowIdAsync( |
| + gfx::NativeViewId window_id, |
| + std::unique_ptr<Ownership> context_reference) = 0; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ |