| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // Note: Overridden only by unit test subclasses. | 91 // Note: Overridden only by unit test subclasses. |
| 92 virtual void Send(IPC::Message* message); | 92 virtual void Send(IPC::Message* message); |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 friend class VideoCaptureImplTest; | 95 friend class VideoCaptureImplTest; |
| 96 friend class MockVideoCaptureImpl; | 96 friend class MockVideoCaptureImpl; |
| 97 | 97 |
| 98 // Carries a shared memory for transferring video frames from browser to | 98 // Carries a shared memory for transferring video frames from browser to |
| 99 // renderer. | 99 // renderer. |
| 100 class ClientBuffer; | 100 class ClientBuffer; |
| 101 class ClientBuffer2; | |
| 102 | 101 |
| 103 // Contains information for a video capture client. Including parameters | 102 // Contains information for a video capture client. Including parameters |
| 104 // for capturing and callbacks to the client. | 103 // for capturing and callbacks to the client. |
| 105 struct ClientInfo { | 104 struct ClientInfo { |
| 106 ClientInfo(); | 105 ClientInfo(); |
| 107 ClientInfo(const ClientInfo& other); | 106 ClientInfo(const ClientInfo& other); |
| 108 ~ClientInfo(); | 107 ~ClientInfo(); |
| 109 media::VideoCaptureParams params; | 108 media::VideoCaptureParams params; |
| 110 VideoCaptureStateUpdateCB state_update_cb; | 109 VideoCaptureStateUpdateCB state_update_cb; |
| 111 VideoCaptureDeliverFrameCB deliver_frame_cb; | 110 VideoCaptureDeliverFrameCB deliver_frame_cb; |
| 112 }; | 111 }; |
| 113 typedef std::map<int, ClientInfo> ClientInfoMap; | 112 typedef std::map<int, ClientInfo> ClientInfoMap; |
| 114 | 113 |
| 115 typedef base::Callback<void(const gpu::SyncToken& sync_token, | 114 typedef base::Callback<void(const gpu::SyncToken& sync_token, |
| 116 double consumer_resource_utilization)> | 115 double consumer_resource_utilization)> |
| 117 BufferFinishedCallback; | 116 BufferFinishedCallback; |
| 118 | 117 |
| 119 // VideoCaptureMessageFilter::Delegate interface. | 118 // VideoCaptureMessageFilter::Delegate interface. |
| 120 void OnBufferCreated(base::SharedMemoryHandle handle, | 119 void OnBufferCreated(base::SharedMemoryHandle handle, |
| 121 int length, | 120 int length, |
| 122 int buffer_id) override; | 121 int buffer_id) override; |
| 123 void OnBufferCreated2(const std::vector<gfx::GpuMemoryBufferHandle>& handles, | |
| 124 const gfx::Size& size, | |
| 125 int buffer_id) override; | |
| 126 void OnBufferDestroyed(int buffer_id) override; | 122 void OnBufferDestroyed(int buffer_id) override; |
| 127 void OnBufferReceived(int buffer_id, | 123 void OnBufferReceived(int buffer_id, |
| 128 base::TimeDelta timestamp, | 124 base::TimeDelta timestamp, |
| 129 const base::DictionaryValue& metadata, | 125 const base::DictionaryValue& metadata, |
| 130 media::VideoPixelFormat pixel_format, | 126 media::VideoPixelFormat pixel_format, |
| 131 media::VideoFrame::StorageType storage_type, | 127 media::VideoFrame::StorageType storage_type, |
| 132 const gfx::Size& coded_size, | 128 const gfx::Size& coded_size, |
| 133 const gfx::Rect& visible_rect) override; | 129 const gfx::Rect& visible_rect) override; |
| 134 void OnStateChanged(VideoCaptureState state) override; | 130 void OnStateChanged(VideoCaptureState state) override; |
| 135 void OnDelegateAdded(int32_t device_id) override; | 131 void OnDelegateAdded(int32_t device_id) override; |
| 136 | 132 |
| 137 // Sends an IPC message to browser process when all clients are done with the | 133 // Sends an IPC message to browser process when all clients are done with the |
| 138 // buffer. | 134 // buffer. |
| 139 void OnClientBufferFinished(int buffer_id, | 135 void OnClientBufferFinished(int buffer_id, |
| 140 const scoped_refptr<ClientBuffer>& buffer, | 136 const scoped_refptr<ClientBuffer>& buffer, |
| 141 const gpu::SyncToken& release_sync_token, | 137 const gpu::SyncToken& release_sync_token, |
| 142 double consumer_resource_utilization); | 138 double consumer_resource_utilization); |
| 143 void OnClientBufferFinished2(int buffer_id, | |
| 144 const scoped_refptr<ClientBuffer2>& buffer, | |
| 145 const gpu::SyncToken& release_sync_token, | |
| 146 double consumer_resource_utilization); | |
| 147 | 139 |
| 148 void StopDevice(); | 140 void StopDevice(); |
| 149 void RestartCapture(); | 141 void RestartCapture(); |
| 150 void StartCaptureInternal(); | 142 void StartCaptureInternal(); |
| 151 | 143 |
| 152 void OnDeviceSupportedFormats( | 144 void OnDeviceSupportedFormats( |
| 153 const VideoCaptureDeviceFormatsCB& callback, | 145 const VideoCaptureDeviceFormatsCB& callback, |
| 154 const media::VideoCaptureFormats& supported_formats); | 146 const media::VideoCaptureFormats& supported_formats); |
| 155 void OnDeviceFormatsInUse( | 147 void OnDeviceFormatsInUse( |
| 156 const VideoCaptureDeviceFormatsCB& callback, | 148 const VideoCaptureDeviceFormatsCB& callback, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 173 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; | 165 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; |
| 174 int device_id_; | 166 int device_id_; |
| 175 const int session_id_; | 167 const int session_id_; |
| 176 | 168 |
| 177 mojom::VideoCaptureHostAssociatedPtr video_capture_host_; | 169 mojom::VideoCaptureHostAssociatedPtr video_capture_host_; |
| 178 mojom::VideoCaptureHost* video_capture_host_for_testing_; | 170 mojom::VideoCaptureHost* video_capture_host_for_testing_; |
| 179 | 171 |
| 180 // Buffers available for sending to the client. | 172 // Buffers available for sending to the client. |
| 181 typedef std::map<int32_t, scoped_refptr<ClientBuffer>> ClientBufferMap; | 173 typedef std::map<int32_t, scoped_refptr<ClientBuffer>> ClientBufferMap; |
| 182 ClientBufferMap client_buffers_; | 174 ClientBufferMap client_buffers_; |
| 183 typedef std::map<int32_t, scoped_refptr<ClientBuffer2>> ClientBuffer2Map; | |
| 184 ClientBuffer2Map client_buffer2s_; | |
| 185 | 175 |
| 186 ClientInfoMap clients_; | 176 ClientInfoMap clients_; |
| 187 ClientInfoMap clients_pending_on_filter_; | 177 ClientInfoMap clients_pending_on_filter_; |
| 188 ClientInfoMap clients_pending_on_restart_; | 178 ClientInfoMap clients_pending_on_restart_; |
| 189 | 179 |
| 190 // Member params_ represents the video format requested by the | 180 // Member params_ represents the video format requested by the |
| 191 // client to this class via StartCapture(). | 181 // client to this class via StartCapture(). |
| 192 media::VideoCaptureParams params_; | 182 media::VideoCaptureParams params_; |
| 193 | 183 |
| 194 // The device's first captured frame reference time sent from browser process | 184 // The device's first captured frame reference time sent from browser process |
| (...skipping 10 matching lines...) Expand all Loading... |
| 205 // in |client_buffers_|. | 195 // in |client_buffers_|. |
| 206 // NOTE: Weak pointers must be invalidated before all other member variables. | 196 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 207 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; | 197 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; |
| 208 | 198 |
| 209 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 199 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
| 210 }; | 200 }; |
| 211 | 201 |
| 212 } // namespace content | 202 } // namespace content |
| 213 | 203 |
| 214 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 204 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |