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

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

Issue 103253003: Prevent upscaling in desktop capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 void ThreadSafeCaptureOracle::UpdateCaptureSize(const gfx::Size& source_size) { 132 void ThreadSafeCaptureOracle::UpdateCaptureSize(const gfx::Size& source_size) {
133 base::AutoLock guard(lock_); 133 base::AutoLock guard(lock_);
134 134
135 // If this is the first call to UpdateCaptureSize(), or the receiver supports 135 // If this is the first call to UpdateCaptureSize(), or the receiver supports
136 // variable resolution, then determine the capture size by treating the 136 // variable resolution, then determine the capture size by treating the
137 // requested width and height as maxima. 137 // requested width and height as maxima.
138 if (!capture_size_updated_ || params_.allow_resolution_change) { 138 if (!capture_size_updated_ || params_.allow_resolution_change) {
139 // The capture resolution should not exceed the source frame size. 139 // The capture resolution should not exceed the source frame size.
140 // In other words it should downscale the image but not upscale it. 140 // In other words it should downscale the image but not upscale it.
141 gfx::Rect capture_rect = media::ComputeLetterboxRegion( 141 if (source_size.width() > params_.requested_format.frame_size.width() ||
142 gfx::Rect(params_.requested_format.frame_size), source_size); 142 source_size.height() > params_.requested_format.frame_size.height()) {
143 capture_size_ = gfx::Size(MakeEven(capture_rect.width()), 143 gfx::Rect capture_rect = media::ComputeLetterboxRegion(
144 MakeEven(capture_rect.height())); 144 gfx::Rect(params_.requested_format.frame_size), source_size);
145 capture_size_ = gfx::Size(MakeEven(capture_rect.width()),
146 MakeEven(capture_rect.height()));
147 } else {
148 capture_size_ = gfx::Size(MakeEven(source_size.width()),
149 MakeEven(source_size.height()));
150 }
145 capture_size_updated_ = true; 151 capture_size_updated_ = true;
146 } 152 }
147 } 153 }
148 154
149 void ThreadSafeCaptureOracle::Stop() { 155 void ThreadSafeCaptureOracle::Stop() {
150 base::AutoLock guard(lock_); 156 base::AutoLock guard(lock_);
151 client_.reset(); 157 client_.reset();
152 } 158 }
153 159
154 void ThreadSafeCaptureOracle::ReportError() { 160 void ThreadSafeCaptureOracle::ReportError() {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return; 295 return;
290 296
291 if (oracle_proxy_) 297 if (oracle_proxy_)
292 oracle_proxy_->ReportError(); 298 oracle_proxy_->ReportError();
293 299
294 StopAndDeAllocate(); 300 StopAndDeAllocate();
295 TransitionStateTo(kError); 301 TransitionStateTo(kError);
296 } 302 }
297 303
298 } // namespace content 304 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698