Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ | |
| 7 | |
| 8 #include "base/memory/ptr_util.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "content/browser/renderer_host/media/ownership.h" | |
| 11 #include "content/public/common/media_stream_request.h" | |
| 12 #include "media/capture/video/video_capture_device.h" | |
| 13 #include "media/capture/video_capture_types.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class VideoCaptureController; | |
| 18 class VideoCaptureDeviceEntry; | |
| 19 | |
| 20 class CONTENT_EXPORT BuildableDeviceCallbacks { | |
| 21 public: | |
| 22 virtual ~BuildableDeviceCallbacks() {} | |
| 23 // Returns false if no descriptor was found. | |
| 24 virtual bool LookupDeviceDescriptor( | |
| 25 const std::string& id, | |
| 26 media::VideoCaptureDeviceDescriptor* descriptor) = 0; | |
| 27 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.
| |
| 28 virtual void OnDeviceStarted(VideoCaptureDeviceEntry* entry) = 0; | |
| 29 virtual void OnDeviceStartFailed(VideoCaptureDeviceEntry* entry) = 0; | |
| 30 }; | |
| 31 | |
| 32 // Abstraction for a video capture device that must be "built" before it can be | |
| 33 // operated and must be "stopped", before it can be released. Typical operation | |
| 34 // is that a newly created instance initially reports HasDevice() == false. | |
| 35 // Clients call CreateAndStartDeviceAsync(), which kicks off the asynchronous | |
| 36 // building of the device. The outcome of the device building is typically | |
| 37 // reported to an instance of BuildableDeviceCallbacks (see above). Once the | |
| 38 // device has been built successfully, the "Device operation methods", are | |
| 39 // allowed to be called. ReleaseDeviceAsync() must be called in order to | |
| 40 // release the device if it has before been built successfully. After calling | |
| 41 // ReleaseDeviceAsync(), it is legal to call CreateAndStartDeviceAsync() to | |
| 42 // rebuild and start the device again. | |
| 43 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
| |
| 44 public: | |
| 45 virtual ~BuildableVideoCaptureDevice() {} | |
| 46 | |
| 47 // Device management methods. | |
| 48 // 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
| |
| 49 // during the asynchronous processing stays alive. | |
| 50 virtual void CreateAndStartDeviceAsync( | |
| 51 VideoCaptureDeviceEntry* entry, | |
| 52 VideoCaptureController* controller, | |
| 53 const media::VideoCaptureParams& params, | |
| 54 BuildableDeviceCallbacks* callbacks, | |
| 55 std::unique_ptr<Ownership> context_reference) = 0; | |
| 56 // The passed-in |context_reference| must guarantee that the context relevant | |
| 57 // during the asynchronous processing stays alive. | |
| 58 virtual void ReleaseDeviceAsync( | |
| 59 VideoCaptureController* controller, | |
| 60 std::unique_ptr<Ownership> context_reference) = 0; | |
| 61 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.
| |
| 62 | |
| 63 // Device operation methods. | |
| 64 virtual void GetPhotoCapabilities( | |
| 65 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) | |
| 66 const = 0; | |
| 67 virtual void SetPhotoOptions( | |
| 68 media::mojom::PhotoSettingsPtr settings, | |
| 69 media::VideoCaptureDevice::SetPhotoOptionsCallback callback) = 0; | |
| 70 virtual void TakePhoto( | |
| 71 media::VideoCaptureDevice::TakePhotoCallback callback) = 0; | |
| 72 virtual void MaybeSuspendDevice() = 0; | |
| 73 virtual void ResumeDevice() = 0; | |
| 74 virtual void RequestRefreshFrame() = 0; | |
| 75 | |
| 76 // Methods for specific types of devices. | |
| 77 // The passed-in |context_reference| must guarantee that the context relevant | |
| 78 // during the asynchronous processing stays alive. | |
| 79 virtual void SetDesktopCaptureWindowIdAsync( | |
| 80 gfx::NativeViewId window_id, | |
| 81 std::unique_ptr<Ownership> context_reference) = 0; | |
| 82 }; | |
| 83 | |
| 84 } // namespace content | |
| 85 | |
| 86 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_BUILDABLE_VIDEO_CAPTURE_DEVICE_H_ | |
| OLD | NEW |