Commit 887c2edd authored by Antoine Cellerier's avatar Antoine Cellerier

Convert v4l2 access to block based access

Fixes some incomplete reads with gspca driver, and makes it possible to use all 3 data acquisition methods (previous code was limited to read()).
parent 288f193a
...@@ -361,10 +361,10 @@ static int DemuxControl( demux_t *, int, va_list ); ...@@ -361,10 +361,10 @@ static int DemuxControl( demux_t *, int, va_list );
static int AccessControl( access_t *, int, va_list ); static int AccessControl( access_t *, int, va_list );
static int Demux( demux_t * ); static int Demux( demux_t * );
static ssize_t AccessRead( access_t *, uint8_t *, size_t ); static block_t *AccessRead( access_t * );
static block_t* GrabVideo( demux_t *p_demux ); static block_t* GrabVideo( vlc_object_t *p_demux, demux_sys_t *p_sys );
static block_t* ProcessVideoFrame( demux_t *p_demux, uint8_t *p_frame, size_t ); static block_t* ProcessVideoFrame( vlc_object_t *p_demux, uint8_t *p_frame, size_t );
static bool IsPixelFormatSupported( demux_t *p_demux, static bool IsPixelFormatSupported( demux_t *p_demux,
unsigned int i_pixelformat ); unsigned int i_pixelformat );
...@@ -1054,7 +1054,7 @@ static int AccessOpen( vlc_object_t * p_this ) ...@@ -1054,7 +1054,7 @@ static int AccessOpen( vlc_object_t * p_this )
if( *p_access->psz_access == '\0' ) return VLC_EGENERIC; if( *p_access->psz_access == '\0' ) return VLC_EGENERIC;
access_InitFields( p_access ); access_InitFields( p_access );
ACCESS_SET_CALLBACKS( AccessRead, NULL, AccessControl, NULL ); ACCESS_SET_CALLBACKS( NULL, AccessRead, AccessControl, NULL );
p_sys = calloc( 1, sizeof( demux_sys_t )); p_sys = calloc( 1, sizeof( demux_sys_t ));
if( !p_sys ) return VLC_ENOMEM; if( !p_sys ) return VLC_ENOMEM;
p_access->p_sys = (access_sys_t*)p_sys; p_access->p_sys = (access_sys_t*)p_sys;
...@@ -1159,44 +1159,25 @@ static int AccessControl( access_t *p_access, int i_query, va_list args ) ...@@ -1159,44 +1159,25 @@ static int AccessControl( access_t *p_access, int i_query, va_list args )
/***************************************************************************** /*****************************************************************************
* AccessRead: access callback * AccessRead: access callback
******************************************************************************/ ******************************************************************************/
static ssize_t AccessRead( access_t * p_access, uint8_t * p_buffer, size_t i_len ) static block_t *AccessRead( access_t * p_access )
{ {
demux_sys_t *p_sys = (demux_sys_t *) p_access->p_sys; demux_sys_t *p_sys = (demux_sys_t *)p_access->p_sys;
struct pollfd ufd;
int i_ret;
ufd.fd = p_sys->i_fd;
ufd.events = POLLIN;
if( p_access->info.b_eof )
return 0;
do
{
if( !vlc_object_alive (p_access) )
return 0;
ufd.revents = 0;
}
while( ( i_ret = poll( &ufd, 1, 500 ) ) == 0 );
if( i_ret < 0 ) struct pollfd fd;
{ fd.fd = p_sys->i_fd;
msg_Err( p_access, "Polling error (%m)." ); fd.events = POLLIN|POLLPRI;
return -1; fd.revents = 0;
}
i_ret = v4l2_read( p_sys->i_fd, p_buffer, i_len ); /* Wait for data */
if( i_ret == 0 ) if( poll( &fd, 1, 500 ) ) /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
{
p_access->info.b_eof = true;
}
else if( i_ret > 0 )
{ {
p_access->info.i_pos += i_ret; if( fd.revents & (POLLIN|POLLPRI) )
{
return GrabVideo( VLC_OBJECT(p_access), p_sys );
}
} }
return i_ret; return NULL;
} }
/***************************************************************************** /*****************************************************************************
...@@ -1216,7 +1197,7 @@ static int Demux( demux_t *p_demux ) ...@@ -1216,7 +1197,7 @@ static int Demux( demux_t *p_demux )
{ {
if( fd.revents & (POLLIN|POLLPRI) ) if( fd.revents & (POLLIN|POLLPRI) )
{ {
block_t *p_block = GrabVideo( p_demux ); block_t *p_block = GrabVideo( VLC_OBJECT(p_demux), p_sys );
if( p_block ) if( p_block )
{ {
es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts ); es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
...@@ -1231,10 +1212,8 @@ static int Demux( demux_t *p_demux ) ...@@ -1231,10 +1212,8 @@ static int Demux( demux_t *p_demux )
/***************************************************************************** /*****************************************************************************
* GrabVideo: Grab a video frame * GrabVideo: Grab a video frame
*****************************************************************************/ *****************************************************************************/
static block_t* GrabVideo( demux_t *p_demux ) static block_t* GrabVideo( vlc_object_t *p_demux, demux_sys_t *p_sys )
{ {
demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_block = NULL; block_t *p_block = NULL;
struct v4l2_buffer buf; struct v4l2_buffer buf;
ssize_t i_ret; ssize_t i_ret;
...@@ -1371,7 +1350,7 @@ static block_t* GrabVideo( demux_t *p_demux ) ...@@ -1371,7 +1350,7 @@ static block_t* GrabVideo( demux_t *p_demux )
* ProcessVideoFrame: Helper function to take a buffer and copy it into * ProcessVideoFrame: Helper function to take a buffer and copy it into
* a new block * a new block
*****************************************************************************/ *****************************************************************************/
static block_t* ProcessVideoFrame( demux_t *p_demux, uint8_t *p_frame, size_t i_size ) static block_t* ProcessVideoFrame( vlc_object_t *p_demux, uint8_t *p_frame, size_t i_size )
{ {
block_t *p_block; block_t *p_block;
...@@ -1393,9 +1372,9 @@ static block_t* ProcessVideoFrame( demux_t *p_demux, uint8_t *p_frame, size_t i_ ...@@ -1393,9 +1372,9 @@ static block_t* ProcessVideoFrame( demux_t *p_demux, uint8_t *p_frame, size_t i_
/***************************************************************************** /*****************************************************************************
* Helper function to initalise video IO using the Read method * Helper function to initalise video IO using the Read method
*****************************************************************************/ *****************************************************************************/
static int InitRead( demux_t *p_demux, unsigned int i_buffer_size ) static int InitRead( vlc_object_t *p_demux, demux_sys_t *p_sys, unsigned int i_buffer_size )
{ {
demux_sys_t *p_sys = p_demux->p_sys; (void)p_demux;
p_sys->p_buffers = calloc( 1, sizeof( *p_sys->p_buffers ) ); p_sys->p_buffers = calloc( 1, sizeof( *p_sys->p_buffers ) );
if( !p_sys->p_buffers ) if( !p_sys->p_buffers )
...@@ -1412,9 +1391,8 @@ static int InitRead( demux_t *p_demux, unsigned int i_buffer_size ) ...@@ -1412,9 +1391,8 @@ static int InitRead( demux_t *p_demux, unsigned int i_buffer_size )
/***************************************************************************** /*****************************************************************************
* Helper function to initalise video IO using the mmap method * Helper function to initalise video IO using the mmap method
*****************************************************************************/ *****************************************************************************/
static int InitMmap( demux_t *p_demux, int i_fd ) static int InitMmap( vlc_object_t *p_demux, demux_sys_t *p_sys, int i_fd )
{ {
demux_sys_t *p_sys = p_demux->p_sys;
struct v4l2_requestbuffers req; struct v4l2_requestbuffers req;
memset( &req, 0, sizeof(req) ); memset( &req, 0, sizeof(req) );
...@@ -1474,9 +1452,8 @@ open_failed: ...@@ -1474,9 +1452,8 @@ open_failed:
/***************************************************************************** /*****************************************************************************
* Helper function to initalise video IO using the userbuf method * Helper function to initalise video IO using the userbuf method
*****************************************************************************/ *****************************************************************************/
static int InitUserP( demux_t *p_demux, int i_fd, unsigned int i_buffer_size ) static int InitUserP( vlc_object_t *p_demux, demux_sys_t *p_sys, int i_fd, unsigned int i_buffer_size )
{ {
demux_sys_t *p_sys = p_demux->p_sys;
struct v4l2_requestbuffers req; struct v4l2_requestbuffers req;
unsigned int i_page_size; unsigned int i_page_size;
...@@ -1838,13 +1815,6 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -1838,13 +1815,6 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
var_GetBool( p_obj, "v4l2-controls-reset" ), b_demux ); var_GetBool( p_obj, "v4l2-controls-reset" ), b_demux );
SetAvailControlsByString( p_obj, p_sys, i_fd ); SetAvailControlsByString( p_obj, p_sys, i_fd );
if( false == b_demux)
{
return i_fd;
}
demux_t *p_demux = (demux_t *) p_obj;
/* Verify device support for the various IO methods */ /* Verify device support for the various IO methods */
switch( p_sys->io ) switch( p_sys->io )
{ {
...@@ -1900,7 +1870,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -1900,7 +1870,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
/* Use current width and height settings */ /* Use current width and height settings */
if( v4l2_ioctl( i_fd, VIDIOC_G_FMT, &fmt ) < 0 ) if( v4l2_ioctl( i_fd, VIDIOC_G_FMT, &fmt ) < 0 )
{ {
msg_Err( p_demux, "Cannot get default width and height." ); msg_Err( p_obj, "Cannot get default width and height." );
goto open_failed; goto open_failed;
} }
...@@ -1914,121 +1884,126 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -1914,121 +1884,126 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
} }
else if( p_sys->i_width < 0 || p_sys->i_height < 0 ) else if( p_sys->i_width < 0 || p_sys->i_height < 0 )
{ {
msg_Dbg( p_demux, "will try to find optimal width and height." ); msg_Dbg( p_obj, "will try to find optimal width and height." );
} }
else else
{ {
/* Use user specified width and height */ /* Use user specified width and height */
msg_Dbg( p_demux, "trying specified size %dx%d", p_sys->i_width, p_sys->i_height ); msg_Dbg( p_obj, "trying specified size %dx%d", p_sys->i_width, p_sys->i_height );
} }
fmt.fmt.pix.width = p_sys->i_width; fmt.fmt.pix.width = p_sys->i_width;
fmt.fmt.pix.height = p_sys->i_height; fmt.fmt.pix.height = p_sys->i_height;
fmt.fmt.pix.field = V4L2_FIELD_NONE; fmt.fmt.pix.field = V4L2_FIELD_NONE;
/* Test and set Chroma */ if (b_demux)
fmt.fmt.pix.pixelformat = 0;
if( p_sys->psz_requested_chroma && *p_sys->psz_requested_chroma )
{ {
/* User specified chroma */ demux_t *p_demux = (demux_t *) p_obj;
const vlc_fourcc_t i_requested_fourcc =
vlc_fourcc_GetCodecFromString( VIDEO_ES, p_sys->psz_requested_chroma );
for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ ) /* Test and set Chroma */
fmt.fmt.pix.pixelformat = 0;
if( p_sys->psz_requested_chroma && *p_sys->psz_requested_chroma )
{ {
if( v4l2chroma_to_fourcc[i].i_fourcc == i_requested_fourcc ) /* User specified chroma */
const vlc_fourcc_t i_requested_fourcc =
vlc_fourcc_GetCodecFromString( VIDEO_ES, p_sys->psz_requested_chroma );
for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
{ {
fmt.fmt.pix.pixelformat = v4l2chroma_to_fourcc[i].i_v4l2; if( v4l2chroma_to_fourcc[i].i_fourcc == i_requested_fourcc )
break; {
fmt.fmt.pix.pixelformat = v4l2chroma_to_fourcc[i].i_v4l2;
break;
}
}
/* Try and set user chroma */
if( !IsPixelFormatSupported( p_demux, fmt.fmt.pix.pixelformat ) || ( fmt.fmt.pix.pixelformat && v4l2_ioctl( i_fd, VIDIOC_S_FMT, &fmt ) < 0 ) )
{
msg_Warn( p_demux, "Driver is unable to use specified chroma %s. Trying defaults.", p_sys->psz_requested_chroma );
fmt.fmt.pix.pixelformat = 0;
} }
} }
/* Try and set user chroma */
if( !IsPixelFormatSupported( p_demux, fmt.fmt.pix.pixelformat ) || ( fmt.fmt.pix.pixelformat && v4l2_ioctl( i_fd, VIDIOC_S_FMT, &fmt ) < 0 ) )
{
msg_Warn( p_demux, "Driver is unable to use specified chroma %s. Trying defaults.", p_sys->psz_requested_chroma );
fmt.fmt.pix.pixelformat = 0;
}
}
/* If no user specified chroma, find best */ /* If no user specified chroma, find best */
/* This also decides if MPEG encoder card or not */ /* This also decides if MPEG encoder card or not */
if( !fmt.fmt.pix.pixelformat ) if( !fmt.fmt.pix.pixelformat )
{
unsigned int i;
for( i = 0; i < ARRAY_SIZE( p_chroma_fallbacks ); i++ )
{ {
fmt.fmt.pix.pixelformat = p_chroma_fallbacks[i]; unsigned int i;
if( IsPixelFormatSupported( p_demux, fmt.fmt.pix.pixelformat ) for( i = 0; i < ARRAY_SIZE( p_chroma_fallbacks ); i++ )
&& v4l2_ioctl( i_fd, VIDIOC_S_FMT, &fmt ) >= 0 ) {
break; fmt.fmt.pix.pixelformat = p_chroma_fallbacks[i];
} if( IsPixelFormatSupported( p_demux, fmt.fmt.pix.pixelformat )
if( i == ARRAY_SIZE( p_chroma_fallbacks ) ) && v4l2_ioctl( i_fd, VIDIOC_S_FMT, &fmt ) >= 0 )
{ break;
msg_Warn( p_demux, "Could not select any of the default chromas; attempting to open as MPEG encoder card (access)" ); }
goto open_failed; if( i == ARRAY_SIZE( p_chroma_fallbacks ) )
{
msg_Warn( p_demux, "Could not select any of the default chromas; attempting to open as MPEG encoder card (access)" );
goto open_failed;
}
} }
}
if( p_sys->i_width < 0 || p_sys->i_height < 0 ) if( p_sys->i_width < 0 || p_sys->i_height < 0 )
{
if( p_sys->f_fps <= 0 )
{ {
p_sys->f_fps = GetAbsoluteMaxFrameRate( p_demux, i_fd, if( p_sys->f_fps <= 0 )
fmt.fmt.pix.pixelformat ); {
msg_Dbg( p_demux, "Found maximum framerate of %f", p_sys->f_fps ); p_sys->f_fps = GetAbsoluteMaxFrameRate( p_demux, i_fd,
fmt.fmt.pix.pixelformat );
msg_Dbg( p_demux, "Found maximum framerate of %f", p_sys->f_fps );
}
GetMaxDimensions( p_demux, i_fd,
fmt.fmt.pix.pixelformat, p_sys->f_fps,
&fmt.fmt.pix.width, &fmt.fmt.pix.height );
msg_Dbg( p_demux, "Found optimal dimensions for framerate %f of %dx%d",
p_sys->f_fps, fmt.fmt.pix.width, fmt.fmt.pix.height );
if( v4l2_ioctl( i_fd, VIDIOC_S_FMT, &fmt ) < 0 ) {;}
} }
GetMaxDimensions( p_demux, i_fd,
fmt.fmt.pix.pixelformat, p_sys->f_fps,
&fmt.fmt.pix.width, &fmt.fmt.pix.height );
msg_Dbg( p_demux, "Found optimal dimensions for framerate %f of %dx%d",
p_sys->f_fps, fmt.fmt.pix.width, fmt.fmt.pix.height );
if( v4l2_ioctl( i_fd, VIDIOC_S_FMT, &fmt ) < 0 ) {;}
}
/* Reassign width, height and chroma incase driver override */ /* Reassign width, height and chroma incase driver override */
p_sys->i_width = fmt.fmt.pix.width; p_sys->i_width = fmt.fmt.pix.width;
p_sys->i_height = fmt.fmt.pix.height; p_sys->i_height = fmt.fmt.pix.height;
}
if( v4l2_ioctl( i_fd, VIDIOC_G_FMT, &fmt ) < 0 ) {;} if( v4l2_ioctl( i_fd, VIDIOC_G_FMT, &fmt ) < 0 ) {;}
/* Print extra info */ /* Print extra info */
msg_Dbg( p_demux, "Driver requires at most %d bytes to store a complete image", fmt.fmt.pix.sizeimage ); msg_Dbg( p_obj, "Driver requires at most %d bytes to store a complete image", fmt.fmt.pix.sizeimage );
/* Check interlacing */ /* Check interlacing */
switch( fmt.fmt.pix.field ) switch( fmt.fmt.pix.field )
{ {
case V4L2_FIELD_NONE: case V4L2_FIELD_NONE:
msg_Dbg( p_demux, "Interlacing setting: progressive" ); msg_Dbg( p_obj, "Interlacing setting: progressive" );
break; break;
case V4L2_FIELD_TOP: case V4L2_FIELD_TOP:
msg_Dbg( p_demux, "Interlacing setting: top field only" ); msg_Dbg( p_obj, "Interlacing setting: top field only" );
break; break;
case V4L2_FIELD_BOTTOM: case V4L2_FIELD_BOTTOM:
msg_Dbg( p_demux, "Interlacing setting: bottom field only" ); msg_Dbg( p_obj, "Interlacing setting: bottom field only" );
break; break;
case V4L2_FIELD_INTERLACED: case V4L2_FIELD_INTERLACED:
msg_Dbg( p_demux, "Interlacing setting: interleaved (bottom top if M/NTSC, top bottom otherwise)" ); msg_Dbg( p_obj, "Interlacing setting: interleaved (bottom top if M/NTSC, top bottom otherwise)" );
break; break;
case V4L2_FIELD_SEQ_TB: case V4L2_FIELD_SEQ_TB:
msg_Dbg( p_demux, "Interlacing setting: sequential top bottom" ); msg_Dbg( p_obj, "Interlacing setting: sequential top bottom" );
break; break;
case V4L2_FIELD_SEQ_BT: case V4L2_FIELD_SEQ_BT:
msg_Dbg( p_demux, "Interlacing setting: sequential bottom top" ); msg_Dbg( p_obj, "Interlacing setting: sequential bottom top" );
break; break;
case V4L2_FIELD_ALTERNATE: case V4L2_FIELD_ALTERNATE:
msg_Dbg( p_demux, "Interlacing setting: alternate fields" ); msg_Dbg( p_obj, "Interlacing setting: alternate fields" );
break; break;
case V4L2_FIELD_INTERLACED_TB: case V4L2_FIELD_INTERLACED_TB:
msg_Dbg( p_demux, "Interlacing setting: interleaved top bottom" ); msg_Dbg( p_obj, "Interlacing setting: interleaved top bottom" );
break; break;
case V4L2_FIELD_INTERLACED_BT: case V4L2_FIELD_INTERLACED_BT:
msg_Dbg( p_demux, "Interlacing setting: interleaved bottom top" ); msg_Dbg( p_obj, "Interlacing setting: interleaved bottom top" );
break; break;
default: default:
msg_Warn( p_demux, "Interlacing setting: unknown type (%d)", msg_Warn( p_obj, "Interlacing setting: unknown type (%d)",
fmt.fmt.pix.field ); fmt.fmt.pix.field );
break; break;
} }
if( fmt.fmt.pix.field != V4L2_FIELD_NONE ) if( fmt.fmt.pix.field != V4L2_FIELD_NONE )
msg_Warn( p_demux, "Interlaced inputs haven't been tested. Please report any issue." ); msg_Warn( p_obj, "Interlaced inputs haven't been tested. Please report any issue." );
/* Look up final fourcc */ /* Look up final fourcc */
p_sys->i_fourcc = 0; p_sys->i_fourcc = 0;
...@@ -2066,21 +2041,21 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2066,21 +2041,21 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
char psz_fourcc[5]; char psz_fourcc[5];
memset( &psz_fourcc, 0, sizeof( psz_fourcc ) ); memset( &psz_fourcc, 0, sizeof( psz_fourcc ) );
vlc_fourcc_to_char( p_sys->i_fourcc, &psz_fourcc ); vlc_fourcc_to_char( p_sys->i_fourcc, &psz_fourcc );
msg_Dbg( p_demux, "supported frame intervals for %4s, %dx%d:", msg_Dbg( p_obj, "supported frame intervals for %4s, %dx%d:",
psz_fourcc, frmival.width, frmival.height ); psz_fourcc, frmival.width, frmival.height );
switch( frmival.type ) switch( frmival.type )
{ {
case V4L2_FRMIVAL_TYPE_DISCRETE: case V4L2_FRMIVAL_TYPE_DISCRETE:
do do
{ {
msg_Dbg( p_demux, " supported frame interval: %d/%d", msg_Dbg( p_obj, " supported frame interval: %d/%d",
frmival.discrete.numerator, frmival.discrete.numerator,
frmival.discrete.denominator ); frmival.discrete.denominator );
frmival.index++; frmival.index++;
} while( v4l2_ioctl( i_fd, VIDIOC_ENUM_FRAMEINTERVALS, &frmival ) >= 0 ); } while( v4l2_ioctl( i_fd, VIDIOC_ENUM_FRAMEINTERVALS, &frmival ) >= 0 );
break; break;
case V4L2_FRMIVAL_TYPE_STEPWISE: case V4L2_FRMIVAL_TYPE_STEPWISE:
msg_Dbg( p_demux, " supported frame intervals: %d/%d to " msg_Dbg( p_obj, " supported frame intervals: %d/%d to "
"%d/%d using %d/%d increments", "%d/%d using %d/%d increments",
frmival.stepwise.min.numerator, frmival.stepwise.min.numerator,
frmival.stepwise.min.denominator, frmival.stepwise.min.denominator,
...@@ -2090,7 +2065,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2090,7 +2065,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
frmival.stepwise.step.denominator ); frmival.stepwise.step.denominator );
break; break;
case V4L2_FRMIVAL_TYPE_CONTINUOUS: case V4L2_FRMIVAL_TYPE_CONTINUOUS:
msg_Dbg( p_demux, " supported frame intervals: %d/%d to %d/%d", msg_Dbg( p_obj, " supported frame intervals: %d/%d to %d/%d",
frmival.stepwise.min.numerator, frmival.stepwise.min.numerator,
frmival.stepwise.min.denominator, frmival.stepwise.min.denominator,
frmival.stepwise.max.numerator, frmival.stepwise.max.numerator,
...@@ -2105,15 +2080,15 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2105,15 +2080,15 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
switch( p_sys->io ) switch( p_sys->io )
{ {
case IO_METHOD_READ: case IO_METHOD_READ:
if( InitRead( p_demux, fmt.fmt.pix.sizeimage ) != VLC_SUCCESS ) goto open_failed; if( InitRead( p_obj, p_sys, fmt.fmt.pix.sizeimage ) != VLC_SUCCESS ) goto open_failed;
break; break;
case IO_METHOD_MMAP: case IO_METHOD_MMAP:
if( InitMmap( p_demux, i_fd ) != VLC_SUCCESS ) goto open_failed; if( InitMmap( p_obj, p_sys, i_fd ) != VLC_SUCCESS ) goto open_failed;
break; break;
case IO_METHOD_USERPTR: case IO_METHOD_USERPTR:
if( InitUserP( p_demux, i_fd, fmt.fmt.pix.sizeimage ) != VLC_SUCCESS ) goto open_failed; if( InitUserP( p_obj, p_sys, i_fd, fmt.fmt.pix.sizeimage ) != VLC_SUCCESS ) goto open_failed;
break; break;
} }
...@@ -2123,9 +2098,13 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2123,9 +2098,13 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
es_fmt.video.i_height = p_sys->i_height; es_fmt.video.i_height = p_sys->i_height;
es_fmt.video.i_aspect = 4 * VOUT_ASPECT_FACTOR / 3; es_fmt.video.i_aspect = 4 * VOUT_ASPECT_FACTOR / 3;
msg_Dbg( p_demux, "added new video es %4.4s %dx%d", if( b_demux )
(char*)&es_fmt.i_codec, es_fmt.video.i_width, es_fmt.video.i_height ); {
p_sys->p_es = es_out_Add( p_demux->out, &es_fmt ); 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->p_es = es_out_Add( p_demux->out, &es_fmt );
}
/* Start Capture */ /* Start Capture */
...@@ -2147,7 +2126,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2147,7 +2126,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
if( v4l2_ioctl( i_fd, VIDIOC_QBUF, &buf ) < 0 ) if( v4l2_ioctl( i_fd, VIDIOC_QBUF, &buf ) < 0 )
{ {
msg_Err( p_demux, "VIDIOC_QBUF failed" ); msg_Err( p_obj, "VIDIOC_QBUF failed" );
goto open_failed; goto open_failed;
} }
} }
...@@ -2155,7 +2134,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2155,7 +2134,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if( v4l2_ioctl( i_fd, VIDIOC_STREAMON, &buf_type ) < 0 ) if( v4l2_ioctl( i_fd, VIDIOC_STREAMON, &buf_type ) < 0 )
{ {
msg_Err( p_demux, "VIDIOC_STREAMON failed" ); msg_Err( p_obj, "VIDIOC_STREAMON failed" );
goto open_failed; goto open_failed;
} }
...@@ -2175,7 +2154,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2175,7 +2154,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
if( v4l2_ioctl( i_fd, VIDIOC_QBUF, &buf ) < 0 ) if( v4l2_ioctl( i_fd, VIDIOC_QBUF, &buf ) < 0 )
{ {
msg_Err( p_demux, "VIDIOC_QBUF failed" ); msg_Err( p_obj, "VIDIOC_QBUF failed" );
goto open_failed; goto open_failed;
} }
} }
...@@ -2183,7 +2162,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2183,7 +2162,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if( v4l2_ioctl( i_fd, VIDIOC_STREAMON, &buf_type ) < 0 ) if( v4l2_ioctl( i_fd, VIDIOC_STREAMON, &buf_type ) < 0 )
{ {
msg_Err( p_demux, "VIDIOC_STREAMON failed" ); msg_Err( p_obj, "VIDIOC_STREAMON failed" );
goto open_failed; goto open_failed;
} }
...@@ -2193,7 +2172,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux ) ...@@ -2193,7 +2172,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
/* report fps */ /* report fps */
if( p_sys->f_fps >= 0.1 ) if( p_sys->f_fps >= 0.1 )
{ {
msg_Dbg( p_demux, "User set fps=%f", p_sys->f_fps ); msg_Dbg( p_obj, "User set fps=%f", p_sys->f_fps );
} }
return i_fd; return i_fd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment