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

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

Issue 100313002: Fix screen capture slowness in Chrome OS feedback report. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add OWNERS for video_capture_device_impl* which got refactored from web_contents_*. Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_device_impl.h" 5 #include "content/browser/renderer_host/media/video_capture_device_impl.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 26 matching lines...) Expand all
37 capture_machine->Stop(); 37 capture_machine->Stop();
38 capture_machine.reset(); 38 capture_machine.reset();
39 } 39 }
40 } 40 }
41 41
42 } // namespace 42 } // namespace
43 43
44 ThreadSafeCaptureOracle::ThreadSafeCaptureOracle( 44 ThreadSafeCaptureOracle::ThreadSafeCaptureOracle(
45 scoped_ptr<media::VideoCaptureDevice::Client> client, 45 scoped_ptr<media::VideoCaptureDevice::Client> client,
46 scoped_ptr<VideoCaptureOracle> oracle, 46 scoped_ptr<VideoCaptureOracle> oracle,
47 const gfx::Size& capture_size, 47 const gfx::Size& max_frame_size,
48 int frame_rate) 48 int frame_rate)
49 : client_(client.Pass()), 49 : client_(client.Pass()),
50 oracle_(oracle.Pass()), 50 oracle_(oracle.Pass()),
51 capture_size_(capture_size), 51 max_frame_size_(max_frame_size),
52 frame_rate_(frame_rate) {} 52 frame_rate_(frame_rate) {
53 // Set initial capture size to maximum frame size.
54 capture_size_ = max_frame_size_;
55 }
53 56
54 ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() {} 57 ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() {}
55 58
56 bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture( 59 bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
57 VideoCaptureOracle::Event event, 60 VideoCaptureOracle::Event event,
58 base::Time event_time, 61 base::Time event_time,
59 scoped_refptr<media::VideoFrame>* storage, 62 scoped_refptr<media::VideoFrame>* storage,
60 CaptureFrameCallback* callback) { 63 CaptureFrameCallback* callback) {
61 base::AutoLock guard(lock_); 64 base::AutoLock guard(lock_);
62 65
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 gfx::Rect(capture_size_), 118 gfx::Rect(capture_size_),
116 capture_size_, 119 capture_size_,
117 static_cast<uint8*>(output_buffer->data()), 120 static_cast<uint8*>(output_buffer->data()),
118 output_buffer->size(), 121 output_buffer->size(),
119 base::SharedMemory::NULLHandle(), 122 base::SharedMemory::NULLHandle(),
120 base::TimeDelta(), 123 base::TimeDelta(),
121 base::Closure()); 124 base::Closure());
122 return true; 125 return true;
123 } 126 }
124 127
128 void ThreadSafeCaptureOracle::UpdateCaptureSize(const gfx::Size& source_size) {
129 base::AutoLock guard(lock_);
130
131 // The capture resolution should not exceed the source frame size.
132 // In other words it should downscale the image but not upscale it.
133 gfx::Size capture_size = max_frame_size_;
134 capture_size.SetToMin(source_size);
135 capture_size_ = capture_size;
136 }
137
125 void ThreadSafeCaptureOracle::Stop() { 138 void ThreadSafeCaptureOracle::Stop() {
126 base::AutoLock guard(lock_); 139 base::AutoLock guard(lock_);
127 client_.reset(); 140 client_.reset();
128 } 141 }
129 142
130 void ThreadSafeCaptureOracle::ReportError() { 143 void ThreadSafeCaptureOracle::ReportError() {
131 base::AutoLock guard(lock_); 144 base::AutoLock guard(lock_);
132 if (client_) 145 if (client_)
133 client_->OnError(); 146 client_->OnError();
134 } 147 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return; 284 return;
272 285
273 if (oracle_proxy_) 286 if (oracle_proxy_)
274 oracle_proxy_->ReportError(); 287 oracle_proxy_->ReportError();
275 288
276 StopAndDeAllocate(); 289 StopAndDeAllocate();
277 TransitionStateTo(kError); 290 TransitionStateTo(kError);
278 } 291 }
279 292
280 } // namespace content 293 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698