Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: media/base/video_capture_types.h

Issue 1204063005: Reland: Video Capture: extract storage info from pixel format in VideoCaptureFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dcheng@ second round of comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // TODO(mcasas): http://crbug.com/504160 Consider making this an enum class.
21 enum VideoPixelFormat { 23 enum VideoPixelFormat {
22 PIXEL_FORMAT_I420, 24 PIXEL_FORMAT_I420,
23 PIXEL_FORMAT_YV12, 25 PIXEL_FORMAT_YV12,
24 PIXEL_FORMAT_NV12, 26 PIXEL_FORMAT_NV12,
25 PIXEL_FORMAT_NV21, 27 PIXEL_FORMAT_NV21,
26 PIXEL_FORMAT_UYVY, 28 PIXEL_FORMAT_UYVY,
27 PIXEL_FORMAT_YUY2, 29 PIXEL_FORMAT_YUY2,
28 PIXEL_FORMAT_RGB24, 30 PIXEL_FORMAT_RGB24,
29 PIXEL_FORMAT_RGB32, 31 PIXEL_FORMAT_RGB32,
30 PIXEL_FORMAT_ARGB, 32 PIXEL_FORMAT_ARGB,
31 PIXEL_FORMAT_MJPEG, 33 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. 34 PIXEL_FORMAT_UNKNOWN, // Color format not set.
35 PIXEL_FORMAT_MAX, 35 PIXEL_FORMAT_MAX,
36 }; 36 };
37 37
38 // Storage type for the pixels. In principle, all combinations of Storage and
39 // Format are possible, though some are very typical, such as texture + ARGB,
40 // and others are only available if the platform allows it e.g. GpuMemoryBuffer.
41 // TODO(mcasas): http://crbug.com/504160 Consider making this an enum class.
42 enum VideoPixelStorage {
43 PIXEL_STORAGE_CPU,
44 PIXEL_STORAGE_TEXTURE,
45 PIXEL_STORAGE_GPUMEMORYBUFFER,
46 PIXEL_STORAGE_MAX = PIXEL_STORAGE_GPUMEMORYBUFFER,
47 };
48
38 // Policies for capture devices that have source content that varies in size. 49 // 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 50 // 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 51 // (e.g., scaling and/or letterboxing) in order to produce video frames that
41 // strictly adheree to one of these policies. 52 // strictly adheree to one of these policies.
42 enum ResolutionChangePolicy { 53 enum ResolutionChangePolicy {
43 // Capture device outputs a fixed resolution all the time. The resolution of 54 // Capture device outputs a fixed resolution all the time. The resolution of
44 // the first frame is the resolution for all frames. 55 // the first frame is the resolution for all frames.
45 RESOLUTION_POLICY_FIXED_RESOLUTION, 56 RESOLUTION_POLICY_FIXED_RESOLUTION,
46 57
47 // Capture device is allowed to output frames of varying resolutions. The 58 // Capture device is allowed to output frames of varying resolutions. The
(...skipping 16 matching lines...) Expand all
64 75
65 // Video capture format specification. 76 // Video capture format specification.
66 // This class is used by the video capture device to specify the format of every 77 // This class is used by the video capture device to specify the format of every
67 // frame captured and returned to a client. It is also used to specify a 78 // frame captured and returned to a client. It is also used to specify a
68 // supported capture format by a device. 79 // supported capture format by a device.
69 struct MEDIA_EXPORT VideoCaptureFormat { 80 struct MEDIA_EXPORT VideoCaptureFormat {
70 VideoCaptureFormat(); 81 VideoCaptureFormat();
71 VideoCaptureFormat(const gfx::Size& frame_size, 82 VideoCaptureFormat(const gfx::Size& frame_size,
72 float frame_rate, 83 float frame_rate,
73 VideoPixelFormat pixel_format); 84 VideoPixelFormat pixel_format);
85 VideoCaptureFormat(const gfx::Size& frame_size,
86 float frame_rate,
87 VideoPixelFormat pixel_format,
88 VideoPixelStorage pixel_storage);
74 89
90 // TODO(mcasas): Remove this method http://crbug.com/501134.
75 std::string ToString() const; 91 std::string ToString() const;
76 static std::string PixelFormatToString(VideoPixelFormat format); 92 static std::string PixelFormatToString(VideoPixelFormat format);
93 static std::string PixelStorageToString(VideoPixelStorage storage);
77 94
78 // Returns the required buffer size to hold an image of a given 95 // Returns the required buffer size to hold an image of a given
79 // VideoCaptureFormat with no padding and tightly packed. 96 // VideoCaptureFormat with no padding and tightly packed.
80 size_t ImageAllocationSize() const; 97 size_t ImageAllocationSize() const;
81 98
82 // Checks that all values are in the expected range. All limits are specified 99 // Checks that all values are in the expected range. All limits are specified
83 // in media::Limits. 100 // in media::Limits.
84 bool IsValid() const; 101 bool IsValid() const;
85 102
86 bool operator==(const VideoCaptureFormat& other) const { 103 bool operator==(const VideoCaptureFormat& other) const {
87 return frame_size == other.frame_size && 104 return frame_size == other.frame_size &&
88 frame_rate == other.frame_rate && 105 frame_rate == other.frame_rate &&
89 pixel_format == other.pixel_format; 106 pixel_format == other.pixel_format;
90 } 107 }
91 108
92 gfx::Size frame_size; 109 gfx::Size frame_size;
93 float frame_rate; 110 float frame_rate;
94 VideoPixelFormat pixel_format; 111 VideoPixelFormat pixel_format;
112 VideoPixelStorage pixel_storage;
95 }; 113 };
96 114
97 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; 115 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats;
98 116
99 // Parameters for starting video capture. 117 // Parameters for starting video capture.
100 // This class is used by the client of a video capture device to specify the 118 // This class is used by the client of a video capture device to specify the
101 // format of frames in which the client would like to have captured frames 119 // format of frames in which the client would like to have captured frames
102 // returned. 120 // returned.
103 struct MEDIA_EXPORT VideoCaptureParams { 121 struct MEDIA_EXPORT VideoCaptureParams {
104 VideoCaptureParams(); 122 VideoCaptureParams();
(...skipping 14 matching lines...) Expand all
119 137
120 #if defined(OS_LINUX) 138 #if defined(OS_LINUX)
121 // Indication to the Driver to try to use native GpuMemoryBuffers. 139 // Indication to the Driver to try to use native GpuMemoryBuffers.
122 bool use_native_gpu_memory_buffers; 140 bool use_native_gpu_memory_buffers;
123 #endif 141 #endif
124 }; 142 };
125 143
126 } // namespace media 144 } // namespace media
127 145
128 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ 146 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698