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 |
mcasas
2015/05/07 22:10:00
nit: I'd refactor this comment out, somehow saying
miu
2015/05/08 06:43:34
Done.
| |
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, | |
mcasas
2015/05/07 22:10:00
IIUC, only Desktop and Tab capture really care abo
miu
2015/05/08 06:43:34
Yes, that is correct. The current implementations
| |
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 |
(...skipping 10 matching lines...) Expand all Loading... | |
70 static std::string PixelFormatToString(VideoPixelFormat format); | 77 static std::string PixelFormatToString(VideoPixelFormat format); |
71 | 78 |
72 // Returns the required buffer size to hold an image of a given | 79 // Returns the required buffer size to hold an image of a given |
73 // VideoCaptureFormat with no padding and tightly packed. | 80 // VideoCaptureFormat with no padding and tightly packed. |
74 size_t ImageAllocationSize() const; | 81 size_t ImageAllocationSize() const; |
75 | 82 |
76 // Checks that all values are in the expected range. All limits are specified | 83 // Checks that all values are in the expected range. All limits are specified |
77 // in media::Limits. | 84 // in media::Limits. |
78 bool IsValid() const; | 85 bool IsValid() const; |
79 | 86 |
87 bool operator==(const VideoCaptureFormat& other) const { | |
88 return frame_size == other.frame_size && | |
89 frame_rate == other.frame_rate && | |
90 pixel_format == other.pixel_format; | |
91 } | |
92 | |
80 gfx::Size frame_size; | 93 gfx::Size frame_size; |
81 float frame_rate; | 94 float frame_rate; |
82 VideoPixelFormat pixel_format; | 95 VideoPixelFormat pixel_format; |
83 }; | 96 }; |
84 | 97 |
85 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; | 98 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; |
86 | 99 |
87 // Parameters for starting video capture. | 100 // Parameters for starting video capture. |
88 // This class is used by the client of a video capture device to specify the | 101 // 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 | 102 // format of frames in which the client would like to have captured frames |
90 // returned. | 103 // returned. |
91 class MEDIA_EXPORT VideoCaptureParams { | 104 class MEDIA_EXPORT VideoCaptureParams { |
92 public: | 105 public: |
93 VideoCaptureParams(); | 106 VideoCaptureParams(); |
94 | 107 |
108 bool operator==(const VideoCaptureParams& other) const { | |
109 return requested_format == other.requested_format && | |
110 resolution_change_policy == other.resolution_change_policy; | |
111 } | |
112 | |
95 // Requests a resolution and format at which the capture will occur. | 113 // Requests a resolution and format at which the capture will occur. |
96 VideoCaptureFormat requested_format; | 114 VideoCaptureFormat requested_format; |
97 | 115 |
98 // Policy for resolution change. | 116 // Policy for resolution change. |
99 ResolutionChangePolicy resolution_change_policy; | 117 ResolutionChangePolicy resolution_change_policy; |
100 }; | 118 }; |
101 | 119 |
102 } // namespace media | 120 } // namespace media |
103 | 121 |
104 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ | 122 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ |
OLD | NEW |