Chromium Code Reviews| Index: content/browser/renderer_host/media/video_capture_device_entry.h |
| diff --git a/content/browser/renderer_host/media/video_capture_device_entry.h b/content/browser/renderer_host/media/video_capture_device_entry.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2c82b76ba54746c0f160befcefd66cc437ef8451 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/media/video_capture_device_entry.h |
| @@ -0,0 +1,95 @@ |
| +// 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_VIDEO_CAPTURE_DEVICE_ENTRY_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_ENTRY_H_ |
| + |
| +#include "content/browser/renderer_host/media/buildable_video_capture_device.h" |
| +#include "content/browser/renderer_host/media/video_capture_controller.h" |
| +#include "content/public/common/media_stream_request.h" |
| + |
| +namespace content { |
| + |
| +// When first created (in GetOrCreateDeviceEntry()), this consists of |
|
miu
2017/03/11 01:13:22
Is GetOrCreateDeviceEntry() in another class? Perh
chfremer
2017/03/13 22:02:03
Thanks for pointing this out. I removed the "(in G
|
| +// only the |controller_|. Clients can already connect to the controller, but |
| +// there is no |video_capture_device| present. A call to |
| +// CreateAndStartDeviceAsync() asynchronously brings up the given |
| +// |buildable_device| and connects it to the controller. If |
| +// CreateAndStartDeviceAsync() has beend called, ReleaseDeviceAsync() must be |
| +// called before releasing the instance. |
| +// Instances must be RefCountedThreadSafe, because an owner |
| +// (VideoCaptureManager) wants to be able to release its reference during an |
| +// (asynchronously executing) run of CreateAndStartDeviceAsync(). To this end, |
| +// the owner passes in the shared ownership as part of |context_reference| into |
| +// CreateAndStartDeviceAsync(). |
| +class VideoCaptureDeviceEntry |
| + : public base::RefCountedThreadSafe<VideoCaptureDeviceEntry> { |
| + public: |
| + VideoCaptureDeviceEntry( |
| + const std::string& id, |
| + MediaStreamType stream_type, |
| + const media::VideoCaptureParams& params, |
| + std::unique_ptr<BuildableVideoCaptureDevice> buildable_device); |
| + |
| + // The passed-in |context_reference| must guarantee that the context relevant |
| + // during the asynchronous processing stays alive. |
| + void CreateAndStartDeviceAsync(const media::VideoCaptureParams& params, |
| + BuildableDeviceCallbacks* callbacks, |
| + std::unique_ptr<Ownership> context_reference); |
| + // The passed-in |context_reference| must guarantee that the context relevant |
| + // during the asynchronous processing stays alive. |
| + void ReleaseDeviceAsync(std::unique_ptr<Ownership> context_reference); |
| + |
| + void OnLog(const std::string& message); |
| + void OnError(); |
| + bool HasDevice() const; |
| + bool CorrespondsToController(const VideoCaptureController* controller) const; |
| + bool HasActiveClient(); |
| + bool HasPausedClient(); |
| + void AddClient(VideoCaptureControllerID id, |
| + VideoCaptureControllerEventHandler* event_handler, |
| + media::VideoCaptureSessionId session_id, |
| + const media::VideoCaptureParams& params); |
| + // Ends a client's session "involuntarily", meaning the session is stopped |
| + // without the client requesting it. |
| + void StopSession(int session_id); |
| + base::WeakPtr<VideoCaptureController> GetControllerWeakPtrForIOThread(); |
| + media::VideoCaptureFormat GetVideoCaptureFormat(); |
| + |
| + void GetPhotoCapabilities( |
| + media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) const; |
| + void SetPhotoOptions( |
| + media::mojom::PhotoSettingsPtr settings, |
| + media::VideoCaptureDevice::SetPhotoOptionsCallback callback); |
| + void TakePhoto(media::VideoCaptureDevice::TakePhotoCallback callback); |
| + void MaybeSuspend(); |
| + void Resume(); |
| + void RequestRefreshFrame(); |
| + |
| + // The passed-in |context_reference| must guarantee that the context relevant |
| + // during the asynchronous processing stays alive. |
| + void SetDesktopCaptureWindowIdAsync( |
| + gfx::NativeViewId window_id, |
| + std::unique_ptr<Ownership> context_reference); |
| + |
| + int serial_id() const { return serial_id_; } |
| + const std::string& id() const { return id_; } |
| + MediaStreamType stream_type() const { return stream_type_; } |
| + const media::VideoCaptureParams& parameters() const { return parameters_; } |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<VideoCaptureDeviceEntry>; |
| + virtual ~VideoCaptureDeviceEntry(); |
| + |
| + const int serial_id_; |
| + const std::string id_; |
| + const MediaStreamType stream_type_; |
| + const media::VideoCaptureParams parameters_; |
| + std::unique_ptr<BuildableVideoCaptureDevice> buildable_device_; |
| + VideoCaptureController controller_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_ENTRY_H_ |