| 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_VIDEO_DEVICE_H_ | 9 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DEVICE_H_ |
| 10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DEVICE_H_ | 10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DEVICE_H_ |
| 11 | 11 |
| 12 #include "media/base/video_decoder_config.h" | 12 #include "media/base/video_decoder_config.h" |
| 13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 15 #include "ui/gl/gl_bindings.h" | 15 #include "ui/gl/gl_bindings.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 class V4L2Device { | 19 class V4L2Device { |
| 20 public: | 20 public: |
| 21 // Utility format conversion functions | 21 // Utility format conversion functions |
| 22 static media::VideoFrame::Format V4L2PixFmtToVideoFrameFormat(uint32 format); | 22 static media::VideoFrame::Format V4L2PixFmtToVideoFrameFormat(uint32 format); |
| 23 static uint32 VideoFrameFormatToV4L2PixFmt(media::VideoFrame::Format format); | 23 static uint32 VideoFrameFormatToV4L2PixFmt(media::VideoFrame::Format format); |
| 24 static uint32 VideoCodecProfileToV4L2PixFmt(media::VideoCodecProfile profile); | 24 static uint32 VideoCodecProfileToV4L2PixFmt(media::VideoCodecProfile profile); |
| 25 static uint32_t V4L2PixFmtToDrmFormat(uint32_t format); | |
| 26 // Convert format requirements requested by a V4L2 device to gfx::Size. | 25 // Convert format requirements requested by a V4L2 device to gfx::Size. |
| 27 static gfx::Size CodedSizeFromV4L2Format(struct v4l2_format format); | 26 static gfx::Size CodedSizeFromV4L2Format(struct v4l2_format format); |
| 28 | 27 |
| 29 virtual ~V4L2Device(); | 28 virtual ~V4L2Device(); |
| 30 | 29 |
| 31 enum Type { | 30 enum Type { |
| 32 kDecoder, | 31 kDecoder, |
| 33 kEncoder, | 32 kEncoder, |
| 34 kImageProcessor, | 33 kImageProcessor, |
| 35 }; | 34 }; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 65 unsigned int len, | 64 unsigned int len, |
| 66 int prot, | 65 int prot, |
| 67 int flags, | 66 int flags, |
| 68 unsigned int offset) = 0; | 67 unsigned int offset) = 0; |
| 69 virtual void Munmap(void* addr, unsigned int len) = 0; | 68 virtual void Munmap(void* addr, unsigned int len) = 0; |
| 70 | 69 |
| 71 // Initializes the V4L2Device to operate as a device of |type|. | 70 // Initializes the V4L2Device to operate as a device of |type|. |
| 72 // Returns true on success. | 71 // Returns true on success. |
| 73 virtual bool Initialize() = 0; | 72 virtual bool Initialize() = 0; |
| 74 | 73 |
| 75 // Return true if the given V4L2 pixfmt can be used in CreateEGLImage() | |
| 76 // for the current platform. | |
| 77 virtual bool CanCreateEGLImageFrom(uint32_t v4l2_pixfmt) = 0; | |
| 78 | |
| 79 // Creates an EGLImageKHR since each V4L2Device may use a different method of | 74 // Creates an EGLImageKHR since each V4L2Device may use a different method of |
| 80 // acquiring one and associating it to the given texture. The texture_id is | 75 // acquiring one and associating it to the given texture. The texture_id is |
| 81 // used to bind the texture to the returned EGLImageKHR. buffer_index can be | 76 // used to bind the texture to the returned EGLImageKHR. buffer_index can be |
| 82 // used to associate the returned EGLImageKHR by the underlying V4L2Device | 77 // used to associate the returned EGLImageKHR by the underlying V4L2Device |
| 83 // implementation. | 78 // implementation. |
| 84 virtual EGLImageKHR CreateEGLImage(EGLDisplay egl_display, | 79 virtual EGLImageKHR CreateEGLImage(EGLDisplay egl_display, |
| 85 EGLContext egl_context, | 80 EGLContext egl_context, |
| 86 GLuint texture_id, | 81 GLuint texture_id, |
| 87 gfx::Size frame_buffer_size, | 82 gfx::Size frame_buffer_size, |
| 88 unsigned int buffer_index, | 83 unsigned int buffer_index, |
| 89 uint32_t v4l2_pixfmt, | 84 size_t planes_count) = 0; |
| 90 size_t num_v4l2_planes) = 0; | |
| 91 | 85 |
| 92 // Destroys the EGLImageKHR. | 86 // Destroys the EGLImageKHR. |
| 93 virtual EGLBoolean DestroyEGLImage(EGLDisplay egl_display, | 87 virtual EGLBoolean DestroyEGLImage(EGLDisplay egl_display, |
| 94 EGLImageKHR egl_image) = 0; | 88 EGLImageKHR egl_image) = 0; |
| 95 | 89 |
| 96 // Returns the supported texture target for the V4L2Device. | 90 // Returns the supported texture target for the V4L2Device. |
| 97 virtual GLenum GetTextureTarget() = 0; | 91 virtual GLenum GetTextureTarget() = 0; |
| 98 | 92 |
| 99 // Returns the preferred V4L2 input format or 0 if don't care. | 93 // Returns the preferred V4L2 input format or 0 if don't care. |
| 100 virtual uint32 PreferredInputFormat() = 0; | 94 virtual uint32 PreferredInputFormat() = 0; |
| 95 |
| 96 // Returns the preferred V4L2 output format or 0 if don't care. |
| 97 virtual uint32 PreferredOutputFormat() = 0; |
| 101 }; | 98 }; |
| 102 | 99 |
| 103 } // namespace content | 100 } // namespace content |
| 104 | 101 |
| 105 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DEVICE_H_ | 102 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DEVICE_H_ |
| OLD | NEW |