Index: content/common/gpu/media/exynos_v4l2_video_device.cc |
diff --git a/content/common/gpu/media/exynos_v4l2_video_device.cc b/content/common/gpu/media/exynos_v4l2_video_device.cc |
index ef40cf0e6854e4a7a9b90aa24d038bfb60977432..5be18a09037baa56cffc8ea4b5f66f8f4b5d37e3 100644 |
--- a/content/common/gpu/media/exynos_v4l2_video_device.cc |
+++ b/content/common/gpu/media/exynos_v4l2_video_device.cc |
@@ -2,7 +2,9 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
// |
+ |
#include <fcntl.h> |
+#include <libdrm/drm_fourcc.h> |
#include <linux/videodev2.h> |
#include <poll.h> |
#include <sys/eventfd.h> |
@@ -12,6 +14,7 @@ |
#include "base/debug/trace_event.h" |
#include "base/posix/eintr_wrapper.h" |
#include "content/common/gpu/media/exynos_v4l2_video_device.h" |
+#include "ui/gl/gl_bindings.h" |
namespace content { |
@@ -114,4 +117,65 @@ bool ExynosV4L2Device::Initialize() { |
} |
return true; |
} |
+ |
+EGLImageKHR ExynosV4L2Device::CreateEGLImage(EGLDisplay egl_display, |
+ GLuint texture_id, |
+ gfx::Size frame_buffer_size, |
+ unsigned int buffer_index) { |
+ DVLOG(3) << "CreateEGLImage()"; |
+ int dmabuf_fds[2] = {-1, -1}; |
Pawel Osciak
2014/03/27 09:09:50
As I mentioned before, num_planes should be passed
shivdasp
2014/03/27 09:33:22
I think this is do-able quickly.Done.
On 2014/03/2
sheu
2014/03/27 09:40:41
I'd disagree here -- if we're defining a preferred
shivdasp
2014/03/27 10:06:46
I think the num_planes depend upon the output form
Pawel Osciak
2014/03/28 05:33:53
Yes this is exactly what I mean. There is no need
shivdasp
2014/03/28 05:42:38
Okay I will make a change to send in the num_plane
|
+ for (size_t i = 0; i < arraysize(dmabuf_fds); ++i) { |
+ // Export the DMABUF fd so we can export it as a texture. |
+ struct v4l2_exportbuffer expbuf; |
+ memset(&expbuf, 0, sizeof(expbuf)); |
+ expbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
+ expbuf.index = buffer_index; |
+ expbuf.plane = i; |
+ expbuf.flags = O_CLOEXEC; |
+ if (HANDLE_EINTR(Ioctl(VIDIOC_EXPBUF, &expbuf) != 0)) { |
+ return EGL_NO_IMAGE_KHR; |
Pawel Osciak
2014/03/27 09:09:50
If this fails on any other than the first fd, we w
shivdasp
2014/03/27 09:33:22
I need to understand the usage here. If I understa
sheu
2014/03/27 09:40:41
See above about preferred format.
In the case we
shivdasp
2014/03/27 10:06:46
Using ScopedFD looks easier, let me make that chan
Pawel Osciak
2014/03/28 05:33:53
Yes, sorry, I forgot we had ScopedFD
|
+ } |
+ dmabuf_fds[i] = expbuf.fd; |
+ } |
+ EGLint attrs[] = { |
+ EGL_WIDTH, 0, EGL_HEIGHT, 0, |
+ EGL_LINUX_DRM_FOURCC_EXT, 0, EGL_DMA_BUF_PLANE0_FD_EXT, 0, |
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, EGL_DMA_BUF_PLANE0_PITCH_EXT, 0, |
+ EGL_DMA_BUF_PLANE1_FD_EXT, 0, EGL_DMA_BUF_PLANE1_OFFSET_EXT, 0, |
+ EGL_DMA_BUF_PLANE1_PITCH_EXT, 0, EGL_NONE, }; |
+ attrs[1] = frame_buffer_size.width(); |
+ attrs[3] = frame_buffer_size.height(); |
+ attrs[5] = DRM_FORMAT_NV12; |
Pawel Osciak
2014/03/27 09:09:50
This shouldn't be hardcoded either actually...
Ho
shivdasp
2014/03/27 09:33:22
How do you propose we remove the hardcoding of DRM
sheu
2014/03/27 09:40:41
See above about preferred format.
Pawel Osciak
2014/03/28 05:33:53
Ok, let's keep it for now and figure it out later.
shivdasp
2014/03/28 05:42:38
I understand there is no more change required here
|
+ attrs[7] = dmabuf_fds[0]; |
+ attrs[9] = 0; |
+ attrs[11] = frame_buffer_size.width(); |
+ attrs[13] = dmabuf_fds[1]; |
+ attrs[15] = 0; |
+ attrs[17] = frame_buffer_size.width(); |
+ |
+ EGLImageKHR egl_image = eglCreateImageKHR( |
+ egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attrs); |
+ if (egl_image == EGL_NO_IMAGE_KHR) { |
+ close(dmabuf_fds[0]); |
+ close(dmabuf_fds[1]); |
+ return egl_image; |
+ } |
+ glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id); |
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image); |
+ |
+ // Close the fds now |
+ close(dmabuf_fds[0]); |
+ close(dmabuf_fds[1]); |
+ return egl_image; |
+} |
+ |
+EGLBoolean ExynosV4L2Device::DestroyEGLImage(EGLDisplay egl_display, |
+ EGLImageKHR egl_image) { |
+ return eglDestroyImageKHR(egl_display, egl_image); |
+} |
+ |
+GLenum ExynosV4L2Device::GetTextureTarget() { return GL_TEXTURE_EXTERNAL_OES; } |
+ |
+uint32 ExynosV4L2Device::PreferredOutputFormat() { return V4L2_PIX_FMT_NV12M; } |
+ |
} // namespace content |