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

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

Issue 2415703002: Move files video_capture*.* from media/base to media/capture (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « media/base/ipc/media_param_traits_macros.h ('k') | media/base/video_capture_types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
6 #define MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
7
8 #include <stddef.h>
9
10 #include <vector>
11
12 #include "build/build_config.h"
13 #include "media/base/media_export.h"
14 #include "media/base/video_types.h"
15 #include "ui/gfx/geometry/size.h"
16
17 namespace media {
18
19 // TODO(wjia): this type should be defined in a common place and
20 // shared with device manager.
21 typedef int VideoCaptureSessionId;
22
23 // Storage type for the pixels.
24 // TODO(mcasas): http://crbug.com/504160 Consider making this an enum class.
25 // TODO(chfremer): Extend or remove this enum.
26 enum VideoPixelStorage {
27 PIXEL_STORAGE_CPU,
28 PIXEL_STORAGE_MAX = PIXEL_STORAGE_CPU,
29 };
30
31 // Policies for capture devices that have source content that varies in size.
32 // It is up to the implementation how the captured content will be transformed
33 // (e.g., scaling and/or letterboxing) in order to produce video frames that
34 // strictly adheree to one of these policies.
35 enum ResolutionChangePolicy {
36 // Capture device outputs a fixed resolution all the time. The resolution of
37 // the first frame is the resolution for all frames.
38 RESOLUTION_POLICY_FIXED_RESOLUTION,
39
40 // Capture device is allowed to output frames of varying resolutions. The
41 // width and height will not exceed the maximum dimensions specified. The
42 // aspect ratio of the frames will match the aspect ratio of the maximum
43 // dimensions as closely as possible.
44 RESOLUTION_POLICY_FIXED_ASPECT_RATIO,
45
46 // Capture device is allowed to output frames of varying resolutions not
47 // exceeding the maximum dimensions specified.
48 RESOLUTION_POLICY_ANY_WITHIN_LIMIT,
49
50 // Must always be equal to largest entry in the enum.
51 RESOLUTION_POLICY_LAST = RESOLUTION_POLICY_ANY_WITHIN_LIMIT,
52 };
53
54 // Potential values of the googPowerLineFrequency optional constraint passed to
55 // getUserMedia. Note that the numeric values are currently significant, and are
56 // used to map enum values to corresponding frequency values.
57 // TODO(ajose): http://crbug.com/525167 Consider making this a class.
58 enum class PowerLineFrequency {
59 FREQUENCY_DEFAULT = 0,
60 FREQUENCY_50HZ = 50,
61 FREQUENCY_60HZ = 60,
62 FREQUENCY_MAX = FREQUENCY_60HZ
63 };
64
65 // Assert that the int:frequency mapping is correct.
66 static_assert(static_cast<int>(PowerLineFrequency::FREQUENCY_DEFAULT) == 0,
67 "static_cast<int>(FREQUENCY_DEFAULT) must equal 0.");
68 static_assert(static_cast<int>(PowerLineFrequency::FREQUENCY_50HZ) == 50,
69 "static_cast<int>(FREQUENCY_DEFAULT) must equal 50.");
70 static_assert(static_cast<int>(PowerLineFrequency::FREQUENCY_60HZ) == 60,
71 "static_cast<int>(FREQUENCY_DEFAULT) must equal 60.");
72
73 // Some drivers use rational time per frame instead of float frame rate, this
74 // constant k is used to convert between both: A fps -> [k/k*A] seconds/frame.
75 const int kFrameRatePrecision = 10000;
76
77 // Video capture format specification.
78 // This class is used by the video capture device to specify the format of every
79 // frame captured and returned to a client. It is also used to specify a
80 // supported capture format by a device.
81 struct MEDIA_EXPORT VideoCaptureFormat {
82 VideoCaptureFormat();
83 VideoCaptureFormat(const gfx::Size& frame_size,
84 float frame_rate,
85 VideoPixelFormat pixel_format);
86 VideoCaptureFormat(const gfx::Size& frame_size,
87 float frame_rate,
88 VideoPixelFormat pixel_format,
89 VideoPixelStorage pixel_storage);
90
91 static std::string ToString(const VideoCaptureFormat& format);
92 static std::string PixelStorageToString(VideoPixelStorage storage);
93
94 // Compares the priority of the pixel formats. Returns true if |lhs| is the
95 // preferred pixel format in comparison with |rhs|. Returns false otherwise.
96 static bool ComparePixelFormatPreference(const VideoPixelFormat& lhs,
97 const VideoPixelFormat& rhs);
98
99 // Returns the required buffer size to hold an image of a given
100 // VideoCaptureFormat with no padding and tightly packed.
101 size_t ImageAllocationSize() const;
102
103 // Checks that all values are in the expected range. All limits are specified
104 // in media::Limits.
105 bool IsValid() const;
106
107 bool operator==(const VideoCaptureFormat& other) const {
108 return frame_size == other.frame_size &&
109 frame_rate == other.frame_rate &&
110 pixel_format == other.pixel_format;
111 }
112
113 gfx::Size frame_size;
114 float frame_rate;
115 VideoPixelFormat pixel_format;
116 VideoPixelStorage pixel_storage;
117 };
118
119 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats;
120
121 // Parameters for starting video capture.
122 // This class is used by the client of a video capture device to specify the
123 // format of frames in which the client would like to have captured frames
124 // returned.
125 struct MEDIA_EXPORT VideoCaptureParams {
126 VideoCaptureParams();
127
128 // Returns true if requested_format.IsValid() and all other values are within
129 // their expected ranges.
130 bool IsValid() const;
131
132 bool operator==(const VideoCaptureParams& other) const {
133 return requested_format == other.requested_format &&
134 resolution_change_policy == other.resolution_change_policy &&
135 power_line_frequency == other.power_line_frequency;
136 }
137
138 // Requests a resolution and format at which the capture will occur.
139 VideoCaptureFormat requested_format;
140
141 // Policy for resolution change.
142 ResolutionChangePolicy resolution_change_policy;
143
144 // User-specified power line frequency.
145 PowerLineFrequency power_line_frequency;
146 };
147
148 } // namespace media
149
150 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
OLDNEW
« no previous file with comments | « media/base/ipc/media_param_traits_macros.h ('k') | media/base/video_capture_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698