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 "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
12 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 | 15 |
16 // TODO(wjia): this type should be defined in a common place and | 16 // TODO(wjia): this type should be defined in a common place and |
17 // shared with device manager. | 17 // shared with device manager. |
18 typedef int VideoCaptureSessionId; | 18 typedef int VideoCaptureSessionId; |
19 | 19 |
20 // Color formats from camera. This list is sorted in order of preference. | 20 // Color formats from camera. This list is sorted in order of preference. |
21 // TODO(mcasas): Consider if this list can be merged with media::Format. | |
22 enum VideoPixelFormat { | 21 enum VideoPixelFormat { |
23 PIXEL_FORMAT_I420, | 22 PIXEL_FORMAT_I420, |
24 PIXEL_FORMAT_YV12, | 23 PIXEL_FORMAT_YV12, |
25 PIXEL_FORMAT_NV12, | 24 PIXEL_FORMAT_NV12, |
26 PIXEL_FORMAT_NV21, | 25 PIXEL_FORMAT_NV21, |
27 PIXEL_FORMAT_UYVY, | 26 PIXEL_FORMAT_UYVY, |
28 PIXEL_FORMAT_YUY2, | 27 PIXEL_FORMAT_YUY2, |
29 PIXEL_FORMAT_RGB24, | 28 PIXEL_FORMAT_RGB24, |
30 PIXEL_FORMAT_RGB32, | 29 PIXEL_FORMAT_RGB32, |
31 PIXEL_FORMAT_ARGB, | 30 PIXEL_FORMAT_ARGB, |
32 PIXEL_FORMAT_MJPEG, | 31 PIXEL_FORMAT_MJPEG, |
| 32 PIXEL_FORMAT_TEXTURE, // Capture format as a GL texture. |
| 33 PIXEL_FORMAT_GPUMEMORYBUFFER, |
33 PIXEL_FORMAT_UNKNOWN, // Color format not set. | 34 PIXEL_FORMAT_UNKNOWN, // Color format not set. |
34 PIXEL_FORMAT_MAX, | 35 PIXEL_FORMAT_MAX, |
35 }; | 36 }; |
36 | 37 |
37 // Storage type for the pixels. In principle, all combinations of Storage and | |
38 // Format are possible, though some are very typical, such as texture + ARGB, | |
39 // and others are only available if the platform allows it e.g. GpuMemoryBuffer. | |
40 enum VideoPixelStorage { | |
41 PIXEL_STORAGE_CPU, | |
42 PIXEL_STORAGE_TEXTURE, | |
43 PIXEL_STORAGE_GPUMEMORYBUFFER, | |
44 }; | |
45 | |
46 // Policies for capture devices that have source content that varies in size. | 38 // Policies for capture devices that have source content that varies in size. |
47 // It is up to the implementation how the captured content will be transformed | 39 // It is up to the implementation how the captured content will be transformed |
48 // (e.g., scaling and/or letterboxing) in order to produce video frames that | 40 // (e.g., scaling and/or letterboxing) in order to produce video frames that |
49 // strictly adheree to one of these policies. | 41 // strictly adheree to one of these policies. |
50 enum ResolutionChangePolicy { | 42 enum ResolutionChangePolicy { |
51 // Capture device outputs a fixed resolution all the time. The resolution of | 43 // Capture device outputs a fixed resolution all the time. The resolution of |
52 // the first frame is the resolution for all frames. | 44 // the first frame is the resolution for all frames. |
53 RESOLUTION_POLICY_FIXED_RESOLUTION, | 45 RESOLUTION_POLICY_FIXED_RESOLUTION, |
54 | 46 |
55 // Capture device is allowed to output frames of varying resolutions. The | 47 // Capture device is allowed to output frames of varying resolutions. The |
(...skipping 16 matching lines...) Expand all Loading... |
72 | 64 |
73 // Video capture format specification. | 65 // Video capture format specification. |
74 // 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 |
75 // 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 |
76 // supported capture format by a device. | 68 // supported capture format by a device. |
77 struct MEDIA_EXPORT VideoCaptureFormat { | 69 struct MEDIA_EXPORT VideoCaptureFormat { |
78 VideoCaptureFormat(); | 70 VideoCaptureFormat(); |
79 VideoCaptureFormat(const gfx::Size& frame_size, | 71 VideoCaptureFormat(const gfx::Size& frame_size, |
80 float frame_rate, | 72 float frame_rate, |
81 VideoPixelFormat pixel_format); | 73 VideoPixelFormat pixel_format); |
82 VideoCaptureFormat(const gfx::Size& frame_size, | |
83 float frame_rate, | |
84 VideoPixelFormat pixel_format, | |
85 VideoPixelStorage pixel_storage); | |
86 | 74 |
87 // TODO(mcasas): Remove this method http://crbug.com/501134. | |
88 std::string ToString() const; | 75 std::string ToString() const; |
89 static std::string PixelFormatToString(VideoPixelFormat format); | 76 static std::string PixelFormatToString(VideoPixelFormat format); |
90 static std::string PixelStorageToString(VideoPixelStorage storage); | |
91 | 77 |
92 // Returns the required buffer size to hold an image of a given | 78 // Returns the required buffer size to hold an image of a given |
93 // VideoCaptureFormat with no padding and tightly packed. | 79 // VideoCaptureFormat with no padding and tightly packed. |
94 size_t ImageAllocationSize() const; | 80 size_t ImageAllocationSize() const; |
95 | 81 |
96 // Checks that all values are in the expected range. All limits are specified | 82 // Checks that all values are in the expected range. All limits are specified |
97 // in media::Limits. | 83 // in media::Limits. |
98 bool IsValid() const; | 84 bool IsValid() const; |
99 | 85 |
100 bool operator==(const VideoCaptureFormat& other) const { | 86 bool operator==(const VideoCaptureFormat& other) const { |
101 return frame_size == other.frame_size && | 87 return frame_size == other.frame_size && |
102 frame_rate == other.frame_rate && | 88 frame_rate == other.frame_rate && |
103 pixel_format == other.pixel_format; | 89 pixel_format == other.pixel_format; |
104 } | 90 } |
105 | 91 |
106 gfx::Size frame_size; | 92 gfx::Size frame_size; |
107 float frame_rate; | 93 float frame_rate; |
108 VideoPixelFormat pixel_format; | 94 VideoPixelFormat pixel_format; |
109 VideoPixelStorage pixel_storage; | |
110 }; | 95 }; |
111 | 96 |
112 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; | 97 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; |
113 | 98 |
114 // Parameters for starting video capture. | 99 // Parameters for starting video capture. |
115 // This class is used by the client of a video capture device to specify the | 100 // This class is used by the client of a video capture device to specify the |
116 // format of frames in which the client would like to have captured frames | 101 // format of frames in which the client would like to have captured frames |
117 // returned. | 102 // returned. |
118 struct MEDIA_EXPORT VideoCaptureParams { | 103 struct MEDIA_EXPORT VideoCaptureParams { |
119 VideoCaptureParams(); | 104 VideoCaptureParams(); |
(...skipping 14 matching lines...) Expand all Loading... |
134 | 119 |
135 #if defined(OS_LINUX) | 120 #if defined(OS_LINUX) |
136 // Indication to the Driver to try to use native GpuMemoryBuffers. | 121 // Indication to the Driver to try to use native GpuMemoryBuffers. |
137 bool use_native_gpu_memory_buffers; | 122 bool use_native_gpu_memory_buffers; |
138 #endif | 123 #endif |
139 }; | 124 }; |
140 | 125 |
141 } // namespace media | 126 } // namespace media |
142 | 127 |
143 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ | 128 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ |
OLD | NEW |