#include <sys/ioctl.h>
#include <sys/mman.h>
-#include <linux/videodev2.h>
+#if defined(HAVE_LINUX_VIDEODEV2_H)
+# include <linux/videodev2.h>
+#elif defined(HAVE_SYS_VIDEOIO_H)
+# include <sys/videoio.h>
+#else
+# error "No Video4Linux2 headers found."
+#endif
#include <poll.h>
set_callbacks( DemuxOpen, DemuxClose )
add_submodule ()
- add_shortcut( "v4l2" )
- add_shortcut( "v4l2c" )
+ add_shortcut( "v4l2", "v4l2c" )
set_description( N_("Video4Linux2 Compressed A/V") )
set_capability( "access", 0 )
/* use these when open as access_demux fails; VLC will use another demux */
#ifdef HAVE_LIBV4L2
static void use_kernel_v4l2( demux_sys_t *p_sys )
{
- p_sys->pf_open = utf8_open;
+ p_sys->pf_open = vlc_open;
p_sys->pf_close = close;
p_sys->pf_dup = dup;
p_sys->pf_ioctl = ioctl;
# define v4l2_mmap (p_sys->pf_mmap)
# define v4l2_munmap (p_sys->pf_munmap)
#else
-# define v4l2_open utf8_open
+# define v4l2_open vlc_open
# define v4l2_close close
# define v4l2_dup dup
# define v4l2_ioctl ioctl
GetV4L2Params(p_sys, (vlc_object_t *) p_demux);
- ParseMRL( p_sys, p_demux->psz_path, (vlc_object_t *) p_demux );
+ ParseMRL( p_sys, p_demux->psz_location, (vlc_object_t *) p_demux );
#ifdef HAVE_LIBV4L2
- if( !var_InheritInteger( p_this, CFG_PREFIX "use-libv4l2" ) )
+ if( !var_InheritBool( p_this, CFG_PREFIX "use-libv4l2" ) )
{
msg_Dbg( p_this, "Trying direct kernel v4l2" );
use_kernel_v4l2( p_sys );
GetV4L2Params( p_sys, (vlc_object_t *) p_access );
- ParseMRL( p_sys, p_access->psz_path, (vlc_object_t *) p_access );
+ ParseMRL( p_sys, p_access->psz_location, (vlc_object_t *) p_access );
#ifdef HAVE_LIBV4L2
- if( !var_InheritInteger( p_this, CFG_PREFIX "use-libv4l2" ) )
+ if( !var_InheritBool( p_this, CFG_PREFIX "use-libv4l2" ) )
{
msg_Dbg( p_this, "Trying direct kernel v4l2" );
use_kernel_v4l2( p_sys );
mtime_t i_dur = (mtime_t)((double)1000000 / (double)p_sys->f_fps);
/* Did we wait long enough ? (frame rate reduction) */
- if( p_sys->i_video_pts + i_dur > mdate() ) return 0;
+ if( p_sys->i_video_pts + i_dur > mdate() )
+ return NULL;
}
/* Grab Video Frame */
switch( errno )
{
case EAGAIN:
- return 0;
+ return NULL;
case EIO:
/* Could ignore EIO, see spec. */
/* fall through */
}
p_block = ProcessVideoFrame( p_demux, (uint8_t*)p_sys->p_buffers[0].start, i_ret );
- if( !p_block ) return 0;
+ if( !p_block )
+ return NULL;
break;
switch( errno )
{
case EAGAIN:
- return 0;
+ return NULL;
case EIO:
/* Could ignore EIO, see spec. */
/* fall through */
default:
msg_Err( p_demux, "Failed to wait (VIDIOC_DQBUF)" );
- return 0;
+ return NULL;
}
}
if( buf.index >= p_sys->i_nbuffers ) {
msg_Err( p_demux, "Failed capturing new frame as i>=nbuffers" );
- return 0;
+ return NULL;
}
p_block = ProcessVideoFrame( p_demux, p_sys->p_buffers[buf.index].start, buf.bytesused );
- if( !p_block ) return 0;
+ if( !p_block )
+ return NULL;
/* Unlock */
if( v4l2_ioctl( p_sys->i_fd, VIDIOC_QBUF, &buf ) < 0 )
{
msg_Err( p_demux, "Failed to unlock (VIDIOC_QBUF)" );
block_Release( p_block );
- return 0;
+ return NULL;
}
break;
switch( errno )
{
case EAGAIN:
- return 0;
+ return NULL;
case EIO:
/* Could ignore EIO, see spec. */
/* fall through */
default:
msg_Err( p_demux, "Failed to wait (VIDIOC_DQBUF)" );
- return 0;
+ return NULL;
}
}
if( i >= p_sys->i_nbuffers )
{
msg_Err( p_demux, "Failed capturing new frame as i>=nbuffers" );
- return 0;
+ return NULL;
}
p_block = ProcessVideoFrame( p_demux, (uint8_t*)buf.m.userptr, buf.bytesused );
- if( !p_block ) return 0;
+ if( !p_block )
+ return NULL;
/* Unlock */
if( v4l2_ioctl( p_sys->i_fd, VIDIOC_QBUF, &buf ) < 0 )
{
msg_Err( p_demux, "Failed to unlock (VIDIOC_QBUF)" );
block_Release( p_block );
- return 0;
+ return NULL;
}
break;
{
block_t *p_block;
- if( !p_frame ) return 0;
+ if( !p_frame ) return NULL;
/* New block */
if( !( p_block = block_New( p_demux, i_size ) ) )
{
msg_Warn( p_demux, "Cannot get new block" );
- return 0;
+ return NULL;
}
/* Copy frame */
msg_Dbg( p_obj, "device supports hardware frequency seeking" );
#endif
if( p_sys->dev_cap.capabilities & V4L2_CAP_VBI_CAPTURE )
- msg_Dbg( p_obj, "device support raw VBI capture" );
+ msg_Dbg( p_obj, "device supports raw VBI capture" );
if( p_sys->dev_cap.capabilities & V4L2_CAP_SLICED_VBI_CAPTURE )
- msg_Dbg( p_obj, "device support sliced VBI capture" );
+ msg_Dbg( p_obj, "device supports sliced VBI capture" );
/* Now, enumerate all the video inputs. This is useless at the moment
since we have no way to present that info to the user except with