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

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: Uploading verbatim original reverted CL Created 5 years, 5 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.
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 {
mcasas 2015/06/24 21:23:23 dcheng@ enum class. I don't understand, do you me
dcheng 2015/06/24 21:41:47 enum class VideoPixelStorage { CPU, TEXTURE,
mcasas 2015/06/25 01:19:51 I wrote a bug to do this in the near future, toget
dcheng 2015/06/25 02:02:18 Some comments here would be nice =)
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 16 matching lines...) Expand all
64 72
65 // Video capture format specification. 73 // Video capture format specification.
66 // This class is used by the video capture device to specify the format of every 74 // 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 75 // frame captured and returned to a client. It is also used to specify a
68 // supported capture format by a device. 76 // supported capture format by a device.
69 struct MEDIA_EXPORT VideoCaptureFormat { 77 struct MEDIA_EXPORT VideoCaptureFormat {
70 VideoCaptureFormat(); 78 VideoCaptureFormat();
71 VideoCaptureFormat(const gfx::Size& frame_size, 79 VideoCaptureFormat(const gfx::Size& frame_size,
72 float frame_rate, 80 float frame_rate,
73 VideoPixelFormat pixel_format); 81 VideoPixelFormat pixel_format);
82 VideoCaptureFormat(const gfx::Size& frame_size,
83 float frame_rate,
84 VideoPixelFormat pixel_format,
85 VideoPixelStorage pixel_storage);
74 86
87 // TODO(mcasas): Remove this method http://crbug.com/501134.
75 std::string ToString() const; 88 std::string ToString() const;
76 static std::string PixelFormatToString(VideoPixelFormat format); 89 static std::string PixelFormatToString(VideoPixelFormat format);
90 static std::string PixelStorageToString(VideoPixelStorage storage);
77 91
78 // Returns the required buffer size to hold an image of a given 92 // Returns the required buffer size to hold an image of a given
79 // VideoCaptureFormat with no padding and tightly packed. 93 // VideoCaptureFormat with no padding and tightly packed.
80 size_t ImageAllocationSize() const; 94 size_t ImageAllocationSize() const;
81 95
82 // Checks that all values are in the expected range. All limits are specified 96 // Checks that all values are in the expected range. All limits are specified
83 // in media::Limits. 97 // in media::Limits.
84 bool IsValid() const; 98 bool IsValid() const;
85 99
86 bool operator==(const VideoCaptureFormat& other) const { 100 bool operator==(const VideoCaptureFormat& other) const {
87 return frame_size == other.frame_size && 101 return frame_size == other.frame_size &&
88 frame_rate == other.frame_rate && 102 frame_rate == other.frame_rate &&
89 pixel_format == other.pixel_format; 103 pixel_format == other.pixel_format;
90 } 104 }
91 105
92 gfx::Size frame_size; 106 gfx::Size frame_size;
93 float frame_rate; 107 float frame_rate;
94 VideoPixelFormat pixel_format; 108 VideoPixelFormat pixel_format;
109 VideoPixelStorage pixel_storage;
95 }; 110 };
96 111
97 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; 112 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats;
98 113
99 // Parameters for starting video capture. 114 // Parameters for starting video capture.
100 // This class is used by the client of a video capture device to specify the 115 // 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 116 // format of frames in which the client would like to have captured frames
102 // returned. 117 // returned.
103 struct MEDIA_EXPORT VideoCaptureParams { 118 struct MEDIA_EXPORT VideoCaptureParams {
104 VideoCaptureParams(); 119 VideoCaptureParams();
(...skipping 14 matching lines...) Expand all
119 134
120 #if defined(OS_LINUX) 135 #if defined(OS_LINUX)
121 // Indication to the Driver to try to use native GpuMemoryBuffers. 136 // Indication to the Driver to try to use native GpuMemoryBuffers.
122 bool use_native_gpu_memory_buffers; 137 bool use_native_gpu_memory_buffers;
123 #endif 138 #endif
124 }; 139 };
125 140
126 } // namespace media 141 } // namespace media
127 142
128 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ 143 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698