Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: content/renderer/media/video_capture_impl.cc

Issue 978993002: Changed thread_checker on VideoCaptureImpl and VideoCaptureImplManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK_IS_ON() fix. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Notes about usage of this object by VideoCaptureImplManager. 5 // Notes about usage of this object by VideoCaptureImplManager.
6 // 6 //
7 // VideoCaptureImplManager access this object by using a Unretained() 7 // VideoCaptureImplManager access this object by using a Unretained()
8 // binding and tasks on the IO thread. It is then important that 8 // binding and tasks on the IO thread. It is then important that
9 // VideoCaptureImpl never post task to itself. All operations must be 9 // VideoCaptureImpl never post task to itself. All operations must be
10 // synchronous. 10 // synchronous.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 VideoCaptureImpl::VideoCaptureImpl( 45 VideoCaptureImpl::VideoCaptureImpl(
46 const media::VideoCaptureSessionId session_id, 46 const media::VideoCaptureSessionId session_id,
47 VideoCaptureMessageFilter* filter) 47 VideoCaptureMessageFilter* filter)
48 : message_filter_(filter), 48 : message_filter_(filter),
49 device_id_(0), 49 device_id_(0),
50 session_id_(session_id), 50 session_id_(session_id),
51 suspended_(false), 51 suspended_(false),
52 state_(VIDEO_CAPTURE_STATE_STOPPED), 52 state_(VIDEO_CAPTURE_STATE_STOPPED),
53 weak_factory_(this) { 53 weak_factory_(this) {
54 DCHECK(filter); 54 DCHECK(filter);
55 render_io_thread_checker_.DetachFromThread();
56 } 55 }
57 56
58 VideoCaptureImpl::~VideoCaptureImpl() { 57 VideoCaptureImpl::~VideoCaptureImpl() {
59 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 58 DCHECK(io_message_loop_->BelongsToCurrentThread());
60 } 59 }
61 60
62 void VideoCaptureImpl::Init() { 61 void VideoCaptureImpl::Init() {
63 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 62 // For creating callbacks in unittest, this class may be constructed from a
63 // different thread than the IO thread, e.g. wherever unittest runs on.
64 // Therefore, this function should define the thread ownership.
65 #if DCHECK_IS_ON()
66 io_message_loop_ = base::MessageLoopProxy::current();
67 #endif
64 message_filter_->AddDelegate(this); 68 message_filter_->AddDelegate(this);
65 } 69 }
66 70
67 void VideoCaptureImpl::DeInit() { 71 void VideoCaptureImpl::DeInit() {
68 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 72 DCHECK(io_message_loop_->BelongsToCurrentThread());
69 if (state_ == VIDEO_CAPTURE_STATE_STARTED) 73 if (state_ == VIDEO_CAPTURE_STATE_STARTED)
70 Send(new VideoCaptureHostMsg_Stop(device_id_)); 74 Send(new VideoCaptureHostMsg_Stop(device_id_));
71 message_filter_->RemoveDelegate(this); 75 message_filter_->RemoveDelegate(this);
72 } 76 }
73 77
74 void VideoCaptureImpl::SuspendCapture(bool suspend) { 78 void VideoCaptureImpl::SuspendCapture(bool suspend) {
75 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 79 DCHECK(io_message_loop_->BelongsToCurrentThread());
76 Send(suspend ? 80 Send(suspend ?
77 static_cast<IPC::Message*>(new VideoCaptureHostMsg_Pause(device_id_)) : 81 static_cast<IPC::Message*>(new VideoCaptureHostMsg_Pause(device_id_)) :
78 static_cast<IPC::Message*>( 82 static_cast<IPC::Message*>(
79 new VideoCaptureHostMsg_Resume(device_id_, session_id_, params_))); 83 new VideoCaptureHostMsg_Resume(device_id_, session_id_, params_)));
80 } 84 }
81 85
82 void VideoCaptureImpl::StartCapture( 86 void VideoCaptureImpl::StartCapture(
83 int client_id, 87 int client_id,
84 const media::VideoCaptureParams& params, 88 const media::VideoCaptureParams& params,
85 const VideoCaptureStateUpdateCB& state_update_cb, 89 const VideoCaptureStateUpdateCB& state_update_cb,
86 const VideoCaptureDeliverFrameCB& deliver_frame_cb) { 90 const VideoCaptureDeliverFrameCB& deliver_frame_cb) {
87 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 91 DCHECK(io_message_loop_->BelongsToCurrentThread());
88 ClientInfo client_info; 92 ClientInfo client_info;
89 client_info.params = params; 93 client_info.params = params;
90 client_info.state_update_cb = state_update_cb; 94 client_info.state_update_cb = state_update_cb;
91 client_info.deliver_frame_cb = deliver_frame_cb; 95 client_info.deliver_frame_cb = deliver_frame_cb;
92 96
93 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { 97 if (state_ == VIDEO_CAPTURE_STATE_ERROR) {
94 state_update_cb.Run(VIDEO_CAPTURE_STATE_ERROR); 98 state_update_cb.Run(VIDEO_CAPTURE_STATE_ERROR);
95 } else if (clients_pending_on_filter_.count(client_id) || 99 } else if (clients_pending_on_filter_.count(client_id) ||
96 clients_pending_on_restart_.count(client_id) || 100 clients_pending_on_restart_.count(client_id) ||
97 clients_.count(client_id)) { 101 clients_.count(client_id)) {
(...skipping 27 matching lines...) Expand all
125 } 129 }
126 DVLOG(1) << "StartCapture: starting with first resolution " 130 DVLOG(1) << "StartCapture: starting with first resolution "
127 << params_.requested_format.frame_size.ToString(); 131 << params_.requested_format.frame_size.ToString();
128 first_frame_timestamp_ = base::TimeTicks(); 132 first_frame_timestamp_ = base::TimeTicks();
129 StartCaptureInternal(); 133 StartCaptureInternal();
130 } 134 }
131 } 135 }
132 } 136 }
133 137
134 void VideoCaptureImpl::StopCapture(int client_id) { 138 void VideoCaptureImpl::StopCapture(int client_id) {
135 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 139 DCHECK(io_message_loop_->BelongsToCurrentThread());
136 140
137 // A client ID can be in only one client list. 141 // A client ID can be in only one client list.
138 // If this ID is in any client list, we can just remove it from 142 // If this ID is in any client list, we can just remove it from
139 // that client list and don't have to run the other following RemoveClient(). 143 // that client list and don't have to run the other following RemoveClient().
140 if (!RemoveClient(client_id, &clients_pending_on_filter_)) { 144 if (!RemoveClient(client_id, &clients_pending_on_filter_)) {
141 if (!RemoveClient(client_id, &clients_pending_on_restart_)) { 145 if (!RemoveClient(client_id, &clients_pending_on_restart_)) {
142 RemoveClient(client_id, &clients_); 146 RemoveClient(client_id, &clients_);
143 } 147 }
144 } 148 }
145 149
146 if (clients_.empty()) { 150 if (clients_.empty()) {
147 DVLOG(1) << "StopCapture: No more client, stopping ..."; 151 DVLOG(1) << "StopCapture: No more client, stopping ...";
148 StopDevice(); 152 StopDevice();
149 client_buffers_.clear(); 153 client_buffers_.clear();
150 weak_factory_.InvalidateWeakPtrs(); 154 weak_factory_.InvalidateWeakPtrs();
151 } 155 }
152 } 156 }
153 157
154 void VideoCaptureImpl::GetDeviceSupportedFormats( 158 void VideoCaptureImpl::GetDeviceSupportedFormats(
155 const VideoCaptureDeviceFormatsCB& callback) { 159 const VideoCaptureDeviceFormatsCB& callback) {
156 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 160 DCHECK(io_message_loop_->BelongsToCurrentThread());
157 device_formats_cb_queue_.push_back(callback); 161 device_formats_cb_queue_.push_back(callback);
158 if (device_formats_cb_queue_.size() == 1) 162 if (device_formats_cb_queue_.size() == 1)
159 Send(new VideoCaptureHostMsg_GetDeviceSupportedFormats(device_id_, 163 Send(new VideoCaptureHostMsg_GetDeviceSupportedFormats(device_id_,
160 session_id_)); 164 session_id_));
161 } 165 }
162 166
163 void VideoCaptureImpl::GetDeviceFormatsInUse( 167 void VideoCaptureImpl::GetDeviceFormatsInUse(
164 const VideoCaptureDeviceFormatsCB& callback) { 168 const VideoCaptureDeviceFormatsCB& callback) {
165 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 169 DCHECK(io_message_loop_->BelongsToCurrentThread());
166 device_formats_in_use_cb_queue_.push_back(callback); 170 device_formats_in_use_cb_queue_.push_back(callback);
167 if (device_formats_in_use_cb_queue_.size() == 1) 171 if (device_formats_in_use_cb_queue_.size() == 1)
168 Send( 172 Send(
169 new VideoCaptureHostMsg_GetDeviceFormatsInUse(device_id_, session_id_)); 173 new VideoCaptureHostMsg_GetDeviceFormatsInUse(device_id_, session_id_));
170 } 174 }
171 175
172 void VideoCaptureImpl::OnBufferCreated( 176 void VideoCaptureImpl::OnBufferCreated(
173 base::SharedMemoryHandle handle, 177 base::SharedMemoryHandle handle,
174 int length, int buffer_id) { 178 int length, int buffer_id) {
175 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 179 DCHECK(io_message_loop_->BelongsToCurrentThread());
176 180
177 // In case client calls StopCapture before the arrival of created buffer, 181 // In case client calls StopCapture before the arrival of created buffer,
178 // just close this buffer and return. 182 // just close this buffer and return.
179 if (state_ != VIDEO_CAPTURE_STATE_STARTED) { 183 if (state_ != VIDEO_CAPTURE_STATE_STARTED) {
180 base::SharedMemory::CloseHandle(handle); 184 base::SharedMemory::CloseHandle(handle);
181 return; 185 return;
182 } 186 }
183 187
184 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory(handle, false)); 188 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory(handle, false));
185 if (!shm->Map(length)) { 189 if (!shm->Map(length)) {
186 DLOG(ERROR) << "OnBufferCreated: Map failed."; 190 DLOG(ERROR) << "OnBufferCreated: Map failed.";
187 return; 191 return;
188 } 192 }
189 193
190 bool inserted = 194 bool inserted =
191 client_buffers_.insert(std::make_pair( 195 client_buffers_.insert(std::make_pair(
192 buffer_id, 196 buffer_id,
193 new ClientBuffer(shm.Pass(), 197 new ClientBuffer(shm.Pass(),
194 length))).second; 198 length))).second;
195 DCHECK(inserted); 199 DCHECK(inserted);
196 } 200 }
197 201
198 void VideoCaptureImpl::OnBufferDestroyed(int buffer_id) { 202 void VideoCaptureImpl::OnBufferDestroyed(int buffer_id) {
199 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 203 DCHECK(io_message_loop_->BelongsToCurrentThread());
200 204
201 const ClientBufferMap::iterator iter = client_buffers_.find(buffer_id); 205 const ClientBufferMap::iterator iter = client_buffers_.find(buffer_id);
202 if (iter == client_buffers_.end()) 206 if (iter == client_buffers_.end())
203 return; 207 return;
204 208
205 DCHECK(!iter->second.get() || iter->second->HasOneRef()) 209 DCHECK(!iter->second.get() || iter->second->HasOneRef())
206 << "Instructed to delete buffer we are still using."; 210 << "Instructed to delete buffer we are still using.";
207 client_buffers_.erase(iter); 211 client_buffers_.erase(iter);
208 } 212 }
209 213
210 void VideoCaptureImpl::OnBufferReceived(int buffer_id, 214 void VideoCaptureImpl::OnBufferReceived(int buffer_id,
211 const gfx::Size& coded_size, 215 const gfx::Size& coded_size,
212 const gfx::Rect& visible_rect, 216 const gfx::Rect& visible_rect,
213 base::TimeTicks timestamp, 217 base::TimeTicks timestamp,
214 const base::DictionaryValue& metadata) { 218 const base::DictionaryValue& metadata) {
215 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 219 DCHECK(io_message_loop_->BelongsToCurrentThread());
216 220
217 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { 221 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) {
218 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); 222 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0));
219 return; 223 return;
220 } 224 }
221 225
222 if (first_frame_timestamp_.is_null()) 226 if (first_frame_timestamp_.is_null())
223 first_frame_timestamp_ = timestamp; 227 first_frame_timestamp_ = timestamp;
224 228
225 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc 229 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc
(...skipping 28 matching lines...) Expand all
254 for (const auto& client : clients_) 258 for (const auto& client : clients_)
255 client.second.deliver_frame_cb.Run(frame, timestamp); 259 client.second.deliver_frame_cb.Run(frame, timestamp);
256 } 260 }
257 261
258 void VideoCaptureImpl::OnMailboxBufferReceived( 262 void VideoCaptureImpl::OnMailboxBufferReceived(
259 int buffer_id, 263 int buffer_id,
260 const gpu::MailboxHolder& mailbox_holder, 264 const gpu::MailboxHolder& mailbox_holder,
261 const gfx::Size& packed_frame_size, 265 const gfx::Size& packed_frame_size,
262 base::TimeTicks timestamp, 266 base::TimeTicks timestamp,
263 const base::DictionaryValue& metadata) { 267 const base::DictionaryValue& metadata) {
264 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 268 DCHECK(io_message_loop_->BelongsToCurrentThread());
265 269
266 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { 270 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) {
267 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); 271 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0));
268 return; 272 return;
269 } 273 }
270 274
271 if (first_frame_timestamp_.is_null()) 275 if (first_frame_timestamp_.is_null())
272 first_frame_timestamp_ = timestamp; 276 first_frame_timestamp_ = timestamp;
273 277
274 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( 278 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture(
275 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), 279 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)),
276 media::BindToCurrentLoop(base::Bind( 280 media::BindToCurrentLoop(base::Bind(
277 &VideoCaptureImpl::OnClientBufferFinished, weak_factory_.GetWeakPtr(), 281 &VideoCaptureImpl::OnClientBufferFinished, weak_factory_.GetWeakPtr(),
278 buffer_id, scoped_refptr<ClientBuffer>())), 282 buffer_id, scoped_refptr<ClientBuffer>())),
279 packed_frame_size, gfx::Rect(packed_frame_size), packed_frame_size, 283 packed_frame_size, gfx::Rect(packed_frame_size), packed_frame_size,
280 timestamp - first_frame_timestamp_, false); 284 timestamp - first_frame_timestamp_, false);
281 frame->metadata()->MergeInternalValuesFrom(metadata); 285 frame->metadata()->MergeInternalValuesFrom(metadata);
282 286
283 for (const auto& client : clients_) 287 for (const auto& client : clients_)
284 client.second.deliver_frame_cb.Run(frame, timestamp); 288 client.second.deliver_frame_cb.Run(frame, timestamp);
285 } 289 }
286 290
287 void VideoCaptureImpl::OnClientBufferFinished( 291 void VideoCaptureImpl::OnClientBufferFinished(
288 int buffer_id, 292 int buffer_id,
289 const scoped_refptr<ClientBuffer>& /* ignored_buffer */, 293 const scoped_refptr<ClientBuffer>& /* ignored_buffer */,
290 uint32 release_sync_point) { 294 uint32 release_sync_point) {
291 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 295 DCHECK(io_message_loop_->BelongsToCurrentThread());
292 Send(new VideoCaptureHostMsg_BufferReady( 296 Send(new VideoCaptureHostMsg_BufferReady(
293 device_id_, buffer_id, release_sync_point)); 297 device_id_, buffer_id, release_sync_point));
294 } 298 }
295 299
296 void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) { 300 void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) {
297 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 301 DCHECK(io_message_loop_->BelongsToCurrentThread());
298 302
299 switch (state) { 303 switch (state) {
300 case VIDEO_CAPTURE_STATE_STARTED: 304 case VIDEO_CAPTURE_STATE_STARTED:
301 // Camera has started in the browser process. Since we have already 305 // Camera has started in the browser process. Since we have already
302 // told all clients that we have started there's nothing to do. 306 // told all clients that we have started there's nothing to do.
303 break; 307 break;
304 case VIDEO_CAPTURE_STATE_STOPPED: 308 case VIDEO_CAPTURE_STATE_STOPPED:
305 state_ = VIDEO_CAPTURE_STATE_STOPPED; 309 state_ = VIDEO_CAPTURE_STATE_STOPPED;
306 DVLOG(1) << "OnStateChanged: stopped!, device_id = " << device_id_; 310 DVLOG(1) << "OnStateChanged: stopped!, device_id = " << device_id_;
307 client_buffers_.clear(); 311 client_buffers_.clear();
(...skipping 21 matching lines...) Expand all
329 clients_.clear(); 333 clients_.clear();
330 state_ = VIDEO_CAPTURE_STATE_ENDED; 334 state_ = VIDEO_CAPTURE_STATE_ENDED;
331 break; 335 break;
332 default: 336 default:
333 break; 337 break;
334 } 338 }
335 } 339 }
336 340
337 void VideoCaptureImpl::OnDeviceSupportedFormatsEnumerated( 341 void VideoCaptureImpl::OnDeviceSupportedFormatsEnumerated(
338 const media::VideoCaptureFormats& supported_formats) { 342 const media::VideoCaptureFormats& supported_formats) {
339 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 343 DCHECK(io_message_loop_->BelongsToCurrentThread());
340 for (size_t i = 0; i < device_formats_cb_queue_.size(); ++i) 344 for (size_t i = 0; i < device_formats_cb_queue_.size(); ++i)
341 device_formats_cb_queue_[i].Run(supported_formats); 345 device_formats_cb_queue_[i].Run(supported_formats);
342 device_formats_cb_queue_.clear(); 346 device_formats_cb_queue_.clear();
343 } 347 }
344 348
345 void VideoCaptureImpl::OnDeviceFormatsInUseReceived( 349 void VideoCaptureImpl::OnDeviceFormatsInUseReceived(
346 const media::VideoCaptureFormats& formats_in_use) { 350 const media::VideoCaptureFormats& formats_in_use) {
347 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 351 DCHECK(io_message_loop_->BelongsToCurrentThread());
348 for (size_t i = 0; i < device_formats_in_use_cb_queue_.size(); ++i) 352 for (size_t i = 0; i < device_formats_in_use_cb_queue_.size(); ++i)
349 device_formats_in_use_cb_queue_[i].Run(formats_in_use); 353 device_formats_in_use_cb_queue_[i].Run(formats_in_use);
350 device_formats_in_use_cb_queue_.clear(); 354 device_formats_in_use_cb_queue_.clear();
351 } 355 }
352 356
353 void VideoCaptureImpl::OnDelegateAdded(int32 device_id) { 357 void VideoCaptureImpl::OnDelegateAdded(int32 device_id) {
354 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 358 DCHECK(io_message_loop_->BelongsToCurrentThread());
355 DVLOG(1) << "OnDelegateAdded: device_id " << device_id; 359 DVLOG(1) << "OnDelegateAdded: device_id " << device_id;
356 360
357 device_id_ = device_id; 361 device_id_ = device_id;
358 ClientInfoMap::iterator it = clients_pending_on_filter_.begin(); 362 ClientInfoMap::iterator it = clients_pending_on_filter_.begin();
359 while (it != clients_pending_on_filter_.end()) { 363 while (it != clients_pending_on_filter_.end()) {
360 const int client_id = it->first; 364 const int client_id = it->first;
361 const ClientInfo client_info = it->second; 365 const ClientInfo client_info = it->second;
362 clients_pending_on_filter_.erase(it++); 366 clients_pending_on_filter_.erase(it++);
363 StartCapture(client_id, client_info.params, client_info.state_update_cb, 367 StartCapture(client_id, client_info.params, client_info.state_update_cb,
364 client_info.deliver_frame_cb); 368 client_info.deliver_frame_cb);
365 } 369 }
366 } 370 }
367 371
368 void VideoCaptureImpl::StopDevice() { 372 void VideoCaptureImpl::StopDevice() {
369 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 373 DCHECK(io_message_loop_->BelongsToCurrentThread());
370 374
371 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { 375 if (state_ == VIDEO_CAPTURE_STATE_STARTED) {
372 state_ = VIDEO_CAPTURE_STATE_STOPPING; 376 state_ = VIDEO_CAPTURE_STATE_STOPPING;
373 Send(new VideoCaptureHostMsg_Stop(device_id_)); 377 Send(new VideoCaptureHostMsg_Stop(device_id_));
374 params_.requested_format.frame_size.SetSize(0, 0); 378 params_.requested_format.frame_size.SetSize(0, 0);
375 } 379 }
376 } 380 }
377 381
378 void VideoCaptureImpl::RestartCapture() { 382 void VideoCaptureImpl::RestartCapture() {
379 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 383 DCHECK(io_message_loop_->BelongsToCurrentThread());
380 DCHECK_EQ(state_, VIDEO_CAPTURE_STATE_STOPPED); 384 DCHECK_EQ(state_, VIDEO_CAPTURE_STATE_STOPPED);
381 385
382 int width = 0; 386 int width = 0;
383 int height = 0; 387 int height = 0;
384 clients_.insert(clients_pending_on_restart_.begin(), 388 clients_.insert(clients_pending_on_restart_.begin(),
385 clients_pending_on_restart_.end()); 389 clients_pending_on_restart_.end());
386 clients_pending_on_restart_.clear(); 390 clients_pending_on_restart_.clear();
387 for (const auto& client : clients_) { 391 for (const auto& client : clients_) {
388 width = std::max(width, 392 width = std::max(width,
389 client.second.params.requested_format.frame_size.width()); 393 client.second.params.requested_format.frame_size.width());
390 height = std::max( 394 height = std::max(
391 height, client.second.params.requested_format.frame_size.height()); 395 height, client.second.params.requested_format.frame_size.height());
392 } 396 }
393 params_.requested_format.frame_size.SetSize(width, height); 397 params_.requested_format.frame_size.SetSize(width, height);
394 DVLOG(1) << "RestartCapture, " 398 DVLOG(1) << "RestartCapture, "
395 << params_.requested_format.frame_size.ToString(); 399 << params_.requested_format.frame_size.ToString();
396 StartCaptureInternal(); 400 StartCaptureInternal();
397 } 401 }
398 402
399 void VideoCaptureImpl::StartCaptureInternal() { 403 void VideoCaptureImpl::StartCaptureInternal() {
400 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 404 DCHECK(io_message_loop_->BelongsToCurrentThread());
401 DCHECK(device_id_); 405 DCHECK(device_id_);
402 406
403 Send(new VideoCaptureHostMsg_Start(device_id_, session_id_, params_)); 407 Send(new VideoCaptureHostMsg_Start(device_id_, session_id_, params_));
404 state_ = VIDEO_CAPTURE_STATE_STARTED; 408 state_ = VIDEO_CAPTURE_STATE_STARTED;
405 } 409 }
406 410
407 void VideoCaptureImpl::Send(IPC::Message* message) { 411 void VideoCaptureImpl::Send(IPC::Message* message) {
408 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 412 DCHECK(io_message_loop_->BelongsToCurrentThread());
409 message_filter_->Send(message); 413 message_filter_->Send(message);
410 } 414 }
411 415
412 bool VideoCaptureImpl::RemoveClient(int client_id, ClientInfoMap* clients) { 416 bool VideoCaptureImpl::RemoveClient(int client_id, ClientInfoMap* clients) {
413 DCHECK(render_io_thread_checker_.CalledOnValidThread()); 417 DCHECK(io_message_loop_->BelongsToCurrentThread());
414 bool found = false; 418 bool found = false;
415 419
416 const ClientInfoMap::iterator it = clients->find(client_id); 420 const ClientInfoMap::iterator it = clients->find(client_id);
417 if (it != clients->end()) { 421 if (it != clients->end()) {
418 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); 422 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED);
419 clients->erase(it); 423 clients->erase(it);
420 found = true; 424 found = true;
421 } 425 }
422 return found; 426 return found;
423 } 427 }
424 428
425 } // namespace content 429 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_impl.h ('k') | content/renderer/media/video_capture_impl_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698