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

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

Issue 2361173002: Move classses VideoCaptureDeviceClient and VideoCaptureBufferPool to media/capture/video (Closed)
Patch Set: mcasas@ comments Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // VideoCaptureController is the glue between a VideoCaptureDevice and all 5 // VideoCaptureController is the glue between a VideoCaptureDevice and all
6 // VideoCaptureHosts that have connected to it. A controller exists on behalf of 6 // VideoCaptureHosts that have connected to it. A controller exists on behalf of
7 // one (and only one) VideoCaptureDevice; both are owned by the 7 // one (and only one) VideoCaptureDevice; both are owned by the
8 // VideoCaptureManager. 8 // VideoCaptureManager.
9 // 9 //
10 // The VideoCaptureController is responsible for: 10 // The VideoCaptureController is responsible for:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 #include "base/compiler_specific.h" 46 #include "base/compiler_specific.h"
47 #include "base/macros.h" 47 #include "base/macros.h"
48 #include "base/memory/ref_counted.h" 48 #include "base/memory/ref_counted.h"
49 #include "base/memory/weak_ptr.h" 49 #include "base/memory/weak_ptr.h"
50 #include "base/process/process.h" 50 #include "base/process/process.h"
51 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" 51 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h"
52 #include "content/common/content_export.h" 52 #include "content/common/content_export.h"
53 #include "content/common/media/video_capture.h" 53 #include "content/common/media/video_capture.h"
54 #include "media/base/video_capture_types.h" 54 #include "media/base/video_capture_types.h"
55 #include "media/capture/video/video_capture_device.h" 55 #include "media/capture/video/video_frame_receiver.h"
56
57 namespace media {
58 class VideoCaptureBufferPool;
59 }
56 60
57 namespace content { 61 namespace content {
58 class VideoCaptureBufferPool;
59 62
60 class CONTENT_EXPORT VideoFrameReceiver { 63 class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver {
61 public:
62 virtual ~VideoFrameReceiver(){};
63
64 virtual void OnIncomingCapturedVideoFrame(
65 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer,
66 const scoped_refptr<media::VideoFrame>& frame) = 0;
67 virtual void OnError() = 0;
68 virtual void OnLog(const std::string& message) = 0;
69 virtual void OnBufferDestroyed(int buffer_id_to_drop) = 0;
70 };
71
72 class CONTENT_EXPORT VideoCaptureController : public VideoFrameReceiver {
73 public: 64 public:
74 // |max_buffers| is the maximum number of video frame buffers in-flight at any 65 // |max_buffers| is the maximum number of video frame buffers in-flight at any
75 // one time. This value should be based on the logical capacity of the 66 // one time. This value should be based on the logical capacity of the
76 // capture pipeline, and not on hardware performance. For example, tab 67 // capture pipeline, and not on hardware performance. For example, tab
77 // capture requires more buffers than webcam capture because the pipeline is 68 // capture requires more buffers than webcam capture because the pipeline is
78 // longer (it includes read-backs pending in the GPU pipeline). 69 // longer (it includes read-backs pending in the GPU pipeline).
79 explicit VideoCaptureController(int max_buffers); 70 explicit VideoCaptureController(int max_buffers);
80 ~VideoCaptureController() override; 71 ~VideoCaptureController() override;
81 72
82 base::WeakPtr<VideoCaptureController> GetWeakPtrForIOThread(); 73 base::WeakPtr<VideoCaptureController> GetWeakPtrForIOThread();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void ReturnBuffer(VideoCaptureControllerID id, 121 void ReturnBuffer(VideoCaptureControllerID id,
131 VideoCaptureControllerEventHandler* event_handler, 122 VideoCaptureControllerEventHandler* event_handler,
132 int buffer_id, 123 int buffer_id,
133 const gpu::SyncToken& sync_token, 124 const gpu::SyncToken& sync_token,
134 double consumer_resource_utilization); 125 double consumer_resource_utilization);
135 126
136 const media::VideoCaptureFormat& GetVideoCaptureFormat() const; 127 const media::VideoCaptureFormat& GetVideoCaptureFormat() const;
137 128
138 bool has_received_frames() const { return has_received_frames_; } 129 bool has_received_frames() const { return has_received_frames_; }
139 130
140 // Implementation of VideoFrameReceiver interface: 131 // Implementation of media::VideoFrameReceiver interface:
141 void OnIncomingCapturedVideoFrame( 132 void OnIncomingCapturedVideoFrame(
142 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, 133 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer,
143 const scoped_refptr<media::VideoFrame>& frame) override; 134 const scoped_refptr<media::VideoFrame>& frame) override;
144 void OnError() override; 135 void OnError() override;
145 void OnLog(const std::string& message) override; 136 void OnLog(const std::string& message) override;
146 void OnBufferDestroyed(int buffer_id_to_drop) override; 137 void OnBufferDestroyed(int buffer_id_to_drop) override;
147 138
148 private: 139 private:
149 struct ControllerClient; 140 struct ControllerClient;
150 typedef std::list<std::unique_ptr<ControllerClient>> ControllerClients; 141 typedef std::list<std::unique_ptr<ControllerClient>> ControllerClients;
151 142
152 // Notify renderer that a new buffer has been created. 143 // Notify renderer that a new buffer has been created.
153 void DoNewBufferOnIOThread(ControllerClient* client, 144 void DoNewBufferOnIOThread(ControllerClient* client,
154 media::VideoCaptureDevice::Client::Buffer* buffer, 145 media::VideoCaptureDevice::Client::Buffer* buffer,
155 const scoped_refptr<media::VideoFrame>& frame); 146 const scoped_refptr<media::VideoFrame>& frame);
156 147
157 // Find a client of |id| and |handler| in |clients|. 148 // Find a client of |id| and |handler| in |clients|.
158 ControllerClient* FindClient(VideoCaptureControllerID id, 149 ControllerClient* FindClient(VideoCaptureControllerID id,
159 VideoCaptureControllerEventHandler* handler, 150 VideoCaptureControllerEventHandler* handler,
160 const ControllerClients& clients); 151 const ControllerClients& clients);
161 152
162 // Find a client of |session_id| in |clients|. 153 // Find a client of |session_id| in |clients|.
163 ControllerClient* FindClient(int session_id, 154 ControllerClient* FindClient(int session_id,
164 const ControllerClients& clients); 155 const ControllerClients& clients);
165 156
166 // The pool of shared-memory buffers used for capturing. 157 // The pool of shared-memory buffers used for capturing.
167 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; 158 const scoped_refptr<media::VideoCaptureBufferPool> buffer_pool_;
168 159
169 // All clients served by this controller. 160 // All clients served by this controller.
170 ControllerClients controller_clients_; 161 ControllerClients controller_clients_;
171 162
172 // Takes on only the states 'STARTED' and 'ERROR'. 'ERROR' is an absorbing 163 // Takes on only the states 'STARTED' and 'ERROR'. 'ERROR' is an absorbing
173 // state which stops the flow of data to clients. 164 // state which stops the flow of data to clients.
174 VideoCaptureState state_; 165 VideoCaptureState state_;
175 166
176 // True if the controller has received a video frame from the device. 167 // True if the controller has received a video frame from the device.
177 bool has_received_frames_; 168 bool has_received_frames_;
178 169
179 media::VideoCaptureFormat video_capture_format_; 170 media::VideoCaptureFormat video_capture_format_;
180 171
181 base::WeakPtrFactory<VideoCaptureController> weak_ptr_factory_; 172 base::WeakPtrFactory<VideoCaptureController> weak_ptr_factory_;
182 173
183 DISALLOW_COPY_AND_ASSIGN(VideoCaptureController); 174 DISALLOW_COPY_AND_ASSIGN(VideoCaptureController);
184 }; 175 };
185 176
186 } // namespace content 177 } // namespace content
187 178
188 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ 179 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698