| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 int buffer_id) override; | 125 int buffer_id) override; |
| 126 void OnBufferDestroyed(int buffer_id) override; | 126 void OnBufferDestroyed(int buffer_id) override; |
| 127 void OnBufferReceived(int buffer_id, | 127 void OnBufferReceived(int buffer_id, |
| 128 base::TimeDelta timestamp, | 128 base::TimeDelta timestamp, |
| 129 const base::DictionaryValue& metadata, | 129 const base::DictionaryValue& metadata, |
| 130 media::VideoPixelFormat pixel_format, | 130 media::VideoPixelFormat pixel_format, |
| 131 media::VideoFrame::StorageType storage_type, | 131 media::VideoFrame::StorageType storage_type, |
| 132 const gfx::Size& coded_size, | 132 const gfx::Size& coded_size, |
| 133 const gfx::Rect& visible_rect) override; | 133 const gfx::Rect& visible_rect) override; |
| 134 void OnStateChanged(VideoCaptureState state) override; | 134 void OnStateChanged(VideoCaptureState state) override; |
| 135 void OnDeviceSupportedFormatsEnumerated( | |
| 136 const media::VideoCaptureFormats& supported_formats) override; | |
| 137 void OnDeviceFormatsInUseReceived( | |
| 138 const media::VideoCaptureFormats& formats_in_use) override; | |
| 139 void OnDelegateAdded(int32_t device_id) override; | 135 void OnDelegateAdded(int32_t device_id) override; |
| 140 | 136 |
| 141 // Sends an IPC message to browser process when all clients are done with the | 137 // Sends an IPC message to browser process when all clients are done with the |
| 142 // buffer. | 138 // buffer. |
| 143 void OnClientBufferFinished(int buffer_id, | 139 void OnClientBufferFinished(int buffer_id, |
| 144 const scoped_refptr<ClientBuffer>& buffer, | 140 const scoped_refptr<ClientBuffer>& buffer, |
| 145 const gpu::SyncToken& release_sync_token, | 141 const gpu::SyncToken& release_sync_token, |
| 146 double consumer_resource_utilization); | 142 double consumer_resource_utilization); |
| 147 void OnClientBufferFinished2(int buffer_id, | 143 void OnClientBufferFinished2(int buffer_id, |
| 148 const scoped_refptr<ClientBuffer2>& buffer, | 144 const scoped_refptr<ClientBuffer2>& buffer, |
| 149 const gpu::SyncToken& release_sync_token, | 145 const gpu::SyncToken& release_sync_token, |
| 150 double consumer_resource_utilization); | 146 double consumer_resource_utilization); |
| 151 | 147 |
| 152 void StopDevice(); | 148 void StopDevice(); |
| 153 void RestartCapture(); | 149 void RestartCapture(); |
| 154 void StartCaptureInternal(); | 150 void StartCaptureInternal(); |
| 155 | 151 |
| 152 void OnDeviceSupportedFormats( |
| 153 const VideoCaptureDeviceFormatsCB& callback, |
| 154 const media::VideoCaptureFormats& supported_formats); |
| 155 void OnDeviceFormatsInUse( |
| 156 const VideoCaptureDeviceFormatsCB& callback, |
| 157 const media::VideoCaptureFormats& formats_in_use); |
| 158 |
| 156 // Tries to remove |client_id| from |clients|, returning false if not found. | 159 // Tries to remove |client_id| from |clients|, returning false if not found. |
| 157 bool RemoveClient(int client_id, ClientInfoMap* clients); | 160 bool RemoveClient(int client_id, ClientInfoMap* clients); |
| 158 | 161 |
| 159 mojom::VideoCaptureHost* GetVideoCaptureHost(); | 162 mojom::VideoCaptureHost* GetVideoCaptureHost(); |
| 160 | 163 |
| 161 // Called (by an unknown thread) when all consumers are done with a VideoFrame | 164 // Called (by an unknown thread) when all consumers are done with a VideoFrame |
| 162 // and its ref-count has gone to zero. This helper function grabs the | 165 // and its ref-count has gone to zero. This helper function grabs the |
| 163 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given | 166 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given |
| 164 // callback, to trampoline back to the IO thread with the values. | 167 // callback, to trampoline back to the IO thread with the values. |
| 165 static void DidFinishConsumingFrame( | 168 static void DidFinishConsumingFrame( |
| 166 const media::VideoFrameMetadata* metadata, | 169 const media::VideoFrameMetadata* metadata, |
| 167 std::unique_ptr<gpu::SyncToken> release_sync_token, | 170 std::unique_ptr<gpu::SyncToken> release_sync_token, |
| 168 const BufferFinishedCallback& callback_to_io_thread); | 171 const BufferFinishedCallback& callback_to_io_thread); |
| 169 | 172 |
| 170 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; | 173 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; |
| 171 int device_id_; | 174 int device_id_; |
| 172 const int session_id_; | 175 const int session_id_; |
| 173 | 176 |
| 174 mojom::VideoCaptureHostAssociatedPtr video_capture_host_; | 177 mojom::VideoCaptureHostAssociatedPtr video_capture_host_; |
| 175 mojom::VideoCaptureHost* video_capture_host_for_testing_; | 178 mojom::VideoCaptureHost* video_capture_host_for_testing_; |
| 176 | 179 |
| 177 // Vector of callbacks to be notified of device format enumerations, used only | |
| 178 // on IO Thread. | |
| 179 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_; | |
| 180 // Vector of callbacks to be notified of a device's in use capture format(s), | |
| 181 // used only on IO Thread. | |
| 182 std::vector<VideoCaptureDeviceFormatsCB> device_formats_in_use_cb_queue_; | |
| 183 | |
| 184 // Buffers available for sending to the client. | 180 // Buffers available for sending to the client. |
| 185 typedef std::map<int32_t, scoped_refptr<ClientBuffer>> ClientBufferMap; | 181 typedef std::map<int32_t, scoped_refptr<ClientBuffer>> ClientBufferMap; |
| 186 ClientBufferMap client_buffers_; | 182 ClientBufferMap client_buffers_; |
| 187 typedef std::map<int32_t, scoped_refptr<ClientBuffer2>> ClientBuffer2Map; | 183 typedef std::map<int32_t, scoped_refptr<ClientBuffer2>> ClientBuffer2Map; |
| 188 ClientBuffer2Map client_buffer2s_; | 184 ClientBuffer2Map client_buffer2s_; |
| 189 | 185 |
| 190 ClientInfoMap clients_; | 186 ClientInfoMap clients_; |
| 191 ClientInfoMap clients_pending_on_filter_; | 187 ClientInfoMap clients_pending_on_filter_; |
| 192 ClientInfoMap clients_pending_on_restart_; | 188 ClientInfoMap clients_pending_on_restart_; |
| 193 | 189 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 209 // in |client_buffers_|. | 205 // in |client_buffers_|. |
| 210 // NOTE: Weak pointers must be invalidated before all other member variables. | 206 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 211 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; | 207 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; |
| 212 | 208 |
| 213 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 209 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
| 214 }; | 210 }; |
| 215 | 211 |
| 216 } // namespace content | 212 } // namespace content |
| 217 | 213 |
| 218 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 214 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |