| 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 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // | 40 // |
| 41 // VideoCaptureImpl is an IO thread only object. See the comments in | 41 // VideoCaptureImpl is an IO thread only object. See the comments in |
| 42 // video_capture_impl_manager.cc for the lifetime of this object. | 42 // video_capture_impl_manager.cc for the lifetime of this object. |
| 43 // All methods must be called on the IO thread. | 43 // All methods must be called on the IO thread. |
| 44 // | 44 // |
| 45 // This is an internal class used by VideoCaptureImplManager only. Do not access | 45 // This is an internal class used by VideoCaptureImplManager only. Do not access |
| 46 // this directly. | 46 // this directly. |
| 47 class CONTENT_EXPORT VideoCaptureImpl | 47 class CONTENT_EXPORT VideoCaptureImpl |
| 48 : public VideoCaptureMessageFilter::Delegate { | 48 : public VideoCaptureMessageFilter::Delegate { |
| 49 public: | 49 public: |
| 50 ~VideoCaptureImpl() override; | |
| 51 | |
| 52 VideoCaptureImpl( | 50 VideoCaptureImpl( |
| 53 media::VideoCaptureSessionId session_id, | 51 media::VideoCaptureSessionId session_id, |
| 54 VideoCaptureMessageFilter* filter, | 52 VideoCaptureMessageFilter* filter, |
| 55 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); | 53 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); |
| 54 ~VideoCaptureImpl() override; |
| 56 | 55 |
| 57 // Stop/resume delivering video frames to clients, based on flag |suspend|. | 56 // Stop/resume delivering video frames to clients, based on flag |suspend|. |
| 58 void SuspendCapture(bool suspend); | 57 void SuspendCapture(bool suspend); |
| 59 | 58 |
| 60 // Start capturing using the provided parameters. | 59 // Start capturing using the provided parameters. |
| 61 // |client_id| must be unique to this object in the render process. It is | 60 // |client_id| must be unique to this object in the render process. It is |
| 62 // used later to stop receiving video frames. | 61 // used later to stop receiving video frames. |
| 63 // |state_update_cb| will be called when state changes. | 62 // |state_update_cb| will be called when state changes. |
| 64 // |deliver_frame_cb| will be called when a frame is ready. | 63 // |deliver_frame_cb| will be called when a frame is ready. |
| 65 void StartCapture(int client_id, | 64 void StartCapture(int client_id, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 double consumer_resource_utilization); | 146 double consumer_resource_utilization); |
| 148 void OnClientBufferFinished2(int buffer_id, | 147 void OnClientBufferFinished2(int buffer_id, |
| 149 const scoped_refptr<ClientBuffer2>& buffer, | 148 const scoped_refptr<ClientBuffer2>& buffer, |
| 150 const gpu::SyncToken& release_sync_token, | 149 const gpu::SyncToken& release_sync_token, |
| 151 double consumer_resource_utilization); | 150 double consumer_resource_utilization); |
| 152 | 151 |
| 153 void StopDevice(); | 152 void StopDevice(); |
| 154 void RestartCapture(); | 153 void RestartCapture(); |
| 155 void StartCaptureInternal(); | 154 void StartCaptureInternal(); |
| 156 | 155 |
| 157 // Helpers. | 156 // Tries to remove |client_id| from |clients|, returning false if not found. |
| 158 bool RemoveClient(int client_id, ClientInfoMap* clients); | 157 bool RemoveClient(int client_id, ClientInfoMap* clients); |
| 159 | 158 |
| 160 mojom::VideoCaptureHost* GetVideoCaptureHost(); | 159 mojom::VideoCaptureHost* GetVideoCaptureHost(); |
| 161 | 160 |
| 162 // Called (by an unknown thread) when all consumers are done with a VideoFrame | 161 // Called (by an unknown thread) when all consumers are done with a VideoFrame |
| 163 // and its ref-count has gone to zero. This helper function grabs the | 162 // and its ref-count has gone to zero. This helper function grabs the |
| 164 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given | 163 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given |
| 165 // callback, to trampoline back to the IO thread with the values. | 164 // callback, to trampoline back to the IO thread with the values. |
| 166 static void DidFinishConsumingFrame( | 165 static void DidFinishConsumingFrame( |
| 167 const media::VideoFrameMetadata* metadata, | 166 const media::VideoFrameMetadata* metadata, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 189 ClientBuffer2Map client_buffer2s_; | 188 ClientBuffer2Map client_buffer2s_; |
| 190 | 189 |
| 191 ClientInfoMap clients_; | 190 ClientInfoMap clients_; |
| 192 ClientInfoMap clients_pending_on_filter_; | 191 ClientInfoMap clients_pending_on_filter_; |
| 193 ClientInfoMap clients_pending_on_restart_; | 192 ClientInfoMap clients_pending_on_restart_; |
| 194 | 193 |
| 195 // Member params_ represents the video format requested by the | 194 // Member params_ represents the video format requested by the |
| 196 // client to this class via StartCapture(). | 195 // client to this class via StartCapture(). |
| 197 media::VideoCaptureParams params_; | 196 media::VideoCaptureParams params_; |
| 198 | 197 |
| 199 // The device's first captured frame referecne time sent from browser process | 198 // The device's first captured frame reference time sent from browser process |
| 200 // side. | 199 // side. |
| 201 base::TimeTicks first_frame_ref_time_; | 200 base::TimeTicks first_frame_ref_time_; |
| 202 | 201 |
| 203 bool suspended_; | |
| 204 VideoCaptureState state_; | 202 VideoCaptureState state_; |
| 205 | 203 |
| 206 // IO message loop reference for checking correct class operation. | 204 // IO message loop reference for checking correct class operation. |
| 207 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 205 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 208 | 206 |
| 209 // WeakPtrFactory pointing back to |this| object, for use with | 207 // WeakPtrFactory pointing back to |this| object, for use with |
| 210 // media::VideoFrames constructed in OnBufferReceived() from buffers cached | 208 // media::VideoFrames constructed in OnBufferReceived() from buffers cached |
| 211 // in |client_buffers_|. | 209 // in |client_buffers_|. |
| 212 // NOTE: Weak pointers must be invalidated before all other member variables. | 210 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 213 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; | 211 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; |
| 214 | 212 |
| 215 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 213 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
| 216 }; | 214 }; |
| 217 | 215 |
| 218 } // namespace content | 216 } // namespace content |
| 219 | 217 |
| 220 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 218 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |