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 "base/memory/ref_counted.h" | |
13 #include "media/base/video_decoder_config.h" | 12 #include "media/base/video_decoder_config.h" |
14 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
15 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gl/gl_bindings.h" | 15 #include "ui/gl/gl_bindings.h" |
17 | 16 |
18 namespace content { | 17 namespace content { |
19 | 18 |
20 class V4L2Device : public base::RefCountedThreadSafe<V4L2Device> { | 19 class V4L2Device { |
21 public: | 20 public: |
22 // Utility format conversion functions | 21 // Utility format conversion functions |
23 static media::VideoFrame::Format V4L2PixFmtToVideoFrameFormat(uint32 format); | 22 static media::VideoFrame::Format V4L2PixFmtToVideoFrameFormat(uint32 format); |
24 static uint32 VideoFrameFormatToV4L2PixFmt(media::VideoFrame::Format format); | 23 static uint32 VideoFrameFormatToV4L2PixFmt(media::VideoFrame::Format format); |
25 static uint32 VideoCodecProfileToV4L2PixFmt(media::VideoCodecProfile profile, | 24 static uint32 VideoCodecProfileToV4L2PixFmt(media::VideoCodecProfile profile); |
26 bool slice_based); | |
27 static uint32_t V4L2PixFmtToDrmFormat(uint32_t format); | 25 static uint32_t V4L2PixFmtToDrmFormat(uint32_t format); |
28 // Convert format requirements requested by a V4L2 device to gfx::Size. | 26 // Convert format requirements requested by a V4L2 device to gfx::Size. |
29 static gfx::Size CodedSizeFromV4L2Format(struct v4l2_format format); | 27 static gfx::Size CodedSizeFromV4L2Format(struct v4l2_format format); |
30 | 28 |
| 29 virtual ~V4L2Device(); |
| 30 |
31 enum Type { | 31 enum Type { |
32 kDecoder, | 32 kDecoder, |
33 kEncoder, | 33 kEncoder, |
34 kImageProcessor, | 34 kImageProcessor, |
35 }; | 35 }; |
36 | 36 |
37 // Creates and initializes an appropriate V4L2Device of |type| for the | 37 // Creates and initializes an appropriate V4L2Device of |type| for the |
38 // current platform and returns a scoped_ptr<V4L2Device> on success, or NULL. | 38 // current platform and returns a scoped_ptr<V4L2Device> on success, or NULL. |
39 static scoped_refptr<V4L2Device> Create(Type type); | 39 static scoped_ptr<V4L2Device> Create(Type type); |
40 | 40 |
41 // Parameters and return value are the same as for the standard ioctl() system | 41 // Parameters and return value are the same as for the standard ioctl() system |
42 // call. | 42 // call. |
43 virtual int Ioctl(int request, void* arg) = 0; | 43 virtual int Ioctl(int request, void* arg) = 0; |
44 | 44 |
45 // This method sleeps until either: | 45 // This method sleeps until either: |
46 // - SetDevicePollInterrupt() is called (on another thread), | 46 // - SetDevicePollInterrupt() is called (on another thread), |
47 // - |poll_device| is true, and there is new data to be read from the device, | 47 // - |poll_device| is true, and there is new data to be read from the device, |
48 // or an event from the device has arrived; in the latter case | 48 // or an event from the device has arrived; in the latter case |
49 // |*event_pending| will be set to true. | 49 // |*event_pending| will be set to true. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 // Destroys the EGLImageKHR. | 92 // Destroys the EGLImageKHR. |
93 virtual EGLBoolean DestroyEGLImage(EGLDisplay egl_display, | 93 virtual EGLBoolean DestroyEGLImage(EGLDisplay egl_display, |
94 EGLImageKHR egl_image) = 0; | 94 EGLImageKHR egl_image) = 0; |
95 | 95 |
96 // Returns the supported texture target for the V4L2Device. | 96 // Returns the supported texture target for the V4L2Device. |
97 virtual GLenum GetTextureTarget() = 0; | 97 virtual GLenum GetTextureTarget() = 0; |
98 | 98 |
99 // Returns the preferred V4L2 input format or 0 if don't care. | 99 // Returns the preferred V4L2 input format or 0 if don't care. |
100 virtual uint32 PreferredInputFormat() = 0; | 100 virtual uint32 PreferredInputFormat() = 0; |
101 | |
102 protected: | |
103 friend class base::RefCountedThreadSafe<V4L2Device>; | |
104 virtual ~V4L2Device(); | |
105 }; | 101 }; |
106 | 102 |
107 } // namespace content | 103 } // namespace content |
108 | 104 |
109 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DEVICE_H_ | 105 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DEVICE_H_ |
OLD | NEW |