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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 // for capturing and callbacks to the client. | 97 // for capturing and callbacks to the client. |
98 struct ClientInfo { | 98 struct ClientInfo { |
99 ClientInfo(); | 99 ClientInfo(); |
100 ~ClientInfo(); | 100 ~ClientInfo(); |
101 media::VideoCaptureParams params; | 101 media::VideoCaptureParams params; |
102 VideoCaptureStateUpdateCB state_update_cb; | 102 VideoCaptureStateUpdateCB state_update_cb; |
103 VideoCaptureDeliverFrameCB deliver_frame_cb; | 103 VideoCaptureDeliverFrameCB deliver_frame_cb; |
104 }; | 104 }; |
105 typedef std::map<int, ClientInfo> ClientInfoMap; | 105 typedef std::map<int, ClientInfo> ClientInfoMap; |
106 | 106 |
107 typedef base::Callback<void(uint32 sync_point, | |
108 const gpu::SyncToken& sync_token, | |
109 double consumer_resource_utilization)> | |
110 BufferFinishedCB; | |
dcheng
2015/10/27 19:09:28
Generally, abbreviations are discouraged: http://g
David Yen
2015/10/28 22:03:43
Done.
| |
111 | |
107 // VideoCaptureMessageFilter::Delegate interface. | 112 // VideoCaptureMessageFilter::Delegate interface. |
108 void OnBufferCreated(base::SharedMemoryHandle handle, | 113 void OnBufferCreated(base::SharedMemoryHandle handle, |
109 int length, | 114 int length, |
110 int buffer_id) override; | 115 int buffer_id) override; |
111 void OnBufferCreated2(const std::vector<gfx::GpuMemoryBufferHandle>& handles, | 116 void OnBufferCreated2(const std::vector<gfx::GpuMemoryBufferHandle>& handles, |
112 const gfx::Size& size, | 117 const gfx::Size& size, |
113 int buffer_id) override; | 118 int buffer_id) override; |
114 void OnBufferDestroyed(int buffer_id) override; | 119 void OnBufferDestroyed(int buffer_id) override; |
115 void OnBufferReceived( | 120 void OnBufferReceived( |
116 int buffer_id, | 121 int buffer_id, |
117 base::TimeTicks timestamp, | 122 base::TimeTicks timestamp, |
118 const base::DictionaryValue& metadata, | 123 const base::DictionaryValue& metadata, |
119 media::VideoPixelFormat pixel_format, | 124 media::VideoPixelFormat pixel_format, |
120 media::VideoFrame::StorageType storage_type, | 125 media::VideoFrame::StorageType storage_type, |
121 const gfx::Size& coded_size, | 126 const gfx::Size& coded_size, |
122 const gfx::Rect& visible_rect, | 127 const gfx::Rect& visible_rect, |
123 const std::vector<gpu::MailboxHolder>& mailbox_holders) override; | 128 const std::vector<gpu::MailboxHolder>& mailbox_holders) override; |
124 void OnStateChanged(VideoCaptureState state) override; | 129 void OnStateChanged(VideoCaptureState state) override; |
125 void OnDeviceSupportedFormatsEnumerated( | 130 void OnDeviceSupportedFormatsEnumerated( |
126 const media::VideoCaptureFormats& supported_formats) override; | 131 const media::VideoCaptureFormats& supported_formats) override; |
127 void OnDeviceFormatsInUseReceived( | 132 void OnDeviceFormatsInUseReceived( |
128 const media::VideoCaptureFormats& formats_in_use) override; | 133 const media::VideoCaptureFormats& formats_in_use) override; |
129 void OnDelegateAdded(int32 device_id) override; | 134 void OnDelegateAdded(int32 device_id) override; |
130 | 135 |
131 // Sends an IPC message to browser process when all clients are done with the | 136 // Sends an IPC message to browser process when all clients are done with the |
132 // buffer. | 137 // buffer. |
133 void OnClientBufferFinished( | 138 void OnClientBufferFinished(int buffer_id, |
134 int buffer_id, | 139 const scoped_refptr<ClientBuffer>& buffer, |
135 const scoped_refptr<ClientBuffer>& buffer, | 140 uint32 release_sync_point, |
136 uint32 release_sync_point, | 141 const gpu::SyncToken& release_sync_token, |
137 double consumer_resource_utilization); | 142 double consumer_resource_utilization); |
138 void OnClientBufferFinished2( | 143 void OnClientBufferFinished2(int buffer_id, |
139 int buffer_id, | 144 const scoped_refptr<ClientBuffer2>& buffer, |
140 const scoped_refptr<ClientBuffer2>& buffer, | 145 uint32 release_sync_point, |
141 uint32 release_sync_point, | 146 const gpu::SyncToken& release_sync_token, |
142 double consumer_resource_utilization); | 147 double consumer_resource_utilization); |
143 | 148 |
144 void StopDevice(); | 149 void StopDevice(); |
145 void RestartCapture(); | 150 void RestartCapture(); |
146 void StartCaptureInternal(); | 151 void StartCaptureInternal(); |
147 | 152 |
148 virtual void Send(IPC::Message* message); | 153 virtual void Send(IPC::Message* message); |
149 | 154 |
150 // Helpers. | 155 // Helpers. |
151 bool RemoveClient(int client_id, ClientInfoMap* clients); | 156 bool RemoveClient(int client_id, ClientInfoMap* clients); |
152 | 157 |
153 // Called (by an unknown thread) when all consumers are done with a VideoFrame | 158 // Called (by an unknown thread) when all consumers are done with a VideoFrame |
154 // and its ref-count has gone to zero. This helper function grabs the | 159 // and its ref-count has gone to zero. This helper function grabs the |
155 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given | 160 // RESOURCE_UTILIZATION value from the |metadata| and then runs the given |
156 // callback, to trampoline back to the IO thread with the values. | 161 // callback, to trampoline back to the IO thread with the values. |
157 static void DidFinishConsumingFrame( | 162 static void DidFinishConsumingFrame( |
158 const media::VideoFrameMetadata* metadata, | 163 const media::VideoFrameMetadata* metadata, |
159 uint32* release_sync_point_storage, // Takes ownership. | 164 uint32* release_sync_point_storage, // Takes ownership. |
160 const base::Callback<void(uint32, double)>& callback_to_io_thread); | 165 gpu::SyncToken* release_sync_token_storage, // Takes ownership |
166 const BufferFinishedCB& callback_to_io_thread); | |
161 | 167 |
162 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; | 168 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; |
163 int device_id_; | 169 int device_id_; |
164 const int session_id_; | 170 const int session_id_; |
165 | 171 |
166 // Vector of callbacks to be notified of device format enumerations, used only | 172 // Vector of callbacks to be notified of device format enumerations, used only |
167 // on IO Thread. | 173 // on IO Thread. |
168 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_; | 174 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_; |
169 // Vector of callbacks to be notified of a device's in use capture format(s), | 175 // Vector of callbacks to be notified of a device's in use capture format(s), |
170 // used only on IO Thread. | 176 // used only on IO Thread. |
(...skipping 27 matching lines...) Expand all Loading... | |
198 // in |client_buffers_|. | 204 // in |client_buffers_|. |
199 // NOTE: Weak pointers must be invalidated before all other member variables. | 205 // NOTE: Weak pointers must be invalidated before all other member variables. |
200 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; | 206 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; |
201 | 207 |
202 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); | 208 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); |
203 }; | 209 }; |
204 | 210 |
205 } // namespace content | 211 } // namespace content |
206 | 212 |
207 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ | 213 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ |
OLD | NEW |