27 #include <sys/types.h>
28 #include <sys/socket.h>
33 int dx_() {
return 640 ; }
34 int dy_() {
return 480 ; }
35 size_t size(
size_t channels ) {
return channels * 640U * 480U ; }
36 size_t rowsize(
size_t channels ) {
return channels * 640U ; }
40 m_generator(generator) ,
79 ::close( m_fd_read ) ;
80 ::close( m_fd_write ) ;
95 return static_cast<unsigned int>(dx_()) ;
100 return static_cast<unsigned int>(dy_()) ;
103 void Gv::CaptureTest::onTimeout()
109 void Gv::CaptureTest::onException( std::exception & )
114 bool Gv::CaptureTest::createSockets()
117 int rc = ::socketpair( AF_LOCAL , SOCK_DGRAM , 0 , fds ) ;
118 if( rc != 0 )
throw std::runtime_error(
"socketpair error" ) ;
120 m_fd_write = fds[1] ;
121 ::fcntl( m_fd_read , F_SETFL , ::fcntl(m_fd_read,F_GETFL) | O_NONBLOCK ) ;
122 ::fcntl( m_fd_write , F_SETFL , ::fcntl(m_fd_write,F_GETFL) | O_NONBLOCK ) ;
126 void Gv::CaptureTest::raiseEvent()
128 if( m_fd_write != -1 )
141 void Gv::CaptureTest::flushEvents()
145 while( ( nread =
G::Msg::recv( m_fd_read , &c , 1U , 0 ) ) == 1 ) ;
153 m_capturing = false ;
164 return std::string() ;
167 void Gv::CaptureTest::readSocket()
170 ssize_t nread =
G::Msg::recv( m_fd_read , &c , 1U , 0 ) ;
172 throw std::runtime_error(
"recv error" ) ;
174 m_timer.startTimer( 0 , 30000U ) ;
193 m_buffer->setFormat( m_format , m_scale ) ;
194 m_generator->fillBuffer( *m_buffer.get() , m_scale ) ;
197 callback( *m_buffer.get() ) ;
triple< unsigned char > rgb(triple< unsigned char > yuv) g__noexcept
A top-level function that calculates rgb from yuv with default implementation options.
virtual bool simple() const override
Override from Capture.
virtual unsigned int dx() const override
Override from Capture.
static ssize_t send(int, const void *, size_t, int, int fd_to_send=-1)
A send() replacement using sendmsg().
An abstract interface for filling a YUYV capture buffer with a generated image.
virtual void start() override
Override from Capture.
virtual int fd() const override
Override from Capture.
A video-capture buffer class to hold image data, with overloaded constructors for the various V4l i/o...
virtual bool init()=0
Initialisation function. Returns true for rgb, false for yuyv.
A structure holding capture buffer dimensions.
virtual bool read(unsigned char *, size_t) override
Override from Capture.
virtual bool active() const override
Override from Capture.
A callback interface for the Gv::Capture class.
virtual void stop() override
Override from Capture.
virtual ~CaptureTest()
Destructor.
CaptureTest(const std::string &config, ImageGenerator *)
Constructor.
A Gv::Capture implementation that serves up dummy frames created by a Gv::ImageGenerator.
virtual std::string info() const override
Override from Capture.
virtual unsigned int dy() const override
Override from Capture.
A descriptor for one colour component in a Gv::CaptureBufferFormat structure.
static ssize_t recv(int, void *, size_t, int, int *fd_received_p=nullptr)
A recv() replacement using recvmsg().