| 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/browser/renderer_host/media/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "content/browser/renderer_host/media/media_stream_manager.h" | 12 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 13 #include "content/browser/renderer_host/media/video_capture_manager.h" | 13 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
| 16 #include "media/base/video_util.h" | 16 #include "media/base/video_util.h" |
| 17 #include "media/base/yuv_convert.h" | 17 #include "media/base/yuv_convert.h" |
| 18 | 18 |
| 19 #if !defined(AVOID_LIBYUV_FOR_ANDROID_WEBVIEW) | 19 #if !defined(AVOID_LIBYUV_FOR_ANDROID_WEBVIEW) |
| 20 #include "third_party/libyuv/include/libyuv.h" | 20 #include "third_party/libyuv/include/libyuv.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 using media::VideoCaptureCapability; | 23 using media::VideoCaptureFormat; |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // The number of buffers that VideoCaptureBufferPool should allocate. | 29 // The number of buffers that VideoCaptureBufferPool should allocate. |
| 30 const int kNoOfBuffers = 3; | 30 const int kNoOfBuffers = 3; |
| 31 | 31 |
| 32 class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { | 32 class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { |
| 33 public: | 33 public: |
| 34 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, | 34 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, |
| 35 int buffer_id, | 35 int buffer_id, |
| 36 void* data, | 36 void* data, |
| 37 size_t size) | 37 size_t size) |
| 38 : Buffer(buffer_id, data, size), pool_(pool) { | 38 : Buffer(buffer_id, data, size), pool_(pool) { |
| 39 DCHECK(pool_); | 39 DCHECK(pool_); |
| 40 } | 40 } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 virtual ~PoolBuffer() { pool_->RelinquishProducerReservation(id()); } | 43 virtual ~PoolBuffer() { pool_->RelinquishProducerReservation(id()); } |
| 44 | 44 |
| 45 const scoped_refptr<VideoCaptureBufferPool> pool_; | 45 const scoped_refptr<VideoCaptureBufferPool> pool_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 } // anonymous namespace | 48 } // anonymous namespace |
| 49 | 49 |
| 50 struct VideoCaptureController::ControllerClient { | 50 struct VideoCaptureController::ControllerClient { |
| 51 ControllerClient( | 51 ControllerClient(const VideoCaptureControllerID& id, |
| 52 const VideoCaptureControllerID& id, | 52 VideoCaptureControllerEventHandler* handler, |
| 53 VideoCaptureControllerEventHandler* handler, | 53 base::ProcessHandle render_process, |
| 54 base::ProcessHandle render_process, | 54 media::VideoCaptureSessionId session_id, |
| 55 const media::VideoCaptureParams& params) | 55 const media::VideoCaptureParams& params) |
| 56 : controller_id(id), | 56 : controller_id(id), |
| 57 event_handler(handler), | 57 event_handler(handler), |
| 58 render_process_handle(render_process), | 58 render_process_handle(render_process), |
| 59 session_id(session_id), |
| 59 parameters(params), | 60 parameters(params), |
| 60 session_closed(false) { | 61 session_closed(false) {} |
| 61 } | |
| 62 | 62 |
| 63 ~ControllerClient() {} | 63 ~ControllerClient() {} |
| 64 | 64 |
| 65 // ID used for identifying this object. | 65 // ID used for identifying this object. |
| 66 VideoCaptureControllerID controller_id; | 66 const VideoCaptureControllerID controller_id; |
| 67 VideoCaptureControllerEventHandler* event_handler; | 67 VideoCaptureControllerEventHandler* const event_handler; |
| 68 | 68 |
| 69 // Handle to the render process that will receive the capture buffers. | 69 // Handle to the render process that will receive the capture buffers. |
| 70 base::ProcessHandle render_process_handle; | 70 const base::ProcessHandle render_process_handle; |
| 71 media::VideoCaptureParams parameters; | 71 const media::VideoCaptureSessionId session_id; |
| 72 const media::VideoCaptureParams parameters; |
| 72 | 73 |
| 73 // Buffers that are currently known to this client. | 74 // Buffers that are currently known to this client. |
| 74 std::set<int> known_buffers; | 75 std::set<int> known_buffers; |
| 75 | 76 |
| 76 // Buffers currently held by this client. | 77 // Buffers currently held by this client. |
| 77 std::set<int> active_buffers; | 78 std::set<int> active_buffers; |
| 78 | 79 |
| 79 // State of capture session, controlled by VideoCaptureManager directly. This | 80 // State of capture session, controlled by VideoCaptureManager directly. This |
| 80 // transitions to true as soon as StopSession() occurs, at which point the | 81 // transitions to true as soon as StopSession() occurs, at which point the |
| 81 // client is sent an OnEnded() event. However, because the client retains a | 82 // client is sent an OnEnded() event. However, because the client retains a |
| (...skipping 26 matching lines...) Expand all Loading... |
| 108 // VideoCaptureDevice::Client implementation. | 109 // VideoCaptureDevice::Client implementation. |
| 109 virtual scoped_refptr<Buffer> ReserveOutputBuffer( | 110 virtual scoped_refptr<Buffer> ReserveOutputBuffer( |
| 110 media::VideoFrame::Format format, | 111 media::VideoFrame::Format format, |
| 111 const gfx::Size& size) OVERRIDE; | 112 const gfx::Size& size) OVERRIDE; |
| 112 virtual void OnIncomingCapturedFrame(const uint8* data, | 113 virtual void OnIncomingCapturedFrame(const uint8* data, |
| 113 int length, | 114 int length, |
| 114 base::Time timestamp, | 115 base::Time timestamp, |
| 115 int rotation, | 116 int rotation, |
| 116 bool flip_vert, | 117 bool flip_vert, |
| 117 bool flip_horiz, | 118 bool flip_horiz, |
| 118 const VideoCaptureCapability& frame_info) | 119 const VideoCaptureFormat& frame_format) |
| 119 OVERRIDE; | 120 OVERRIDE; |
| 120 virtual void OnIncomingCapturedBuffer(const scoped_refptr<Buffer>& buffer, | 121 virtual void OnIncomingCapturedBuffer(const scoped_refptr<Buffer>& buffer, |
| 121 media::VideoFrame::Format format, | 122 media::VideoFrame::Format format, |
| 122 const gfx::Size& dimensions, | 123 const gfx::Size& dimensions, |
| 123 base::Time timestamp, | 124 base::Time timestamp, |
| 124 int frame_rate) OVERRIDE; | 125 int frame_rate) OVERRIDE; |
| 125 virtual void OnError() OVERRIDE; | 126 virtual void OnError() OVERRIDE; |
| 126 | 127 |
| 127 private: | 128 private: |
| 128 scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format, | 129 scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 VideoCaptureController::NewDeviceClient() { | 161 VideoCaptureController::NewDeviceClient() { |
| 161 scoped_ptr<media::VideoCaptureDevice::Client> result( | 162 scoped_ptr<media::VideoCaptureDevice::Client> result( |
| 162 new VideoCaptureDeviceClient(this->GetWeakPtr(), buffer_pool_)); | 163 new VideoCaptureDeviceClient(this->GetWeakPtr(), buffer_pool_)); |
| 163 return result.Pass(); | 164 return result.Pass(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 void VideoCaptureController::AddClient( | 167 void VideoCaptureController::AddClient( |
| 167 const VideoCaptureControllerID& id, | 168 const VideoCaptureControllerID& id, |
| 168 VideoCaptureControllerEventHandler* event_handler, | 169 VideoCaptureControllerEventHandler* event_handler, |
| 169 base::ProcessHandle render_process, | 170 base::ProcessHandle render_process, |
| 171 media::VideoCaptureSessionId session_id, |
| 170 const media::VideoCaptureParams& params) { | 172 const media::VideoCaptureParams& params) { |
| 171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 172 DVLOG(1) << "VideoCaptureController::AddClient, id " << id.device_id | 174 DVLOG(1) << "VideoCaptureController::AddClient, id " << id.device_id |
| 173 << ", (" << params.requested_format.width | 175 << ", " << params.requested_format.frame_size.ToString() |
| 174 << ", " << params.requested_format.height | |
| 175 << ", " << params.requested_format.frame_rate | 176 << ", " << params.requested_format.frame_rate |
| 176 << ", " << params.session_id | 177 << ", " << session_id |
| 177 << ")"; | 178 << ")"; |
| 178 | 179 |
| 179 // Signal error in case device is already in error state. | 180 // Signal error in case device is already in error state. |
| 180 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { | 181 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { |
| 181 event_handler->OnError(id); | 182 event_handler->OnError(id); |
| 182 return; | 183 return; |
| 183 } | 184 } |
| 184 | 185 |
| 185 // Do nothing if this client has called AddClient before. | 186 // Do nothing if this client has called AddClient before. |
| 186 if (FindClient(id, event_handler, controller_clients_)) | 187 if (FindClient(id, event_handler, controller_clients_)) |
| 187 return; | 188 return; |
| 188 | 189 |
| 189 ControllerClient* client = new ControllerClient(id, event_handler, | 190 ControllerClient* client = new ControllerClient( |
| 190 render_process, params); | 191 id, event_handler, render_process, session_id, params); |
| 191 // If we already have gotten frame_info from the device, repeat it to the new | 192 // If we already have gotten frame_info from the device, repeat it to the new |
| 192 // client. | 193 // client. |
| 193 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 194 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 194 controller_clients_.push_back(client); | 195 controller_clients_.push_back(client); |
| 195 return; | 196 return; |
| 196 } | 197 } |
| 197 } | 198 } |
| 198 | 199 |
| 199 int VideoCaptureController::RemoveClient( | 200 int VideoCaptureController::RemoveClient( |
| 200 const VideoCaptureControllerID& id, | 201 const VideoCaptureControllerID& id, |
| 201 VideoCaptureControllerEventHandler* event_handler) { | 202 VideoCaptureControllerEventHandler* event_handler) { |
| 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 203 DVLOG(1) << "VideoCaptureController::RemoveClient, id " << id.device_id; | 204 DVLOG(1) << "VideoCaptureController::RemoveClient, id " << id.device_id; |
| 204 | 205 |
| 205 ControllerClient* client = FindClient(id, event_handler, controller_clients_); | 206 ControllerClient* client = FindClient(id, event_handler, controller_clients_); |
| 206 if (!client) | 207 if (!client) |
| 207 return kInvalidMediaCaptureSessionId; | 208 return kInvalidMediaCaptureSessionId; |
| 208 | 209 |
| 209 // Take back all buffers held by the |client|. | 210 // Take back all buffers held by the |client|. |
| 210 for (std::set<int>::iterator buffer_it = client->active_buffers.begin(); | 211 for (std::set<int>::iterator buffer_it = client->active_buffers.begin(); |
| 211 buffer_it != client->active_buffers.end(); | 212 buffer_it != client->active_buffers.end(); |
| 212 ++buffer_it) { | 213 ++buffer_it) { |
| 213 int buffer_id = *buffer_it; | 214 int buffer_id = *buffer_it; |
| 214 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); | 215 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); |
| 215 } | 216 } |
| 216 client->active_buffers.clear(); | 217 client->active_buffers.clear(); |
| 217 | 218 |
| 218 int session_id = client->parameters.session_id; | 219 int session_id = client->session_id; |
| 219 controller_clients_.remove(client); | 220 controller_clients_.remove(client); |
| 220 delete client; | 221 delete client; |
| 221 | 222 |
| 222 return session_id; | 223 return session_id; |
| 223 } | 224 } |
| 224 | 225 |
| 225 void VideoCaptureController::StopSession(int session_id) { | 226 void VideoCaptureController::StopSession(int session_id) { |
| 226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 227 DVLOG(1) << "VideoCaptureController::StopSession, id " << session_id; | 228 DVLOG(1) << "VideoCaptureController::StopSession, id " << session_id; |
| 228 | 229 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 259 return DoReserveOutputBuffer(format, size, 0); | 260 return DoReserveOutputBuffer(format, size, 0); |
| 260 } | 261 } |
| 261 | 262 |
| 262 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame( | 263 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame( |
| 263 const uint8* data, | 264 const uint8* data, |
| 264 int length, | 265 int length, |
| 265 base::Time timestamp, | 266 base::Time timestamp, |
| 266 int rotation, | 267 int rotation, |
| 267 bool flip_vert, | 268 bool flip_vert, |
| 268 bool flip_horiz, | 269 bool flip_horiz, |
| 269 const VideoCaptureCapability& frame_info) { | 270 const VideoCaptureFormat& frame_format) { |
| 270 TRACE_EVENT0("video", "VideoCaptureController::OnIncomingCapturedFrame"); | 271 TRACE_EVENT0("video", "VideoCaptureController::OnIncomingCapturedFrame"); |
| 271 | 272 |
| 272 if (!frame_info.IsValid()) | 273 if (!frame_format.IsValid()) |
| 273 return; | 274 return; |
| 274 | 275 |
| 275 // Chopped pixels in width/height in case video capture device has odd | 276 // Chopped pixels in width/height in case video capture device has odd |
| 276 // numbers for width/height. | 277 // numbers for width/height. |
| 277 int chopped_width = 0; | 278 int chopped_width = 0; |
| 278 int chopped_height = 0; | 279 int chopped_height = 0; |
| 279 int new_width = frame_info.width; | 280 int new_width = frame_format.frame_size.width(); |
| 280 int new_height = frame_info.height; | 281 int new_height = frame_format.frame_size.height(); |
| 281 | 282 |
| 282 if (frame_info.width & 1) { | 283 if (new_width & 1) { |
| 283 --new_width; | 284 --new_width; |
| 284 chopped_width = 1; | 285 chopped_width = 1; |
| 285 } | 286 } |
| 286 if (frame_info.height & 1) { | 287 if (new_height & 1) { |
| 287 --new_height; | 288 --new_height; |
| 288 chopped_height = 1; | 289 chopped_height = 1; |
| 289 } | 290 } |
| 290 | 291 |
| 291 const gfx::Size dimensions(new_width, new_height); | 292 const gfx::Size dimensions(new_width, new_height); |
| 292 scoped_refptr<Buffer> buffer = | 293 scoped_refptr<Buffer> buffer = |
| 293 DoReserveOutputBuffer(media::VideoFrame::I420, dimensions, rotation); | 294 DoReserveOutputBuffer(media::VideoFrame::I420, dimensions, rotation); |
| 294 | 295 |
| 295 if (!buffer) | 296 if (!buffer) |
| 296 return; | 297 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 317 // new_vertical_flip = horizontal_flip XOR vertical_flip | 318 // new_vertical_flip = horizontal_flip XOR vertical_flip |
| 318 int new_rotation_angle = (rotation + 180 * flip_vert) % 360; | 319 int new_rotation_angle = (rotation + 180 * flip_vert) % 360; |
| 319 libyuv::RotationMode rotation_mode = libyuv::kRotate0; | 320 libyuv::RotationMode rotation_mode = libyuv::kRotate0; |
| 320 if (new_rotation_angle == 90) | 321 if (new_rotation_angle == 90) |
| 321 rotation_mode = libyuv::kRotate90; | 322 rotation_mode = libyuv::kRotate90; |
| 322 else if (new_rotation_angle == 180) | 323 else if (new_rotation_angle == 180) |
| 323 rotation_mode = libyuv::kRotate180; | 324 rotation_mode = libyuv::kRotate180; |
| 324 else if (new_rotation_angle == 270) | 325 else if (new_rotation_angle == 270) |
| 325 rotation_mode = libyuv::kRotate270; | 326 rotation_mode = libyuv::kRotate270; |
| 326 | 327 |
| 327 switch (frame_info.color) { | 328 switch (frame_format.pixel_format) { |
| 328 case media::PIXEL_FORMAT_UNKNOWN: // Color format not set. | 329 case media::PIXEL_FORMAT_UNKNOWN: // Color format not set. |
| 329 break; | 330 break; |
| 330 case media::PIXEL_FORMAT_I420: | 331 case media::PIXEL_FORMAT_I420: |
| 331 DCHECK(!chopped_width && !chopped_height); | 332 DCHECK(!chopped_width && !chopped_height); |
| 332 origin_colorspace = libyuv::FOURCC_I420; | 333 origin_colorspace = libyuv::FOURCC_I420; |
| 333 break; | 334 break; |
| 334 case media::PIXEL_FORMAT_YV12: | 335 case media::PIXEL_FORMAT_YV12: |
| 335 DCHECK(!chopped_width && !chopped_height); | 336 DCHECK(!chopped_width && !chopped_height); |
| 336 origin_colorspace = libyuv::FOURCC_YV12; | 337 origin_colorspace = libyuv::FOURCC_YV12; |
| 337 break; | 338 break; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 357 origin_colorspace = libyuv::FOURCC_MJPG; | 358 origin_colorspace = libyuv::FOURCC_MJPG; |
| 358 break; | 359 break; |
| 359 default: | 360 default: |
| 360 NOTREACHED(); | 361 NOTREACHED(); |
| 361 } | 362 } |
| 362 | 363 |
| 363 int need_convert_rgb24_on_win = false; | 364 int need_convert_rgb24_on_win = false; |
| 364 #if defined(OS_WIN) | 365 #if defined(OS_WIN) |
| 365 // kRGB24 on Windows start at the bottom line and has a negative stride. This | 366 // kRGB24 on Windows start at the bottom line and has a negative stride. This |
| 366 // is not supported by libyuv, so the media API is used instead. | 367 // is not supported by libyuv, so the media API is used instead. |
| 367 if (frame_info.color == media::PIXEL_FORMAT_RGB24) { | 368 if (frame_format.pixel_format == media::PIXEL_FORMAT_RGB24) { |
| 368 // Rotation and flipping is not supported in kRGB24 and OS_WIN case. | 369 // Rotation and flipping is not supported in kRGB24 and OS_WIN case. |
| 369 DCHECK(!rotation && !flip_vert && !flip_horiz); | 370 DCHECK(!rotation && !flip_vert && !flip_horiz); |
| 370 need_convert_rgb24_on_win = true; | 371 need_convert_rgb24_on_win = true; |
| 371 } | 372 } |
| 372 #endif | 373 #endif |
| 373 if (need_convert_rgb24_on_win) { | 374 if (need_convert_rgb24_on_win) { |
| 374 int rgb_stride = -3 * (new_width + chopped_width); | 375 int rgb_stride = -3 * (new_width + chopped_width); |
| 375 const uint8* rgb_src = data + 3 * (new_width + chopped_width) * | 376 const uint8* rgb_src = data + 3 * (new_width + chopped_width) * |
| 376 (new_height - 1 + chopped_height); | 377 (new_height - 1 + chopped_height); |
| 377 media::ConvertRGB24ToYUV(rgb_src, | 378 media::ConvertRGB24ToYUV(rgb_src, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 NOTREACHED(); | 428 NOTREACHED(); |
| 428 #endif // if !defined(AVOID_LIBYUV_FOR_ANDROID_WEBVIEW) | 429 #endif // if !defined(AVOID_LIBYUV_FOR_ANDROID_WEBVIEW) |
| 429 BrowserThread::PostTask( | 430 BrowserThread::PostTask( |
| 430 BrowserThread::IO, | 431 BrowserThread::IO, |
| 431 FROM_HERE, | 432 FROM_HERE, |
| 432 base::Bind( | 433 base::Bind( |
| 433 &VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread, | 434 &VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread, |
| 434 controller_, | 435 controller_, |
| 435 buffer, | 436 buffer, |
| 436 dimensions, | 437 dimensions, |
| 437 frame_info.frame_rate, | 438 frame_format.frame_rate, |
| 438 timestamp)); | 439 timestamp)); |
| 439 } | 440 } |
| 440 | 441 |
| 441 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedBuffer( | 442 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedBuffer( |
| 442 const scoped_refptr<Buffer>& buffer, | 443 const scoped_refptr<Buffer>& buffer, |
| 443 media::VideoFrame::Format format, | 444 media::VideoFrame::Format format, |
| 444 const gfx::Size& dimensions, | 445 const gfx::Size& dimensions, |
| 445 base::Time timestamp, | 446 base::Time timestamp, |
| 446 int frame_rate) { | 447 int frame_rate) { |
| 447 // The capture pipeline expects I420 for now. | 448 // The capture pipeline expects I420 for now. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 } | 518 } |
| 518 | 519 |
| 519 void VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread( | 520 void VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread( |
| 520 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 521 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, |
| 521 const gfx::Size& dimensions, | 522 const gfx::Size& dimensions, |
| 522 int frame_rate, | 523 int frame_rate, |
| 523 base::Time timestamp) { | 524 base::Time timestamp) { |
| 524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 525 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 525 DCHECK_NE(buffer->id(), VideoCaptureBufferPool::kInvalidId); | 526 DCHECK_NE(buffer->id(), VideoCaptureBufferPool::kInvalidId); |
| 526 | 527 |
| 527 media::VideoCaptureFormat frame_format( | 528 VideoCaptureFormat frame_format( |
| 528 dimensions.width(), | 529 dimensions, frame_rate, media::PIXEL_FORMAT_I420); |
| 529 dimensions.height(), | |
| 530 frame_rate, | |
| 531 media::VariableResolutionVideoCaptureDevice); | |
| 532 | 530 |
| 533 int count = 0; | 531 int count = 0; |
| 534 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 532 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 535 for (ControllerClients::iterator client_it = controller_clients_.begin(); | 533 for (ControllerClients::iterator client_it = controller_clients_.begin(); |
| 536 client_it != controller_clients_.end(); ++client_it) { | 534 client_it != controller_clients_.end(); ++client_it) { |
| 537 ControllerClient* client = *client_it; | 535 ControllerClient* client = *client_it; |
| 538 if (client->session_closed) | 536 if (client->session_closed) |
| 539 continue; | 537 continue; |
| 540 | 538 |
| 541 bool is_new_buffer = client->known_buffers.insert(buffer->id()).second; | 539 bool is_new_buffer = client->known_buffers.insert(buffer->id()).second; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 } | 602 } |
| 605 return NULL; | 603 return NULL; |
| 606 } | 604 } |
| 607 | 605 |
| 608 VideoCaptureController::ControllerClient* | 606 VideoCaptureController::ControllerClient* |
| 609 VideoCaptureController::FindClient( | 607 VideoCaptureController::FindClient( |
| 610 int session_id, | 608 int session_id, |
| 611 const ControllerClients& clients) { | 609 const ControllerClients& clients) { |
| 612 for (ControllerClients::const_iterator client_it = clients.begin(); | 610 for (ControllerClients::const_iterator client_it = clients.begin(); |
| 613 client_it != clients.end(); ++client_it) { | 611 client_it != clients.end(); ++client_it) { |
| 614 if ((*client_it)->parameters.session_id == session_id) { | 612 if ((*client_it)->session_id == session_id) { |
| 615 return *client_it; | 613 return *client_it; |
| 616 } | 614 } |
| 617 } | 615 } |
| 618 return NULL; | 616 return NULL; |
| 619 } | 617 } |
| 620 | 618 |
| 621 int VideoCaptureController::GetClientCount() { | 619 int VideoCaptureController::GetClientCount() { |
| 622 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 620 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 623 return controller_clients_.size(); | 621 return controller_clients_.size(); |
| 624 } | 622 } |
| 625 | 623 |
| 626 } // namespace content | 624 } // namespace content |
| OLD | NEW |