Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 60 |
| 61 namespace content { | 61 namespace content { |
| 62 | 62 |
| 63 class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { | 63 class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { |
| 64 public: | 64 public: |
| 65 VideoCaptureController(); | 65 VideoCaptureController(); |
| 66 ~VideoCaptureController() override; | 66 ~VideoCaptureController() override; |
| 67 | 67 |
| 68 base::WeakPtr<VideoCaptureController> GetWeakPtrForIOThread(); | 68 base::WeakPtr<VideoCaptureController> GetWeakPtrForIOThread(); |
| 69 | 69 |
| 70 // Factory code creating instances of VideoCaptureController must set a | 70 // Factory code creating instances of VideoCaptureController may optionally |
| 71 // FrameBufferPool before any of the media::VideoFrameReceiver are used. | 71 // set a FrameBufferPool. Setting the host is done in this method |
| 72 // Setting the observer is done in this method separate from the constructor | 72 // separate from the constructor to allow clients to create and use instances |
| 73 // in order to allow use the media::VideoFrameReceiver methods | 73 // before they can provide the observer. (This is the case with |
|
mcasas
2017/01/05 20:37:01
If you're using Sublime, Sublime-wrap-plus [1] can
chfremer
2017/01/05 22:44:48
Done. Thanks for the link to the plugin.
Super use
| |
| 74 // before the observer can be provided. (This is the case with | |
| 75 // VideoCaptureManager). | 74 // VideoCaptureManager). |
| 76 void SetFrameBufferPool( | 75 void SetFrameBufferPool( |
| 77 std::unique_ptr<media::FrameBufferPool> frame_buffer_pool); | 76 std::unique_ptr<media::FrameBufferPool> frame_buffer_pool); |
| 78 | 77 |
| 79 // Factory code creating instances of VideoCaptureController may optionally | 78 // Factory code creating instances of VideoCaptureController may optionally |
| 80 // set a VideoFrameConsumerFeedbackObserver. Setting the observer is done in | 79 // set a VideoFrameConsumerFeedbackObserver. Setting the observer is done in |
| 81 // this method separate from the constructor to allow clients to create and | 80 // this method separate from the constructor to allow clients to create and |
| 82 // use instances before they can provide the observer. (This is the case with | 81 // use instances before they can provide the observer. (This is the case with |
| 83 // VideoCaptureManager). | 82 // VideoCaptureManager). |
| 84 void SetConsumerFeedbackObserver( | 83 void SetConsumerFeedbackObserver( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 VideoCaptureControllerEventHandler* event_handler, | 126 VideoCaptureControllerEventHandler* event_handler, |
| 128 int buffer_id, | 127 int buffer_id, |
| 129 double consumer_resource_utilization); | 128 double consumer_resource_utilization); |
| 130 | 129 |
| 131 const media::VideoCaptureFormat& GetVideoCaptureFormat() const; | 130 const media::VideoCaptureFormat& GetVideoCaptureFormat() const; |
| 132 | 131 |
| 133 bool has_received_frames() const { return has_received_frames_; } | 132 bool has_received_frames() const { return has_received_frames_; } |
| 134 | 133 |
| 135 // Implementation of media::VideoFrameReceiver interface: | 134 // Implementation of media::VideoFrameReceiver interface: |
| 136 void OnIncomingCapturedVideoFrame( | 135 void OnIncomingCapturedVideoFrame( |
| 137 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 136 media::VideoCaptureDevice::Client::Buffer buffer, |
| 138 scoped_refptr<media::VideoFrame> frame) override; | 137 scoped_refptr<media::VideoFrame> frame) override; |
| 139 void OnError() override; | 138 void OnError() override; |
| 140 void OnLog(const std::string& message) override; | 139 void OnLog(const std::string& message) override; |
| 141 void OnBufferDestroyed(int buffer_id_to_drop) override; | 140 void OnBufferDestroyed(int buffer_id_to_drop) override; |
| 142 | 141 |
| 143 private: | 142 private: |
| 144 struct ControllerClient; | 143 struct ControllerClient; |
| 145 typedef std::list<std::unique_ptr<ControllerClient>> ControllerClients; | 144 typedef std::list<std::unique_ptr<ControllerClient>> ControllerClients; |
| 146 | 145 |
| 147 class BufferState { | 146 class BufferState { |
| 148 public: | 147 public: |
| 149 explicit BufferState( | 148 explicit BufferState( |
| 150 int buffer_id, | 149 int buffer_id, |
| 151 int frame_feedback_id, | 150 int frame_feedback_id, |
| 152 media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer, | 151 media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer, |
| 153 media::FrameBufferPool* frame_buffer_pool, | 152 media::FrameBufferPool* frame_buffer_pool); |
| 154 scoped_refptr<media::VideoFrame> frame); | |
| 155 ~BufferState(); | 153 ~BufferState(); |
| 156 BufferState(const BufferState& other); | 154 BufferState(const BufferState& other); |
| 157 void RecordConsumerUtilization(double utilization); | 155 void RecordConsumerUtilization(double utilization); |
| 158 void IncreaseConsumerCount(); | 156 void IncreaseConsumerCount(); |
| 159 void DecreaseConsumerCount(); | 157 void DecreaseConsumerCount(); |
| 160 bool HasZeroConsumerHoldCount(); | 158 bool HasZeroConsumerHoldCount(); |
| 161 void SetConsumerFeedbackObserver( | 159 void SetConsumerFeedbackObserver( |
| 162 media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer); | 160 media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer); |
| 163 void SetFrameBufferPool(media::FrameBufferPool* frame_buffer_pool); | 161 void SetFrameBufferPool(media::FrameBufferPool* frame_buffer_pool); |
| 164 | 162 |
| 165 private: | 163 private: |
| 166 const int buffer_id_; | 164 const int buffer_id_; |
| 167 const int frame_feedback_id_; | 165 const int frame_feedback_id_; |
| 168 media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer_; | 166 media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer_; |
| 169 media::FrameBufferPool* frame_buffer_pool_; | 167 media::FrameBufferPool* frame_buffer_pool_; |
| 170 const scoped_refptr<media::VideoFrame> frame_; | |
| 171 double max_consumer_utilization_; | 168 double max_consumer_utilization_; |
| 172 int consumer_hold_count_; | 169 int consumer_hold_count_; |
| 173 }; | 170 }; |
| 174 | 171 |
| 175 // Notify renderer that a new buffer has been created. | |
| 176 void DoNewBufferOnIOThread(ControllerClient* client, | |
| 177 media::VideoCaptureDevice::Client::Buffer* buffer, | |
| 178 const scoped_refptr<media::VideoFrame>& frame); | |
| 179 | |
| 180 // Find a client of |id| and |handler| in |clients|. | 172 // Find a client of |id| and |handler| in |clients|. |
| 181 ControllerClient* FindClient(VideoCaptureControllerID id, | 173 ControllerClient* FindClient(VideoCaptureControllerID id, |
| 182 VideoCaptureControllerEventHandler* handler, | 174 VideoCaptureControllerEventHandler* handler, |
| 183 const ControllerClients& clients); | 175 const ControllerClients& clients); |
| 184 | 176 |
| 185 // Find a client of |session_id| in |clients|. | 177 // Find a client of |session_id| in |clients|. |
| 186 ControllerClient* FindClient(int session_id, | 178 ControllerClient* FindClient(int session_id, |
| 187 const ControllerClients& clients); | 179 const ControllerClients& clients); |
| 188 | 180 |
| 189 std::unique_ptr<media::FrameBufferPool> frame_buffer_pool_; | 181 std::unique_ptr<media::FrameBufferPool> frame_buffer_pool_; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 206 media::VideoCaptureFormat video_capture_format_; | 198 media::VideoCaptureFormat video_capture_format_; |
| 207 | 199 |
| 208 base::WeakPtrFactory<VideoCaptureController> weak_ptr_factory_; | 200 base::WeakPtrFactory<VideoCaptureController> weak_ptr_factory_; |
| 209 | 201 |
| 210 DISALLOW_COPY_AND_ASSIGN(VideoCaptureController); | 202 DISALLOW_COPY_AND_ASSIGN(VideoCaptureController); |
| 211 }; | 203 }; |
| 212 | 204 |
| 213 } // namespace content | 205 } // namespace content |
| 214 | 206 |
| 215 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ | 207 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ |
| OLD | NEW |