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
3 // found in the LICENSE file.
5 // This file contains the implementation of GenericV4L2Device used on
6 // platforms, which provide generic V4L2 video codec devices.
8 #ifndef CONTENT_COMMON_GPU_MEDIA_GENERIC_V4L2_DEVICE_H_
9 #define CONTENT_COMMON_GPU_MEDIA_GENERIC_V4L2_DEVICE_H_
11 #include "base/files/scoped_file.h"
12 #include "content/common/gpu/media/v4l2_device.h"
16 class GenericV4L2Device
: public V4L2Device
{
18 explicit GenericV4L2Device(Type type
);
20 // V4L2Device implementation.
21 int Ioctl(int request
, void* arg
) override
;
22 bool Poll(bool poll_device
, bool* event_pending
) override
;
23 bool SetDevicePollInterrupt() override
;
24 bool ClearDevicePollInterrupt() override
;
25 void* Mmap(void* addr
,
29 unsigned int offset
) override
;
30 void Munmap(void* addr
, unsigned int len
) override
;
31 bool Initialize() override
;
32 bool CanCreateEGLImageFrom(uint32_t v4l2_pixfmt
) override
;
33 EGLImageKHR
CreateEGLImage(EGLDisplay egl_display
,
34 EGLContext egl_context
,
36 gfx::Size frame_buffer_size
,
37 unsigned int buffer_index
,
39 size_t num_v4l2_planes
) override
;
40 EGLBoolean
DestroyEGLImage(EGLDisplay egl_display
,
41 EGLImageKHR egl_image
) override
;
42 GLenum
GetTextureTarget() override
;
43 uint32
PreferredInputFormat() override
;
46 ~GenericV4L2Device() override
;
48 // The actual device fd.
49 base::ScopedFD device_fd_
;
51 // eventfd fd to signal device poll thread when its poll() should be
53 base::ScopedFD device_poll_interrupt_fd_
;
55 // Use libv4l2 when operating |device_fd_|.
58 DISALLOW_COPY_AND_ASSIGN(GenericV4L2Device
);
60 // Lazily initialize static data after sandbox is enabled. Return false on
62 static bool PostSandboxInitialization();
64 } // namespace content
66 #endif // CONTENT_COMMON_GPU_MEDIA_GENERIC_V4L2_DEVICE_H_