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 <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 media::VideoCaptureSessionId session_id() const { return session_id_; } | 78 media::VideoCaptureSessionId session_id() const { return session_id_; } |
79 | 79 |
80 private: | 80 private: |
81 friend class VideoCaptureImplTest; | 81 friend class VideoCaptureImplTest; |
82 friend class MockVideoCaptureImpl; | 82 friend class MockVideoCaptureImpl; |
83 | 83 |
84 // Carries a shared memory for transferring video frames from browser to | 84 // Carries a shared memory for transferring video frames from browser to |
85 // renderer. | 85 // renderer. |
86 class ClientBuffer; | 86 class ClientBuffer; |
| 87 class ClientBuffer2; |
87 | 88 |
88 // VideoCaptureMessageFilter::Delegate interface. | 89 // VideoCaptureMessageFilter::Delegate interface. |
89 void OnBufferCreated(base::SharedMemoryHandle handle, | 90 void OnBufferCreated(base::SharedMemoryHandle handle, |
90 int length, | 91 int length, |
91 int buffer_id) override; | 92 int buffer_id) override; |
| 93 void OnBufferCreated2(const std::vector<gfx::GpuMemoryBufferHandle>& handles, |
| 94 const gfx::Size& size, |
| 95 int buffer_id) override; |
92 void OnBufferDestroyed(int buffer_id) override; | 96 void OnBufferDestroyed(int buffer_id) override; |
93 void OnBufferReceived(int buffer_id, | 97 void OnBufferReceived( |
94 base::TimeTicks timestamp, | 98 int buffer_id, |
95 const base::DictionaryValue& metadata, | 99 base::TimeTicks timestamp, |
96 media::VideoPixelFormat pixel_format, | 100 const base::DictionaryValue& metadata, |
97 media::VideoFrame::StorageType storage_type, | 101 media::VideoPixelFormat pixel_format, |
98 const gfx::Size& coded_size, | 102 media::VideoFrame::StorageType storage_type, |
99 const gfx::Rect& visible_rect, | 103 const gfx::Size& coded_size, |
100 const gpu::MailboxHolder& mailbox_holder) override; | 104 const gfx::Rect& visible_rect, |
| 105 const gpu::MailboxHolder& mailbox_holder) override; |
101 void OnStateChanged(VideoCaptureState state) override; | 106 void OnStateChanged(VideoCaptureState state) override; |
102 void OnDeviceSupportedFormatsEnumerated( | 107 void OnDeviceSupportedFormatsEnumerated( |
103 const media::VideoCaptureFormats& supported_formats) override; | 108 const media::VideoCaptureFormats& supported_formats) override; |
104 void OnDeviceFormatsInUseReceived( | 109 void OnDeviceFormatsInUseReceived( |
105 const media::VideoCaptureFormats& formats_in_use) override; | 110 const media::VideoCaptureFormats& formats_in_use) override; |
106 void OnDelegateAdded(int32 device_id) override; | 111 void OnDelegateAdded(int32 device_id) override; |
107 | 112 |
108 // Sends an IPC message to browser process when all clients are done with the | 113 // Sends an IPC message to browser process when all clients are done with the |
109 // buffer. | 114 // buffer. |
110 void OnClientBufferFinished(int buffer_id, | 115 void OnClientBufferFinished( |
111 const scoped_refptr<ClientBuffer>& buffer, | 116 int buffer_id, |
112 uint32 release_sync_point, | 117 const scoped_refptr<ClientBuffer>& buffer, |
113 double consumer_resource_utilization); | 118 uint32 release_sync_point, |
| 119 double consumer_resource_utilization); |
| 120 void OnClientBufferFinished2( |
| 121 int buffer_id, |
| 122 const scoped_refptr<ClientBuffer2>& buffer, |
| 123 uint32 release_sync_point, |
| 124 double consumer_resource_utilization); |
114 | 125 |
115 void StopDevice(); | 126 void StopDevice(); |
116 void RestartCapture(); | 127 void RestartCapture(); |
117 void StartCaptureInternal(); | 128 void StartCaptureInternal(); |
118 | 129 |
119 virtual void Send(IPC::Message* message); | 130 virtual void Send(IPC::Message* message); |
120 | 131 |
121 // Helpers. | 132 // Helpers. |
122 // Called (by an unknown thread) when all consumers are done with a VideoFrame | 133 // Called (by an unknown thread) when all consumers are done with a VideoFrame |
123 // and its ref-count has gone to zero. This helper function grabs the | 134 // and its ref-count has gone to zero. This helper function grabs the |
(...skipping 16 matching lines...) Expand all Loading... |
140 const int session_id_; | 151 const int session_id_; |
141 | 152 |
142 // Vector of callbacks to be notified of device format enumerations, used only | 153 // Vector of callbacks to be notified of device format enumerations, used only |
143 // on IO Thread. | 154 // on IO Thread. |
144 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_; | 155 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_; |
145 // Vector of callbacks to be notified of a device's in use capture format(s), | 156 // Vector of callbacks to be notified of a device's in use capture format(s), |
146 // used only on IO Thread. | 157 // used only on IO Thread. |
147 std::vector<VideoCaptureDeviceFormatsCB> device_formats_in_use_cb_queue_; | 158 std::vector<VideoCaptureDeviceFormatsCB> device_formats_in_use_cb_queue_; |
148 | 159 |
149 // Buffers available for sending to the client. | 160 // Buffers available for sending to the client. |
150 typedef std::map<int32, scoped_refptr<ClientBuffer> > ClientBufferMap; | 161 typedef std::map<int32, scoped_refptr<ClientBuffer>> ClientBufferMap; |
151 ClientBufferMap client_buffers_; | 162 ClientBufferMap client_buffers_; |
| 163 typedef std::map<int32, scoped_refptr<ClientBuffer2>> ClientBuffer2Map; |
| 164 ClientBuffer2Map client_buffer2s_; |
152 | 165 |
153 // Track information for the video capture client, consisting of parameters | 166 // Track information for the video capture client, consisting of parameters |
154 // for capturing and callbacks to the client. | 167 // for capturing and callbacks to the client. |
155 media::VideoCaptureParams client_params_; | 168 media::VideoCaptureParams client_params_; |
156 VideoCaptureStateUpdateCB state_update_cb_; | 169 VideoCaptureStateUpdateCB state_update_cb_; |
157 VideoCaptureDeliverFrameCB deliver_frame_cb_; | 170 VideoCaptureDeliverFrameCB deliver_frame_cb_; |
158 | 171 |
159 // The device's first captured frame timestamp sent from browser process side. | 172 // The device's first captured frame timestamp sent from browser process side. |
160 base::TimeTicks first_frame_timestamp_; | 173 base::TimeTicks first_frame_timestamp_; |
161 | 174 |
162 // State of this VideoCaptureImpl. | 175 // State of this VideoCaptureImpl. |
163 VideoCaptureState state_; | 176 VideoCaptureState state_; |
164 | 177 |
165 // IO message loop reference for checking correct class operation. | 178 // IO message loop reference for checking correct class operation. |
166 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 179 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
167 | 180 |
168 // WeakPtrFactory pointing back to |this| object, for use with | 181 // WeakPtrFactory pointing back to |this| object, for use with |
169 // media::VideoFrames constructed in OnBufferReceived() from buffers cached | 182 // media::VideoFrames constructed in OnBufferReceived() from buffers cached |
170 // in |client_buffers_|. | 183 // in |client_buffers_|. |
171 // NOTE: Weak pointers must be invalidated before all other member variables. | 184 // NOTE: Weak pointers must be invalidated before all other member variables. |
172 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; | 185 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; |
173 | 186 |
174 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 187 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
175 }; | 188 }; |
176 | 189 |
177 } // namespace content | 190 } // namespace content |
178 | 191 |
179 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 192 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
OLD | NEW |