int i_height;
unsigned int i_aspect;
float f_fps; /* <= 0.0 mean to grab at full rate */
- mtime_t i_video_pts; /* only used when f_fps > 0 */
int i_fourcc;
uint32_t i_block_flags;
/* Controls */
char *psz_set_ctrls;
-
#ifdef HAVE_LIBV4L2
/* */
int (*pf_open)(const char *, int, ...);
*****************************************************************************/
static void GetV4L2Params( demux_sys_t *p_sys, vlc_object_t *p_obj )
{
- p_sys->i_video_pts = -1;
-
p_sys->i_selected_standard_id =
i_standards_list[var_CreateGetInteger( p_obj, "v4l2-standard" )];
fd.revents = 0;
/* Wait for data */
- if( poll( &fd, 1, 500 ) ) /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
- {
- if( fd.revents & (POLLIN|POLLPRI) )
- {
- return GrabVideo( VLC_OBJECT(p_access), p_sys );
- }
- }
+ if( poll( &fd, 1, 500 ) > 0 ) /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
+ return GrabVideo( VLC_OBJECT(p_access), p_sys );
return NULL;
}
if( i_ret < 0 )
{
- msg_Err( p_access, "Polling error (%m)." );
+ if( errno != EINTR )
+ msg_Err( p_access, "poll error" );
return -1;
}
fd.revents = 0;
/* Wait for data */
- if( poll( &fd, 1, 500 ) ) /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
- {
- if( fd.revents & (POLLIN|POLLPRI) )
+ /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
+ while( poll( &fd, 1, 500 ) == -1 )
+ if( errno != EINTR )
{
- block_t *p_block = GrabVideo( VLC_OBJECT(p_demux), p_sys );
- if( p_block )
- {
- es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
- es_out_Send( p_demux->out, p_sys->p_es, p_block );
- }
+ msg_Err( p_demux, "poll error: %m" );
+ return -1;
+ }
+
+ if( fd.revents )
+ {
+ block_t *p_block = GrabVideo( VLC_OBJECT(p_demux), p_sys );
+ if( p_block )
+ {
+ es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
+ es_out_Send( p_demux->out, p_sys->p_es, p_block );
}
}
struct v4l2_buffer buf;
ssize_t i_ret;
- if( p_sys->f_fps >= 0.1 && p_sys->i_video_pts > 0 )
- {
- 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 NULL;
- }
-
/* Grab Video Frame */
switch( p_sys->io )
{
}
/* Timestamp */
- p_sys->i_video_pts = p_block->i_pts = p_block->i_dts = mdate();
+ p_block->i_pts = p_block->i_dts = mdate();
p_block->i_flags |= p_sys->i_block_flags;
return p_block;
es_fmt.video.i_sar_num = p_sys->i_aspect * es_fmt.video.i_height;
es_fmt.video.i_sar_den = VOUT_ASPECT_FACTOR * es_fmt.video.i_width;
+ /* Framerate */
+ es_fmt.video.i_frame_rate = p_sys->f_fps * INT64_C(1000000);
+ es_fmt.video.i_frame_rate_base = INT64_C(1000000);
+
demux_t *p_demux = (demux_t *) p_obj;
msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
(char*)&es_fmt.i_codec, es_fmt.video.i_width, es_fmt.video.i_height );
p_sys->i_input = 0;
while( v4l2_ioctl( i_fd, VIDIOC_ENUMINPUT, &t_input ) >= 0 )
{
+ if( t_input.index != p_sys->i_input )
+ break;
p_sys->i_input++;
t_input.index = p_sys->i_input;
}
p_sys->i_standard = 0;
while( v4l2_ioctl( i_fd, VIDIOC_ENUMSTD, &t_standards ) >=0 )
{
+ if( t_standards.index != p_sys->i_standard )
+ break;
p_sys->i_standard++;
t_standards.index = p_sys->i_standard;
}
p_sys->i_tuner = 0;
while( v4l2_ioctl( i_fd, VIDIOC_G_TUNER, &tuner ) >= 0 )
{
+ if( tuner.index != p_sys->i_tuner )
+ break;
p_sys->i_tuner++;
memset( &tuner, 0, sizeof(tuner) );
tuner.index = p_sys->i_tuner;
while( v4l2_ioctl( i_fd, VIDIOC_ENUM_FMT, &codec ) >= 0 )
{
+ if( codec.index != i_index )
+ break;
i_index++;
codec.index = i_index;
}