Skip to content

Commit

Permalink
Generalize video encode/decode device name
Browse files Browse the repository at this point in the history
BUG=405861
TEST=manually test on pi

Review URL: https://codereview.chromium.org/763743002

Cr-Commit-Position: refs/heads/master@{#306062}
  • Loading branch information
henryhsu authored and Commit bot committed Nov 28, 2014
1 parent 482177c commit 64dbe03
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
#include "base/debug/trace_event.h"
#include "base/files/scoped_file.h"
#include "base/posix/eintr_wrapper.h"
#include "content/common/gpu/media/exynos_v4l2_video_device.h"
#include "content/common/gpu/media/generic_v4l2_video_device.h"
#include "ui/gl/gl_bindings.h"

namespace content {

namespace {
const char kDecoderDevice[] = "/dev/mfc-dec";
const char kEncoderDevice[] = "/dev/mfc-enc";
const char kDecoderDevice[] = "/dev/video-dec";
const char kEncoderDevice[] = "/dev/video-enc";
const char kImageProcessorDevice[] = "/dev/gsc1";
}

ExynosV4L2Device::ExynosV4L2Device(Type type)
GenericV4L2Device::GenericV4L2Device(Type type)
: type_(type),
device_fd_(-1),
device_poll_interrupt_fd_(-1) {}

ExynosV4L2Device::~ExynosV4L2Device() {
GenericV4L2Device::~GenericV4L2Device() {
if (device_poll_interrupt_fd_ != -1) {
close(device_poll_interrupt_fd_);
device_poll_interrupt_fd_ = -1;
Expand All @@ -41,11 +41,11 @@ ExynosV4L2Device::~ExynosV4L2Device() {
}
}

int ExynosV4L2Device::Ioctl(int request, void* arg) {
int GenericV4L2Device::Ioctl(int request, void* arg) {
return HANDLE_EINTR(ioctl(device_fd_, request, arg));
}

bool ExynosV4L2Device::Poll(bool poll_device, bool* event_pending) {
bool GenericV4L2Device::Poll(bool poll_device, bool* event_pending) {
struct pollfd pollfds[2];
nfds_t nfds;
int pollfd = -1;
Expand All @@ -70,19 +70,19 @@ bool ExynosV4L2Device::Poll(bool poll_device, bool* event_pending) {
return true;
}

void* ExynosV4L2Device::Mmap(void* addr,
void* GenericV4L2Device::Mmap(void* addr,
unsigned int len,
int prot,
int flags,
unsigned int offset) {
return mmap(addr, len, prot, flags, device_fd_, offset);
}

void ExynosV4L2Device::Munmap(void* addr, unsigned int len) {
void GenericV4L2Device::Munmap(void* addr, unsigned int len) {
munmap(addr, len);
}

bool ExynosV4L2Device::SetDevicePollInterrupt() {
bool GenericV4L2Device::SetDevicePollInterrupt() {
DVLOG(3) << "SetDevicePollInterrupt()";

const uint64 buf = 1;
Expand All @@ -93,7 +93,7 @@ bool ExynosV4L2Device::SetDevicePollInterrupt() {
return true;
}

bool ExynosV4L2Device::ClearDevicePollInterrupt() {
bool GenericV4L2Device::ClearDevicePollInterrupt() {
DVLOG(3) << "ClearDevicePollInterrupt()";

uint64 buf;
Expand All @@ -109,7 +109,7 @@ bool ExynosV4L2Device::ClearDevicePollInterrupt() {
return true;
}

bool ExynosV4L2Device::Initialize() {
bool GenericV4L2Device::Initialize() {
const char* device_path = NULL;
switch (type_) {
case kDecoder:
Expand Down Expand Up @@ -137,7 +137,7 @@ bool ExynosV4L2Device::Initialize() {
return true;
}

EGLImageKHR ExynosV4L2Device::CreateEGLImage(EGLDisplay egl_display,
EGLImageKHR GenericV4L2Device::CreateEGLImage(EGLDisplay egl_display,
EGLContext /* egl_context */,
GLuint texture_id,
gfx::Size frame_buffer_size,
Expand Down Expand Up @@ -187,21 +187,21 @@ EGLImageKHR ExynosV4L2Device::CreateEGLImage(EGLDisplay egl_display,
return egl_image;
}

EGLBoolean ExynosV4L2Device::DestroyEGLImage(EGLDisplay egl_display,
EGLBoolean GenericV4L2Device::DestroyEGLImage(EGLDisplay egl_display,
EGLImageKHR egl_image) {
return eglDestroyImageKHR(egl_display, egl_image);
}

GLenum ExynosV4L2Device::GetTextureTarget() { return GL_TEXTURE_EXTERNAL_OES; }
GLenum GenericV4L2Device::GetTextureTarget() { return GL_TEXTURE_EXTERNAL_OES; }

uint32 ExynosV4L2Device::PreferredInputFormat() {
uint32 GenericV4L2Device::PreferredInputFormat() {
// TODO(posciak): We should support "dontcare" returns here once we
// implement proper handling (fallback, negotiation) for this in users.
CHECK_EQ(type_, kEncoder);
return V4L2_PIX_FMT_NV12M;
}

uint32 ExynosV4L2Device::PreferredOutputFormat() {
uint32 GenericV4L2Device::PreferredOutputFormat() {
// TODO(posciak): We should support "dontcare" returns here once we
// implement proper handling (fallback, negotiation) for this in users.
CHECK_EQ(type_, kDecoder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file contains the implementation of ExynosV4L2Device used on
// Exynos platform.
// This file contains the implementation of GenericV4L2Device used on
// Generic platform.

#ifndef CONTENT_COMMON_GPU_MEDIA_EXYNOS_V4L2_VIDEO_DEVICE_H_
#define CONTENT_COMMON_GPU_MEDIA_EXYNOS_V4L2_VIDEO_DEVICE_H_
#ifndef CONTENT_COMMON_GPU_MEDIA_GENERIC_V4L2_VIDEO_DEVICE_H_
#define CONTENT_COMMON_GPU_MEDIA_GENERIC_V4L2_VIDEO_DEVICE_H_

#include "content/common/gpu/media/v4l2_video_device.h"

namespace content {

class ExynosV4L2Device : public V4L2Device {
class GenericV4L2Device : public V4L2Device {
public:
explicit ExynosV4L2Device(Type type);
virtual ~ExynosV4L2Device();
explicit GenericV4L2Device(Type type);
virtual ~GenericV4L2Device();

// V4L2Device implementation.
virtual int Ioctl(int request, void* arg) override;
Expand Down Expand Up @@ -51,8 +51,8 @@ class ExynosV4L2Device : public V4L2Device {
// interrupted.
int device_poll_interrupt_fd_;

DISALLOW_COPY_AND_ASSIGN(ExynosV4L2Device);
DISALLOW_COPY_AND_ASSIGN(GenericV4L2Device);
};
} // namespace content

#endif // CONTENT_COMMON_GPU_MEDIA_EXYNOS_V4L2_VIDEO_DEVICE_H_
#endif // CONTENT_COMMON_GPU_MEDIA_GENERIC_V4L2_VIDEO_DEVICE_H_
8 changes: 4 additions & 4 deletions content/common/gpu/media/v4l2_video_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <linux/videodev2.h>

#include "base/numerics/safe_conversions.h"
#include "content/common/gpu/media/exynos_v4l2_video_device.h"
#include "content/common/gpu/media/generic_v4l2_video_device.h"
#include "content/common/gpu/media/tegra_v4l2_video_device.h"

namespace content {
Expand All @@ -16,9 +16,9 @@ V4L2Device::~V4L2Device() {}
scoped_ptr<V4L2Device> V4L2Device::Create(Type type) {
DVLOG(3) << __PRETTY_FUNCTION__;

scoped_ptr<ExynosV4L2Device> exynos_device(new ExynosV4L2Device(type));
if (exynos_device->Initialize())
return exynos_device.Pass();
scoped_ptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type));
if (generic_device->Initialize())
return generic_device.Pass();

scoped_ptr<TegraV4L2Device> tegra_device(new TegraV4L2Device(type));
if (tegra_device->Initialize())
Expand Down
4 changes: 2 additions & 2 deletions content/content_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,8 @@
'../media/media.gyp:media',
],
'sources': [
'common/gpu/media/exynos_v4l2_video_device.cc',
'common/gpu/media/exynos_v4l2_video_device.h',
'common/gpu/media/generic_v4l2_video_device.cc',
'common/gpu/media/generic_v4l2_video_device.h',
'common/gpu/media/tegra_v4l2_video_device.cc',
'common/gpu/media/tegra_v4l2_video_device.h',
'common/gpu/media/v4l2_image_processor.cc',
Expand Down

0 comments on commit 64dbe03

Please sign in to comment.