Removing warning in video capture module for linux and auto test.

Review URL: http://webrtc-codereview.appspot.com/134002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@457 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mflodman@webrtc.org 2011-08-26 10:54:48 +00:00
parent b55c988b22
commit 4fcb0caf78
3 changed files with 3 additions and 83 deletions

View File

@ -323,84 +323,5 @@ WebRtc_Word32 DeviceInfoLinux::FillCapabilityMap(int fd)
return _captureCapabilities.Size();
}
// this function doesn't quite work because of work on v4l2
// the ioctl function doesn't work on many systems
// We will return 0 as a default. Cannot use -1 because it's unsigned num
// not full implemented
// see: http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-enum-framesizes.html
// for information
bool DeviceInfoLinux::GetMaxFPS(int fd, VideoCaptureCapability* cap)
{
struct v4l2_frmivalenum video_enum;
memset(&video_enum, 0, sizeof(struct v4l2_frmivalenum));
// try to open control and query about frame stuff
if (ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &video_enum) >= 0)
{
switch (video_enum.type)
{
case V4L2_FRMIVAL_TYPE_DISCRETE:
{
v4l2_fract discrete = video_enum.discrete;
cap->maxFPS = (WebRtc_UWord32)(discrete.numerator
/ (float) discrete.denominator);
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, _id,
"FrameSize type is DISCRETE. Numerator=%u Denominator=%u FPS=%u",
discrete.numerator, discrete.denominator, cap->maxFPS);
break;
}
case V4L2_FRMIVAL_TYPE_STEPWISE: // stepwise and continuous are close enough for what we need
case V4L2_FRMIVAL_TYPE_CONTINUOUS:
{
v4l2_frmival_stepwise stepwise = video_enum.stepwise;
v4l2_fract min = stepwise.min;
v4l2_fract max = stepwise.max;
cap->maxFPS = (WebRtc_UWord32)(max.numerator / (float) max.denominator);
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture,
_id,
"FrameSize type is STEPWISE or CONTINUOUS. max.num=%u max.den=%u FPS=%u",
max.numerator, max.denominator, cap->maxFPS);
break;
}
default:
{
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, _id,
"video_enum type is unknown");
return false;
break;
}
}
}
else
{
// having problems w/ ioctl.... get error
switch (errno)
{
case EBADF:
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, _id,
"Could not query capture device for framerate. Error:EBADF");
break;
case EFAULT:
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, _id,
"Could not query capture device for framerate. Error:EFAULT");
break;
case EINVAL:
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, _id,
"Could not query capture device for framerate. Error:EINVAL");
break;
case ENOTTY:
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, _id,
"Could not query capture device for framerate. Error:ENOTTY");
break;
default:
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, _id,
"Could not query capture device for framerate. Error:undocumented by \"man ioctl\"");
break;
}
}
return false;
}
}// namespace videocapturemodule
} // namespace videocapturemodule
} // namespace webrtc

View File

@ -45,7 +45,6 @@ public:
private:
bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8);
bool GetMaxFPS(int fd, VideoCaptureCapability* cap);
};
} // namespace videocapturemodule
} // namespace webrtc

View File

@ -152,7 +152,7 @@ int VideoEngineSampleCode(void* window1, void* window2)
captureIdx = 0;
printf("0\n");
#else
int dummy = scanf("%d", &captureIdx);
scanf("%d", &captureIdx);
getchar();
captureIdx = captureIdx - 1; // Compensate for idx start at 1.
#endif
@ -308,7 +308,7 @@ int VideoEngineSampleCode(void* window1, void* window2)
codecIdx = 0;
printf("0\n");
#else
dummy = scanf("%d", &codecIdx);
scanf("%d", &codecIdx);
getchar();
codecIdx = codecIdx - 1; // Compensate for idx start at 1.
#endif