Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / media / base / video_capture_types.h
blobc849ed7b35f9673d9112da267904754c9aafd25e
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.
5 #ifndef MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
6 #define MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
8 #include <vector>
10 #include "media/base/media_export.h"
11 #include "ui/gfx/geometry/size.h"
13 namespace media {
15 // TODO(wjia): this type should be defined in a common place and
16 // shared with device manager.
17 typedef int VideoCaptureSessionId;
19 // Color formats from camera. This list is sorted in order of preference.
20 enum VideoPixelFormat {
21 PIXEL_FORMAT_I420,
22 PIXEL_FORMAT_YV12,
23 PIXEL_FORMAT_NV12,
24 PIXEL_FORMAT_NV21,
25 PIXEL_FORMAT_UYVY,
26 PIXEL_FORMAT_YUY2,
27 PIXEL_FORMAT_RGB24,
28 PIXEL_FORMAT_RGB32,
29 PIXEL_FORMAT_ARGB,
30 PIXEL_FORMAT_MJPEG,
31 PIXEL_FORMAT_TEXTURE, // Capture format as a GL texture.
32 PIXEL_FORMAT_GPUMEMORYBUFFER,
33 PIXEL_FORMAT_UNKNOWN, // Color format not set.
34 PIXEL_FORMAT_MAX,
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.
41 enum ResolutionChangePolicy {
42 // Capture device outputs a fixed resolution all the time. The resolution of
43 // the first frame is the resolution for all frames.
44 RESOLUTION_POLICY_FIXED_RESOLUTION,
46 // Capture device is allowed to output frames of varying resolutions. The
47 // width and height will not exceed the maximum dimensions specified. The
48 // aspect ratio of the frames will match the aspect ratio of the maximum
49 // dimensions as closely as possible.
50 RESOLUTION_POLICY_FIXED_ASPECT_RATIO,
52 // Capture device is allowed to output frames of varying resolutions not
53 // exceeding the maximum dimensions specified.
54 RESOLUTION_POLICY_ANY_WITHIN_LIMIT,
56 RESOLUTION_POLICY_LAST,
59 // Some drivers use rational time per frame instead of float frame rate, this
60 // constant k is used to convert between both: A fps -> [k/k*A] seconds/frame.
61 const int kFrameRatePrecision = 10000;
63 // Video capture format specification.
64 // This class is used by the video capture device to specify the format of every
65 // frame captured and returned to a client. It is also used to specify a
66 // supported capture format by a device.
67 class MEDIA_EXPORT VideoCaptureFormat {
68 public:
69 VideoCaptureFormat();
70 VideoCaptureFormat(const gfx::Size& frame_size,
71 float frame_rate,
72 VideoPixelFormat pixel_format);
74 std::string ToString() const;
75 static std::string PixelFormatToString(VideoPixelFormat format);
77 // Returns the required buffer size to hold an image of a given
78 // VideoCaptureFormat with no padding and tightly packed.
79 size_t ImageAllocationSize() const;
81 // Checks that all values are in the expected range. All limits are specified
82 // in media::Limits.
83 bool IsValid() const;
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;
91 gfx::Size frame_size;
92 float frame_rate;
93 VideoPixelFormat pixel_format;
96 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats;
98 // Parameters for starting video capture.
99 // This class is used by the client of a video capture device to specify the
100 // format of frames in which the client would like to have captured frames
101 // returned.
102 class MEDIA_EXPORT VideoCaptureParams {
103 public:
104 VideoCaptureParams();
106 bool operator==(const VideoCaptureParams& other) const {
107 return requested_format == other.requested_format &&
108 resolution_change_policy == other.resolution_change_policy;
111 // Requests a resolution and format at which the capture will occur.
112 VideoCaptureFormat requested_format;
114 // Policy for resolution change.
115 ResolutionChangePolicy resolution_change_policy;
118 } // namespace media
120 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_