Exemplo n.º 1
0
void Preview::captureFrame()
{
    if (poll(&wc->fpolls, 1, 50) > 0) {
        // dequeue buffer
        if (ioctl(wc->fd, VIDIOC_DQBUF, &wc->buffer) == 0) {

            QVideoFrame vframe( pixelformat, QSize(preview_buffer_width, preview_buffer_height),
                        reinterpret_cast<uchar*>(preview_buffer_data));
            emit frameReady(vframe);

            int ret = ioctl(wc->fd, VIDIOC_QBUF, &wc->buffer);

            // queue up next buffer
            if(ret == -1) {
                if(errno == EAGAIN) {
                    qDebug()<<"nonblocking io slected O_NONBLOCK and no buffer was  in outgoing queue";
                }  else if(errno == EINVAL) {
                    qDebug()<<"buffer type not supported or index OOB or no buffers have been alloced";
                }else if(errno == ENOMEM) {
                    qDebug()<<"insufficient memory";
                }else if(errno == EIO) {
                    qDebug()<<"internal error";
                }
            }
        }
    }
}
// --- next_older ------------------------------------------------------------
// Skip to the next visible Java frame.
// Makes visible inlined compiled frames.
// Skips non-Java frames.
vframe vframe::next_older() const {
assert(!done(),"asking for next but there is no next vframe");
  // Can we walk up inlined Java frames?
if(_fr.is_compiled_frame()){
    const DebugScope *ds = scope();
    if( ds->caller() ) return vframe(_fr,ds->caller(),_sbafid); // Next virtual caller
  }
  // Time to skip a real physical frame
  frame fr = _fr.sender();
  int sbafid = _sbafid;
  while( 1 ) {
    Untested("");
    if( fr.is_java_frame() || fr.is_first_frame() ) {
#ifdef ASSERT
      assert(!_fr.is_runtime_frame(), "unexpected runtime stub");
#endif
      return vframe(fr, LAZY_DEBUG, sbafid);
    }
    if( fr.is_entry_frame() ) sbafid--; // Each entry frame pushes an SBA frame
    fr = fr.sender();
  }
}
Exemplo n.º 3
0
void V4L1Preview::captureFrame()
{
    // Start capturing the next frame (we alternate between 0 and 1).
    int frame = wc->currentFrame;
    struct video_mmap capture;
    if ( wc->mbuf.frames > 1 ) {
        wc->currentFrame = !wc->currentFrame;
        capture.frame = wc->currentFrame;
        capture.width = wc->width;
        capture.height = wc->height;
        capture.format = VIDEO_PALETTE_RGB32;
        ioctl( wc->fd, VIDIOCMCAPTURE, &capture );
    }

    // Wait for the current frame to complete.
    ioctl( wc->fd, VIDIOCSYNC, &frame );


    preview_buffer_width = wc->width;
    preview_buffer_height = wc->height;
    preview_buffer_data = wc->frames + wc->mbuf.offsets[frame];

    QVideoFrame vframe(QVideoFrame::Format_RGB32, QSize(wc->width, wc->height),
                        reinterpret_cast<uchar*>(preview_buffer_data));
    emit frameReady(vframe);

    // Queue up another frame if the device only supports one at a time.
    if ( wc->mbuf.frames <= 1 ) {
        capture.frame = wc->currentFrame;
        capture.width = wc->width;
        capture.height = wc->height;
        capture.format = VIDEO_PALETTE_RGB32;
        ioctl( wc->fd, VIDIOCMCAPTURE, &capture );
    }

}