Logo Search packages:      
Sourcecode: camstream version File versions  Download package

bool CVideoDevice::SetFramerate ( int  fps  ) 

Try to set a framerate.

Parameters:
fps The framerate, in frames per second.
Returns:
TRUE if the framerate was accepted, FALSE otherwise
Some webcams allow their framerate to be set; this functions tries to do just that; in general, the camera will use the framerate closest to what it supports. In case a device does not support framerates or only a fixed framerate (grabber cards!) we use the framerate to set the timer.

Definition at line 889 of file VideoDevice.cc.

References FramerateChanged().

{
   struct video_window vwin;
qDebug("CVideoDevice::SetFramerate(%d)", fps);
   if (CamFD < 0 || ioctl(CamFD, VIDIOCGWIN, &vwin) < 0)
     return FALSE;

   if (HasFramerate) {
//     MSync(); // Drop current frame
     FrameRate = fps;
     if (FrameRate <= 0)
       FrameRate = 0;
     if (FrameRate > 63)
       FrameRate = 63;
#if defined(PWC_FPS_SHIFT)
     vwin.flags = (vwin.flags & ~PWC_FPS_MASK) | (FrameRate << PWC_FPS_SHIFT);
//qDebug("Setting framerate -> 0x%x\n", vwin.flags);
#endif     
     if (ioctl(CamFD, VIDIOCSWIN, &vwin) < 0)
       return FALSE;
//     MCapture(CurBuffer); // Try to grab new frame
   }
   else {
     FrameRate = fps;
     if (FrameRate <= 0) 
       FrameRate = 1;
     if (FrameRate > 60)
       FrameRate = 60;
     if (pImageTimer)
       pImageTimer->start(1000 / FrameRate);
   }
   emit FramerateChanged(FrameRate);
   return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index