OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This file defines the V4L2Device interface which is used by the | 5 // This file defines the V4L2Device interface which is used by the |
6 // V4L2DecodeAccelerator class to delegate/pass the device specific | 6 // V4L2DecodeAccelerator class to delegate/pass the device specific |
7 // handling of any of the functionalities. | 7 // handling of any of the functionalities. |
8 | 8 |
9 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_DEVICE_H_ | 9 #ifndef MEDIA_GPU_V4L2_DEVICE_H_ |
10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_DEVICE_H_ | 10 #define MEDIA_GPU_V4L2_DEVICE_H_ |
11 | 11 |
12 #include <stddef.h> | 12 #include <stddef.h> |
13 #include <stdint.h> | 13 #include <stdint.h> |
14 | 14 |
15 #include <linux/videodev2.h> | 15 #include <linux/videodev2.h> |
16 | 16 |
17 #include "base/files/scoped_file.h" | 17 #include "base/files/scoped_file.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "content/common/content_export.h" | |
20 #include "media/base/video_decoder_config.h" | 19 #include "media/base/video_decoder_config.h" |
21 #include "media/base/video_frame.h" | 20 #include "media/base/video_frame.h" |
| 21 #include "media/gpu/media_gpu_export.h" |
22 #include "media/video/video_decode_accelerator.h" | 22 #include "media/video/video_decode_accelerator.h" |
23 #include "ui/gfx/geometry/size.h" | 23 #include "ui/gfx/geometry/size.h" |
24 #include "ui/gl/gl_bindings.h" | 24 #include "ui/gl/gl_bindings.h" |
25 | 25 |
26 // TODO(posciak): remove this once V4L2 headers are updated. | 26 // TODO(posciak): remove this once V4L2 headers are updated. |
27 #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') | 27 #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') |
28 #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') | 28 #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') |
29 #define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') | 29 #define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') |
30 #define V4L2_PIX_FMT_MT21 v4l2_fourcc('M', 'T', '2', '1') | 30 #define V4L2_PIX_FMT_MT21 v4l2_fourcc('M', 'T', '2', '1') |
31 | 31 |
32 namespace content { | 32 namespace media { |
33 | 33 |
34 class CONTENT_EXPORT V4L2Device | 34 class MEDIA_GPU_EXPORT V4L2Device |
35 : public base::RefCountedThreadSafe<V4L2Device> { | 35 : public base::RefCountedThreadSafe<V4L2Device> { |
36 public: | 36 public: |
37 // Utility format conversion functions | 37 // Utility format conversion functions |
38 static media::VideoPixelFormat V4L2PixFmtToVideoPixelFormat(uint32_t format); | 38 static media::VideoPixelFormat V4L2PixFmtToVideoPixelFormat(uint32_t format); |
39 static uint32_t VideoPixelFormatToV4L2PixFmt(media::VideoPixelFormat format); | 39 static uint32_t VideoPixelFormatToV4L2PixFmt(media::VideoPixelFormat format); |
40 static uint32_t VideoCodecProfileToV4L2PixFmt( | 40 static uint32_t VideoCodecProfileToV4L2PixFmt( |
41 media::VideoCodecProfile profile, | 41 media::VideoCodecProfile profile, |
42 bool slice_based); | 42 bool slice_based); |
43 static uint32_t V4L2PixFmtToDrmFormat(uint32_t format); | 43 static uint32_t V4L2PixFmtToDrmFormat(uint32_t format); |
44 // Convert format requirements requested by a V4L2 device to gfx::Size. | 44 // Convert format requirements requested by a V4L2 device to gfx::Size. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 EGLImageKHR egl_image) = 0; | 121 EGLImageKHR egl_image) = 0; |
122 | 122 |
123 // Returns the supported texture target for the V4L2Device. | 123 // Returns the supported texture target for the V4L2Device. |
124 virtual GLenum GetTextureTarget() = 0; | 124 virtual GLenum GetTextureTarget() = 0; |
125 | 125 |
126 // Returns the preferred V4L2 input format or 0 if don't care. | 126 // Returns the preferred V4L2 input format or 0 if don't care. |
127 virtual uint32_t PreferredInputFormat() = 0; | 127 virtual uint32_t PreferredInputFormat() = 0; |
128 | 128 |
129 // Get minimum and maximum resolution for fourcc |pixelformat| and store to | 129 // Get minimum and maximum resolution for fourcc |pixelformat| and store to |
130 // |min_resolution| and |max_resolution|. | 130 // |min_resolution| and |max_resolution|. |
131 void GetSupportedResolution(uint32_t pixelformat, gfx::Size* min_resolution, | 131 void GetSupportedResolution(uint32_t pixelformat, |
| 132 gfx::Size* min_resolution, |
132 gfx::Size* max_resolution); | 133 gfx::Size* max_resolution); |
133 | 134 |
134 // Return supported profiles for decoder, including only profiles for given | 135 // Return supported profiles for decoder, including only profiles for given |
135 // fourcc |pixelformats|. | 136 // fourcc |pixelformats|. |
136 media::VideoDecodeAccelerator::SupportedProfiles GetSupportedDecodeProfiles( | 137 media::VideoDecodeAccelerator::SupportedProfiles GetSupportedDecodeProfiles( |
137 const size_t num_formats, const uint32_t pixelformats[]); | 138 const size_t num_formats, |
| 139 const uint32_t pixelformats[]); |
138 | 140 |
139 // Return true if the device supports |profile|, taking into account only | 141 // Return true if the device supports |profile|, taking into account only |
140 // fourccs from the given array of |pixelformats| of size |num_formats|. | 142 // fourccs from the given array of |pixelformats| of size |num_formats|. |
141 bool SupportsDecodeProfileForV4L2PixelFormats( | 143 bool SupportsDecodeProfileForV4L2PixelFormats( |
142 media::VideoCodecProfile profile, | 144 media::VideoCodecProfile profile, |
143 const size_t num_formats, | 145 const size_t num_formats, |
144 const uint32_t pixelformats[]); | 146 const uint32_t pixelformats[]); |
145 | 147 |
146 protected: | 148 protected: |
147 friend class base::RefCountedThreadSafe<V4L2Device>; | 149 friend class base::RefCountedThreadSafe<V4L2Device>; |
148 explicit V4L2Device(Type type); | 150 explicit V4L2Device(Type type); |
149 virtual ~V4L2Device(); | 151 virtual ~V4L2Device(); |
150 | 152 |
151 const Type type_; | 153 const Type type_; |
152 }; | 154 }; |
153 | 155 |
154 } // namespace content | 156 } // namespace media |
155 | 157 |
156 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_DEVICE_H_ | 158 #endif // MEDIA_GPU_V4L2_DEVICE_H_ |
OLD | NEW |