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

Side by Side Diff: media/base/video_capture_types.h

Issue 1124263004: New resolution change policies for desktop and tab capture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from mcasas. Created 5 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
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 #ifndef MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ 5 #ifndef MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
6 #define MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ 6 #define MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
(...skipping 16 matching lines...) Expand all
27 PIXEL_FORMAT_RGB24, 27 PIXEL_FORMAT_RGB24,
28 PIXEL_FORMAT_RGB32, 28 PIXEL_FORMAT_RGB32,
29 PIXEL_FORMAT_ARGB, 29 PIXEL_FORMAT_ARGB,
30 PIXEL_FORMAT_MJPEG, 30 PIXEL_FORMAT_MJPEG,
31 PIXEL_FORMAT_TEXTURE, // Capture format as a GL texture. 31 PIXEL_FORMAT_TEXTURE, // Capture format as a GL texture.
32 PIXEL_FORMAT_GPUMEMORYBUFFER, 32 PIXEL_FORMAT_GPUMEMORYBUFFER,
33 PIXEL_FORMAT_UNKNOWN, // Color format not set. 33 PIXEL_FORMAT_UNKNOWN, // Color format not set.
34 PIXEL_FORMAT_MAX, 34 PIXEL_FORMAT_MAX,
35 }; 35 };
36 36
37 // Policies for capture devices that has source content with dynamic resolution. 37 // Policies for capture devices that have source content that varies in size.
38 // It is up to the implementation how the captured content will be transformed
39 // (e.g., scaling and/or letterboxing) in order to produce video frames that
40 // strictly adheree to one of these policies.
38 enum ResolutionChangePolicy { 41 enum ResolutionChangePolicy {
39 // Capture device outputs a fixed resolution all the time. The resolution of 42 // Capture device outputs a fixed resolution all the time. The resolution of
40 // the first frame is the resolution for all frames. 43 // the first frame is the resolution for all frames.
41 // It is implementation specific for the capture device to scale, letter-box 44 RESOLUTION_POLICY_FIXED_RESOLUTION,
42 // and pillar-box. The only guarantee is that resolution will never change.
43 RESOLUTION_POLICY_FIXED,
44 45
45 // Capture device outputs frames with dynamic resolution. The width and height 46 // Capture device is allowed to output frames of varying resolutions. The
46 // will not exceed the maximum dimensions specified. The typical scenario is 47 // width and height will not exceed the maximum dimensions specified. The
47 // the frames will have the same aspect ratio as the original content and 48 // aspect ratio of the frames will match the aspect ratio of the maximum
48 // scaled down to fit inside the limit. 49 // dimensions as closely as possible.
49 RESOLUTION_POLICY_DYNAMIC_WITHIN_LIMIT, 50 RESOLUTION_POLICY_FIXED_ASPECT_RATIO,
51
52 // Capture device is allowed to output frames of varying resolutions not
53 // exceeding the maximum dimensions specified.
54 RESOLUTION_POLICY_ANY_WITHIN_LIMIT,
50 55
51 RESOLUTION_POLICY_LAST, 56 RESOLUTION_POLICY_LAST,
52 }; 57 };
53 58
54 // Some drivers use rational time per frame instead of float frame rate, this 59 // Some drivers use rational time per frame instead of float frame rate, this
55 // constant k is used to convert between both: A fps -> [k/k*A] seconds/frame. 60 // constant k is used to convert between both: A fps -> [k/k*A] seconds/frame.
56 const int kFrameRatePrecision = 10000; 61 const int kFrameRatePrecision = 10000;
57 62
58 // Video capture format specification. 63 // Video capture format specification.
59 // This class is used by the video capture device to specify the format of every 64 // This class is used by the video capture device to specify the format of every
(...skipping 10 matching lines...) Expand all
70 static std::string PixelFormatToString(VideoPixelFormat format); 75 static std::string PixelFormatToString(VideoPixelFormat format);
71 76
72 // Returns the required buffer size to hold an image of a given 77 // Returns the required buffer size to hold an image of a given
73 // VideoCaptureFormat with no padding and tightly packed. 78 // VideoCaptureFormat with no padding and tightly packed.
74 size_t ImageAllocationSize() const; 79 size_t ImageAllocationSize() const;
75 80
76 // Checks that all values are in the expected range. All limits are specified 81 // Checks that all values are in the expected range. All limits are specified
77 // in media::Limits. 82 // in media::Limits.
78 bool IsValid() const; 83 bool IsValid() const;
79 84
85 bool operator==(const VideoCaptureFormat& other) const {
86 return frame_size == other.frame_size &&
87 frame_rate == other.frame_rate &&
88 pixel_format == other.pixel_format;
89 }
90
80 gfx::Size frame_size; 91 gfx::Size frame_size;
81 float frame_rate; 92 float frame_rate;
82 VideoPixelFormat pixel_format; 93 VideoPixelFormat pixel_format;
83 }; 94 };
84 95
85 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; 96 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats;
86 97
87 // Parameters for starting video capture. 98 // Parameters for starting video capture.
88 // This class is used by the client of a video capture device to specify the 99 // This class is used by the client of a video capture device to specify the
89 // format of frames in which the client would like to have captured frames 100 // format of frames in which the client would like to have captured frames
90 // returned. 101 // returned.
91 class MEDIA_EXPORT VideoCaptureParams { 102 class MEDIA_EXPORT VideoCaptureParams {
92 public: 103 public:
93 VideoCaptureParams(); 104 VideoCaptureParams();
94 105
106 bool operator==(const VideoCaptureParams& other) const {
107 return requested_format == other.requested_format &&
108 resolution_change_policy == other.resolution_change_policy;
109 }
110
95 // Requests a resolution and format at which the capture will occur. 111 // Requests a resolution and format at which the capture will occur.
96 VideoCaptureFormat requested_format; 112 VideoCaptureFormat requested_format;
97 113
98 // Policy for resolution change. 114 // Policy for resolution change.
99 ResolutionChangePolicy resolution_change_policy; 115 ResolutionChangePolicy resolution_change_policy;
100 }; 116 };
101 117
102 } // namespace media 118 } // namespace media
103 119
104 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ 120 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698