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

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

Issue 8037055: Add OnRemoved() in VideoCapture::EventHandler API (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/renderer/media/video_capture_impl.h" 5 #include "content/renderer/media/video_capture_impl.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "content/common/child_process.h" 8 #include "content/common/child_process.h"
9 #include "content/common/media/video_capture_messages.h" 9 #include "content/common/media/video_capture_messages.h"
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 void VideoCaptureImpl::DoStartCapture( 138 void VideoCaptureImpl::DoStartCapture(
139 media::VideoCapture::EventHandler* handler, 139 media::VideoCapture::EventHandler* handler,
140 const VideoCaptureCapability& capability) { 140 const VideoCaptureCapability& capability) {
141 DCHECK(ml_proxy_->BelongsToCurrentThread()); 141 DCHECK(ml_proxy_->BelongsToCurrentThread());
142 142
143 ClientInfo::iterator it = pending_clients_.find(handler); 143 ClientInfo::iterator it = pending_clients_.find(handler);
144 144
145 if (it != pending_clients_.end()) { 145 if (it != pending_clients_.end()) {
146 handler->OnError(this, 1); 146 handler->OnError(this, 1);
147 handler->OnRemoved(this);
147 return; 148 return;
148 } 149 }
149 150
150 if (!device_id_) { 151 if (!device_id_) {
151 pending_clients_[handler] = capability; 152 pending_clients_[handler] = capability;
152 return; 153 return;
153 } 154 }
154 155
155 if (capability.resolution_fixed && master_clients_.size() && 156 if (capability.resolution_fixed && master_clients_.size() &&
156 (capability.width != current_params_.width || 157 (capability.width != current_params_.width ||
157 capability.height != current_params_.height)) { 158 capability.height != current_params_.height)) {
158 // Can't have 2 master clients with different resolutions. 159 // Can't have 2 master clients with different resolutions.
159 handler->OnError(this, 1); 160 handler->OnError(this, 1);
161 handler->OnRemoved(this);
160 return; 162 return;
161 } 163 }
162 164
163 clients_[handler] = capability; 165 clients_[handler] = capability;
164 if (capability.resolution_fixed) { 166 if (capability.resolution_fixed) {
165 master_clients_.push_back(handler); 167 master_clients_.push_back(handler);
166 if (master_clients_.size() > 1) 168 if (master_clients_.size() > 1)
167 return; 169 return;
168 } 170 }
169 171
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 StartCaptureInternal(); 214 StartCaptureInternal();
213 } 215 }
214 216
215 void VideoCaptureImpl::DoStopCapture( 217 void VideoCaptureImpl::DoStopCapture(
216 media::VideoCapture::EventHandler* handler) { 218 media::VideoCapture::EventHandler* handler) {
217 DCHECK(ml_proxy_->BelongsToCurrentThread()); 219 DCHECK(ml_proxy_->BelongsToCurrentThread());
218 220
219 ClientInfo::iterator it = pending_clients_.find(handler); 221 ClientInfo::iterator it = pending_clients_.find(handler);
220 if (it != pending_clients_.end()) { 222 if (it != pending_clients_.end()) {
221 handler->OnStopped(this); 223 handler->OnStopped(this);
224 handler->OnRemoved(this);
222 pending_clients_.erase(it); 225 pending_clients_.erase(it);
223 return; 226 return;
224 } 227 }
225 228
226 if (clients_.find(handler) == clients_.end()) 229 if (clients_.find(handler) == clients_.end())
227 return; 230 return;
228 231
229 handler->OnStopped(this); 232 handler->OnStopped(this);
233 handler->OnRemoved(this);
230 clients_.erase(handler); 234 clients_.erase(handler);
231 master_clients_.remove(handler); 235 master_clients_.remove(handler);
232 236
233 // Still have at least one master client. 237 // Still have at least one master client.
234 if (master_clients_.size() > 0) 238 if (master_clients_.size() > 0)
235 return; 239 return;
236 240
237 // TODO(wjia): Is it really needed to handle resolution change for non-master 241 // TODO(wjia): Is it really needed to handle resolution change for non-master
238 // clients, except no client case? 242 // clients, except no client case?
239 if (clients_.size() > 0) { 243 if (clients_.size() > 0) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 for (ClientInfo::iterator it = clients_.begin(); 365 for (ClientInfo::iterator it = clients_.begin();
362 it != clients_.end(); it++) { 366 it != clients_.end(); it++) {
363 it->first->OnPaused(this); 367 it->first->OnPaused(this);
364 } 368 }
365 break; 369 break;
366 case media::VideoCapture::kError: 370 case media::VideoCapture::kError:
367 for (ClientInfo::iterator it = clients_.begin(); 371 for (ClientInfo::iterator it = clients_.begin();
368 it != clients_.end(); it++) { 372 it != clients_.end(); it++) {
369 // TODO(wjia): browser process would send error code. 373 // TODO(wjia): browser process would send error code.
370 it->first->OnError(this, 1); 374 it->first->OnError(this, 1);
375 it->first->OnRemoved(this);
371 } 376 }
377 clients_.clear();
378 master_clients_.clear();
379 state_ = kStopped;
380 current_params_.width = current_params_.height = 0;
372 break; 381 break;
373 default: 382 default:
374 break; 383 break;
375 } 384 }
376 } 385 }
377 386
378 void VideoCaptureImpl::DoDeviceInfoReceived( 387 void VideoCaptureImpl::DoDeviceInfoReceived(
379 const media::VideoCaptureParams& device_info) { 388 const media::VideoCaptureParams& device_info) {
380 DCHECK(ml_proxy_->BelongsToCurrentThread()); 389 DCHECK(ml_proxy_->BelongsToCurrentThread());
381 390
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 455 }
447 456
448 void VideoCaptureImpl::Send(IPC::Message* message) { 457 void VideoCaptureImpl::Send(IPC::Message* message) {
449 base::MessageLoopProxy* io_message_loop_proxy = 458 base::MessageLoopProxy* io_message_loop_proxy =
450 ChildProcess::current()->io_message_loop_proxy(); 459 ChildProcess::current()->io_message_loop_proxy();
451 460
452 io_message_loop_proxy->PostTask(FROM_HERE, 461 io_message_loop_proxy->PostTask(FROM_HERE,
453 NewRunnableMethod(message_filter_.get(), 462 NewRunnableMethod(message_filter_.get(),
454 &VideoCaptureMessageFilter::Send, message)); 463 &VideoCaptureMessageFilter::Send, message));
455 } 464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698