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_VIDEO_CAPTURE_DEVICE_ENTRY_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_ENTRY_H_ | |
7 | |
8 #include "content/browser/renderer_host/media/buildable_video_capture_device.h" | |
9 #include "content/browser/renderer_host/media/video_capture_controller.h" | |
10 #include "content/public/common/media_stream_request.h" | |
11 | |
12 namespace content { | |
13 | |
14 // 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
| |
15 // only the |controller_|. Clients can already connect to the controller, but | |
16 // there is no |video_capture_device| present. A call to | |
17 // CreateAndStartDeviceAsync() asynchronously brings up the given | |
18 // |buildable_device| and connects it to the controller. If | |
19 // CreateAndStartDeviceAsync() has beend called, ReleaseDeviceAsync() must be | |
20 // called before releasing the instance. | |
21 // Instances must be RefCountedThreadSafe, because an owner | |
22 // (VideoCaptureManager) wants to be able to release its reference during an | |
23 // (asynchronously executing) run of CreateAndStartDeviceAsync(). To this end, | |
24 // the owner passes in the shared ownership as part of |context_reference| into | |
25 // CreateAndStartDeviceAsync(). | |
26 class VideoCaptureDeviceEntry | |
27 : public base::RefCountedThreadSafe<VideoCaptureDeviceEntry> { | |
28 public: | |
29 VideoCaptureDeviceEntry( | |
30 const std::string& id, | |
31 MediaStreamType stream_type, | |
32 const media::VideoCaptureParams& params, | |
33 std::unique_ptr<BuildableVideoCaptureDevice> buildable_device); | |
34 | |
35 // The passed-in |context_reference| must guarantee that the context relevant | |
36 // during the asynchronous processing stays alive. | |
37 void CreateAndStartDeviceAsync(const media::VideoCaptureParams& params, | |
38 BuildableDeviceCallbacks* callbacks, | |
39 std::unique_ptr<Ownership> context_reference); | |
40 // The passed-in |context_reference| must guarantee that the context relevant | |
41 // during the asynchronous processing stays alive. | |
42 void ReleaseDeviceAsync(std::unique_ptr<Ownership> context_reference); | |
43 | |
44 void OnLog(const std::string& message); | |
45 void OnError(); | |
46 bool HasDevice() const; | |
47 bool CorrespondsToController(const VideoCaptureController* controller) const; | |
48 bool HasActiveClient(); | |
49 bool HasPausedClient(); | |
50 void AddClient(VideoCaptureControllerID id, | |
51 VideoCaptureControllerEventHandler* event_handler, | |
52 media::VideoCaptureSessionId session_id, | |
53 const media::VideoCaptureParams& params); | |
54 // Ends a client's session "involuntarily", meaning the session is stopped | |
55 // without the client requesting it. | |
56 void StopSession(int session_id); | |
57 base::WeakPtr<VideoCaptureController> GetControllerWeakPtrForIOThread(); | |
58 media::VideoCaptureFormat GetVideoCaptureFormat(); | |
59 | |
60 void GetPhotoCapabilities( | |
61 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) const; | |
62 void SetPhotoOptions( | |
63 media::mojom::PhotoSettingsPtr settings, | |
64 media::VideoCaptureDevice::SetPhotoOptionsCallback callback); | |
65 void TakePhoto(media::VideoCaptureDevice::TakePhotoCallback callback); | |
66 void MaybeSuspend(); | |
67 void Resume(); | |
68 void RequestRefreshFrame(); | |
69 | |
70 // The passed-in |context_reference| must guarantee that the context relevant | |
71 // during the asynchronous processing stays alive. | |
72 void SetDesktopCaptureWindowIdAsync( | |
73 gfx::NativeViewId window_id, | |
74 std::unique_ptr<Ownership> context_reference); | |
75 | |
76 int serial_id() const { return serial_id_; } | |
77 const std::string& id() const { return id_; } | |
78 MediaStreamType stream_type() const { return stream_type_; } | |
79 const media::VideoCaptureParams& parameters() const { return parameters_; } | |
80 | |
81 private: | |
82 friend class base::RefCountedThreadSafe<VideoCaptureDeviceEntry>; | |
83 virtual ~VideoCaptureDeviceEntry(); | |
84 | |
85 const int serial_id_; | |
86 const std::string id_; | |
87 const MediaStreamType stream_type_; | |
88 const media::VideoCaptureParams parameters_; | |
89 std::unique_ptr<BuildableVideoCaptureDevice> buildable_device_; | |
90 VideoCaptureController controller_; | |
91 }; | |
92 | |
93 } // namespace content | |
94 | |
95 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_ENTRY_H_ | |
OLD | NEW |