整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
81
video/v4l2/Output.cpp
Executable file
81
video/v4l2/Output.cpp
Executable file
|
|
@ -0,0 +1,81 @@
|
|||
#include "Output.h"
|
||||
#include "MmapDevice.h"
|
||||
#include "ReadWriteDevice.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
namespace Video
|
||||
{
|
||||
namespace V4L2
|
||||
{
|
||||
Output* Output::create(const DeviceParameters& param)
|
||||
{
|
||||
Output* videoOutput = NULL;
|
||||
Device* videoDevice = NULL;
|
||||
int caps = V4L2_CAP_VIDEO_OUTPUT;
|
||||
switch (param.m_iotype)
|
||||
{
|
||||
case IOTYPE_MMAP:
|
||||
videoDevice = new MmapDevice(param, V4L2_BUF_TYPE_VIDEO_OUTPUT);
|
||||
caps |= V4L2_CAP_STREAMING;
|
||||
break;
|
||||
|
||||
case IOTYPE_READWRITE:
|
||||
videoDevice = new ReadWriteDevice(param, V4L2_BUF_TYPE_VIDEO_OUTPUT);
|
||||
caps |= V4L2_CAP_READWRITE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (videoDevice && !videoDevice->init(caps))
|
||||
{
|
||||
delete videoDevice;
|
||||
videoDevice = NULL;
|
||||
}
|
||||
|
||||
if (videoDevice)
|
||||
{
|
||||
videoOutput = new Output(videoDevice);
|
||||
}
|
||||
return videoOutput;
|
||||
}
|
||||
|
||||
Output::Output(Device* device): Access(device)
|
||||
{
|
||||
}
|
||||
|
||||
Output::~Output()
|
||||
{
|
||||
}
|
||||
|
||||
bool Output::isWritable(timeval* tv)
|
||||
{
|
||||
int fd = m_device->getFd();
|
||||
fd_set fdset;
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(fd, &fdset);
|
||||
return (select(fd + 1, NULL, &fdset, NULL, tv) == 1);
|
||||
}
|
||||
|
||||
size_t Output::write(char* buffer, size_t bufferSize)
|
||||
{
|
||||
return m_device->writeInternal(buffer, bufferSize);
|
||||
}
|
||||
|
||||
bool Output::startPartialWrite()
|
||||
{
|
||||
return m_device->startPartialWrite();
|
||||
}
|
||||
|
||||
size_t Output::writePartial(char* buffer, size_t bufferSize)
|
||||
{
|
||||
return m_device->writePartialInternal(buffer, bufferSize);
|
||||
}
|
||||
|
||||
bool Output::endPartialWrite()
|
||||
{
|
||||
return m_device->endPartialWrite();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue