Commit faa35c22 authored by Benjamin Pracht's avatar Benjamin Pracht

cleaning of pvr input : settings are only set if given on command line

(no more default values).

Patch from Tim O Callaghan (tim.ocallaghan - AT - limestudios - DOT - com)
parent 3f6bf89a
......@@ -2,7 +2,7 @@
* pvr.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: pvr.c,v 1.11 2004/01/25 17:31:22 gbazin Exp $
* $Id: pvr.c,v 1.12 2004/02/20 15:38:40 bigben Exp $
*
* Authors: Eric Petit <titer@videolan.org>
*
......@@ -127,14 +127,15 @@ static int Open( vlc_object_t * p_this )
/* defaults values */
psz_device = 0;
p_sys->i_standard = V4L2_STD_SECAM;
p_sys->i_width = 720;
p_sys->i_height = 576;
p_sys->i_frequency = 567250; /* M6 ;) */
p_sys->i_framerate = 25;
p_sys->i_bitrate = 3000000;
p_sys->i_bitrate_peak = 4000000;
p_sys->i_input = 4;
p_sys->i_standard = V4L2_STD_UNKNOWN;
p_sys->i_width = -1;
p_sys->i_height = -1;
p_sys->i_frequency = -1; /* M6 ;) */
p_sys->i_framerate = -1;
p_sys->i_bitrate = -1;
p_sys->i_bitrate_peak = -1;
p_sys->i_bitrate_mode = -1;
p_sys->i_input = -1;
/* parse command line options */
psz_tofree = strdup( p_input->psz_name );
......@@ -270,14 +271,12 @@ static int Open( vlc_object_t * p_this )
{
char *psz_parser_init;
psz_parser_init = psz_parser;
while ( *psz_parser != ':' && *psz_parser != ','
&& *psz_parser != '\0' )
while ( *psz_parser != ':' && *psz_parser != ',' && *psz_parser != '\0' )
{
psz_parser++;
}
psz_device = calloc( psz_parser - psz_parser_init + 1, 1 );
strncpy( psz_device, psz_parser_init,
psz_parser - psz_parser_init );
strncpy( psz_device, psz_parser_init, psz_parser - psz_parser_init );
}
if( *psz_parser )
psz_parser++;
......@@ -296,49 +295,68 @@ static int Open( vlc_object_t * p_this )
free( psz_tofree );
msg_Dbg( p_input, "device: %s, input: %d, standard: %x, size: %dx%d, "
"frequency: %d, framerate: %d, bitrate: %d/%d/%d",
psz_device, p_sys->i_input, p_sys->i_standard, p_sys->i_width,
p_sys->i_height, p_sys->i_frequency, p_sys->i_framerate,
p_sys->i_bitrate, p_sys->i_bitrate_peak,p_sys->i_bitrate_mode );
/* open the device */
if( ( p_sys->i_fd = open( psz_device, O_RDWR ) ) < 0 )
{
msg_Err( p_input, "cannot open device (%s)", strerror( errno ) );
return VLC_EGENERIC;
}
else
msg_Dbg( p_input, "using video device: %s",psz_device);
free( psz_device );
/* set the input */
if( ioctl( p_sys->i_fd, VIDIOC_S_INPUT, &p_sys->i_input ) < 0 )
if( p_sys->i_input != -1)
{
if(ioctl( p_sys->i_fd, VIDIOC_S_INPUT, &p_sys->i_input ) < 0 )
{
msg_Warn( p_input, "VIDIOC_S_INPUT failed" );
}
else
msg_Dbg( p_input,"input set to:%d",p_sys->i_input);
}
/* set the video standard */
if( ioctl( p_sys->i_fd, VIDIOC_S_STD, &p_sys->i_standard ) < 0 )
if(p_sys->i_standard != V4L2_STD_UNKNOWN)
{
if(ioctl( p_sys->i_fd, VIDIOC_S_STD, &p_sys->i_standard ) < 0 )
{
msg_Warn( p_input, "VIDIOC_S_STD failed" );
}
else
msg_Dbg( p_input,"video standard set to:%x",p_sys->i_standard);
}
/* set the picture size */
if( ioctl( p_sys->i_fd, VIDIOC_G_FMT, &vfmt ) < 0 )
if(p_sys->i_width != -1 || p_sys->i_height != -1)
{
if(ioctl( p_sys->i_fd, VIDIOC_G_FMT, &vfmt ) < 0 )
{
msg_Warn( p_input, "VIDIOC_G_FMT failed" );
}
else
{
if(p_sys->i_width != -1)
vfmt.fmt.pix.width = p_sys->i_width;
if(p_sys->i_height != -1)
vfmt.fmt.pix.height = p_sys->i_height;
if( ioctl( p_sys->i_fd, VIDIOC_S_FMT, &vfmt ) < 0 )
{
msg_Warn( p_input, "VIDIOC_S_FMT failed" );
}
else
{
msg_Dbg( p_input,"picture size set to:%dx%d",vfmt.fmt.pix.width, vfmt.fmt.pix.height);
}
}
}
/* set the frequency */
if (p_sys->i_frequency != -1)
{
vf.tuner = 0; /* TODO: let the user choose the tuner */
if( ioctl( p_sys->i_fd, VIDIOC_G_FREQUENCY, &vf ) < 0 )
{
......@@ -353,14 +371,29 @@ static int Open( vlc_object_t * p_this )
msg_Warn( p_input, "VIDIOC_S_FREQUENCY failed (%s)",
strerror( errno ) );
}
else
{
msg_Dbg( p_input,"Tuner frequency set to:%d",p_sys->i_frequency);
}
}
}
/* codec parameters */
if(p_sys->i_framerate != -1
|| p_sys->i_bitrate_mode != -1
|| p_sys->i_bitrate_peak != -1
|| p_sys->i_bitrate != -1
)
{
if( ioctl( p_sys->i_fd, IVTV_IOC_G_CODEC, &codec ) < 0 )
{
msg_Warn( p_input, "IVTV_IOC_G_CODEC failed" );
}
else
{
if(p_sys->i_framerate != -1)
{
switch( p_sys->i_framerate )
{
......@@ -377,15 +410,41 @@ static int Open( vlc_object_t * p_this )
codec.framerate = 1;
break;
}
}
if(p_sys->i_bitrate != -1)
codec.bitrate = p_sys->i_bitrate;
if(p_sys->i_bitrate_peak != -1)
codec.bitrate_peak = p_sys->i_bitrate_peak;
if(p_sys->i_bitrate_mode != -1)
codec.bitrate_mode = p_sys->i_bitrate_mode;
if( ioctl( p_sys->i_fd, IVTV_IOC_S_CODEC, &codec ) < 0 )
{
msg_Warn( p_input, "IVTV_IOC_S_CODEC failed" );
}
else
{
msg_Dbg( p_input, "Setting codec parameters to: framerate: %d, bitrate: %d/%d/%d",
codec.framerate, codec.bitrate, codec.bitrate_peak, codec.bitrate_mode);
}
}
}
/* do a quick read */
if(p_sys->i_fd)
{
if(read(p_sys->i_fd,&" ",1))
{
msg_Dbg(p_input, "Could read byte from device");
}
else
{
msg_Warn(p_input, "Could not read byte from device");
}
}
return VLC_SUCCESS;
}
......
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