static int AccessOpen ( vlc_object_t * );
static void AccessClose( vlc_object_t * );
+#define DEVICE_TEXT N_( "Device" )
+#define DEVICE_LONGTEXT N_( \
+ "Video device (Default: /dev/video0)." )
#define STANDARD_TEXT N_( "Standard" )
#define STANDARD_LONGTEXT N_( \
"Video standard (Default, SECAM, PAL, or NTSC)." )
static const char *const psz_iomethod_list_text[] =
{ N_("AUTO"), N_("READ"), N_("MMAP"), N_("USERPTR") };
-static const int i_tuner_audio_modes_list[] =
- { V4L2_TUNER_MODE_MONO, V4L2_TUNER_MODE_STEREO,
+static const int i_tuner_audio_modes_list[] = {
+ -1, V4L2_TUNER_MODE_MONO, V4L2_TUNER_MODE_STEREO,
V4L2_TUNER_MODE_LANG1, V4L2_TUNER_MODE_LANG2,
V4L2_TUNER_MODE_SAP, V4L2_TUNER_MODE_LANG1_LANG2 };
-static const char *const psz_tuner_audio_modes_list_text[] =
- { N_( "Mono" ),
+static const char *const psz_tuner_audio_modes_list_text[] = {
+ N_("Unspecified"),
+ N_( "Mono" ),
N_( "Stereo" ),
N_( "Primary language (Analog TV tuners only)" ),
N_( "Secondary language (Analog TV tuners only)" ),
set_subcategory( SUBCAT_INPUT_ACCESS )
set_section( N_( "Video input" ), NULL )
+ add_string( CFG_PREFIX "dev", "/dev/video0", DEVICE_TEXT, DEVICE_LONGTEXT,
+ false )
add_integer( CFG_PREFIX "standard", 0, STANDARD_TEXT,
STANDARD_LONGTEXT, false )
change_integer_list( i_standards_list, psz_standards_list_text )
add_string( CFG_PREFIX "set-ctrls", NULL, S_CTRLS_TEXT,
S_CTRLS_LONGTEXT, true )
- add_obsolete_string( CFG_PREFIX "dev" )
-
add_obsolete_string( CFG_PREFIX "adev" )
add_obsolete_integer( CFG_PREFIX "audio-method" )
add_obsolete_bool( CFG_PREFIX "stereo" )
struct v4l2_capability dev_cap;
- int i_input;
+ unsigned i_input;
struct v4l2_input *p_inputs;
- int i_selected_input;
+ unsigned i_selected_input;
- int i_standard;
+ unsigned i_standard;
struct v4l2_standard *p_standards;
v4l2_std_id i_selected_standard_id;
- int i_audio;
+ unsigned i_audio;
/* V4L2 devices cannot have more than 32 audio inputs */
struct v4l2_audio p_audios[32];
int i_selected_audio_input;
- int i_tuner;
+ unsigned i_tuner;
struct v4l2_tuner *p_tuners;
- int i_codec;
+ unsigned i_codec;
struct v4l2_fmtdesc *p_codecs;
struct buffer_t *p_buffers;
*****************************************************************************/
static void GetV4L2Params( demux_sys_t *p_sys, vlc_object_t *p_obj )
{
- p_sys->i_selected_standard_id =
- i_standards_list[var_CreateGetInteger( p_obj, "v4l2-standard" )];
+ p_sys->psz_device = var_CreateGetNonEmptyString( p_obj, "v4l2-dev" );
+ p_sys->i_selected_standard_id =
+ var_CreateGetInteger( p_obj, "v4l2-standard" );
p_sys->i_selected_input = var_CreateGetInteger( p_obj, "v4l2-input" );
p_sys->i_selected_audio_input =
var_CreateGetInteger( p_obj, "v4l2-audio-input" );
}
free( psz_aspect );
- p_sys->psz_device = NULL;
p_sys->i_fd = -1;
p_sys->p_es = NULL;
/* Main device */
if( *psz_dup )
+ {
+ free( p_sys->psz_device );
p_sys->psz_device = strdup( psz_dup );
- else
+ }
+ else if( p_sys->psz_device == NULL )
p_sys->psz_device = strdup( V4L2_DEFAULT );
free( psz_dup );
}
if( i_ret < 0 )
{
- msg_Err( p_access, "Polling error (%m)." );
+ if( errno != EINTR )
+ msg_Err( p_access, "poll error" );
return -1;
}
{
demux_sys_t *p_sys = p_demux->p_sys;
- for( int i_index = 0; i_index < p_sys->i_codec; i_index++ )
+ for( unsigned i_index = 0; i_index < p_sys->i_codec; i_index++ )
{
if( p_sys->p_codecs[i_index].pixelformat == i_pixelformat )
return true;
}
#endif
+ /* Select standard */
+
+ if( p_sys->i_selected_standard_id != V4L2_STD_UNKNOWN )
+ {
+ if( v4l2_ioctl( i_fd, VIDIOC_S_STD, &p_sys->i_selected_standard_id ) < 0 )
+ {
+ msg_Err( p_obj, "cannot set standard (%m)" );
+ goto open_failed;
+ }
+ if( v4l2_ioctl( i_fd, VIDIOC_G_STD, &p_sys->i_selected_standard_id ) < 0 )
+ {
+ msg_Err( p_obj, "cannot get standard (%m). This should never happen!" );
+ goto open_failed;
+ }
+ msg_Dbg( p_obj, "Set standard to (0x%"PRIx64"):", (int64_t)p_sys->i_selected_standard_id );
+ for(unsigned i_standard = 0; i_standard<p_sys->i_standard; i_standard++)
+ {
+ if( p_sys->p_standards[i_standard].id & p_sys->i_selected_standard_id )
+ {
+ msg_Dbg( p_obj, " %s",
+ p_sys->p_standards[i_standard].name );
+ }
+ }
+ }
+
/* Tune the tuner */
if( p_sys->i_frequency >= 0 )
{
- if( p_sys->i_cur_tuner < 0 || p_sys->i_cur_tuner >= p_sys->i_tuner )
+ if( p_sys->i_cur_tuner < 0 || (unsigned)p_sys->i_cur_tuner >= p_sys->i_tuner )
{
msg_Err( p_obj, "invalid tuner %d.", p_sys->i_cur_tuner );
goto open_failed;
/* Set the tuner's audio mode */
if( p_sys->i_audio_mode >= 0 )
{
- if( p_sys->i_cur_tuner < 0 || p_sys->i_cur_tuner >= p_sys->i_tuner )
+ if( p_sys->i_cur_tuner < 0 || (unsigned)p_sys->i_cur_tuner >= p_sys->i_tuner )
{
msg_Err( p_obj, "invalid tuner %d.", p_sys->i_cur_tuner );
goto open_failed;
msg_Dbg( p_obj, "Tuner audio mode set" );
}
- /* Select standard */
-
- if( p_sys->i_selected_standard_id != V4L2_STD_UNKNOWN )
- {
- if( v4l2_ioctl( i_fd, VIDIOC_S_STD, &p_sys->i_selected_standard_id ) < 0 )
- {
- msg_Err( p_obj, "cannot set standard (%m)" );
- goto open_failed;
- }
- if( v4l2_ioctl( i_fd, VIDIOC_G_STD, &p_sys->i_selected_standard_id ) < 0 )
- {
- msg_Err( p_obj, "cannot get standard (%m). This should never happen!" );
- goto open_failed;
- }
- msg_Dbg( p_obj, "Set standard to (0x%"PRIx64"):", p_sys->i_selected_standard_id );
- int i_standard;
- for( i_standard = 0; i_standard<p_sys->i_standard; i_standard++)
- {
- if( p_sys->p_standards[i_standard].id & p_sys->i_selected_standard_id )
- {
- msg_Dbg( p_obj, " %s",
- p_sys->p_standards[i_standard].name );
- }
- }
- }
-
/* Select input */
if( p_sys->i_selected_input >= p_sys->i_input )
if( p_sys->i_audio > 0 )
{
if( p_sys->i_selected_audio_input < 0
- || p_sys->i_selected_audio_input >= p_sys->i_audio )
+ || (unsigned)p_sys->i_selected_audio_input >= p_sys->i_audio )
{
msg_Warn( p_obj, "invalid audio input. Using the default one" );
p_sys->i_selected_audio_input = 0;
static bool ProbeVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys,
const char *psz_device )
{
- int i_index;
- int i_standard;
-
int i_fd;
if( ( i_fd = v4l2_open( psz_device, O_RDWR ) ) < 0 )
p_sys->p_inputs = calloc( 1, p_sys->i_input * sizeof( struct v4l2_input ) );
if( !p_sys->p_inputs ) goto open_failed;
- for( i_index = 0; i_index < p_sys->i_input; i_index++ )
+ for( unsigned i_index = 0; i_index < p_sys->i_input; i_index++ )
{
p_sys->p_inputs[i_index].index = i_index;
msg_Err( p_obj, "cannot get video input characteristics (%m)" );
goto open_failed;
}
- msg_Dbg( p_obj, "video input %i (%s) has type: %s %c",
+ msg_Dbg( p_obj, "video input %u (%s) has type: %s %c",
i_index,
p_sys->p_inputs[i_index].name,
p_sys->p_inputs[i_index].type
p_sys->p_standards = calloc( 1, p_sys->i_standard * sizeof( struct v4l2_standard ) );
if( !p_sys->p_standards ) goto open_failed;
- for( i_standard = 0; i_standard < p_sys->i_standard; i_standard++ )
+ for( unsigned i_standard = 0; i_standard < p_sys->i_standard; i_standard++ )
{
p_sys->p_standards[i_standard].index = i_standard;
msg_Err( p_obj, "cannot get video input standards (%m)" );
goto open_failed;
}
- msg_Dbg( p_obj, "video standard %i is: %s %c",
+ msg_Dbg( p_obj, "video standard %u is: %s %c",
i_standard,
p_sys->p_standards[i_standard].name,
(p_sys->p_standards[i_standard].id & p_sys->i_selected_standard_id) ? '*' : ' ' );
}
/* initialize the structures for the ioctls */
- for( i_index = 0; i_index < 32; i_index++ )
+ for( unsigned i_index = 0; i_index < 32; i_index++ )
{
p_sys->p_audios[i_index].index = i_index;
}
goto open_failed;
}
- msg_Dbg( p_obj, "audio input %i (%s) is %s %s %c",
+ msg_Dbg( p_obj, "audio input %u (%s) is %s %s %c",
p_sys->i_audio,
p_sys->p_audios[p_sys->i_audio].name,
p_sys->p_audios[p_sys->i_audio].capability &
p_sys->p_audios[p_sys->i_audio].capability &
V4L2_AUDCAP_AVL ?
"(Automatic Volume Level supported)" : "",
- p_sys->i_audio == p_sys->i_selected_audio_input ? '*' : ' ' );
+ p_sys->i_audio == (unsigned)p_sys->i_selected_audio_input ? '*' : ' ' );
p_sys->i_audio++;
}
p_sys->p_tuners = calloc( 1, p_sys->i_tuner * sizeof( struct v4l2_tuner ) );
if( !p_sys->p_tuners ) goto open_failed;
- for( i_index = 0; i_index < p_sys->i_tuner; i_index++ )
+ for( unsigned i_index = 0; i_index < p_sys->i_tuner; i_index++ )
{
p_sys->p_tuners[i_index].index = i_index;
msg_Err( p_obj, "cannot get tuner characteristics (%m)" );
goto open_failed;
}
- msg_Dbg( p_obj, "tuner %i (%s) has type: %s, "
+ msg_Dbg( p_obj, "tuner %u (%s) has type: %s, "
"frequency range: %.1f %s -> %.1f %s",
i_index,
p_sys->p_tuners[i_index].name,
msg_Err( p_obj, "cannot get tuner frequency (%m)" );
goto open_failed;
}
- msg_Dbg( p_obj, "tuner %i (%s) frequency: %.1f %s",
+ msg_Dbg( p_obj, "tuner %u (%s) frequency: %.1f %s",
i_index,
p_sys->p_tuners[i_index].name,
frequency.frequency * 62.5,
{
struct v4l2_fmtdesc codec;
- i_index = 0;
+ unsigned i_index = 0;
memset( &codec, 0, sizeof(codec) );
codec.index = i_index;
codec.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;