1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAPTURE_CAPTURE_RESOLUTION_CHOOSER_H_
6 #define MEDIA_CAPTURE_CAPTURE_RESOLUTION_CHOOSER_H_
8 #include "media/base/media_export.h"
9 #include "media/base/video_capture_types.h"
10 #include "ui/gfx/geometry/size.h"
14 // Encapsulates the logic that determines the capture frame resolution based on:
15 // 1. The configured maximum frame resolution and resolution change policy.
16 // 2. The resolution of the source content.
17 // 3. The current capabilities of the end-to-end system, in terms of the
18 // maximum number of pixels per frame.
19 class MEDIA_EXPORT CaptureResolutionChooser
{
21 // media::ResolutionChangePolicy determines whether the variable frame
22 // resolutions being computed must adhere to a fixed aspect ratio or not, or
23 // that there must only be a single fixed resolution.
24 CaptureResolutionChooser(
25 const gfx::Size
& max_frame_size
,
26 ResolutionChangePolicy resolution_change_policy
);
27 ~CaptureResolutionChooser();
29 // Returns the current capture frame resolution to use.
30 gfx::Size
capture_size() const {
34 // Updates the capture size based on a change in the resolution of the source
36 void SetSourceSize(const gfx::Size
& source_size
);
39 // Called after any update that requires |capture_size_| be re-computed.
40 void RecomputeCaptureSize();
43 const gfx::Size max_frame_size_
;
44 const gfx::Size min_frame_size_
; // Computed from the ctor arguments.
46 // Specifies the set of heuristics to use.
47 const ResolutionChangePolicy resolution_change_policy_
;
49 // The capture frame resolution to use, ignoring the limitations imposed by
50 // the capability metric.
51 gfx::Size constrained_size_
;
53 // The current computed capture frame resolution.
54 gfx::Size capture_size_
;
59 #endif // MEDIA_CAPTURE_RESOLUTION_CHOOSER_H_