1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

style(video): Simplified ifdefs, made them USING_V4L to be explicit.

Changed complex ifdef statements into simpler ones using the easy to
read token USING_V4L.
This commit is contained in:
Yuri 2017-02-02 13:38:53 -08:00
parent 5c5dce4d33
commit 2340a7491a

View File

@ -28,10 +28,12 @@ extern "C" {
#include "cameradevice.h" #include "cameradevice.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#define USING_V4L defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include "src/platform/camera/directshow.h" #include "src/platform/camera/directshow.h"
#endif #endif
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if USING_V4L
#include "src/platform/camera/v4l2.h" #include "src/platform/camera/v4l2.h"
#endif #endif
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
@ -150,7 +152,7 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode)
AVDictionary* options = nullptr; AVDictionary* options = nullptr;
if (!iformat); if (!iformat);
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if USING_V4L
else if (devName.startsWith("x11grab#")) else if (devName.startsWith("x11grab#"))
{ {
QSize screen; QSize screen;
@ -359,7 +361,7 @@ QVector<QPair<QString, QString>> CameraDevice::getDeviceList()
else if (iformat->name == QString("dshow")) else if (iformat->name == QString("dshow"))
devices += DirectShow::getDeviceList(); devices += DirectShow::getDeviceList();
#endif #endif
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if USING_V4L
else if (iformat->name == QString("video4linux2,v4l2")) else if (iformat->name == QString("video4linux2,v4l2"))
devices += v4l2::getDeviceList(); devices += v4l2::getDeviceList();
#endif #endif
@ -467,7 +469,7 @@ QVector<VideoMode> CameraDevice::getVideoModes(QString devName)
else if (iformat->name == QString("dshow")) else if (iformat->name == QString("dshow"))
return DirectShow::getDeviceModes(devName); return DirectShow::getDeviceModes(devName);
#endif #endif
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if USING_V4L
else if (iformat->name == QString("video4linux2,v4l2")) else if (iformat->name == QString("video4linux2,v4l2"))
return v4l2::getDeviceModes(devName); return v4l2::getDeviceModes(devName);
#endif #endif
@ -488,7 +490,7 @@ QVector<VideoMode> CameraDevice::getVideoModes(QString devName)
*/ */
QString CameraDevice::getPixelFormatString(uint32_t pixel_format) QString CameraDevice::getPixelFormatString(uint32_t pixel_format)
{ {
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if USING_V4L
return v4l2::getPixelFormatString(pixel_format); return v4l2::getPixelFormatString(pixel_format);
#else #else
return QString("unknown"); return QString("unknown");
@ -504,7 +506,7 @@ QString CameraDevice::getPixelFormatString(uint32_t pixel_format)
*/ */
bool CameraDevice::betterPixelFormat(uint32_t a, uint32_t b) bool CameraDevice::betterPixelFormat(uint32_t a, uint32_t b)
{ {
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if USING_V4L
return v4l2::betterPixelFormat(a, b); return v4l2::betterPixelFormat(a, b);
#else #else
return false; return false;
@ -524,7 +526,7 @@ bool CameraDevice::getDefaultInputFormat()
avdevice_register_all(); avdevice_register_all();
// Desktop capture input formats // Desktop capture input formats
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if USING_V4L
idesktopFormat = av_find_input_format("x11grab"); idesktopFormat = av_find_input_format("x11grab");
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -532,7 +534,7 @@ bool CameraDevice::getDefaultInputFormat()
#endif #endif
// Webcam input formats // Webcam input formats
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if USING_V4L
if ((iformat = av_find_input_format("v4l2"))) if ((iformat = av_find_input_format("v4l2")))
return true; return true;
#endif #endif