OLD | NEW |
---|---|
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 20 matching lines...) Expand all Loading... | |
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 has source content with dynamic resolution. |
38 enum ResolutionChangePolicy { | 38 enum ResolutionChangePolicy { |
39 // Capture device outputs a fixed resolution all the time. The resolution of | 39 // Capture device outputs a fixed resolution all the time. The resolution of |
40 // the first frame is the resolution for all frames. | 40 // the first frame is the resolution for all frames. |
41 // It is implementation specific for the capture device to scale, letter-box | 41 // It is implementation-specific for the capture device to scale, letter-box |
42 // and pillar-box. The only guarantee is that resolution will never change. | 42 // and pillar-box. The only guarantee is that resolution will never change. |
43 RESOLUTION_POLICY_FIXED, | 43 RESOLUTION_POLICY_FIXED_RESOLUTION, |
44 | 44 |
45 // Capture device outputs frames with dynamic resolution. The width and height | 45 // Capture device is allowed to output frames of varying resolutions. The |
46 // will not exceed the maximum dimensions specified. The typical scenario is | 46 // 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 | 47 // aspect ratio of the frames will be fixed to the aspect ratio of the maximum |
48 // scaled down to fit inside the limit. | 48 // dimensions. |
49 RESOLUTION_POLICY_DYNAMIC_WITHIN_LIMIT, | 49 // It is implementation-specific for the capture device to scale, letter-box |
50 // and pillar-box. The only guarantee is that the aspect ratio will never | |
51 // change. | |
52 RESOLUTION_POLICY_FIXED_ASPECT_RATIO, | |
53 | |
54 // Capture device is allowed to output frames of varying resolutions not | |
55 // exceeding the maximum dimensions specified. | |
56 RESOLUTION_POLICY_ANY_WITHIN_LIMIT, | |
50 | 57 |
51 RESOLUTION_POLICY_LAST, | 58 RESOLUTION_POLICY_LAST, |
52 }; | 59 }; |
53 | 60 |
54 // Some drivers use rational time per frame instead of float frame rate, this | 61 // 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. | 62 // constant k is used to convert between both: A fps -> [k/k*A] seconds/frame. |
56 const int kFrameRatePrecision = 10000; | 63 const int kFrameRatePrecision = 10000; |
57 | 64 |
58 // Video capture format specification. | 65 // Video capture format specification. |
59 // This class is used by the video capture device to specify the format of every | 66 // This class is used by the video capture device to specify the format of every |
60 // frame captured and returned to a client. It is also used to specify a | 67 // frame captured and returned to a client. It is also used to specify a |
61 // supported capture format by a device. | 68 // supported capture format by a device. |
62 class MEDIA_EXPORT VideoCaptureFormat { | 69 class MEDIA_EXPORT VideoCaptureFormat { |
63 public: | 70 public: |
64 VideoCaptureFormat(); | 71 VideoCaptureFormat(); |
65 VideoCaptureFormat(const gfx::Size& frame_size, | 72 VideoCaptureFormat(const gfx::Size& frame_size, |
66 float frame_rate, | 73 float frame_rate, |
67 VideoPixelFormat pixel_format); | 74 VideoPixelFormat pixel_format); |
68 | 75 |
76 bool operator==(const VideoCaptureFormat& other) const; | |
miu
2015/05/07 00:54:22
Note: I added an operator==() method here and belo
DaleCurtis
2015/05/07 01:13:38
If it's just for tests you can use MATCHER_P()
ht
miu
2015/05/07 02:49:18
Done. Good point here. I went with the inline op
| |
77 | |
69 std::string ToString() const; | 78 std::string ToString() const; |
70 static std::string PixelFormatToString(VideoPixelFormat format); | 79 static std::string PixelFormatToString(VideoPixelFormat format); |
71 | 80 |
72 // Returns the required buffer size to hold an image of a given | 81 // Returns the required buffer size to hold an image of a given |
73 // VideoCaptureFormat with no padding and tightly packed. | 82 // VideoCaptureFormat with no padding and tightly packed. |
74 size_t ImageAllocationSize() const; | 83 size_t ImageAllocationSize() const; |
75 | 84 |
76 // Checks that all values are in the expected range. All limits are specified | 85 // Checks that all values are in the expected range. All limits are specified |
77 // in media::Limits. | 86 // in media::Limits. |
78 bool IsValid() const; | 87 bool IsValid() const; |
79 | 88 |
80 gfx::Size frame_size; | 89 gfx::Size frame_size; |
81 float frame_rate; | 90 float frame_rate; |
82 VideoPixelFormat pixel_format; | 91 VideoPixelFormat pixel_format; |
83 }; | 92 }; |
84 | 93 |
85 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; | 94 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; |
86 | 95 |
87 // Parameters for starting video capture. | 96 // Parameters for starting video capture. |
88 // This class is used by the client of a video capture device to specify the | 97 // 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 | 98 // format of frames in which the client would like to have captured frames |
90 // returned. | 99 // returned. |
91 class MEDIA_EXPORT VideoCaptureParams { | 100 class MEDIA_EXPORT VideoCaptureParams { |
92 public: | 101 public: |
93 VideoCaptureParams(); | 102 VideoCaptureParams(); |
94 | 103 |
104 bool operator==(const VideoCaptureParams& other) const; | |
105 | |
95 // Requests a resolution and format at which the capture will occur. | 106 // Requests a resolution and format at which the capture will occur. |
96 VideoCaptureFormat requested_format; | 107 VideoCaptureFormat requested_format; |
97 | 108 |
98 // Policy for resolution change. | 109 // Policy for resolution change. |
99 ResolutionChangePolicy resolution_change_policy; | 110 ResolutionChangePolicy resolution_change_policy; |
100 }; | 111 }; |
101 | 112 |
102 } // namespace media | 113 } // namespace media |
103 | 114 |
104 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ | 115 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ |
OLD | NEW |