| 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 #include "content/renderer/media/video_capture_impl.h" | 5 #include "content/renderer/media/video_capture_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "content/common/child_process.h" | 9 #include "content/common/child_process.h" |
| 10 #include "content/common/media/video_capture_messages.h" | 10 #include "content/common/media/video_capture_messages.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 ~DIBBuffer() {} | 23 ~DIBBuffer() {} |
| 24 | 24 |
| 25 scoped_ptr<base::SharedMemory> dib; | 25 scoped_ptr<base::SharedMemory> dib; |
| 26 scoped_refptr<media::VideoCapture::VideoFrameBuffer> mapped_memory; | 26 scoped_refptr<media::VideoCapture::VideoFrameBuffer> mapped_memory; |
| 27 | 27 |
| 28 // Number of clients which hold this DIB. | 28 // Number of clients which hold this DIB. |
| 29 int references; | 29 int references; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 bool VideoCaptureImpl::CaptureStarted() { | 32 bool VideoCaptureImpl::CaptureStarted() { |
| 33 return state_ == video_capture::kStarted; | 33 return state_ == VIDEO_CAPTURE_STATE_STARTED; |
| 34 } | 34 } |
| 35 | 35 |
| 36 int VideoCaptureImpl::CaptureWidth() { | 36 int VideoCaptureImpl::CaptureWidth() { |
| 37 return current_params_.width; | 37 return current_params_.width; |
| 38 } | 38 } |
| 39 | 39 |
| 40 int VideoCaptureImpl::CaptureHeight() { | 40 int VideoCaptureImpl::CaptureHeight() { |
| 41 return current_params_.height; | 41 return current_params_.height; |
| 42 } | 42 } |
| 43 | 43 |
| 44 int VideoCaptureImpl::CaptureFrameRate() { | 44 int VideoCaptureImpl::CaptureFrameRate() { |
| 45 return current_params_.frame_per_second; | 45 return current_params_.frame_per_second; |
| 46 } | 46 } |
| 47 | 47 |
| 48 VideoCaptureImpl::VideoCaptureImpl( | 48 VideoCaptureImpl::VideoCaptureImpl( |
| 49 const media::VideoCaptureSessionId id, | 49 const media::VideoCaptureSessionId id, |
| 50 base::MessageLoopProxy* capture_message_loop_proxy, | 50 base::MessageLoopProxy* capture_message_loop_proxy, |
| 51 VideoCaptureMessageFilter* filter) | 51 VideoCaptureMessageFilter* filter) |
| 52 : VideoCapture(), | 52 : VideoCapture(), |
| 53 message_filter_(filter), | 53 message_filter_(filter), |
| 54 capture_message_loop_proxy_(capture_message_loop_proxy), | 54 capture_message_loop_proxy_(capture_message_loop_proxy), |
| 55 io_message_loop_proxy_(ChildProcess::current()->io_message_loop_proxy()), | 55 io_message_loop_proxy_(ChildProcess::current()->io_message_loop_proxy()), |
| 56 device_id_(0), | 56 device_id_(0), |
| 57 video_type_(media::VideoCaptureCapability::kI420), | 57 video_type_(media::VideoCaptureCapability::kI420), |
| 58 device_info_available_(false), | 58 device_info_available_(false), |
| 59 state_(video_capture::kStopped) { | 59 state_(VIDEO_CAPTURE_STATE_STOPPED) { |
| 60 DCHECK(filter); | 60 DCHECK(filter); |
| 61 memset(¤t_params_, 0, sizeof(current_params_)); | 61 memset(¤t_params_, 0, sizeof(current_params_)); |
| 62 memset(&device_info_, 0, sizeof(device_info_)); | 62 memset(&device_info_, 0, sizeof(device_info_)); |
| 63 current_params_.session_id = id; | 63 current_params_.session_id = id; |
| 64 } | 64 } |
| 65 | 65 |
| 66 VideoCaptureImpl::~VideoCaptureImpl() { | 66 VideoCaptureImpl::~VideoCaptureImpl() { |
| 67 STLDeleteValues(&cached_dibs_); | 67 STLDeleteValues(&cached_dibs_); |
| 68 } | 68 } |
| 69 | 69 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 base::Bind(&VideoCaptureImpl::DoBufferCreatedOnCaptureThread, | 112 base::Bind(&VideoCaptureImpl::DoBufferCreatedOnCaptureThread, |
| 113 base::Unretained(this), handle, length, buffer_id)); | 113 base::Unretained(this), handle, length, buffer_id)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void VideoCaptureImpl::OnBufferReceived(int buffer_id, base::Time timestamp) { | 116 void VideoCaptureImpl::OnBufferReceived(int buffer_id, base::Time timestamp) { |
| 117 capture_message_loop_proxy_->PostTask(FROM_HERE, | 117 capture_message_loop_proxy_->PostTask(FROM_HERE, |
| 118 base::Bind(&VideoCaptureImpl::DoBufferReceivedOnCaptureThread, | 118 base::Bind(&VideoCaptureImpl::DoBufferReceivedOnCaptureThread, |
| 119 base::Unretained(this), buffer_id, timestamp)); | 119 base::Unretained(this), buffer_id, timestamp)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void VideoCaptureImpl::OnStateChanged(video_capture::State state) { | 122 void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) { |
| 123 capture_message_loop_proxy_->PostTask(FROM_HERE, | 123 capture_message_loop_proxy_->PostTask(FROM_HERE, |
| 124 base::Bind(&VideoCaptureImpl::DoStateChangedOnCaptureThread, | 124 base::Bind(&VideoCaptureImpl::DoStateChangedOnCaptureThread, |
| 125 base::Unretained(this), state)); | 125 base::Unretained(this), state)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void VideoCaptureImpl::OnDeviceInfoReceived( | 128 void VideoCaptureImpl::OnDeviceInfoReceived( |
| 129 const media::VideoCaptureParams& device_info) { | 129 const media::VideoCaptureParams& device_info) { |
| 130 capture_message_loop_proxy_->PostTask(FROM_HERE, | 130 capture_message_loop_proxy_->PostTask(FROM_HERE, |
| 131 base::Bind(&VideoCaptureImpl::DoDeviceInfoReceivedOnCaptureThread, | 131 base::Bind(&VideoCaptureImpl::DoDeviceInfoReceivedOnCaptureThread, |
| 132 base::Unretained(this), device_info)); | 132 base::Unretained(this), device_info)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void VideoCaptureImpl::OnDelegateAdded(int32 device_id) { | 135 void VideoCaptureImpl::OnDelegateAdded(int32 device_id) { |
| 136 capture_message_loop_proxy_->PostTask(FROM_HERE, | 136 capture_message_loop_proxy_->PostTask(FROM_HERE, |
| 137 base::Bind(&VideoCaptureImpl::DoDelegateAddedOnCaptureThread, | 137 base::Bind(&VideoCaptureImpl::DoDelegateAddedOnCaptureThread, |
| 138 base::Unretained(this), device_id)); | 138 base::Unretained(this), device_id)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void VideoCaptureImpl::DoDeInitOnCaptureThread(base::Closure task) { | 141 void VideoCaptureImpl::DoDeInitOnCaptureThread(base::Closure task) { |
| 142 if (state_ == video_capture::kStarted) | 142 if (state_ == VIDEO_CAPTURE_STATE_STARTED) |
| 143 Send(new VideoCaptureHostMsg_Stop(device_id_)); | 143 Send(new VideoCaptureHostMsg_Stop(device_id_)); |
| 144 | 144 |
| 145 io_message_loop_proxy_->PostTask(FROM_HERE, | 145 io_message_loop_proxy_->PostTask(FROM_HERE, |
| 146 base::Bind(&VideoCaptureImpl::RemoveDelegateOnIOThread, | 146 base::Bind(&VideoCaptureImpl::RemoveDelegateOnIOThread, |
| 147 base::Unretained(this), task)); | 147 base::Unretained(this), task)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void VideoCaptureImpl::DoStartCaptureOnCaptureThread( | 150 void VideoCaptureImpl::DoStartCaptureOnCaptureThread( |
| 151 media::VideoCapture::EventHandler* handler, | 151 media::VideoCapture::EventHandler* handler, |
| 152 const media::VideoCaptureCapability& capability) { | 152 const media::VideoCaptureCapability& capability) { |
| 153 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 153 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 154 | 154 |
| 155 if (state_ == video_capture::kError) { | 155 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { |
| 156 handler->OnError(this, 1); | 156 handler->OnError(this, 1); |
| 157 handler->OnRemoved(this); | 157 handler->OnRemoved(this); |
| 158 } else if ((clients_pending_on_filter_.find(handler) != | 158 } else if ((clients_pending_on_filter_.find(handler) != |
| 159 clients_pending_on_filter_.end()) || | 159 clients_pending_on_filter_.end()) || |
| 160 (clients_pending_on_restart_.find(handler) != | 160 (clients_pending_on_restart_.find(handler) != |
| 161 clients_pending_on_restart_.end()) || | 161 clients_pending_on_restart_.end()) || |
| 162 clients_.find(handler) != clients_.end() ) { | 162 clients_.find(handler) != clients_.end() ) { |
| 163 // This client has started. | 163 // This client has started. |
| 164 } else if (!device_id_) { | 164 } else if (!device_id_) { |
| 165 clients_pending_on_filter_[handler] = capability; | 165 clients_pending_on_filter_[handler] = capability; |
| 166 } else { | 166 } else { |
| 167 handler->OnStarted(this); | 167 handler->OnStarted(this); |
| 168 if (state_ == video_capture::kStarted) { | 168 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 169 // TODO(wjia): Temporarily disable restarting till client supports | 169 // TODO(wjia): Temporarily disable restarting till client supports |
| 170 // resampling. | 170 // resampling. |
| 171 #if 0 | 171 #if 0 |
| 172 if (capability.width > current_params_.width || | 172 if (capability.width > current_params_.width || |
| 173 capability.height > current_params_.height) { | 173 capability.height > current_params_.height) { |
| 174 StopDevice(); | 174 StopDevice(); |
| 175 DVLOG(1) << "StartCapture: Got client with higher resolution (" | 175 DVLOG(1) << "StartCapture: Got client with higher resolution (" |
| 176 << capability.width << ", " << capability.height << ") " | 176 << capability.width << ", " << capability.height << ") " |
| 177 << "after started, try to restart."; | 177 << "after started, try to restart."; |
| 178 clients_pending_on_restart_[handler] = capability; | 178 clients_pending_on_restart_[handler] = capability; |
| 179 } else { | 179 } else { |
| 180 #endif | 180 #endif |
| 181 { | 181 { |
| 182 if (device_info_available_) { | 182 if (device_info_available_) { |
| 183 handler->OnDeviceInfoReceived(this, device_info_); | 183 handler->OnDeviceInfoReceived(this, device_info_); |
| 184 } | 184 } |
| 185 | 185 |
| 186 clients_[handler] = capability; | 186 clients_[handler] = capability; |
| 187 } | 187 } |
| 188 } else if (state_ == video_capture::kStopping) { | 188 } else if (state_ == VIDEO_CAPTURE_STATE_STOPPING) { |
| 189 clients_pending_on_restart_[handler] = capability; | 189 clients_pending_on_restart_[handler] = capability; |
| 190 DVLOG(1) << "StartCapture: Got new resolution (" | 190 DVLOG(1) << "StartCapture: Got new resolution (" |
| 191 << capability.width << ", " << capability.height << ") " | 191 << capability.width << ", " << capability.height << ") " |
| 192 << ", during stopping."; | 192 << ", during stopping."; |
| 193 } else { | 193 } else { |
| 194 clients_[handler] = capability; | 194 clients_[handler] = capability; |
| 195 DCHECK_EQ(1ul, clients_.size()); | 195 DCHECK_EQ(1ul, clients_.size()); |
| 196 video_type_ = capability.color; | 196 video_type_ = capability.color; |
| 197 current_params_.width = capability.width; | 197 current_params_.width = capability.width; |
| 198 current_params_.height = capability.height; | 198 current_params_.height = capability.height; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 void VideoCaptureImpl::DoBufferCreatedOnCaptureThread( | 244 void VideoCaptureImpl::DoBufferCreatedOnCaptureThread( |
| 245 base::SharedMemoryHandle handle, | 245 base::SharedMemoryHandle handle, |
| 246 int length, int buffer_id) { | 246 int length, int buffer_id) { |
| 247 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 247 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 248 | 248 |
| 249 // In case client calls StopCapture before the arrival of created buffer, | 249 // In case client calls StopCapture before the arrival of created buffer, |
| 250 // just close this buffer and return. | 250 // just close this buffer and return. |
| 251 if (state_ != video_capture::kStarted) { | 251 if (state_ != VIDEO_CAPTURE_STATE_STARTED) { |
| 252 base::SharedMemory::CloseHandle(handle); | 252 base::SharedMemory::CloseHandle(handle); |
| 253 return; | 253 return; |
| 254 } | 254 } |
| 255 | 255 |
| 256 DCHECK(device_info_available_); | 256 DCHECK(device_info_available_); |
| 257 | 257 |
| 258 media::VideoCapture::VideoFrameBuffer* buffer; | 258 media::VideoCapture::VideoFrameBuffer* buffer; |
| 259 DCHECK(cached_dibs_.find(buffer_id) == cached_dibs_.end()); | 259 DCHECK(cached_dibs_.find(buffer_id) == cached_dibs_.end()); |
| 260 | 260 |
| 261 base::SharedMemory* dib = new base::SharedMemory(handle, false); | 261 base::SharedMemory* dib = new base::SharedMemory(handle, false); |
| 262 dib->Map(length); | 262 dib->Map(length); |
| 263 buffer = new VideoFrameBuffer(); | 263 buffer = new VideoFrameBuffer(); |
| 264 buffer->memory_pointer = static_cast<uint8*>(dib->memory()); | 264 buffer->memory_pointer = static_cast<uint8*>(dib->memory()); |
| 265 buffer->buffer_size = length; | 265 buffer->buffer_size = length; |
| 266 buffer->width = device_info_.width; | 266 buffer->width = device_info_.width; |
| 267 buffer->height = device_info_.height; | 267 buffer->height = device_info_.height; |
| 268 buffer->stride = device_info_.width; | 268 buffer->stride = device_info_.width; |
| 269 | 269 |
| 270 DIBBuffer* dib_buffer = new DIBBuffer(dib, buffer); | 270 DIBBuffer* dib_buffer = new DIBBuffer(dib, buffer); |
| 271 cached_dibs_[buffer_id] = dib_buffer; | 271 cached_dibs_[buffer_id] = dib_buffer; |
| 272 } | 272 } |
| 273 | 273 |
| 274 void VideoCaptureImpl::DoBufferReceivedOnCaptureThread( | 274 void VideoCaptureImpl::DoBufferReceivedOnCaptureThread( |
| 275 int buffer_id, base::Time timestamp) { | 275 int buffer_id, base::Time timestamp) { |
| 276 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 276 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 277 | 277 |
| 278 if (state_ != video_capture::kStarted) { | 278 if (state_ != VIDEO_CAPTURE_STATE_STARTED) { |
| 279 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id)); | 279 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id)); |
| 280 return; | 280 return; |
| 281 } | 281 } |
| 282 | 282 |
| 283 media::VideoCapture::VideoFrameBuffer* buffer; | 283 media::VideoCapture::VideoFrameBuffer* buffer; |
| 284 DCHECK(cached_dibs_.find(buffer_id) != cached_dibs_.end()); | 284 DCHECK(cached_dibs_.find(buffer_id) != cached_dibs_.end()); |
| 285 buffer = cached_dibs_[buffer_id]->mapped_memory; | 285 buffer = cached_dibs_[buffer_id]->mapped_memory; |
| 286 buffer->timestamp = timestamp; | 286 buffer->timestamp = timestamp; |
| 287 | 287 |
| 288 for (ClientInfo::iterator it = clients_.begin(); it != clients_.end(); ++it) { | 288 for (ClientInfo::iterator it = clients_.begin(); it != clients_.end(); ++it) { |
| 289 it->first->OnBufferReady(this, buffer); | 289 it->first->OnBufferReady(this, buffer); |
| 290 } | 290 } |
| 291 cached_dibs_[buffer_id]->references = clients_.size(); | 291 cached_dibs_[buffer_id]->references = clients_.size(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void VideoCaptureImpl::DoStateChangedOnCaptureThread( | 294 void VideoCaptureImpl::DoStateChangedOnCaptureThread(VideoCaptureState state) { |
| 295 video_capture::State state) { | |
| 296 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 295 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 297 | 296 |
| 298 switch (state) { | 297 switch (state) { |
| 299 case video_capture::kStarted: | 298 case VIDEO_CAPTURE_STATE_STARTED: |
| 300 break; | 299 break; |
| 301 case video_capture::kStopped: | 300 case VIDEO_CAPTURE_STATE_STOPPED: |
| 302 state_ = video_capture::kStopped; | 301 state_ = VIDEO_CAPTURE_STATE_STOPPED; |
| 303 DVLOG(1) << "OnStateChanged: stopped!, device_id = " << device_id_; | 302 DVLOG(1) << "OnStateChanged: stopped!, device_id = " << device_id_; |
| 304 STLDeleteValues(&cached_dibs_); | 303 STLDeleteValues(&cached_dibs_); |
| 305 if (!clients_.empty() || !clients_pending_on_restart_.empty()) | 304 if (!clients_.empty() || !clients_pending_on_restart_.empty()) |
| 306 RestartCapture(); | 305 RestartCapture(); |
| 307 break; | 306 break; |
| 308 case video_capture::kPaused: | 307 case VIDEO_CAPTURE_STATE_PAUSED: |
| 309 for (ClientInfo::iterator it = clients_.begin(); | 308 for (ClientInfo::iterator it = clients_.begin(); |
| 310 it != clients_.end(); ++it) { | 309 it != clients_.end(); ++it) { |
| 311 it->first->OnPaused(this); | 310 it->first->OnPaused(this); |
| 312 } | 311 } |
| 313 break; | 312 break; |
| 314 case video_capture::kError: | 313 case VIDEO_CAPTURE_STATE_ERROR: |
| 315 DVLOG(1) << "OnStateChanged: error!, device_id = " << device_id_; | 314 DVLOG(1) << "OnStateChanged: error!, device_id = " << device_id_; |
| 316 for (ClientInfo::iterator it = clients_.begin(); | 315 for (ClientInfo::iterator it = clients_.begin(); |
| 317 it != clients_.end(); ++it) { | 316 it != clients_.end(); ++it) { |
| 318 // TODO(wjia): browser process would send error code. | 317 // TODO(wjia): browser process would send error code. |
| 319 it->first->OnError(this, 1); | 318 it->first->OnError(this, 1); |
| 320 it->first->OnRemoved(this); | 319 it->first->OnRemoved(this); |
| 321 } | 320 } |
| 322 clients_.clear(); | 321 clients_.clear(); |
| 323 state_ = video_capture::kError; | 322 state_ = VIDEO_CAPTURE_STATE_ERROR; |
| 324 break; | 323 break; |
| 325 default: | 324 default: |
| 326 break; | 325 break; |
| 327 } | 326 } |
| 328 } | 327 } |
| 329 | 328 |
| 330 void VideoCaptureImpl::DoDeviceInfoReceivedOnCaptureThread( | 329 void VideoCaptureImpl::DoDeviceInfoReceivedOnCaptureThread( |
| 331 const media::VideoCaptureParams& device_info) { | 330 const media::VideoCaptureParams& device_info) { |
| 332 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 331 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 333 DCHECK(!ClientHasDIB()); | 332 DCHECK(!ClientHasDIB()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 352 const media::VideoCaptureCapability capability = it->second; | 351 const media::VideoCaptureCapability capability = it->second; |
| 353 clients_pending_on_filter_.erase(it++); | 352 clients_pending_on_filter_.erase(it++); |
| 354 StartCapture(handler, capability); | 353 StartCapture(handler, capability); |
| 355 } | 354 } |
| 356 } | 355 } |
| 357 | 356 |
| 358 void VideoCaptureImpl::StopDevice() { | 357 void VideoCaptureImpl::StopDevice() { |
| 359 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 358 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 360 | 359 |
| 361 device_info_available_ = false; | 360 device_info_available_ = false; |
| 362 if (state_ == video_capture::kStarted) { | 361 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 363 state_ = video_capture::kStopping; | 362 state_ = VIDEO_CAPTURE_STATE_STOPPING; |
| 364 Send(new VideoCaptureHostMsg_Stop(device_id_)); | 363 Send(new VideoCaptureHostMsg_Stop(device_id_)); |
| 365 current_params_.width = current_params_.height = 0; | 364 current_params_.width = current_params_.height = 0; |
| 366 } | 365 } |
| 367 } | 366 } |
| 368 | 367 |
| 369 void VideoCaptureImpl::RestartCapture() { | 368 void VideoCaptureImpl::RestartCapture() { |
| 370 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 369 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 371 DCHECK_EQ(state_, video_capture::kStopped); | 370 DCHECK_EQ(state_, VIDEO_CAPTURE_STATE_STOPPED); |
| 372 | 371 |
| 373 int width = 0; | 372 int width = 0; |
| 374 int height = 0; | 373 int height = 0; |
| 375 for (ClientInfo::iterator it = clients_.begin(); | 374 for (ClientInfo::iterator it = clients_.begin(); |
| 376 it != clients_.end(); ++it) { | 375 it != clients_.end(); ++it) { |
| 377 width = std::max(width, it->second.width); | 376 width = std::max(width, it->second.width); |
| 378 height = std::max(height, it->second.height); | 377 height = std::max(height, it->second.height); |
| 379 } | 378 } |
| 380 for (ClientInfo::iterator it = clients_pending_on_restart_.begin(); | 379 for (ClientInfo::iterator it = clients_pending_on_restart_.begin(); |
| 381 it != clients_pending_on_restart_.end(); ) { | 380 it != clients_pending_on_restart_.end(); ) { |
| 382 width = std::max(width, it->second.width); | 381 width = std::max(width, it->second.width); |
| 383 height = std::max(height, it->second.height); | 382 height = std::max(height, it->second.height); |
| 384 clients_[it->first] = it->second; | 383 clients_[it->first] = it->second; |
| 385 clients_pending_on_restart_.erase(it++); | 384 clients_pending_on_restart_.erase(it++); |
| 386 } | 385 } |
| 387 current_params_.width = width; | 386 current_params_.width = width; |
| 388 current_params_.height = height; | 387 current_params_.height = height; |
| 389 DVLOG(1) << "RestartCapture, " << current_params_.width << ", " | 388 DVLOG(1) << "RestartCapture, " << current_params_.width << ", " |
| 390 << current_params_.height; | 389 << current_params_.height; |
| 391 StartCaptureInternal(); | 390 StartCaptureInternal(); |
| 392 } | 391 } |
| 393 | 392 |
| 394 void VideoCaptureImpl::StartCaptureInternal() { | 393 void VideoCaptureImpl::StartCaptureInternal() { |
| 395 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 394 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 396 DCHECK(device_id_); | 395 DCHECK(device_id_); |
| 397 | 396 |
| 398 Send(new VideoCaptureHostMsg_Start(device_id_, current_params_)); | 397 Send(new VideoCaptureHostMsg_Start(device_id_, current_params_)); |
| 399 state_ = video_capture::kStarted; | 398 state_ = VIDEO_CAPTURE_STATE_STARTED; |
| 400 } | 399 } |
| 401 | 400 |
| 402 void VideoCaptureImpl::AddDelegateOnIOThread() { | 401 void VideoCaptureImpl::AddDelegateOnIOThread() { |
| 403 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 402 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 404 message_filter_->AddDelegate(this); | 403 message_filter_->AddDelegate(this); |
| 405 } | 404 } |
| 406 | 405 |
| 407 void VideoCaptureImpl::RemoveDelegateOnIOThread(base::Closure task) { | 406 void VideoCaptureImpl::RemoveDelegateOnIOThread(base::Closure task) { |
| 408 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 407 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 409 message_filter_->RemoveDelegate(this); | 408 message_filter_->RemoveDelegate(this); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 436 if (it != clients->end()) { | 435 if (it != clients->end()) { |
| 437 handler->OnStopped(this); | 436 handler->OnStopped(this); |
| 438 handler->OnRemoved(this); | 437 handler->OnRemoved(this); |
| 439 clients->erase(it); | 438 clients->erase(it); |
| 440 found = true; | 439 found = true; |
| 441 } | 440 } |
| 442 return found; | 441 return found; |
| 443 } | 442 } |
| 444 | 443 |
| 445 } // namespace content | 444 } // namespace content |
| OLD | NEW |