[Ozone-Gbm] Explicitly crash if trying software rendering on GBM
[chromium-blink-merge.git] / media / base / video_capture_types.h
blob8ca8ed6bc809f4d7834a67925fd7500ff588d230
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_ARGB,
29 PIXEL_FORMAT_MJPEG,
30 PIXEL_FORMAT_TEXTURE, // Capture format as a GL texture.
31 PIXEL_FORMAT_UNKNOWN, // Color format not set.
32 PIXEL_FORMAT_MAX,
35 // Policies for capture devices that has source content with dynamic resolution.
36 enum ResolutionChangePolicy {
37 // Capture device outputs a fixed resolution all the time. The resolution of
38 // the first frame is the resolution for all frames.
39 // It is implementation specific for the capture device to scale, letter-box
40 // and pillar-box. The only guarantee is that resolution will never change.
41 RESOLUTION_POLICY_FIXED,
43 // Capture device outputs frames with dynamic resolution. The width and height
44 // will not exceed the maximum dimensions specified. The typical scenario is
45 // the frames will have the same aspect ratio as the original content and
46 // scaled down to fit inside the limit.
47 RESOLUTION_POLICY_DYNAMIC_WITHIN_LIMIT,
49 RESOLUTION_POLICY_LAST,
52 // Some drivers use rational time per frame instead of float frame rate, this
53 // constant k is used to convert between both: A fps -> [k/k*A] seconds/frame.
54 const int kFrameRatePrecision = 10000;
56 // Video capture format specification.
57 // This class is used by the video capture device to specify the format of every
58 // frame captured and returned to a client. It is also used to specify a
59 // supported capture format by a device.
60 class MEDIA_EXPORT VideoCaptureFormat {
61 public:
62 VideoCaptureFormat();
63 VideoCaptureFormat(const gfx::Size& frame_size,
64 float frame_rate,
65 VideoPixelFormat pixel_format);
67 std::string ToString() const;
68 static std::string PixelFormatToString(VideoPixelFormat format);
70 // Returns the required buffer size to hold an image of a given
71 // VideoCaptureFormat with no padding and tightly packed.
72 size_t ImageAllocationSize() const;
74 // Checks that all values are in the expected range. All limits are specified
75 // in media::Limits.
76 bool IsValid() const;
78 gfx::Size frame_size;
79 float frame_rate;
80 VideoPixelFormat pixel_format;
83 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats;
85 // Parameters for starting video capture.
86 // This class is used by the client of a video capture device to specify the
87 // format of frames in which the client would like to have captured frames
88 // returned.
89 class MEDIA_EXPORT VideoCaptureParams {
90 public:
91 VideoCaptureParams();
93 // Requests a resolution and format at which the capture will occur.
94 VideoCaptureFormat requested_format;
96 // Policy for resolution change.
97 ResolutionChangePolicy resolution_change_policy;
100 } // namespace media
102 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_