| 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 // VideoCaptureImpl represents a capture device in renderer process. It provides | 5 // VideoCaptureImpl represents a capture device in renderer process. It provides |
| 6 // interfaces for clients to Start/Stop capture. It also communicates to clients | 6 // interfaces for clients to Start/Stop capture. It also communicates to clients |
| 7 // when buffer is ready, state of capture device is changed. | 7 // when buffer is ready, state of capture device is changed. |
| 8 | 8 |
| 9 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which relays | 9 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which relays |
| 10 // operation of a capture device to the browser process and receives responses | 10 // operation of a capture device to the browser process and receives responses |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 VideoCaptureDeliverFrameCB deliver_frame_cb; | 106 VideoCaptureDeliverFrameCB deliver_frame_cb; |
| 107 }; | 107 }; |
| 108 typedef std::map<int, ClientInfo> ClientInfoMap; | 108 typedef std::map<int, ClientInfo> ClientInfoMap; |
| 109 | 109 |
| 110 // VideoCaptureMessageFilter::Delegate interface. | 110 // VideoCaptureMessageFilter::Delegate interface. |
| 111 void OnBufferCreated(base::SharedMemoryHandle handle, | 111 void OnBufferCreated(base::SharedMemoryHandle handle, |
| 112 int length, | 112 int length, |
| 113 int buffer_id) override; | 113 int buffer_id) override; |
| 114 void OnBufferDestroyed(int buffer_id) override; | 114 void OnBufferDestroyed(int buffer_id) override; |
| 115 void OnBufferReceived(int buffer_id, | 115 void OnBufferReceived(int buffer_id, |
| 116 const media::VideoCaptureFormat& format, | 116 const gfx::Size& coded_size, |
| 117 const gfx::Rect& visible_rect, | 117 const gfx::Rect& visible_rect, |
| 118 base::TimeTicks) override; | 118 base::TimeTicks timestamp, |
| 119 const base::DictionaryValue& metadata) override; |
| 119 void OnMailboxBufferReceived(int buffer_id, | 120 void OnMailboxBufferReceived(int buffer_id, |
| 120 const gpu::MailboxHolder& mailbox_holder, | 121 const gpu::MailboxHolder& mailbox_holder, |
| 121 const media::VideoCaptureFormat& format, | 122 const gfx::Size& packed_frame_size, |
| 122 base::TimeTicks timestamp) override; | 123 base::TimeTicks timestamp, |
| 124 const base::DictionaryValue& metadata) override; |
| 123 void OnStateChanged(VideoCaptureState state) override; | 125 void OnStateChanged(VideoCaptureState state) override; |
| 124 void OnDeviceSupportedFormatsEnumerated( | 126 void OnDeviceSupportedFormatsEnumerated( |
| 125 const media::VideoCaptureFormats& supported_formats) override; | 127 const media::VideoCaptureFormats& supported_formats) override; |
| 126 void OnDeviceFormatsInUseReceived( | 128 void OnDeviceFormatsInUseReceived( |
| 127 const media::VideoCaptureFormats& formats_in_use) override; | 129 const media::VideoCaptureFormats& formats_in_use) override; |
| 128 void OnDelegateAdded(int32 device_id) override; | 130 void OnDelegateAdded(int32 device_id) override; |
| 129 | 131 |
| 130 // Sends an IPC message to browser process when all clients are done with the | 132 // Sends an IPC message to browser process when all clients are done with the |
| 131 // buffer. | 133 // buffer. |
| 132 void OnClientBufferFinished(int buffer_id, | 134 void OnClientBufferFinished(int buffer_id, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 158 ClientBufferMap client_buffers_; | 160 ClientBufferMap client_buffers_; |
| 159 | 161 |
| 160 ClientInfoMap clients_; | 162 ClientInfoMap clients_; |
| 161 ClientInfoMap clients_pending_on_filter_; | 163 ClientInfoMap clients_pending_on_filter_; |
| 162 ClientInfoMap clients_pending_on_restart_; | 164 ClientInfoMap clients_pending_on_restart_; |
| 163 | 165 |
| 164 // Member params_ represents the video format requested by the | 166 // Member params_ represents the video format requested by the |
| 165 // client to this class via StartCapture(). | 167 // client to this class via StartCapture(). |
| 166 media::VideoCaptureParams params_; | 168 media::VideoCaptureParams params_; |
| 167 | 169 |
| 168 // The device's video capture format sent from browser process side. | |
| 169 media::VideoCaptureFormat last_frame_format_; | |
| 170 | |
| 171 // The device's first captured frame timestamp sent from browser process side. | 170 // The device's first captured frame timestamp sent from browser process side. |
| 172 base::TimeTicks first_frame_timestamp_; | 171 base::TimeTicks first_frame_timestamp_; |
| 173 | 172 |
| 174 bool suspended_; | 173 bool suspended_; |
| 175 VideoCaptureState state_; | 174 VideoCaptureState state_; |
| 176 | 175 |
| 177 // |weak_factory_| and |thread_checker_| are bound to the IO thread. | 176 // |weak_factory_| and |thread_checker_| are bound to the IO thread. |
| 178 base::ThreadChecker thread_checker_; | 177 base::ThreadChecker thread_checker_; |
| 179 | 178 |
| 180 // WeakPtrFactory pointing back to |this| object, for use with | 179 // WeakPtrFactory pointing back to |this| object, for use with |
| 181 // media::VideoFrames constructed in OnBufferReceived() from buffers cached | 180 // media::VideoFrames constructed in OnBufferReceived() from buffers cached |
| 182 // in |client_buffers_|. | 181 // in |client_buffers_|. |
| 183 // NOTE: Weak pointers must be invalidated before all other member variables. | 182 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 184 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; | 183 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; |
| 185 | 184 |
| 186 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 185 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
| 187 }; | 186 }; |
| 188 | 187 |
| 189 } // namespace content | 188 } // namespace content |
| 190 | 189 |
| 191 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 190 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |