camera/drv-v4l2.c
VidFrame* v4l2CaptureQueryFrame(V4L2Capture* capture){
  VidFrame *frame=0;
  int n;
		
  if (capture->iomode == V4L2_CAP_STREAMING){
		
    capture->curr_frame_idx++;
		
    if (capture->curr_frame_idx >= capture->frames){
      capture->curr_frame_idx = 0;	
    }
		
    capture_dequeue(capture);
		
    frame= &capture->framesbuffer[capture->curr_frame_idx];
    //#ifndef BURST_MODE
    if (!capture->burst_mode){
      int next = capture->curr_frame_idx +1;
		
      if (next >= capture->frames)
        next=0;
		
      capture_enqueue(capture,next);
    } else {
      //#else
      capture_enqueue(capture,capture->curr_frame_idx);
    }
    //#endif		
		
  } else if (capture->iomode == V4L2_CAP_READWRITE) {
		
    if (!capture->frames){ 
      capture_create_frames_buffer(capture,2);	
    }
		
    capture->curr_frame_idx++;
    if (capture->curr_frame_idx >= capture->frames){
      capture->curr_frame_idx = 0;	
    }
		
    frame= &capture->framesbuffer[capture->curr_frame_idx]; 
		
    if (vidFrameGetBufferLength(frame) < capture->bufsize){
      //frame->data = realloc(frame->data,capture->bufsize);
      vidFrameResizeBuffer(frame,capture->bufsize);
    }
		
    n = read(capture->fd,frame->data,capture->bufsize);
		
    if (n!=capture->bufsize){
      capture_log(capture,"Excepted %d of bytes read but only %d retruned\n",
                  capture->bufsize,n); 						
      frame = 0;
    }
		
  } else { 
    capture_log(capture,"Unknown IO Mode\n");
  }
  return frame;
}
/**
 *  @param capture - video capture structure
 *  @return A newly grabbed video frame. It should not be released or modified by user.
 * 
 *  \todo time stamp
 */
@param capture - video capture structure
@return A newly grabbed video frame. It should not be released or modified by user.

\todo time stamp
@param capture - video capture structure @return A newly grabbed video frame . It should not be released or modified by user . \ todo time stamp
VidFrame* v4l2CaptureQueryFrame(V4L2Capture* capture){
  VidFrame *frame=0;
  int n;
  if (capture->iomode == V4L2_CAP_STREAMING){
    capture->curr_frame_idx++;
    if (capture->curr_frame_idx >= capture->frames){
      capture->curr_frame_idx = 0;	
    }
    capture_dequeue(capture);
    frame= &capture->framesbuffer[capture->curr_frame_idx];
    if (!capture->burst_mode){
      int next = capture->curr_frame_idx +1;
      if (next >= capture->frames)
        next=0;
      capture_enqueue(capture,next);
    } else {
      capture_enqueue(capture,capture->curr_frame_idx);
    }
  } else if (capture->iomode == V4L2_CAP_READWRITE) {
    if (!capture->frames){ 
      capture_create_frames_buffer(capture,2);	
    }
    capture->curr_frame_idx++;
    if (capture->curr_frame_idx >= capture->frames){
      capture->curr_frame_idx = 0;	
    }
    frame= &capture->framesbuffer[capture->curr_frame_idx]; 
    if (vidFrameGetBufferLength(frame) < capture->bufsize){
      vidFrameResizeBuffer(frame,capture->bufsize);
    }
    n = read(capture->fd,frame->data,capture->bufsize);
    if (n!=capture->bufsize){
      capture_log(capture,"Excepted %d of bytes read but only %d retruned\n",
                  capture->bufsize,n); 						
      frame = 0;
    }
  } else { 
    capture_log(capture,"Unknown IO Mode\n");
  }
  return frame;
}
VidFrame * v4l2CaptureQueryFrame ( V4L2Capture * capture ) { VidFrame * frame = 0 ; int n ; if ( capture -> iomode == V4L2_CAP_STREAMING ) { capture -> curr_frame_idx ++ ; if ( capture -> curr_frame_idx >= capture -> frames ) { capture -> curr_frame_idx = 0 ; } capture_dequeue ( capture ) ; frame = & capture -> framesbuffer [ capture -> curr_frame_idx ] ; if ( ! capture -> burst_mode ) { int next = capture -> curr_frame_idx + 1 ; if ( next >= capture -> frames ) next = 0 ; capture_enqueue ( capture , next ) ; } else { capture_enqueue ( capture , capture -> curr_frame_idx ) ; } } else if ( capture -> iomode == V4L2_CAP_READWRITE ) { if ( ! capture -> frames ) { capture_create_frames_buffer ( capture , 2 ) ; } capture -> curr_frame_idx ++ ; if ( capture -> curr_frame_idx >= capture -> frames ) { capture -> curr_frame_idx = 0 ; } frame = & capture -> framesbuffer [ capture -> curr_frame_idx ] ; if ( vidFrameGetBufferLength ( frame ) < capture -> bufsize ) { vidFrameResizeBuffer ( frame , capture -> bufsize ) ; } n = read ( capture -> fd , frame -> data , capture -> bufsize ) ; if ( n != capture -> bufsize ) { capture_log ( capture , " \n " , capture -> bufsize , n ) ; frame = 0 ; } } else { capture_log ( capture , " \n " ) ; } return frame ; }
@param capture - video capture structure
  @return A newly grabbed video frame.
@param capture - video capture structure @return A newly grabbed video frame .
//#ifndef BURST_MODE //#else //#endif		 //frame->data = realloc(frame->data,capture->bufsize);