| 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 CONTENT_COMMON_GPU_MEDIA_V4L2_DEVICE_H_ |
| 10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_DEVICE_H_ | 10 #define CONTENT_COMMON_GPU_MEDIA_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> |
| 16 |
| 17 #include "base/files/scoped_file.h" |
| 15 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 16 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 17 #include "media/base/video_decoder_config.h" | 20 #include "media/base/video_decoder_config.h" |
| 18 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
| 19 #include "media/video/video_decode_accelerator.h" | 22 #include "media/video/video_decode_accelerator.h" |
| 20 #include "ui/gfx/geometry/size.h" | 23 #include "ui/gfx/geometry/size.h" |
| 21 #include "ui/gl/gl_bindings.h" | 24 #include "ui/gl/gl_bindings.h" |
| 22 | 25 |
| 23 // TODO(posciak): remove this once V4L2 headers are updated. | 26 // TODO(posciak): remove this once V4L2 headers are updated. |
| 24 #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') | 27 #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 unsigned int len, | 82 unsigned int len, |
| 80 int prot, | 83 int prot, |
| 81 int flags, | 84 int flags, |
| 82 unsigned int offset) = 0; | 85 unsigned int offset) = 0; |
| 83 virtual void Munmap(void* addr, unsigned int len) = 0; | 86 virtual void Munmap(void* addr, unsigned int len) = 0; |
| 84 | 87 |
| 85 // Initializes the V4L2Device to operate as a device of |type|. | 88 // Initializes the V4L2Device to operate as a device of |type|. |
| 86 // Returns true on success. | 89 // Returns true on success. |
| 87 virtual bool Initialize() = 0; | 90 virtual bool Initialize() = 0; |
| 88 | 91 |
| 92 // Return a vector of dmabuf file descriptors, exported for V4L2 buffer with |
| 93 // |index|, assuming the buffer contains |num_planes| V4L2 planes and is of |
| 94 // |type|. Return an empty vector on failure. |
| 95 // The caller is responsible for closing the file descriptors after use. |
| 96 virtual std::vector<base::ScopedFD> GetDmabufsForV4L2Buffer( |
| 97 int index, |
| 98 size_t num_planes, |
| 99 enum v4l2_buf_type type) = 0; |
| 100 |
| 89 // Return true if the given V4L2 pixfmt can be used in CreateEGLImage() | 101 // Return true if the given V4L2 pixfmt can be used in CreateEGLImage() |
| 90 // for the current platform. | 102 // for the current platform. |
| 91 virtual bool CanCreateEGLImageFrom(uint32_t v4l2_pixfmt) = 0; | 103 virtual bool CanCreateEGLImageFrom(uint32_t v4l2_pixfmt) = 0; |
| 92 | 104 |
| 93 // Creates an EGLImageKHR since each V4L2Device may use a different method of | 105 // Create an EGLImage from provided |dmabuf_fds| and bind |texture_id| to it. |
| 94 // acquiring one and associating it to the given texture. The texture_id is | 106 // Some implementations may also require the V4L2 |buffer_index| of the buffer |
| 95 // used to bind the texture to the returned EGLImageKHR. buffer_index can be | 107 // for which |dmabuf_fds| have been exported. |
| 96 // used to associate the returned EGLImageKHR by the underlying V4L2Device | 108 // The caller may choose to close the file descriptors after this method |
| 97 // implementation. | 109 // returns, and may expect the buffers to remain valid for the lifetime of |
| 98 virtual EGLImageKHR CreateEGLImage(EGLDisplay egl_display, | 110 // the created EGLImage. |
| 99 EGLContext egl_context, | 111 // Return EGL_NO_IMAGE_KHR on failure. |
| 100 GLuint texture_id, | 112 virtual EGLImageKHR CreateEGLImage( |
| 101 gfx::Size frame_buffer_size, | 113 EGLDisplay egl_display, |
| 102 unsigned int buffer_index, | 114 EGLContext egl_context, |
| 103 uint32_t v4l2_pixfmt, | 115 GLuint texture_id, |
| 104 size_t num_v4l2_planes) = 0; | 116 const gfx::Size& size, |
| 117 unsigned int buffer_index, |
| 118 uint32_t v4l2_pixfmt, |
| 119 const std::vector<base::ScopedFD>& dmabuf_fds) = 0; |
| 105 | 120 |
| 106 // Destroys the EGLImageKHR. | 121 // Destroys the EGLImageKHR. |
| 107 virtual EGLBoolean DestroyEGLImage(EGLDisplay egl_display, | 122 virtual EGLBoolean DestroyEGLImage(EGLDisplay egl_display, |
| 108 EGLImageKHR egl_image) = 0; | 123 EGLImageKHR egl_image) = 0; |
| 109 | 124 |
| 110 // Returns the supported texture target for the V4L2Device. | 125 // Returns the supported texture target for the V4L2Device. |
| 111 virtual GLenum GetTextureTarget() = 0; | 126 virtual GLenum GetTextureTarget() = 0; |
| 112 | 127 |
| 113 // Returns the preferred V4L2 input format or 0 if don't care. | 128 // Returns the preferred V4L2 input format or 0 if don't care. |
| 114 virtual uint32_t PreferredInputFormat() = 0; | 129 virtual uint32_t PreferredInputFormat() = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 134 friend class base::RefCountedThreadSafe<V4L2Device>; | 149 friend class base::RefCountedThreadSafe<V4L2Device>; |
| 135 explicit V4L2Device(Type type); | 150 explicit V4L2Device(Type type); |
| 136 virtual ~V4L2Device(); | 151 virtual ~V4L2Device(); |
| 137 | 152 |
| 138 const Type type_; | 153 const Type type_; |
| 139 }; | 154 }; |
| 140 | 155 |
| 141 } // namespace content | 156 } // namespace content |
| 142 | 157 |
| 143 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_DEVICE_H_ | 158 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_DEVICE_H_ |
| OLD | NEW |