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

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller.cc

Issue 270263008: Add a ChromeOS implementation of VideoCaptureDevice (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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) 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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 // The pool of shared-memory buffers used for capturing. 142 // The pool of shared-memory buffers used for capturing.
143 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; 143 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_;
144 144
145 bool first_frame_; 145 bool first_frame_;
146 }; 146 };
147 147
148 VideoCaptureController::VideoCaptureController() 148 VideoCaptureController::VideoCaptureController()
149 : buffer_pool_(new VideoCaptureBufferPool(kNoOfBuffers)), 149 : buffer_pool_(new VideoCaptureBufferPool(kNoOfBuffers)),
150 state_(VIDEO_CAPTURE_STATE_STARTED), 150 state_(VIDEO_CAPTURE_STATE_STARTED),
151 display_rotation_(gfx::Display::ROTATE_0),
151 weak_ptr_factory_(this) { 152 weak_ptr_factory_(this) {
152 } 153 }
153 154
154 VideoCaptureController::VideoCaptureDeviceClient::VideoCaptureDeviceClient( 155 VideoCaptureController::VideoCaptureDeviceClient::VideoCaptureDeviceClient(
155 const base::WeakPtr<VideoCaptureController>& controller, 156 const base::WeakPtr<VideoCaptureController>& controller,
156 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool) 157 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool)
157 : controller_(controller), buffer_pool_(buffer_pool), first_frame_(true) {} 158 : controller_(controller), buffer_pool_(buffer_pool), first_frame_(true) {}
158 159
159 VideoCaptureController::VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {} 160 VideoCaptureController::VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {}
160 161
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 287 }
287 288
288 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedData( 289 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedData(
289 const uint8* data, 290 const uint8* data,
290 int length, 291 int length,
291 const VideoCaptureFormat& frame_format, 292 const VideoCaptureFormat& frame_format,
292 int rotation, 293 int rotation,
293 base::TimeTicks timestamp) { 294 base::TimeTicks timestamp) {
294 TRACE_EVENT0("video", "VideoCaptureController::OnIncomingCapturedData"); 295 TRACE_EVENT0("video", "VideoCaptureController::OnIncomingCapturedData");
295 296
297 if (controller_) {
298 switch (controller_->display_rotation()) {
299 case gfx::Display::ROTATE_0:
300 break;
301 case gfx::Display::ROTATE_90:
302 rotation = (rotation + 90) % 360;
303 break;
304 case gfx::Display::ROTATE_180:
305 rotation = (rotation + 180) % 360;
306 break;
307 case gfx::Display::ROTATE_270:
308 rotation = (rotation + 270) % 360;
309 break;
310 }
311 }
296 if (!frame_format.IsValid()) 312 if (!frame_format.IsValid())
297 return; 313 return;
298 314
299 // Chopped pixels in width/height in case video capture device has odd 315 // Chopped pixels in width/height in case video capture device has odd
300 // numbers for width/height. 316 // numbers for width/height.
301 int chopped_width = 0; 317 int chopped_width = 0;
302 int chopped_height = 0; 318 int chopped_height = 0;
303 int new_unrotated_width = frame_format.frame_size.width(); 319 int new_unrotated_width = frame_format.frame_size.width();
304 int new_unrotated_height = frame_format.frame_size.height(); 320 int new_unrotated_height = frame_format.frame_size.height();
305 321
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 } 651 }
636 return NULL; 652 return NULL;
637 } 653 }
638 654
639 int VideoCaptureController::GetClientCount() { 655 int VideoCaptureController::GetClientCount() {
640 DCHECK_CURRENTLY_ON(BrowserThread::IO); 656 DCHECK_CURRENTLY_ON(BrowserThread::IO);
641 return controller_clients_.size(); 657 return controller_clients_.size();
642 } 658 }
643 659
644 } // namespace content 660 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698