| 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 void VideoCaptureController::DoFrameInfoOnIOThread() { | 566 void VideoCaptureController::DoFrameInfoOnIOThread() { |
| 567 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 567 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 568 DCHECK(!buffer_pool_.get()) | 568 DCHECK(!buffer_pool_.get()) |
| 569 << "Device is restarted without releasing shared memory."; | 569 << "Device is restarted without releasing shared memory."; |
| 570 | 570 |
| 571 // Allocate memory only when device has been started. | 571 // Allocate memory only when device has been started. |
| 572 if (state_ != VIDEO_CAPTURE_STATE_STARTED) | 572 if (state_ != VIDEO_CAPTURE_STATE_STARTED) |
| 573 return; | 573 return; |
| 574 | 574 |
| 575 scoped_refptr<VideoCaptureBufferPool> buffer_pool = | 575 scoped_refptr<VideoCaptureBufferPool> buffer_pool = |
| 576 new VideoCaptureBufferPool(frame_info_.width * frame_info_.height * 3 / 2, | 576 new VideoCaptureBufferPool( |
| 577 kNoOfBuffers); | 577 media::VideoFrame::AllocationSize( |
| 578 media::VideoFrame::I420, |
| 579 gfx::Size(frame_info_.width, frame_info_.height)), |
| 580 kNoOfBuffers); |
| 578 | 581 |
| 579 // Check whether all buffers were created successfully. | 582 // Check whether all buffers were created successfully. |
| 580 if (!buffer_pool->Allocate()) { | 583 if (!buffer_pool->Allocate()) { |
| 581 state_ = VIDEO_CAPTURE_STATE_ERROR; | 584 state_ = VIDEO_CAPTURE_STATE_ERROR; |
| 582 for (ControllerClients::iterator client_it = controller_clients_.begin(); | 585 for (ControllerClients::iterator client_it = controller_clients_.begin(); |
| 583 client_it != controller_clients_.end(); ++client_it) { | 586 client_it != controller_clients_.end(); ++client_it) { |
| 584 (*client_it)->event_handler->OnError((*client_it)->controller_id); | 587 (*client_it)->event_handler->OnError((*client_it)->controller_id); |
| 585 } | 588 } |
| 586 return; | 589 return; |
| 587 } | 590 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 controller_clients_.push_back((*client_it)); | 726 controller_clients_.push_back((*client_it)); |
| 724 pending_clients_.erase(client_it++); | 727 pending_clients_.erase(client_it++); |
| 725 } | 728 } |
| 726 // Request the manager to start the actual capture. | 729 // Request the manager to start the actual capture. |
| 727 video_capture_manager_->Start(current_params_, this); | 730 video_capture_manager_->Start(current_params_, this); |
| 728 state_ = VIDEO_CAPTURE_STATE_STARTED; | 731 state_ = VIDEO_CAPTURE_STATE_STARTED; |
| 729 device_in_use_ = true; | 732 device_in_use_ = true; |
| 730 } | 733 } |
| 731 | 734 |
| 732 } // namespace content | 735 } // namespace content |
| OLD | NEW |