Fixes for Kopete videodevice support

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/34/head
Mavridis Philippe 3 years ago
parent e7fdaa7a61
commit de786a075b
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -46,13 +46,13 @@ endif( )
### Check for videodev header ### Check for videodev header
check_include_file( "libv4l1-videodev.h" HAVE_LIBV4L1_VIDEODEV_H ) check_include_file( "linux/videodev2.h" HAVE_VIDEODEV_H )
if( HAVE_LIBV4L1_VIDEODEV_H ) if( HAVE_VIDEODEV_H )
set( VIDEODEV_HEADER "libv4l1-videodev.h" CACHE INTERNAL "" ) set( VIDEODEV_HEADER "linux/videodev2.h" CACHE INTERNAL "" )
else( ) else( )
check_include_file( "linux/videodev.h" HAVE_VIDEODEV_H ) check_include_file( "libv4l1-videodev.h" HAVE_LIBV4L1_VIDEODEV_H )
if( HAVE_VIDEODEV_H ) if( HAVE_LIBV4L1_VIDEODEV_H )
set( VIDEODEV_HEADER "linux/videodev.h" CACHE INTERNAL "" ) set( VIDEODEV_HEADER "libv4l1-videodev.h" CACHE INTERNAL "" )
else( ) else( )
if( BUILD_KOPETE_PLUGIN_MOTIONAUTOAWAY ) if( BUILD_KOPETE_PLUGIN_MOTIONAUTOAWAY )
tde_message_fatal( "libv4l1-videodev.h or linux/videodev.h is required, but not found on your system" ) tde_message_fatal( "libv4l1-videodev.h or linux/videodev.h is required, but not found on your system" )

@ -57,7 +57,7 @@ VideoDevice::~VideoDevice()
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
void VideoDevice::enumerateMenu (void) void VideoDevice::enumerateMenu (void)
{ {
@ -181,7 +181,7 @@ int VideoDevice::checkDevice()
m_driver=VIDEODEV_DRIVER_NONE; m_driver=VIDEODEV_DRIVER_NONE;
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
//if(!getWorkaroundBrokenDriver()) //if(!getWorkaroundBrokenDriver())
{ {
@ -321,7 +321,7 @@ kdDebug(14010) << k_funcinfo << " Control: " << TQString(TQString::fromLocal8Bi
kdDebug(14010) << k_funcinfo << "Checking CID private controls" << endl; kdDebug(14010) << k_funcinfo << "Checking CID private controls" << endl;
for (currentid = V4L2_CID_PRIVATE_BASE;; currentid++) for (currentid = V4L2_CID_PRIVATE_BASE; currentid < V4L2_CID_PRIVATE_BASE + V4L2_CID_LASTP1 - V4L2_CID_BASE; currentid++)
//for (queryctrl.id = 9963776; queryctrl.id < 9963800; queryctrl.id++) //for (queryctrl.id = 9963776; queryctrl.id < 9963800; queryctrl.id++)
{ {
queryctrl.id = currentid; queryctrl.id = currentid;
@ -358,7 +358,7 @@ kdDebug(14010) << k_funcinfo << " Control: " << TQString(TQString::fromLocal8Bi
} }
} }
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
CLEAR(V4L_capabilities); CLEAR(V4L_capabilities);
@ -423,6 +423,7 @@ kdDebug(14010) << k_funcinfo << " Control: " << TQString(TQString::fromLocal8Bi
} }
} }
#endif
#endif #endif
m_name=m_model; // Take care about changing the name to be different from the model itself... m_name=m_model; // Take care about changing the name to be different from the model itself...
@ -512,7 +513,7 @@ int VideoDevice::initDevice()
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
if(V4L2_capabilities.capabilities & V4L2_CAP_READWRITE) if(V4L2_capabilities.capabilities & V4L2_CAP_READWRITE)
{ {
@ -538,7 +539,7 @@ int VideoDevice::initDevice()
return EXIT_FAILURE; return EXIT_FAILURE;
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
m_videoread=true; m_videoread=true;
m_io_method=IO_METHOD_READ; m_io_method=IO_METHOD_READ;
@ -549,6 +550,7 @@ int VideoDevice::initDevice()
kdDebug(14010) << k_funcinfo << " Streaming interface" << endl; kdDebug(14010) << k_funcinfo << " Streaming interface" << endl;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -558,7 +560,7 @@ int VideoDevice::initDevice()
// Select video input, video standard and tune here. // Select video input, video standard and tune here.
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl (VIDIOC_CROPCAP, &cropcap)) if (-1 == xioctl (VIDIOC_CROPCAP, &cropcap))
{ // Errors ignored. { // Errors ignored.
@ -676,7 +678,7 @@ kdDebug(14010) << k_funcinfo << "setSize(" << newwidth << ", " << newheight <<
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
// CLEAR (fmt); // CLEAR (fmt);
if (-1 == xioctl (VIDIOC_G_FMT, &fmt)) if (-1 == xioctl (VIDIOC_G_FMT, &fmt))
@ -703,7 +705,7 @@ kdDebug(14010) << k_funcinfo << "VIDIOC_S_FMT worked (" << errno << ").Returned
m_buffer_size=fmt.fmt.pix.sizeimage ; m_buffer_size=fmt.fmt.pix.sizeimage ;
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
{ {
struct video_window V4L_videowindow; struct video_window V4L_videowindow;
@ -732,6 +734,7 @@ kdDebug(14010) << "------------- width: " << V4L_videowindow.width << " Height:
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -759,17 +762,6 @@ kdDebug(14010) << k_funcinfo << "setSize(" << newwidth << ", " << newheight <<
} }
pixel_format VideoDevice::setPixelFormat(pixel_format newformat) pixel_format VideoDevice::setPixelFormat(pixel_format newformat)
{ {
pixel_format ret = PIXELFORMAT_NONE; pixel_format ret = PIXELFORMAT_NONE;
@ -778,7 +770,7 @@ pixel_format VideoDevice::setPixelFormat(pixel_format newformat)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
// CLEAR (fmt); // CLEAR (fmt);
if (-1 == xioctl (VIDIOC_G_FMT, &fmt)) if (-1 == xioctl (VIDIOC_G_FMT, &fmt))
@ -803,7 +795,7 @@ pixel_format VideoDevice::setPixelFormat(pixel_format newformat)
} }
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
{ {
struct video_picture V4L_picture; struct video_picture V4L_picture;
@ -827,6 +819,7 @@ pixel_format VideoDevice::setPixelFormat(pixel_format newformat)
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -867,7 +860,7 @@ int VideoDevice::selectInput(int newinput)
switch (m_driver) switch (m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
if (-1 == ioctl (descriptor, VIDIOC_S_INPUT, &newinput)) if (-1 == ioctl (descriptor, VIDIOC_S_INPUT, &newinput))
{ {
@ -875,7 +868,7 @@ int VideoDevice::selectInput(int newinput)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
struct video_channel V4L_input; struct video_channel V4L_input;
V4L_input.channel=newinput; V4L_input.channel=newinput;
@ -886,6 +879,7 @@ int VideoDevice::selectInput(int newinput)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -935,7 +929,7 @@ int VideoDevice::startCapturing()
break; break;
case IO_METHOD_MMAP: case IO_METHOD_MMAP:
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
{ {
unsigned int loop; unsigned int loop;
for (loop = 0; loop < m_streambuffers; ++loop) for (loop = 0; loop < m_streambuffers; ++loop)
@ -957,7 +951,7 @@ int VideoDevice::startCapturing()
break; break;
case IO_METHOD_USERPTR: case IO_METHOD_USERPTR:
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
{ {
unsigned int loop; unsigned int loop;
for (loop = 0; loop < m_streambuffers; ++loop) for (loop = 0; loop < m_streambuffers; ++loop)
@ -995,7 +989,7 @@ int VideoDevice::getFrame()
ssize_t bytesread; ssize_t bytesread;
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
struct v4l2_buffer v4l2buffer; struct v4l2_buffer v4l2buffer;
#endif #endif
#endif #endif
@ -1029,7 +1023,7 @@ int VideoDevice::getFrame()
break; break;
case IO_METHOD_MMAP: case IO_METHOD_MMAP:
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
CLEAR (v4l2buffer); CLEAR (v4l2buffer);
v4l2buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v4l2buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2buffer.memory = V4L2_MEMORY_MMAP; v4l2buffer.memory = V4L2_MEMORY_MMAP;
@ -1089,7 +1083,7 @@ memcpy(&m_currentbuffer.data[0], m_rawbuffers[v4l2buffer.index].start, m_current
break; break;
case IO_METHOD_USERPTR: case IO_METHOD_USERPTR:
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
{ {
unsigned int i; unsigned int i;
CLEAR (v4l2buffer); CLEAR (v4l2buffer);
@ -1414,7 +1408,7 @@ int VideoDevice::stopCapturing()
break; break;
case IO_METHOD_MMAP: case IO_METHOD_MMAP:
case IO_METHOD_USERPTR: case IO_METHOD_USERPTR:
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
{ {
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl (VIDIOC_STREAMOFF, &type)) if (-1 == xioctl (VIDIOC_STREAMOFF, &type))
@ -1475,7 +1469,7 @@ float VideoDevice::setBrightness(float brightness)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
struct v4l2_queryctrl queryctrl; struct v4l2_queryctrl queryctrl;
@ -1510,7 +1504,7 @@ float VideoDevice::setBrightness(float brightness)
} }
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
{ {
struct video_picture V4L_picture; struct video_picture V4L_picture;
@ -1521,6 +1515,7 @@ float VideoDevice::setBrightness(float brightness)
kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting image brightness. Fallback to it is not yet implemented." << endl; kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting image brightness. Fallback to it is not yet implemented." << endl;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -1545,7 +1540,7 @@ float VideoDevice::setContrast(float contrast)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
struct v4l2_queryctrl queryctrl; struct v4l2_queryctrl queryctrl;
@ -1580,7 +1575,7 @@ float VideoDevice::setContrast(float contrast)
} }
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
{ {
struct video_picture V4L_picture; struct video_picture V4L_picture;
@ -1591,6 +1586,7 @@ float VideoDevice::setContrast(float contrast)
kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting image contrast. Fallback to it is not yet implemented." << endl; kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting image contrast. Fallback to it is not yet implemented." << endl;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -1615,7 +1611,7 @@ float VideoDevice::setSaturation(float saturation)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
struct v4l2_queryctrl queryctrl; struct v4l2_queryctrl queryctrl;
@ -1650,7 +1646,7 @@ float VideoDevice::setSaturation(float saturation)
} }
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
{ {
struct video_picture V4L_picture; struct video_picture V4L_picture;
@ -1661,6 +1657,7 @@ float VideoDevice::setSaturation(float saturation)
kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting image saturation. Fallback to it is not yet implemented." << endl; kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting image saturation. Fallback to it is not yet implemented." << endl;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -1685,7 +1682,7 @@ float VideoDevice::setWhiteness(float whiteness)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
struct v4l2_queryctrl queryctrl; struct v4l2_queryctrl queryctrl;
@ -1720,7 +1717,7 @@ float VideoDevice::setWhiteness(float whiteness)
} }
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
{ {
struct video_picture V4L_picture; struct video_picture V4L_picture;
@ -1731,6 +1728,7 @@ float VideoDevice::setWhiteness(float whiteness)
kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting white level. Fallback to it is not yet implemented." << endl; kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting white level. Fallback to it is not yet implemented." << endl;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -1755,7 +1753,7 @@ float VideoDevice::setHue(float hue)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
struct v4l2_queryctrl queryctrl; struct v4l2_queryctrl queryctrl;
@ -1790,7 +1788,7 @@ float VideoDevice::setHue(float hue)
} }
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
{ {
struct video_picture V4L_picture; struct video_picture V4L_picture;
@ -1801,6 +1799,7 @@ float VideoDevice::setHue(float hue)
kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting image hue. Fallback to it is not yet implemented." << endl; kdDebug(14010) << k_funcinfo << "Card seems to not support adjusting image hue. Fallback to it is not yet implemented." << endl;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -1876,7 +1875,7 @@ pixel_format VideoDevice::pixelFormatForPalette( int palette )
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(palette) switch(palette)
{ {
@ -1925,7 +1924,7 @@ pixel_format VideoDevice::pixelFormatForPalette( int palette )
case V4L2_PIX_FMT_YYUV : return PIXELFORMAT_YYUV; break; case V4L2_PIX_FMT_YYUV : return PIXELFORMAT_YYUV; break;
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
switch(palette) switch(palette)
{ {
@ -1945,6 +1944,7 @@ pixel_format VideoDevice::pixelFormatForPalette( int palette )
case VIDEO_PALETTE_YUV422P : return PIXELFORMAT_YUV422P; break; case VIDEO_PALETTE_YUV422P : return PIXELFORMAT_YUV422P; break;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -1958,7 +1958,7 @@ int VideoDevice::pixelFormatCode(pixel_format pixelformat)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(pixelformat) switch(pixelformat)
{ {
@ -2007,7 +2007,7 @@ int VideoDevice::pixelFormatCode(pixel_format pixelformat)
case PIXELFORMAT_YYUV : return V4L2_PIX_FMT_YYUV; break; case PIXELFORMAT_YYUV : return V4L2_PIX_FMT_YYUV; break;
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
switch(pixelformat) switch(pixelformat)
{ {
@ -2056,6 +2056,7 @@ int VideoDevice::pixelFormatCode(pixel_format pixelformat)
case PIXELFORMAT_YYUV : return 0; break; case PIXELFORMAT_YYUV : return 0; break;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -2172,7 +2173,7 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(pixelformat) switch(pixelformat)
{ {
@ -2221,7 +2222,7 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
case V4L2_PIX_FMT_YYUV : returnvalue = pixelFormatName(PIXELFORMAT_YYUV); break; case V4L2_PIX_FMT_YYUV : returnvalue = pixelFormatName(PIXELFORMAT_YYUV); break;
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
switch(pixelformat) switch(pixelformat)
{ {
@ -2240,6 +2241,7 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
case VIDEO_PALETTE_YUV422P : returnvalue = pixelFormatName(PIXELFORMAT_YUV422P); break; case VIDEO_PALETTE_YUV422P : returnvalue = pixelFormatName(PIXELFORMAT_YUV422P); break;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -2251,14 +2253,14 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
int VideoDevice::detectPixelFormats() int VideoDevice::detectPixelFormats()
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
int err = 0; int err = 0;
#endif #endif
#endif #endif
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
fmtdesc.index = 0; fmtdesc.index = 0;
fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@ -2278,7 +2280,7 @@ int VideoDevice::detectPixelFormats()
} }
} }
// break; // break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
// TODO: THis thing can be used to detec what pixel formats are supported in a API-independent way, but V4L2 has VIDIOC_ENUM_PIXFMT. // TODO: THis thing can be used to detec what pixel formats are supported in a API-independent way, but V4L2 has VIDIOC_ENUM_PIXFMT.
// The correct thing to do is to isolate these calls and do a proper implementation for V4L and another for V4L2 when this thing will be migrated to a plugin architecture. // The correct thing to do is to isolate these calls and do a proper implementation for V4L and another for V4L2 when this thing will be migrated to a plugin architecture.
@ -2322,6 +2324,7 @@ int VideoDevice::detectPixelFormats()
if(PIXELFORMAT_NONE != setPixelFormat(PIXELFORMAT_WNVA)) kdDebug(14010) << k_funcinfo << pixelFormatName(PIXELFORMAT_WNVA) << endl; if(PIXELFORMAT_NONE != setPixelFormat(PIXELFORMAT_WNVA)) kdDebug(14010) << k_funcinfo << pixelFormatName(PIXELFORMAT_WNVA) << endl;
if(PIXELFORMAT_NONE != setPixelFormat(PIXELFORMAT_YYUV)) kdDebug(14010) << k_funcinfo << pixelFormatName(PIXELFORMAT_YYUV) << endl; if(PIXELFORMAT_NONE != setPixelFormat(PIXELFORMAT_YYUV)) kdDebug(14010) << k_funcinfo << pixelFormatName(PIXELFORMAT_YYUV) << endl;
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -2335,7 +2338,7 @@ __u64 VideoDevice::signalStandardCode(signal_standard standard)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(standard) switch(standard)
{ {
@ -2376,7 +2379,7 @@ __u64 VideoDevice::signalStandardCode(signal_standard standard)
case STANDARD_ALL : return V4L2_STD_ALL; break; case STANDARD_ALL : return V4L2_STD_ALL; break;
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
switch(standard) switch(standard)
{ {
@ -2417,6 +2420,7 @@ __u64 VideoDevice::signalStandardCode(signal_standard standard)
case STANDARD_ALL : return VIDEO_MODE_AUTO; break; case STANDARD_ALL : return VIDEO_MODE_AUTO; break;
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -2477,7 +2481,7 @@ TQString VideoDevice::signalStandardName(int standard)
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(standard) switch(standard)
{ {
@ -2517,7 +2521,7 @@ TQString VideoDevice::signalStandardName(int standard)
case V4L2_STD_ALL : returnvalue = signalStandardName(STANDARD_ALL); break; case V4L2_STD_ALL : returnvalue = signalStandardName(STANDARD_ALL); break;
} }
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
switch(standard) switch(standard)
{ {
@ -2531,6 +2535,7 @@ TQString VideoDevice::signalStandardName(int standard)
case VIDEO_MODE_NTSC_JP : returnvalue = signalStandardName(STANDARD_NTSC_M_JP); break; // Undocumented value found to be compatible with V4L bttv driver case VIDEO_MODE_NTSC_JP : returnvalue = signalStandardName(STANDARD_NTSC_M_JP); break; // Undocumented value found to be compatible with V4L bttv driver
} }
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -2547,12 +2552,13 @@ int VideoDevice::detectSignalStandards()
switch(m_driver) switch(m_driver)
{ {
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
break; break;
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
case VIDEODEV_DRIVER_V4L: case VIDEODEV_DRIVER_V4L:
break; break;
#endif
#endif #endif
case VIDEODEV_DRIVER_NONE: case VIDEODEV_DRIVER_NONE:
default: default:
@ -2606,7 +2612,7 @@ int VideoDevice::initMmap()
if(isOpen()) if(isOpen())
{ {
kdDebug(14010) << k_funcinfo << full_filename << " Trying to MMAP" << endl; kdDebug(14010) << k_funcinfo << full_filename << " Trying to MMAP" << endl;
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
struct v4l2_requestbuffers req; struct v4l2_requestbuffers req;
CLEAR (req); CLEAR (req);
@ -2678,7 +2684,7 @@ int VideoDevice::initUserptr()
/// @todo implement me /// @todo implement me
if(isOpen()) if(isOpen())
{ {
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
struct v4l2_requestbuffers req; struct v4l2_requestbuffers req;
CLEAR (req); CLEAR (req);

@ -92,11 +92,12 @@ typedef enum
{ {
VIDEODEV_DRIVER_NONE VIDEODEV_DRIVER_NONE
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
, #if defined(__LINUX_VIDEODEV2_H) /* V4L2 */
VIDEODEV_DRIVER_V4L
#ifdef V4L2_CAP_VIDEO_CAPTURE
, ,
VIDEODEV_DRIVER_V4L2 VIDEODEV_DRIVER_V4L2
#elif defined(__LINUX_VIDEODEV_H) /* V4L */
,
VIDEODEV_DRIVER_V4L
#endif #endif
#endif #endif
} videodev_driver; } videodev_driver;
@ -288,7 +289,7 @@ public:
//protected: //protected:
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #if defined(__LINUX_VIDEODEV2_H) /* V4L2 */
struct v4l2_capability V4L2_capabilities; struct v4l2_capability V4L2_capabilities;
struct v4l2_cropcap cropcap; struct v4l2_cropcap cropcap;
struct v4l2_crop crop; struct v4l2_crop crop;
@ -299,8 +300,7 @@ public:
struct v4l2_querymenu querymenu; struct v4l2_querymenu querymenu;
void enumerateMenu (void); void enumerateMenu (void);
#endif #elif defined(__LINUX_VIDEODEV_H) /* V4L */
#ifdef ENABLE_AV
struct video_capability V4L_capabilities; struct video_capability V4L_capabilities;
struct video_buffer V4L_videobuffer; struct video_buffer V4L_videobuffer;
#endif #endif

@ -608,8 +608,10 @@ int VideoDevicePool::scanDevices()
kdDebug(14010) << k_funcinfo << "called" << endl; kdDebug(14010) << k_funcinfo << "called" << endl;
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
TQDir videodevice_dir; TQDir videodevice_dir;
const TQString videodevice_dir_path=TQString::fromLocal8Bit("/dev/v4l/");
const TQString videodevice_dir_filter=TQString::fromLocal8Bit("video*"); // Check *video* symlinks in /dev/v4l/by-id
const TQString videodevice_dir_path=TQString::fromLocal8Bit("/dev/v4l/by-id/");
const TQString videodevice_dir_filter=TQString::fromLocal8Bit("*video*");
VideoDevice videodevice; VideoDevice videodevice;
m_videodevice.clear(); m_videodevice.clear();
@ -617,7 +619,7 @@ int VideoDevicePool::scanDevices()
videodevice_dir.setPath(videodevice_dir_path); videodevice_dir.setPath(videodevice_dir_path);
videodevice_dir.setNameFilter(videodevice_dir_filter); videodevice_dir.setNameFilter(videodevice_dir_filter);
videodevice_dir.setFilter( TQDir::System | TQDir::NoSymLinks | TQDir::Readable | TQDir::Writable ); videodevice_dir.setFilter( TQDir::System | TQDir::Readable | TQDir::Writable );
videodevice_dir.setSorting( TQDir::Name ); videodevice_dir.setSorting( TQDir::Name );
kdDebug(14010) << k_funcinfo << "Looking for devices in " << videodevice_dir_path << endl; kdDebug(14010) << k_funcinfo << "Looking for devices in " << videodevice_dir_path << endl;
@ -627,6 +629,8 @@ int VideoDevicePool::scanDevices()
{ {
kdDebug(14010) << k_funcinfo << "Found no suitable devices in " << videodevice_dir_path << endl; kdDebug(14010) << k_funcinfo << "Found no suitable devices in " << videodevice_dir_path << endl;
TQDir videodevice_dir; TQDir videodevice_dir;
// Alternatively, check all block devices starting with 'video' in /dev
const TQString videodevice_dir_path=TQString::fromLocal8Bit("/dev/"); const TQString videodevice_dir_path=TQString::fromLocal8Bit("/dev/");
const TQString videodevice_dir_filter=TQString::fromLocal8Bit("video*"); const TQString videodevice_dir_filter=TQString::fromLocal8Bit("video*");
VideoDevice videodevice; VideoDevice videodevice;
@ -679,7 +683,12 @@ int VideoDevicePool::scanDevices()
kdDebug(14010) << k_funcinfo << "scanning devices in " << videodevice_dir_path << "..." << endl; kdDebug(14010) << k_funcinfo << "scanning devices in " << videodevice_dir_path << "..." << endl;
while ( (fileinfo = fileiterator.current()) != 0 ) while ( (fileinfo = fileiterator.current()) != 0 )
{ {
videodevice.setFileName(fileinfo->absFilePath()); if( fileinfo->isSymLink() ) {
TQFileInfo realfileinfo(videodevice_dir_path + fileinfo->readLink());
videodevice.setFileName(realfileinfo.absFilePath());
} else {
videodevice.setFileName(fileinfo->absFilePath());
}
kdDebug(14010) << k_funcinfo << "Found device " << videodevice.full_filename << endl; kdDebug(14010) << k_funcinfo << "Found device " << videodevice.full_filename << endl;
videodevice.open(); // It should be opened with O_NONBLOCK (it's a FIFO) but I dunno how to do it using TQFile videodevice.open(); // It should be opened with O_NONBLOCK (it's a FIFO) but I dunno how to do it using TQFile
if(videodevice.isOpen()) if(videodevice.isOpen())

Loading…
Cancel
Save