char *psz_adev;
int i_fd_audio;
-
+
char *psz_requested_chroma;
/* Video */
p_sys->i_height =
strtol( psz_parser + strlen( "height=" ),
&psz_parser, 0 );
- }
+ }
else if( !strncmp( psz_parser, "samplerate=",
strlen( "samplerate=" ) ) )
{
buf.length == p_sys->p_buffers[i].length ) break;
}
- if( i >= p_sys->i_nbuffers )
+ if( i >= p_sys->i_nbuffers )
{
msg_Err( p_demux, "Failed capturing new frame as i>=nbuffers" );
return 0;
memset( &fmt, 0, sizeof(fmt) );
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if( p_sys->i_width <= 0 || p_sys->i_height <= 0 )
+ if( p_sys->i_width <= 0 || p_sys->i_height <= 0 )
{
if( ioctl( i_fd, VIDIOC_G_FMT, &fmt ) < 0 )
{
p_sys->i_height = p_sys->i_height * 2;
}
}
- else
+ else
{
msg_Dbg( p_demux, "trying specified size %dx%d", p_sys->i_width, p_sys->i_height );
}
{
/* User specified chroma */
if( strlen( p_sys->psz_requested_chroma ) >= 4 )
- {
- int i_requested_fourcc = VLC_FOURCC(
- p_sys->psz_requested_chroma[0], p_sys->psz_requested_chroma[1],
+ {
+ int i_requested_fourcc = VLC_FOURCC(
+ p_sys->psz_requested_chroma[0], p_sys->psz_requested_chroma[1],
p_sys->psz_requested_chroma[2], p_sys->psz_requested_chroma[3] );
for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
{
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
- if( ioctl( i_fd, VIDIOC_QBUF, &buf ) < 0 )
+ if( ioctl( i_fd, VIDIOC_QBUF, &buf ) < 0 )
{
msg_Err( p_demux, "VIDIOC_QBUF failed" );
goto open_failed;
}
buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if( ioctl( i_fd, VIDIOC_STREAMON, &buf_type ) < 0 )
+ if( ioctl( i_fd, VIDIOC_STREAMON, &buf_type ) < 0 )
{
msg_Err( p_demux, "VIDIOC_STREAMON failed" );
goto open_failed;
buf.m.userptr = (unsigned long)p_sys->p_buffers[i].start;
buf.length = p_sys->p_buffers[i].length;
- if( ioctl( i_fd, VIDIOC_QBUF, &buf ) < 0 )
+ if( ioctl( i_fd, VIDIOC_QBUF, &buf ) < 0 )
{
msg_Err( p_demux, "VIDIOC_QBUF failed" );
goto open_failed;
}
buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if( ioctl( i_fd, VIDIOC_STREAMON, &buf_type ) < 0 )
+ if( ioctl( i_fd, VIDIOC_STREAMON, &buf_type ) < 0 )
{
msg_Err( p_demux, "VIDIOC_STREAMON failed" );
goto open_failed;
msg_Err( p_demux, "cannot get codec description (%m)" );
goto open_failed;
}
-
+
/* only print if vlc supports the format */
vlc_bool_t b_codec_supported = VLC_FALSE;
for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
if( v4l2chroma_to_fourcc[i].i_v4l2 == p_sys->p_codecs[i_index].pixelformat )
{
b_codec_supported = VLC_TRUE;
-
+
char psz_fourcc[5];
memset( &psz_fourcc, 0, sizeof( psz_fourcc ) );
vlc_fourcc_to_char( v4l2chroma_to_fourcc[i].i_fourcc, &psz_fourcc );
msg_Dbg( p_demux, "device supports chroma %4s [%s]",
psz_fourcc,
p_sys->p_codecs[i_index].description );
+
+ /* List valid frame sizes for this format */
+ struct v4l2_frmsizeenum frmsize;
+ frmsize.index = 0;
+ frmsize.pixel_format = p_sys->p_codecs[i_index].pixelformat;
+ if( ioctl( i_fd, VIDIOC_ENUM_FRAMESIZES, &frmsize ) < 0 )
+ {
+ msg_Err( p_demux, "Error while querying for frame size" );
+ }
+ else
+ {
+ switch( frmsize.type )
+ {
+ case V4L2_FRMSIZE_TYPE_DISCRETE:
+ do
+ {
+ msg_Dbg( p_demux,
+ "device supports size %dx%d",
+ frmsize.discrete.width, frmsize.discrete.height );
+ frmsize.index++;
+ } while( ioctl( i_fd, VIDIOC_ENUM_FRAMESIZES, &frmsize ) >= 0 );
+ break;
+ case V4L2_FRMSIZE_TYPE_STEPWISE:
+ msg_Dbg( p_demux,
+ "device supports sizes %dx%d to %dx%d using %dx%d increments",
+ frmsize.stepwise.min_width, frmsize.stepwise.min_height,
+ frmsize.stepwise.max_width, frmsize.stepwise.max_height,
+ frmsize.stepwise.step_width, frmsize.stepwise.step_height );
+ break;
+ case V4L2_FRMSIZE_TYPE_CONTINUOUS:
+ msg_Dbg( p_demux,
+ "device supports all sizes %dx%d to %dx%d",
+ frmsize.stepwise.min_width, frmsize.stepwise.min_height,
+ frmsize.stepwise.max_width, frmsize.stepwise.max_height );
+ break;
+ }
+ }
}
}
if( !b_codec_supported )