Chromium Code Reviews| 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. | |
| 21 enum VideoPixelFormat { | 22 enum VideoPixelFormat { |
| 22 PIXEL_FORMAT_I420, | 23 PIXEL_FORMAT_I420, |
| 23 PIXEL_FORMAT_YV12, | 24 PIXEL_FORMAT_YV12, |
| 24 PIXEL_FORMAT_NV12, | 25 PIXEL_FORMAT_NV12, |
| 25 PIXEL_FORMAT_NV21, | 26 PIXEL_FORMAT_NV21, |
| 26 PIXEL_FORMAT_UYVY, | 27 PIXEL_FORMAT_UYVY, |
| 27 PIXEL_FORMAT_YUY2, | 28 PIXEL_FORMAT_YUY2, |
| 28 PIXEL_FORMAT_RGB24, | 29 PIXEL_FORMAT_RGB24, |
| 29 PIXEL_FORMAT_RGB32, | 30 PIXEL_FORMAT_RGB32, |
| 30 PIXEL_FORMAT_ARGB, | 31 PIXEL_FORMAT_ARGB, |
| 31 PIXEL_FORMAT_MJPEG, | 32 PIXEL_FORMAT_MJPEG, |
| 32 PIXEL_FORMAT_TEXTURE, // Capture format as a GL texture. | |
| 33 PIXEL_FORMAT_GPUMEMORYBUFFER, | |
| 34 PIXEL_FORMAT_UNKNOWN, // Color format not set. | 33 PIXEL_FORMAT_UNKNOWN, // Color format not set. |
| 35 PIXEL_FORMAT_MAX, | 34 PIXEL_FORMAT_MAX, |
| 36 }; | 35 }; |
| 37 | 36 |
| 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 | |
| 38 // Policies for capture devices that have source content that varies in size. | 46 // Policies for capture devices that have source content that varies in size. |
| 39 // It is up to the implementation how the captured content will be transformed | 47 // It is up to the implementation how the captured content will be transformed |
| 40 // (e.g., scaling and/or letterboxing) in order to produce video frames that | 48 // (e.g., scaling and/or letterboxing) in order to produce video frames that |
| 41 // strictly adheree to one of these policies. | 49 // strictly adheree to one of these policies. |
| 42 enum ResolutionChangePolicy { | 50 enum ResolutionChangePolicy { |
| 43 // Capture device outputs a fixed resolution all the time. The resolution of | 51 // Capture device outputs a fixed resolution all the time. The resolution of |
| 44 // the first frame is the resolution for all frames. | 52 // the first frame is the resolution for all frames. |
| 45 RESOLUTION_POLICY_FIXED_RESOLUTION, | 53 RESOLUTION_POLICY_FIXED_RESOLUTION, |
| 46 | 54 |
| 47 // Capture device is allowed to output frames of varying resolutions. The | 55 // Capture device is allowed to output frames of varying resolutions. The |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 63 | 71 |
| 64 // Video capture format specification. | 72 // Video capture format specification. |
| 65 // This class is used by the video capture device to specify the format of every | 73 // This class is used by the video capture device to specify the format of every |
| 66 // frame captured and returned to a client. It is also used to specify a | 74 // frame captured and returned to a client. It is also used to specify a |
| 67 // supported capture format by a device. | 75 // supported capture format by a device. |
| 68 struct MEDIA_EXPORT VideoCaptureFormat { | 76 struct MEDIA_EXPORT VideoCaptureFormat { |
| 69 VideoCaptureFormat(); | 77 VideoCaptureFormat(); |
| 70 VideoCaptureFormat(const gfx::Size& frame_size, | 78 VideoCaptureFormat(const gfx::Size& frame_size, |
| 71 float frame_rate, | 79 float frame_rate, |
| 72 VideoPixelFormat pixel_format); | 80 VideoPixelFormat pixel_format); |
| 81 VideoCaptureFormat(const gfx::Size& frame_size, | |
| 82 float frame_rate, | |
| 83 VideoPixelFormat pixel_format, | |
| 84 VideoPixelStorage pixel_storage); | |
| 73 | 85 |
| 86 // TODO(mcasas): Remove this method http://crbug.com/501134. | |
| 74 std::string ToString() const; | 87 std::string ToString() const; |
| 75 static std::string PixelFormatToString(VideoPixelFormat format); | 88 static std::string PixelFormatToString(VideoPixelFormat format); |
| 89 static std::string PixelStorageToString(VideoPixelStorage storage); | |
| 76 | 90 |
| 77 // Returns the required buffer size to hold an image of a given | 91 // Returns the required buffer size to hold an image of a given |
| 78 // VideoCaptureFormat with no padding and tightly packed. | 92 // VideoCaptureFormat with no padding and tightly packed. |
| 79 size_t ImageAllocationSize() const; | 93 size_t ImageAllocationSize() const; |
| 80 | 94 |
| 81 // Checks that all values are in the expected range. All limits are specified | 95 // Checks that all values are in the expected range. All limits are specified |
| 82 // in media::Limits. | 96 // in media::Limits. |
| 83 bool IsValid() const; | 97 bool IsValid() const; |
| 84 | 98 |
| 85 bool operator==(const VideoCaptureFormat& other) const { | 99 bool operator==(const VideoCaptureFormat& other) const { |
| 86 return frame_size == other.frame_size && | 100 return frame_size == other.frame_size && |
| 87 frame_rate == other.frame_rate && | 101 frame_rate == other.frame_rate && |
| 88 pixel_format == other.pixel_format; | 102 pixel_format == other.pixel_format; |
| 89 } | 103 } |
| 90 | 104 |
| 91 gfx::Size frame_size; | 105 gfx::Size frame_size; |
| 92 float frame_rate; | 106 float frame_rate; |
| 93 VideoPixelFormat pixel_format; | 107 VideoPixelFormat pixel_format; |
| 108 VideoPixelStorage pixel_storage; | |
|
miu
2015/06/23 22:58:15
Should this extra field be added in content/common
mcasas
2015/06/23 23:24:43
I don't understand, VideoPixelStorage is not
sent
miu
2015/06/23 23:35:55
I meant: There's a declaration of the VideoCapture
mcasas
2015/06/24 00:16:39
Oh yes, media_param_traits.cc, good catch, thanks.
| |
| 94 }; | 109 }; |
| 95 | 110 |
| 96 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; | 111 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; |
| 97 | 112 |
| 98 // Parameters for starting video capture. | 113 // Parameters for starting video capture. |
| 99 // This class is used by the client of a video capture device to specify the | 114 // 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 | 115 // format of frames in which the client would like to have captured frames |
| 101 // returned. | 116 // returned. |
| 102 struct MEDIA_EXPORT VideoCaptureParams { | 117 struct MEDIA_EXPORT VideoCaptureParams { |
| 103 VideoCaptureParams(); | 118 VideoCaptureParams(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 118 | 133 |
| 119 #if defined(OS_LINUX) | 134 #if defined(OS_LINUX) |
| 120 // Indication to the Driver to try to use native GpuMemoryBuffers. | 135 // Indication to the Driver to try to use native GpuMemoryBuffers. |
| 121 bool use_native_gpu_memory_buffers; | 136 bool use_native_gpu_memory_buffers; |
| 122 #endif | 137 #endif |
| 123 }; | 138 }; |
| 124 | 139 |
| 125 } // namespace media | 140 } // namespace media |
| 126 | 141 |
| 127 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ | 142 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ |
| OLD | NEW |