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

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

Issue 1179323002: Video Capture: extract storage info from pixel format in VideoCaptureFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hubbe@s comments and minor rebase 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 enum VideoPixelFormat { 21 enum VideoPixelFormat {
hubbe 2015/06/18 19:23:11 Would it be possible to unify VideoPixelFormat and
mcasas 2015/06/19 02:58:36 Added a TODO(). It would not be trivial because th
22 PIXEL_FORMAT_I420, 22 PIXEL_FORMAT_I420,
23 PIXEL_FORMAT_YV12, 23 PIXEL_FORMAT_YV12,
24 PIXEL_FORMAT_NV12, 24 PIXEL_FORMAT_NV12,
25 PIXEL_FORMAT_NV21, 25 PIXEL_FORMAT_NV21,
26 PIXEL_FORMAT_UYVY, 26 PIXEL_FORMAT_UYVY,
27 PIXEL_FORMAT_YUY2, 27 PIXEL_FORMAT_YUY2,
28 PIXEL_FORMAT_RGB24, 28 PIXEL_FORMAT_RGB24,
29 PIXEL_FORMAT_RGB32, 29 PIXEL_FORMAT_RGB32,
30 PIXEL_FORMAT_ARGB, 30 PIXEL_FORMAT_ARGB,
31 PIXEL_FORMAT_MJPEG, 31 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. 32 PIXEL_FORMAT_UNKNOWN, // Color format not set.
35 PIXEL_FORMAT_MAX, 33 PIXEL_FORMAT_MAX,
36 }; 34 };
37 35
36 // Storage type for the pixels. In principle, all combinations of Storage and
37 // Format are possible, though some are very typical, such as texture + ARGB,
hubbe 2015/06/18 19:23:11 I don't think this is clear enough / struct. What
mcasas 2015/06/19 02:58:36 Same as with VideoFrame, the specification of sto
hubbe 2015/06/23 23:35:40 A texture is not a formatless buffer. OpenGL doesn
38 // and others are only available if the platform allows it e.g. GpuMemoryBuffer.
39 enum VideoPixelStorage {
hubbe 2015/06/18 19:23:11 Shouldn't this really be media::VideoFrame::Storag
mcasas 2015/06/19 02:58:36 Again is only partially coincidental with media::V
40 PIXEL_STORAGE_CPU,
41 PIXEL_STORAGE_TEXTURE,
42 PIXEL_STORAGE_GPUMEMORYBUFFER,
43 };
44
38 // Policies for capture devices that have source content that varies in size. 45 // 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 46 // 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 47 // (e.g., scaling and/or letterboxing) in order to produce video frames that
41 // strictly adheree to one of these policies. 48 // strictly adheree to one of these policies.
42 enum ResolutionChangePolicy { 49 enum ResolutionChangePolicy {
43 // Capture device outputs a fixed resolution all the time. The resolution of 50 // Capture device outputs a fixed resolution all the time. The resolution of
44 // the first frame is the resolution for all frames. 51 // the first frame is the resolution for all frames.
45 RESOLUTION_POLICY_FIXED_RESOLUTION, 52 RESOLUTION_POLICY_FIXED_RESOLUTION,
46 53
47 // Capture device is allowed to output frames of varying resolutions. The 54 // Capture device is allowed to output frames of varying resolutions. The
(...skipping 15 matching lines...) Expand all
63 70
64 // Video capture format specification. 71 // Video capture format specification.
65 // This class is used by the video capture device to specify the format of every 72 // 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 73 // frame captured and returned to a client. It is also used to specify a
67 // supported capture format by a device. 74 // supported capture format by a device.
68 struct MEDIA_EXPORT VideoCaptureFormat { 75 struct MEDIA_EXPORT VideoCaptureFormat {
69 VideoCaptureFormat(); 76 VideoCaptureFormat();
70 VideoCaptureFormat(const gfx::Size& frame_size, 77 VideoCaptureFormat(const gfx::Size& frame_size,
71 float frame_rate, 78 float frame_rate,
72 VideoPixelFormat pixel_format); 79 VideoPixelFormat pixel_format);
80 VideoCaptureFormat(const gfx::Size& frame_size,
81 float frame_rate,
82 VideoPixelFormat pixel_format,
83 VideoPixelStorage pixel_storage);
73 84
85 // TODO(mcasas): Remove this method http://crbug.com/501134.
74 std::string ToString() const; 86 std::string ToString() const;
75 static std::string PixelFormatToString(VideoPixelFormat format); 87 static std::string PixelFormatToString(VideoPixelFormat format);
88 static std::string PixelStorageToString(VideoPixelStorage storage);
76 89
77 // Returns the required buffer size to hold an image of a given 90 // Returns the required buffer size to hold an image of a given
78 // VideoCaptureFormat with no padding and tightly packed. 91 // VideoCaptureFormat with no padding and tightly packed.
79 size_t ImageAllocationSize() const; 92 size_t ImageAllocationSize() const;
80 93
81 // Checks that all values are in the expected range. All limits are specified 94 // Checks that all values are in the expected range. All limits are specified
82 // in media::Limits. 95 // in media::Limits.
83 bool IsValid() const; 96 bool IsValid() const;
84 97
85 bool operator==(const VideoCaptureFormat& other) const { 98 bool operator==(const VideoCaptureFormat& other) const {
86 return frame_size == other.frame_size && 99 return frame_size == other.frame_size &&
87 frame_rate == other.frame_rate && 100 frame_rate == other.frame_rate &&
88 pixel_format == other.pixel_format; 101 pixel_format == other.pixel_format;
89 } 102 }
90 103
91 gfx::Size frame_size; 104 gfx::Size frame_size;
92 float frame_rate; 105 float frame_rate;
93 VideoPixelFormat pixel_format; 106 VideoPixelFormat pixel_format;
107 VideoPixelStorage pixel_storage;
94 }; 108 };
95 109
96 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats; 110 typedef std::vector<VideoCaptureFormat> VideoCaptureFormats;
97 111
98 // Parameters for starting video capture. 112 // Parameters for starting video capture.
99 // This class is used by the client of a video capture device to specify the 113 // 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 114 // format of frames in which the client would like to have captured frames
101 // returned. 115 // returned.
102 struct MEDIA_EXPORT VideoCaptureParams { 116 struct MEDIA_EXPORT VideoCaptureParams {
103 VideoCaptureParams(); 117 VideoCaptureParams();
(...skipping 14 matching lines...) Expand all
118 132
119 #if defined(OS_LINUX) 133 #if defined(OS_LINUX)
120 // Indication to the Driver to try to use native GpuMemoryBuffers. 134 // Indication to the Driver to try to use native GpuMemoryBuffers.
121 bool use_native_gpu_memory_buffers; 135 bool use_native_gpu_memory_buffers;
122 #endif 136 #endif
123 }; 137 };
124 138
125 } // namespace media 139 } // namespace media
126 140
127 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_ 141 #endif // MEDIA_BASE_VIDEO_CAPTURE_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698