| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 EGLImageKHR egl_image) = 0; | 124 EGLImageKHR egl_image) = 0; |
| 125 | 125 |
| 126 // Returns the supported texture target for the V4L2Device. | 126 // Returns the supported texture target for the V4L2Device. |
| 127 virtual GLenum GetTextureTarget() = 0; | 127 virtual GLenum GetTextureTarget() = 0; |
| 128 | 128 |
| 129 // Returns the preferred V4L2 input format or 0 if don't care. | 129 // Returns the preferred V4L2 input format or 0 if don't care. |
| 130 virtual uint32_t PreferredInputFormat() = 0; | 130 virtual uint32_t PreferredInputFormat() = 0; |
| 131 | 131 |
| 132 // Get minimum and maximum resolution for fourcc |pixelformat| and store to | 132 // Get minimum and maximum resolution for fourcc |pixelformat| and store to |
| 133 // |min_resolution| and |max_resolution|. | 133 // |min_resolution| and |max_resolution|. |
| 134 void GetSupportedResolution(uint32_t pixelformat, gfx::Size* min_resolution, | 134 void GetSupportedResolution(uint32_t pixelformat, |
| 135 gfx::Size* min_resolution, |
| 135 gfx::Size* max_resolution); | 136 gfx::Size* max_resolution); |
| 136 | 137 |
| 137 // Return supported profiles for decoder, including only profiles for given | 138 // Return supported profiles for decoder, including only profiles for given |
| 138 // fourcc |pixelformats|. | 139 // fourcc |pixelformats|. |
| 139 media::VideoDecodeAccelerator::SupportedProfiles GetSupportedDecodeProfiles( | 140 media::VideoDecodeAccelerator::SupportedProfiles GetSupportedDecodeProfiles( |
| 140 const size_t num_formats, const uint32_t pixelformats[]); | 141 const size_t num_formats, |
| 142 const uint32_t pixelformats[]); |
| 141 | 143 |
| 142 // Return true if the device supports |profile|, taking into account only | 144 // Return true if the device supports |profile|, taking into account only |
| 143 // fourccs from the given array of |pixelformats| of size |num_formats|. | 145 // fourccs from the given array of |pixelformats| of size |num_formats|. |
| 144 bool SupportsDecodeProfileForV4L2PixelFormats( | 146 bool SupportsDecodeProfileForV4L2PixelFormats( |
| 145 media::VideoCodecProfile profile, | 147 media::VideoCodecProfile profile, |
| 146 const size_t num_formats, | 148 const size_t num_formats, |
| 147 const uint32_t pixelformats[]); | 149 const uint32_t pixelformats[]); |
| 148 | 150 |
| 149 protected: | 151 protected: |
| 150 friend class base::RefCountedThreadSafe<V4L2Device>; | 152 friend class base::RefCountedThreadSafe<V4L2Device>; |
| 151 explicit V4L2Device(Type type); | 153 explicit V4L2Device(Type type); |
| 152 virtual ~V4L2Device(); | 154 virtual ~V4L2Device(); |
| 153 | 155 |
| 154 const Type type_; | 156 const Type type_; |
| 155 }; | 157 }; |
| 156 | 158 |
| 157 } // namespace content | 159 } // namespace media |
| 158 | 160 |
| 159 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_DEVICE_H_ | 161 #endif // MEDIA_GPU_V4L2_DEVICE_H_ |
| OLD | NEW |