aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--src/Makefile.am2
-rw-r--r--src/commands.c44
-rw-r--r--src/tvtime-startup.c1
-rw-r--r--src/tvtime.c35
-rw-r--r--src/vbidata.c2
-rw-r--r--src/videoinput.c1307
7 files changed, 295 insertions, 1097 deletions
diff --git a/configure.ac b/configure.ac
index 59802c4..eac6c20 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,6 @@ AC_PROG_LIBTOOL
AC_HEADER_STDC
AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h getopt.h langinfo.h math.h netinet/in.h pwd.h signal.h stdint.h stdio.h stdlib.h string.h sys/ioctl.h sys/mman.h sys/resource.h sys/stat.h sys/time.h sys/wait.h sys/types.h unistd.h wordexp.h locale.h])
-AC_CHECK_HEADER([linux/videodev.h], [], AC_MSG_ERROR(linux/videodev.h not found))
AC_CHECK_HEADER([linux/videodev2.h], [], AC_MSG_ERROR(linux/videodev2.h not found))
# Checks for typedefs, structures, and compiler characteristics.
diff --git a/src/Makefile.am b/src/Makefile.am
index 7655e9e..50687c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,7 +38,7 @@ COMMON_SRCS = mixer.c videoinput.c rtctimer.c leetft.c osdtools.c tvtimeconf.c \
speedtools.h vbiscreen.h vbiscreen.c fifo.h fifo.c commands.h \
commands.c videofilter.h videofilter.c station.h station.c bands.h \
utils.h utils.c pulldown.h pulldown.c hashtable.h hashtable.c \
- cpuinfo.h cpuinfo.c videodev.h videodev2.h menu.c menu.h \
+ cpuinfo.h cpuinfo.c videodev2.h menu.c menu.h \
outputfilter.h outputfilter.c xmltv.h xmltv.c gettext.h tvtimeglyphs.h \
copyfunctions.h copyfunctions.c alsa_stream.c
diff --git a/src/commands.c b/src/commands.c
index 8b13be7..964cab7 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -527,7 +527,6 @@ static void reinit_tuner( commands_t *cmd )
tvtime_osd_set_channel_name( cmd->osd, station_get_current_channel_name( cmd->stationmgr ) );
}
tvtime_osd_set_norm( cmd->osd, videoinput_get_norm_name( videoinput_get_norm( cmd->vidin ) ) );
- tvtime_osd_set_audio_mode( cmd->osd, videoinput_get_audio_mode_name( cmd->vidin, videoinput_get_audio_mode( cmd->vidin ) ) );
tvtime_osd_set_freq_table( cmd->osd, station_get_current_band( cmd->stationmgr ) );
tvtime_osd_set_channel_number( cmd->osd, channel_display );
tvtime_osd_set_network_call( cmd->osd, station_get_current_network_call_letters( cmd->stationmgr ) );
@@ -1377,13 +1376,6 @@ commands_t *commands_new( config_t *cfg, videoinput_t *vidin,
_("Setup"), _("Input configuration"), _("Preferred audio mode") );
menu_set_text( menu, 0, string );
commands_add_menu( cmd, menu );
- if( cmd->vidin ) {
- reset_audio_mode_menu( commands_get_menu( cmd, "audiomode" ),
- videoinput_get_norm( cmd->vidin ) == VIDEOINPUT_NTSC,
- videoinput_get_audio_mode( cmd->vidin ) );
- } else {
- reset_audio_mode_menu( commands_get_menu( cmd, "audiomode" ), 0, 0 );
- }
menu = menu_new( "audioboost" );
snprintf( string, sizeof( string ), "%s - %s - %s",
@@ -2710,45 +2702,9 @@ void commands_handle( commands_t *cmd, int tvtime_cmd, const char *arg )
break;
case TVTIME_SET_AUDIO_MODE:
- if( cmd->vidin ) {
- if( !strcasecmp( arg, "mono" ) ) {
- videoinput_set_audio_mode( cmd->vidin, VIDEOINPUT_MONO );
- } else if( !strcasecmp( arg, "stereo" ) ) {
- videoinput_set_audio_mode( cmd->vidin, VIDEOINPUT_STEREO );
- } else if( !strcasecmp( arg, "sap" ) || !strcasecmp( arg, "lang1" ) ) {
- videoinput_set_audio_mode( cmd->vidin, VIDEOINPUT_LANG1 );
- } else {
- videoinput_set_audio_mode( cmd->vidin, VIDEOINPUT_LANG2 );
- }
- if( cmd->osd ) {
- if( !cmd->menuactive ) {
- osd_list_audio_modes( cmd->osd, videoinput_get_norm( cmd->vidin ) == VIDEOINPUT_NTSC,
- videoinput_get_audio_mode( cmd->vidin ) );
- }
- tvtime_osd_set_audio_mode( cmd->osd, videoinput_get_audio_mode_name( cmd->vidin, videoinput_get_audio_mode( cmd->vidin ) ) );
- tvtime_osd_show_info( cmd->osd );
- reset_audio_mode_menu( commands_get_menu( cmd, "audiomode" ),
- videoinput_get_norm( cmd->vidin ) == VIDEOINPUT_NTSC,
- videoinput_get_audio_mode( cmd->vidin ) );
- commands_refresh_menu( cmd );
- }
- }
break;
case TVTIME_TOGGLE_AUDIO_MODE:
- if( cmd->vidin ) {
- videoinput_set_audio_mode( cmd->vidin, videoinput_get_audio_mode( cmd->vidin ) << 1 );
- if( cmd->osd ) {
- osd_list_audio_modes( cmd->osd, videoinput_get_norm( cmd->vidin ) == VIDEOINPUT_NTSC,
- videoinput_get_audio_mode( cmd->vidin ) );
- tvtime_osd_set_audio_mode( cmd->osd, videoinput_get_audio_mode_name( cmd->vidin, videoinput_get_audio_mode( cmd->vidin ) ) );
- tvtime_osd_show_info( cmd->osd );
- reset_audio_mode_menu( commands_get_menu( cmd, "audiomode" ),
- videoinput_get_norm( cmd->vidin ) == VIDEOINPUT_NTSC,
- videoinput_get_audio_mode( cmd->vidin ) );
- commands_refresh_menu( cmd );
- }
- }
break;
case TVTIME_TOGGLE_DEINTERLACER:
diff --git a/src/tvtime-startup.c b/src/tvtime-startup.c
index d850a89..5a7a3c4 100644
--- a/src/tvtime-startup.c
+++ b/src/tvtime-startup.c
@@ -35,7 +35,6 @@
#else
# define _(string) string
#endif
-#include <linux/videodev.h>
#include <linux/videodev2.h>
typedef struct v4l_device_s v4l_device_t;
diff --git a/src/tvtime.c b/src/tvtime.c
index 43b2385..75257d1 100644
--- a/src/tvtime.c
+++ b/src/tvtime.c
@@ -1351,19 +1351,6 @@ int tvtime_main( rtctimer_t *rtctimer, int read_stdin, int realtime,
const char *audiomode = config_get_audio_mode( ct );
videoinput_set_input_num( vidin, config_get_inputnum( ct ) );
- if( audiomode ) {
- if( !strcasecmp( audiomode, "mono" ) ) {
- videoinput_set_audio_mode( vidin, VIDEOINPUT_MONO );
- } else if( !strcasecmp( audiomode, "stereo" ) ) {
- videoinput_set_audio_mode( vidin, VIDEOINPUT_STEREO );
- } else if( !strcasecmp( audiomode, "sap" )
- || !strcasecmp( audiomode, "lang1" ) ) {
- videoinput_set_audio_mode( vidin, VIDEOINPUT_LANG1 );
- } else {
- videoinput_set_audio_mode( vidin, VIDEOINPUT_LANG2 );
- }
- }
-
width = videoinput_get_width( vidin );
height = videoinput_get_height( vidin );
if( verbose ) {
@@ -1397,23 +1384,13 @@ int tvtime_main( rtctimer_t *rtctimer, int read_stdin, int realtime,
}
if( fieldsavailable < 4 ) {
- if( videoinput_is_bttv( vidin ) ) {
- lfprintf( stderr,
- _("\n"
- " You are using the bttv driver, but have not configured enough\n"
- " buffers for tvtime to process the video optimally. This is\n"
- " true by default with bttv in kernels before 2.4.21. Please\n"
- " set the option gbuffers=4 when loading bttv. For more\n"
- " information see our support page at %s\n\n"), PACKAGE_BUGREPORT );
- } else {
- lfprintf( stderr, _("\n"
+ lfprintf( stderr, _("\n"
" Your capture card driver, %s, is not providing\n"
" enough buffers for tvtime to process the video. Please check with\n"
" your driver documentation to see if you can increase the number\n"
" of buffers provided to applications, and report this to the tvtime\n"
" bug tracker at %s\n\n"), videoinput_get_driver_name( vidin ),
PACKAGE_BUGREPORT );
- }
}
} else {
fieldsavailable = 4;
@@ -2590,16 +2567,6 @@ int tvtime_main( rtctimer_t *rtctimer, int read_stdin, int realtime,
snprintf( number, 4, "%d", videoinput_get_input_num( vidin ) );
config_save( ct, "V4LInput", number );
- if( videoinput_get_audio_mode( vidin ) == VIDEOINPUT_MONO ) {
- config_save( ct, "AudioMode", "mono" );
- } else if( videoinput_get_audio_mode( vidin ) == VIDEOINPUT_LANG1 ) {
- config_save( ct, "AudioMode", "lang1" );
- } else if( videoinput_get_audio_mode( vidin ) == VIDEOINPUT_LANG2 ) {
- config_save( ct, "AudioMode", "lang2" );
- } else {
- config_save( ct, "AudioMode", "stereo" );
- }
-
snprintf( number, 4, "%d", videoinput_get_pal_audio_mode( vidin ) );
config_save( ct, "PalDKMode", number );
}
diff --git a/src/vbidata.c b/src/vbidata.c
index 69e198f..2fe6a2d 100644
--- a/src/vbidata.c
+++ b/src/vbidata.c
@@ -38,7 +38,7 @@
#include <math.h>
#include <errno.h>
#include "vbidata.h"
-#include <linux/videodev.h>
+#include <linux/videodev2.h>
struct vbidata_s
{
diff --git a/src/videoinput.c b/src/videoinput.c
index 0f8a036..dd60334 100644
--- a/src/videoinput.c
+++ b/src/videoinput.c
@@ -35,7 +35,6 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include <linux/videodev.h>
#include <linux/videodev2.h>
#include "videoinput.h"
#include "mixer.h"
@@ -102,27 +101,6 @@ static v4l2_std_id videoinput_get_v4l2_norm( int norm )
}
}
-static int videoinput_get_v4l1_norm( int norm )
-{
- if( norm == VIDEOINPUT_NTSC ) {
- return VIDEO_MODE_NTSC;
- } else if( norm == VIDEOINPUT_PAL ) {
- return VIDEO_MODE_PAL;
- } else if( norm == VIDEOINPUT_SECAM ) {
- return VIDEO_MODE_SECAM;
- } else if( norm == VIDEOINPUT_PAL_NC ) {
- return 3;
- } else if( norm == VIDEOINPUT_PAL_M ) {
- return 4;
- } else if( norm == VIDEOINPUT_PAL_N ) {
- return 5;
- } else if( norm == VIDEOINPUT_NTSC_JP ) {
- return 6;
- } else {
- return 0;
- }
-}
-
static int videoinput_get_audmode_v4l2( int mode )
{
if( mode == VIDEOINPUT_MONO ) {
@@ -194,7 +172,6 @@ struct videoinput_s
int volume;
int amode;
- int isbttv;
int isv4l2;
int isuyvy;
@@ -221,39 +198,8 @@ struct videoinput_s
/* V4L2 capture state. */
capture_buffer_t capbuffers[ MAX_CAPTURE_BUFFERS ];
int is_streaming;
-
- /* V4L1 mmap-mode state. */
- int have_mmap;
- uint8_t *map;
- struct video_mmap *grab_buf;
- struct video_mbuf gb_buffers;
-
- /* V4L1 read-mode state. */
- int grab_size;
- uint8_t *grab_data;
};
-const char *videoinput_get_audio_mode_name( videoinput_t *vidin, int mode )
-{
- if( mode == VIDEO_SOUND_MONO ) {
- return "Mono";
- } else if( mode == VIDEO_SOUND_STEREO ) {
- return "Stereo";
- } else if( vidin->norm == VIDEOINPUT_NTSC ) {
- if( mode == VIDEO_SOUND_LANG2 ) {
- return "SAP";
- }
- } else {
- if( mode == VIDEO_SOUND_LANG1 ) {
- return "Language 1";
- } else if( mode == VIDEO_SOUND_LANG2 ) {
- return "Language 2";
- }
- }
-
- return "ERROR";
-}
-
static void videoinput_start_capture_v4l2( videoinput_t *vidin )
{
if( !vidin->is_streaming ) {
@@ -296,23 +242,16 @@ static void siginit( void )
static void free_frame( videoinput_t *vidin, int frameid )
{
- if( vidin->isv4l2 ) {
- if( ioctl( vidin->grab_fd, VIDIOC_QBUF, &vidin->capbuffers[ frameid ].vidbuf ) < 0 ) {
- fprintf( stderr, "videoinput: Can't free frame %d: %s\n",
- frameid, strerror( errno ) );
- }
- vidin->capbuffers[ frameid ].free = 1;
- } else {
- if( ioctl( vidin->grab_fd, VIDIOCMCAPTURE, vidin->grab_buf + frameid ) < 0 ) {
- fprintf( stderr, "videoinput: Can't free frame %d: %s\n",
- frameid, strerror( errno ) );
- }
+ if( ioctl( vidin->grab_fd, VIDIOC_QBUF, &vidin->capbuffers[ frameid ].vidbuf ) < 0 ) {
+ fprintf( stderr, "videoinput: Can't free frame %d: %s\n",
+ frameid, strerror( errno ) );
}
+ vidin->capbuffers[ frameid ].free = 1;
}
void videoinput_free_frame( videoinput_t *vidin, int frameid )
{
- if( vidin->isv4l2 || vidin->have_mmap ) {
+ if( vidin->isv4l2 ) {
free_frame( vidin, frameid );
}
}
@@ -327,27 +266,6 @@ static void videoinput_free_all_frames( videoinput_t *vidin )
vidin->curframe = 0;
}
-static void wait_for_frame_v4l1( videoinput_t *vidin, int frameid )
-{
- alarms = 0;
- alarm( SYNC_TIMEOUT );
- if( ioctl( vidin->grab_fd, VIDIOCSYNC, vidin->grab_buf + frameid ) < 0 ) {
- fprintf( stderr, "videoinput: Can't wait for frame %d: %s\n",
- frameid, strerror( errno ) );
- }
- if( alarms ) {
- fprintf( stderr, "\n"
- " Your capture card driver: %s\n"
- " is taking too long to provide frames to tvtime. This could be due\n"
- " either to a broken capture card, a signal that has become unstable\n"
- " or very noisy, or a driver misconfiguration.\n"
- "\n"
- " Please report this on our bugs page: " PACKAGE_BUGREPORT "\n\n",
- vidin->drivername );
- }
- alarm( 0 );
-}
-
static void wait_for_frame_v4l2( videoinput_t * vidin )
{
struct timeval timeout;
@@ -371,67 +289,41 @@ static void wait_for_frame_v4l2( videoinput_t * vidin )
uint8_t *videoinput_next_frame( videoinput_t *vidin, int *frameid )
{
- if( vidin->isv4l2 ) {
- struct v4l2_buffer cur_buf;
+ struct v4l2_buffer cur_buf;
- wait_for_frame_v4l2( vidin );
+ wait_for_frame_v4l2( vidin );
- cur_buf.type = vidin->capbuffers[ 0 ].vidbuf.type;
- if( ioctl( vidin->grab_fd, VIDIOC_DQBUF, &cur_buf ) < 0 ) {
- /* some drivers return EIO when there is no signal */
- if( errno != EIO ) {
- fprintf( stderr, "videoinput: Can't read frame. Error was: %s (%d).\n",
- strerror( errno ), vidin->frames_since_start );
- }
- /* We must now restart capture. */
- videoinput_stop_capture_v4l2( vidin );
- videoinput_free_all_frames( vidin );
- videoinput_start_capture_v4l2( vidin );
- *frameid = -1;
- return 0;
- }
- vidin->frames_since_start++;
- vidin->capbuffers[ cur_buf.index ].free = 0;
- *frameid = cur_buf.index;
- return vidin->capbuffers[ cur_buf.index ].data;
- } else {
- if( vidin->have_mmap ) {
- uint8_t *cur;
- wait_for_frame_v4l1( vidin, vidin->curframe );
- cur = vidin->map + vidin->gb_buffers.offsets[ vidin->curframe ];
- *frameid = vidin->curframe;
- vidin->curframe = ( vidin->curframe + 1 ) % vidin->numframes;
- return cur;
- } else {
- int rc = read( vidin->grab_fd, vidin->grab_data, vidin->grab_size );
- if( vidin->grab_size != rc ) {
- fprintf( stderr, "videoinput: Can't read frame. Returned %d, error: %s.\n",
- rc, strerror( errno ) );
- return 0;
- } else {
- return vidin->grab_data;
- }
- }
+ cur_buf.type = vidin->capbuffers[ 0 ].vidbuf.type;
+ if( ioctl( vidin->grab_fd, VIDIOC_DQBUF, &cur_buf ) < 0 ) {
+ /* some drivers return EIO when there is no signal */
+ if( errno != EIO ) {
+ fprintf( stderr, "videoinput: Can't read frame. Error was: %s (%d).\n",
+ strerror( errno ), vidin->frames_since_start );
+ }
+ /* We must now restart capture. */
+ videoinput_stop_capture_v4l2( vidin );
+ videoinput_free_all_frames( vidin );
+ videoinput_start_capture_v4l2( vidin );
+ *frameid = -1;
+ return 0;
}
+ vidin->frames_since_start++;
+ vidin->capbuffers[ cur_buf.index ].free = 0;
+ *frameid = cur_buf.index;
+ return vidin->capbuffers[ cur_buf.index ].data;
}
int videoinput_buffer_invalid( videoinput_t *vidin, int frameid )
{
- if( !vidin->isv4l2 ) {
- return 0;
- } else {
- return vidin->capbuffers[ frameid ].free;
- }
+ return vidin->capbuffers[ frameid ].free;
}
videoinput_t *videoinput_new( const char *v4l_device, int capwidth,
int volume, int norm, int verbose, char *error_string )
{
videoinput_t *vidin = malloc( sizeof( videoinput_t ) );
- struct video_capability caps_v4l1;
struct v4l2_capability caps_v4l2;
- struct video_picture grab_pict;
- struct video_window grab_win;
+ struct v4l2_input in;
int i;
if( capwidth & 1 ) {
@@ -464,7 +356,6 @@ videoinput_t *videoinput_new( const char *v4l_device, int capwidth,
vidin->tunerlow = 0;
vidin->isv4l2 = 0;
- vidin->isbttv = 0;
vidin->isuyvy = 0;
vidin->signal_recover_wait = 0;
@@ -475,7 +366,6 @@ videoinput_t *videoinput_new( const char *v4l_device, int capwidth,
vidin->hasaudio = 1;
vidin->audiomode = 0;
vidin->curinput = 0;
- vidin->have_mmap = 0;
vidin->is_streaming = 0;
memset( vidin->inputname, 0, sizeof( vidin->inputname ) );
@@ -498,22 +388,11 @@ videoinput_t *videoinput_new( const char *v4l_device, int capwidth,
*/
if( ioctl( vidin->grab_fd, VIDIOC_QUERYCAP, &caps_v4l2 ) < 0 ) {
/* Can't get V4L2 capabilities, maybe this is a V4L1 device? */
- if( ioctl( vidin->grab_fd, VIDIOCGCAP, &caps_v4l1 ) < 0 ) {
- fprintf( stderr, "videoinput: %s is not a video4linux device.\n",
- v4l_device );
- sprintf( error_string, "Not a video4linux device" );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- } else if( vidin->verbose ) {
- fprintf( stderr, "videoinput: Using video4linux driver '%s'.\n"
- "videoinput: Card type is %x, audio %d.\n",
- caps_v4l1.name, caps_v4l1.type, caps_v4l1.audios );
- }
- snprintf( vidin->drivername, sizeof( vidin->drivername ),
- "%s", caps_v4l1.name );
- snprintf( vidin->shortdriver, sizeof( vidin->shortdriver ),
- "%s", caps_v4l1.name );
+ fprintf(stderr, "V4L1 devices not supported\n");
+ sprintf( error_string, "V4L1 devices not supported" );
+ close( vidin->grab_fd );
+ free( vidin );
+ return 0;
} else {
if( vidin->verbose ) {
fprintf( stderr, "videoinput: Using video4linux2 driver '%s', card '%s' (bus %s).\n"
@@ -530,124 +409,51 @@ videoinput_t *videoinput_new( const char *v4l_device, int capwidth,
"%s", caps_v4l2.driver );
}
- if( vidin->isv4l2 ) {
- struct v4l2_input in;
-
- vidin->numinputs = 0;
- in.index = vidin->numinputs;
-
- /**
- * We have to enumerate all of the inputs just to know how many
- * there are.
- */
- while( ioctl( vidin->grab_fd, VIDIOC_ENUMINPUT, &in ) >= 0 ) {
- vidin->numinputs++;
- in.index = vidin->numinputs;
- }
- if( !vidin->numinputs ) {
- fprintf( stderr, "videoinput: No inputs available on "
- "video4linux2 device '%s'.\n", v4l_device );
- sprintf( error_string, "No inputs available" );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
- } else {
- /* The capabilities should tell us how many inputs this card has. */
- vidin->numinputs = caps_v4l1.channels;
- if( vidin->numinputs == 0 ) {
- fprintf( stderr, "videoinput: No inputs available on "
- "video4linux device '%s'.\n", v4l_device );
- sprintf( error_string, "No inputs available" );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
- }
+ vidin->numinputs = 0;
+ in.index = vidin->numinputs;
- /* Check if this is a bttv-based card. Code taken from xawtv. */
-#define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
- /* dirty hack time / v4l design flaw -- works with bttv only
- * this adds support for a few less common PAL versions */
- if( !(ioctl( vidin->grab_fd, BTTV_VERSION, &i ) < 0) ) {
- vidin->isbttv = 1;
+ /**
+ * We have to enumerate all of the inputs just to know how many
+ * there are.
+ */
+ while( ioctl( vidin->grab_fd, VIDIOC_ENUMINPUT, &in ) >= 0 ) {
+ vidin->numinputs++;
+ in.index = vidin->numinputs;
}
-#undef BTTV_VERSION
-
- if( !vidin->isv4l2 ) {
- if( !vidin->isbttv && norm > VIDEOINPUT_SECAM ) {
- fprintf( stderr, "videoinput: Capture card '%s' does not seem to use the bttv driver.\n"
- "videoinput: The norm %s is only supported in V4L1 for bttv-supported cards.\n",
- v4l_device, videoinput_get_norm_name( norm ) );
- sprintf( error_string, "%s unsupported by %s", videoinput_get_norm_name( norm ), vidin->shortdriver );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
- if( norm > VIDEOINPUT_NTSC_JP ) {
- fprintf( stderr, "videoinput: Detected only a V4L1 driver. The PAL-60 norm\n"
- "videoinput: is only available if driver supports V4L2.\n" );
- sprintf( error_string, "%s unsupported by %s", videoinput_get_norm_name( norm ), vidin->shortdriver );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
+ if( !vidin->numinputs ) {
+ fprintf( stderr, "videoinput: No inputs available on "
+ "video4linux2 device '%s'.\n", v4l_device );
+ sprintf( error_string, "No inputs available" );
+ close( vidin->grab_fd );
+ free( vidin );
+ return 0;
}
/* On initialization, set to input 0. This is just to start things up. */
videoinput_set_input_num( vidin, 0 );
- /* Test for audio support. */
- if( !vidin->isv4l2 ) {
- struct video_audio audio;
-
- if( ( ioctl( vidin->grab_fd, VIDIOCGAUDIO, &audio ) < 0 ) && vidin->verbose ) {
- vidin->hasaudio = 0;
- fprintf( stderr, "videoinput: No audio capability detected (asked for audio, got '%s').\n",
- strerror( errno ) );
- } else if( verbose ) {
- fprintf( stderr, "videoinput: Audio supports " );
- if( audio.flags & VIDEO_AUDIO_MUTE ) {
- fprintf( stderr, "Mute " );
- } else if( audio.flags & VIDEO_AUDIO_MUTABLE ) {
- fprintf( stderr, "Mutable " );
- } else if( audio.flags & VIDEO_AUDIO_VOLUME ) {
- fprintf( stderr, "Volume " );
- } else if( audio.flags & VIDEO_AUDIO_BASS ) {
- fprintf( stderr, "Bass " );
- } else if( audio.flags & VIDEO_AUDIO_TREBLE ) {
- fprintf( stderr, "Treble " );
- }
- fprintf( stderr, "\n" );
- }
- }
-
- /* Set to stereo by default. */
- videoinput_set_audio_mode( vidin, VIDEO_SOUND_STEREO );
-
/**
* Once we're here, we've set the hardware norm. Now confirm that
* our width is acceptable by again asking what the capabilities
* are.
*/
- if( vidin->isv4l2 ) {
- struct v4l2_format imgformat;
+ struct v4l2_format imgformat;
- imgformat.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- memset( &(imgformat.fmt.pix), 0, sizeof( struct v4l2_pix_format ) );
- imgformat.fmt.pix.width = capwidth;
- imgformat.fmt.pix.height = vidin->height;
- imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
- imgformat.fmt.pix.field = V4L2_FIELD_INTERLACED;
+ imgformat.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ memset( &(imgformat.fmt.pix), 0, sizeof( struct v4l2_pix_format ) );
+ imgformat.fmt.pix.width = capwidth;
+ imgformat.fmt.pix.height = vidin->height;
+ imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
+ imgformat.fmt.pix.field = V4L2_FIELD_INTERLACED;
- if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ) {
- /* Try for UYVY instead. */
- imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
- if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ) {
+ if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ) {
+ /* Try for UYVY instead. */
+ imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
+ if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ) {
- fprintf( stderr, "\n"
+ fprintf( stderr, "\n"
" Your capture card driver: %s\n"
" does not support studio-quality colour images required by tvtime.\n"
" This is a hardware limitation of some cards including many\n"
@@ -655,305 +461,141 @@ videoinput_t *videoinput_new( const char *v4l_device, int capwidth,
" with the command line option --device.\n"
"\n"
" Message from the card was: %s\n\n",
- vidin->drivername, strerror( errno ) );
-
- sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
- vidin->isuyvy = 1;
- }
+ vidin->drivername, strerror( errno ) );
+
+ sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
+ close( vidin->grab_fd );
+ free( vidin );
+ return 0;
+ }
+ vidin->isuyvy = 1;
+ }
- if( vidin->height != imgformat.fmt.pix.height ) {
- fprintf( stderr, "\n"
+ if( vidin->height != imgformat.fmt.pix.height ) {
+ fprintf( stderr, "\n"
" Your capture card driver: %s\n"
" does not support full size studio-quality images required by tvtime.\n"
" This is true for many low-quality webcams. Please select a\n"
" different video device for tvtime to use with the command line\n"
" option --device.\n\n", vidin->drivername );
- sprintf( error_string, "Frames too short from %s", vidin->shortdriver );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
-
- if( capwidth != imgformat.fmt.pix.width && verbose ) {
- fprintf( stderr, "videoinput: Width %d too high, using %d "
- "instead as suggested by the driver.\n",
- capwidth, imgformat.fmt.pix.width );
- }
- vidin->width = imgformat.fmt.pix.width;
-
- /* Query the maximum input width - I wish there was a nicer way */
- imgformat.fmt.pix.width = 10000;
- if( ioctl( vidin->grab_fd, VIDIOC_TRY_FMT, &imgformat ) < 0 ) {
- vidin->maxwidth = 768;
- if( verbose ) {
- fprintf( stderr, "videoinput: Your capture card driver does "
- "not implement the TRY_FMT query.\n"
- "Setting maximum input width to 768.\n" );
- }
- } else {
- vidin->maxwidth = imgformat.fmt.pix.width;
- if( verbose ) {
- fprintf( stderr, "videoinput: Maximum input width: %d "
- "pixels.\n", vidin->maxwidth );
- }
- }
-
- } else {
- if( ioctl( vidin->grab_fd, VIDIOCGCAP, &caps_v4l1 ) < 0 ) {
- fprintf( stderr, "videoinput: video4linux device '%s' refuses "
- "to provide set capability information, giving up.\n",
- v4l_device );
- sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
- vidin->maxwidth = caps_v4l1.maxwidth;
- if( verbose ) {
- fprintf( stderr, "videoinput: Maximum input width: %d pixels.\n",
- vidin->maxwidth );
- }
- if( capwidth > caps_v4l1.maxwidth ) {
- if( verbose ) {
- fprintf( stderr, "videoinput: Width %d too high, using %d "
- "instead as suggested by the driver.\n",
- capwidth, caps_v4l1.maxwidth );
- }
- capwidth = caps_v4l1.maxwidth;
- }
- if( capwidth < caps_v4l1.minwidth ) {
- if( verbose ) {
- fprintf( stderr, "videoinput: Width %d too low, using %d "
- "instead as suggested by the driver.\n",
- capwidth, caps_v4l1.minwidth );
- }
- capwidth = caps_v4l1.minwidth;
- }
- vidin->width = capwidth;
-
-
- /* Set the format using the SPICT ioctl. */
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) < 0 ) {
- fprintf( stderr, "videoinput: Can't get image information from the card, unable to "
- "process the output: %s.\n", strerror( errno ) );
- fprintf( stderr, "videoinput: Please post a bug report to " PACKAGE_BUGREPORT
- " indicating your capture card, driver, and the error message above.\n" );
- sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
-
- grab_pict.depth = 16;
- grab_pict.palette = VIDEO_PALETTE_YUV422;
- if( ioctl( vidin->grab_fd, VIDIOCSPICT, &grab_pict ) < 0 ) {
- /* Try for UYVY instead. */
- grab_pict.palette = VIDEO_PALETTE_UYVY;
- if( ioctl( vidin->grab_fd, VIDIOCSPICT, &grab_pict ) < 0 ) {
- fprintf( stderr, "\n"
- " Your capture card driver: %s\n"
- " does not support studio-quality colour images required by tvtime.\n"
- " This is a hardware limitation of some cards including many\n"
- " low-quality webcams. Please select a different video device to use\n"
- " with the command line option --device.\n"
- "\n"
- " Message from the card was: %s\n\n",
- vidin->drivername, strerror( errno ) );
- sprintf( error_string, "Format unsupported by %s", vidin->shortdriver );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
- vidin->isuyvy = 1;
- }
- if( vidin->verbose ) {
- fprintf( stderr, "videoinput: Brightness %d, hue %d, colour %d, contrast %d\n"
- "videoinput: Whiteness %d, depth %d, palette %d.\n",
- grab_pict.brightness, grab_pict.hue, grab_pict.colour, grab_pict.contrast,
- grab_pict.whiteness, grab_pict.depth, grab_pict.palette );
- }
-
- /* Set and get the window settings. */
- memset( &grab_win, 0, sizeof( struct video_window ) );
- grab_win.width = vidin->width;
- grab_win.height = vidin->height;
- if( ioctl( vidin->grab_fd, VIDIOCSWIN, &grab_win ) < 0 ) {
- fprintf( stderr, "videoinput: Failed to set the V4L window size (capture width and height): %s\n",
- strerror( errno ) );
- sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
+ sprintf( error_string, "Frames too short from %s", vidin->shortdriver );
+ close( vidin->grab_fd );
+ free( vidin );
+ return 0;
}
- if( vidin->isv4l2 ) {
- struct v4l2_requestbuffers req;
-
- /**
- * Ask Video Device for Buffers
- */
- req.count = 4;
- req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- req.memory = V4L2_MEMORY_MMAP;
-
- if( ioctl( vidin->grab_fd, VIDIOC_REQBUFS, &req ) < 0 ) {
- fprintf( stderr, "videoinput: Card failed to allocate capture buffers: %s\n",
- strerror( errno ) );
- sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
- vidin->numframes = req.count;
-
- if( vidin->numframes < 1 ) {
- fprintf( stderr, "videoinput: No capture buffers available from card.\n" );
- sprintf( error_string, "%s: No capture buffers", vidin->shortdriver );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- } else if( vidin->numframes > 4 ) {
- /* If we got more frames than we asked for, limit to 4 for now. */
- if( vidin->verbose ) {
- fprintf( stderr, "videoinput: Capture card provides %d buffers, but we only need 4.\n",
- vidin->numframes );
- }
- vidin->numframes = 4;
- }
-
- /**
- * Query each buffer and map it to the video device
- */
- for( i = 0; i < vidin->numframes; i++ ) {
- struct v4l2_buffer *vidbuf = &(vidin->capbuffers[ i ].vidbuf);
-
- vidbuf->index = i;
- vidbuf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- vidbuf->memory = V4L2_MEMORY_MMAP;
- if( ioctl( vidin->grab_fd, VIDIOC_QUERYBUF, vidbuf ) < 0 ) {
- fprintf( stderr, "videoinput: Can't get information about buffer %d: %s.\n",
- i, strerror( errno ) );
- sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
-
- vidin->capbuffers[ i ].data = mmap( 0, vidbuf->length,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, vidin->grab_fd,
- vidbuf->m.offset );
- if( vidin->capbuffers[ i ].data == MAP_FAILED ) {
- fprintf( stderr, "videoinput: Can't map buffer %d: %s.\n",
- i, strerror( errno ) );
- sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
- vidin->capbuffers[ i ].length = vidbuf->length;
- }
- videoinput_free_all_frames( vidin );
-
- /**
- * Tell video stream to begin capture.
- */
- videoinput_start_capture_v4l2( vidin );
-
- return vidin;
+ if( capwidth != imgformat.fmt.pix.width && verbose ) {
+ fprintf( stderr, "videoinput: Width %d too high, using %d "
+ "instead as suggested by the driver.\n",
+ capwidth, imgformat.fmt.pix.width );
+ }
+ vidin->width = imgformat.fmt.pix.width;
+
+ /* Query the maximum input width - I wish there was a nicer way */
+ imgformat.fmt.pix.width = 10000;
+ if( ioctl( vidin->grab_fd, VIDIOC_TRY_FMT, &imgformat ) < 0 ) {
+ vidin->maxwidth = 768;
+ if( verbose ) {
+ fprintf( stderr, "videoinput: Your capture card driver does "
+ "not implement the TRY_FMT query.\n"
+ "Setting maximum input width to 768.\n" );
+ }
} else {
- /* Try to set up mmap-based capture. */
- if( ioctl( vidin->grab_fd, VIDIOCGMBUF, &(vidin->gb_buffers) ) < 0 ) {
- fprintf( stderr, "videoinput: Can't get capture buffer properties. No mmap support?\n"
- "Please post a bug report about this to " PACKAGE_BUGREPORT "\n"
- "with your card, driver and this error message: %s.\n", strerror( errno ) );
- fprintf( stderr, "videoinput: Will try to fall back to (untested) read()-based capture..\n" );
- } else {
- /* If we got more frames than we asked for, limit to 4 for now. */
- if( vidin->gb_buffers.frames > 4 ) {
- if( vidin->verbose ) {
- fprintf( stderr, "videoinput: Capture card provides %d buffers, but we only need 4.\n",
- vidin->gb_buffers.frames );
- }
- vidin->numframes = 4;
- } else {
- vidin->numframes = vidin->gb_buffers.frames;
- }
-
- vidin->grab_buf = malloc( sizeof( struct video_mmap ) *
- vidin->numframes );
- if( !vidin->grab_buf ) {
- fprintf( stderr, "videoinput: Can't allocate memory.\n" );
- sprintf( error_string, "%s", strerror( ENOMEM ) );
- close( vidin->grab_fd );
- free( vidin );
- return 0;
- }
+ vidin->maxwidth = imgformat.fmt.pix.width;
+ if( verbose ) {
+ fprintf( stderr, "videoinput: Maximum input width: %d "
+ "pixels.\n", vidin->maxwidth );
+ }
+ }
- /* Setup mmap capture buffers. */
- for( i = 0; i < vidin->numframes; i++ ) {
- if( vidin->isuyvy ) {
- vidin->grab_buf[ i ].format = VIDEO_PALETTE_UYVY;
- } else {
- vidin->grab_buf[ i ].format = VIDEO_PALETTE_YUV422;
- }
- vidin->grab_buf[ i ].frame = i;
- vidin->grab_buf[ i ].width = vidin->width;
- vidin->grab_buf[ i ].height = vidin->height;
- }
+ struct v4l2_requestbuffers req;
- vidin->map = mmap( 0, vidin->gb_buffers.size, PROT_READ|PROT_WRITE,
- MAP_SHARED, vidin->grab_fd, 0 );
- if( vidin->map != MAP_FAILED ) {
- vidin->have_mmap = 1;
- videoinput_free_all_frames( vidin );
- return vidin;
- } else {
- fprintf( stderr, "videoinput: mmap() failed. Will try to fall back to "
- "(untested) read()-based capture..\n" );
- }
- }
+ /**
+ * Ask Video Device for Buffers
+ */
+ req.count = 4;
+ req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ req.memory = V4L2_MEMORY_MMAP;
+
+ if( ioctl( vidin->grab_fd, VIDIOC_REQBUFS, &req ) < 0 ) {
+ fprintf( stderr, "videoinput: Card failed to allocate capture buffers: %s\n",
+ strerror( errno ) );
+ sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
+ close( vidin->grab_fd );
+ free( vidin );
+ return 0;
+ }
+ vidin->numframes = req.count;
+
+ if( vidin->numframes < 1 ) {
+ fprintf( stderr, "videoinput: No capture buffers available from card.\n" );
+ sprintf( error_string, "%s: No capture buffers", vidin->shortdriver );
+ close( vidin->grab_fd );
+ free( vidin );
+ return 0;
+ } else if( vidin->numframes > 4 ) {
+ /* If we got more frames than we asked for, limit to 4 for now. */
+ if( vidin->verbose ) {
+ fprintf( stderr, "videoinput: Capture card provides %d buffers, but we only need 4.\n",
+ vidin->numframes );
+ }
+ vidin->numframes = 4;
+ }
- /* Fallback to read(). THIS CODE IS UNTESTED. IS THIS EVEN FINISHED? */
- if( vidin->verbose ) {
- fprintf( stderr, "videoinput: No mmap support available, using read().\n" );
- }
+ /**
+ * Query each buffer and map it to the video device
+ */
+ for( i = 0; i < vidin->numframes; i++ ) {
+ struct v4l2_buffer *vidbuf = &(vidin->capbuffers[ i ].vidbuf);
+
+ vidbuf->index = i;
+ vidbuf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ vidbuf->memory = V4L2_MEMORY_MMAP;
+ if( ioctl( vidin->grab_fd, VIDIOC_QUERYBUF, vidbuf ) < 0 ) {
+ fprintf( stderr, "videoinput: Can't get information about buffer %d: %s.\n",
+ i, strerror( errno ) );
+ sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
+ close( vidin->grab_fd );
+ free( vidin );
+ return 0;
+ }
+
+ vidin->capbuffers[ i ].data = mmap( 0, vidbuf->length,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, vidin->grab_fd,
+ vidbuf->m.offset );
+ if( vidin->capbuffers[ i ].data == MAP_FAILED ) {
+ fprintf( stderr, "videoinput: Can't map buffer %d: %s.\n",
+ i, strerror( errno ) );
+ sprintf( error_string, "%s: %s", vidin->shortdriver, strerror( errno ) );
+ close( vidin->grab_fd );
+ free( vidin );
+ return 0;
+ }
+ vidin->capbuffers[ i ].length = vidbuf->length;
+ }
+ videoinput_free_all_frames( vidin );
- vidin->have_mmap = 0;
- vidin->grab_size = (capwidth * vidin->height * 2);
- vidin->grab_data = malloc( vidin->grab_size );
- vidin->numframes = 2;
+ /**
+ * Tell video stream to begin capture.
+ */
+ videoinput_start_capture_v4l2( vidin );
- return vidin;
- }
+ return vidin;
}
void videoinput_delete( videoinput_t *vidin )
{
+ int i;
+
/* Mute audio on exit. */
videoinput_mute( vidin, 1 );
- if( vidin->isv4l2 ) {
- int i;
+ videoinput_stop_capture_v4l2( vidin );
+ videoinput_free_all_frames( vidin );
- videoinput_stop_capture_v4l2( vidin );
- videoinput_free_all_frames( vidin );
-
- for( i = 0; i < vidin->numframes; i++ ) {
- munmap( vidin->capbuffers[ i ].data, vidin->capbuffers[ i ].length );
- }
- } else {
- if( vidin->have_mmap ) {
- munmap( vidin->map, vidin->gb_buffers.size );
- free( vidin->grab_buf );
- } else {
- free( vidin->grab_data );
- }
+ for( i = 0; i < vidin->numframes; i++ ) {
+ munmap( vidin->capbuffers[ i ].data, vidin->capbuffers[ i ].length );
}
close( vidin->grab_fd );
@@ -990,15 +632,7 @@ static void videoinput_set_control_v4l2( videoinput_t *vidin, uint32_t id, doubl
int videoinput_get_hue( videoinput_t *vidin )
{
- if( vidin->isv4l2 ) {
- return (int) ((videoinput_get_control_v4l2( vidin, V4L2_CID_HUE ) * 100.0) + 0.5);
- } else {
- struct video_picture grab_pict;
-
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) >= 0 ) {
- return (int) ((((double) grab_pict.hue / 65535.0) * 100.0) + 0.5);
- }
- }
+ return (int) ((videoinput_get_control_v4l2( vidin, V4L2_CID_HUE ) * 100.0) + 0.5);
return 0;
}
@@ -1008,16 +642,7 @@ void videoinput_set_hue( videoinput_t *vidin, int newhue )
if( newhue > 100 ) newhue = 100;
if( newhue < 0 ) newhue = 50;
- if( vidin->isv4l2 ) {
- videoinput_set_control_v4l2( vidin, V4L2_CID_HUE, ((double) newhue) / 100.0 );
- } else {
- struct video_picture grab_pict;
-
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) >= 0 ) {
- grab_pict.hue = (int) (((((double) newhue) / 100.0) * 65535.0) + 0.5);
- ioctl( vidin->grab_fd, VIDIOCSPICT, &grab_pict );
- }
- }
+ videoinput_set_control_v4l2( vidin, V4L2_CID_HUE, ((double) newhue) / 100.0 );
}
void videoinput_set_hue_relative( videoinput_t *vidin, int offset )
@@ -1030,17 +655,7 @@ void videoinput_set_hue_relative( videoinput_t *vidin, int offset )
int videoinput_get_brightness( videoinput_t *vidin )
{
- if( vidin->isv4l2 ) {
- return (int) ((videoinput_get_control_v4l2( vidin, V4L2_CID_BRIGHTNESS ) * 100.0) + 0.5);
- } else {
- struct video_picture grab_pict;
-
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) >= 0 ) {
- return (int) ((((double) grab_pict.brightness / 65535.0) * 100.0) + 0.5);
- }
- }
-
- return 0;
+ return (int) ((videoinput_get_control_v4l2( vidin, V4L2_CID_BRIGHTNESS ) * 100.0) + 0.5);
}
void videoinput_set_brightness( videoinput_t *vidin, int newbright )
@@ -1048,16 +663,8 @@ void videoinput_set_brightness( videoinput_t *vidin, int newbright )
if( newbright > 100 ) newbright = 100;
if( newbright < 0 ) newbright = 50;
- if( vidin->isv4l2 ) {
- videoinput_set_control_v4l2( vidin, V4L2_CID_BRIGHTNESS, ((double) newbright) / 100.0 );
- } else {
- struct video_picture grab_pict;
-
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) >= 0 ) {
- grab_pict.brightness = (int) (((((double) newbright) / 100.0) * 65535.0) + 0.5);
- ioctl( vidin->grab_fd, VIDIOCSPICT, &grab_pict );
- }
- }
+ videoinput_set_control_v4l2( vidin, V4L2_CID_BRIGHTNESS,
+ ((double) newbright) / 100.0 );
}
void videoinput_set_brightness_relative( videoinput_t *vidin, int offset )
@@ -1070,17 +677,7 @@ void videoinput_set_brightness_relative( videoinput_t *vidin, int offset )
int videoinput_get_contrast( videoinput_t *vidin )
{
- if( vidin->isv4l2 ) {
- return (int) ((videoinput_get_control_v4l2( vidin, V4L2_CID_CONTRAST ) * 100.0) + 0.5);
- } else {
- struct video_picture grab_pict;
-
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) >= 0 ) {
- return (int) ((((double) grab_pict.contrast / 65535.0) * 100.0) + 0.5);
- }
- }
-
- return 0;
+ return (int) ((videoinput_get_control_v4l2( vidin, V4L2_CID_CONTRAST ) * 100.0) + 0.5);
}
void videoinput_set_contrast( videoinput_t *vidin, int newcont )
@@ -1088,16 +685,8 @@ void videoinput_set_contrast( videoinput_t *vidin, int newcont )
if( newcont > 100 ) newcont = 100;
if( newcont < 0 ) newcont = 50;
- if( vidin->isv4l2 ) {
- videoinput_set_control_v4l2( vidin, V4L2_CID_CONTRAST, ((double) newcont) / 100.0 );
- } else {
- struct video_picture grab_pict;
-
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) >= 0 ) {
- grab_pict.contrast = (int) (((((double) newcont) / 100.0) * 65535.0) + 0.5);
- ioctl( vidin->grab_fd, VIDIOCSPICT, &grab_pict );
- }
- }
+ videoinput_set_control_v4l2( vidin, V4L2_CID_CONTRAST,
+ ((double) newcont) / 100.0 );
}
void videoinput_set_contrast_relative( videoinput_t *vidin, int offset )
@@ -1110,17 +699,7 @@ void videoinput_set_contrast_relative( videoinput_t *vidin, int offset )
int videoinput_get_saturation( videoinput_t *vidin )
{
- if( vidin->isv4l2 ) {
- return (int) ((videoinput_get_control_v4l2( vidin, V4L2_CID_SATURATION ) * 100.0) + 0.5);
- } else {
- struct video_picture grab_pict;
-
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) >= 0 ) {
- return (int) ((((double) grab_pict.colour / 65535.0) * 100.0) + 0.5);
- }
- }
-
- return 0;
+ return (int) ((videoinput_get_control_v4l2( vidin, V4L2_CID_SATURATION ) * 100.0) + 0.5);
}
void videoinput_set_saturation( videoinput_t *vidin, int newsaturation )
@@ -1128,16 +707,8 @@ void videoinput_set_saturation( videoinput_t *vidin, int newsaturation )
if( newsaturation > 100 ) newsaturation = 100;
if( newsaturation < 0 ) newsaturation = 50;
- if( vidin->isv4l2 ) {
- videoinput_set_control_v4l2( vidin, V4L2_CID_SATURATION, ((double) newsaturation) / 100.0 );
- } else {
- struct video_picture grab_pict;
-
- if( ioctl( vidin->grab_fd, VIDIOCGPICT, &grab_pict ) >= 0 ) {
- grab_pict.colour = (int) (((((double) newsaturation) / 100.0) * 65535.0) + 0.5);
- ioctl( vidin->grab_fd, VIDIOCSPICT, &grab_pict );
- }
- }
+ videoinput_set_control_v4l2( vidin, V4L2_CID_SATURATION,
+ ((double) newsaturation) / 100.0 );
}
void videoinput_set_saturation_relative( videoinput_t *vidin, int offset )
@@ -1151,110 +722,30 @@ void videoinput_set_saturation_relative( videoinput_t *vidin, int offset )
static void videoinput_do_mute( videoinput_t *vidin, int mute )
{
if( vidin->hasaudio && mute != vidin->hw_muted ) {
- if( vidin->isv4l2 ) {
- struct v4l2_control control;
-
- control.id = V4L2_CID_AUDIO_MUTE;
- control.value = mute ? 1 : 0;
+ struct v4l2_control control;
- if( ioctl( vidin->grab_fd, VIDIOC_S_CTRL, &control ) < 0 ) {
- fprintf( stderr, "videoinput: Can't mute card. Post a bug report with your\n"
- "videoinput: driver info to " PACKAGE_BUGREPORT "\n" );
- fprintf( stderr, "videoinput: Include this error: '%s'\n", strerror( errno ) );
- }
+ control.id = V4L2_CID_AUDIO_MUTE;
+ control.value = mute ? 1 : 0;
- if( !mute && vidin->volume > 0 ) {
- videoinput_set_control_v4l2( vidin, V4L2_CID_AUDIO_VOLUME, ((double) vidin->volume) / 100.0 );
- }
- } else {
- struct video_audio audio;
+ if( ioctl( vidin->grab_fd, VIDIOC_S_CTRL, &control ) < 0 ) {
+ fprintf( stderr, "videoinput: Can't mute card. Post a bug report with your\n"
+ "videoinput: driver info to " PACKAGE_BUGREPORT "\n" );
+ fprintf( stderr, "videoinput: Include this error: '%s'\n", strerror( errno ) );
+ }
- if( ioctl( vidin->grab_fd, VIDIOCGAUDIO, &audio ) < 0 ) {
- fprintf( stderr, "videoinput: Audio state query failed (got '%s').\n",
- strerror( errno ) );
- } else {
- if( mute ) {
- audio.flags |= VIDEO_AUDIO_MUTE;
- } else {
- audio.flags &= ~VIDEO_AUDIO_MUTE;
- }
- if( vidin->volume > 0 ) {
- audio.volume = (vidin->volume * 65535) / 100;
- }
-
- if( ioctl( vidin->grab_fd, VIDIOCSAUDIO, &audio ) < 0 ) {
- fprintf( stderr, "videoinput: Can't set audio settings. I have no idea what "
- "might cause this. Post a bug report with your driver info to "
- PACKAGE_BUGREPORT "\n" );
- fprintf( stderr, "videoinput: Include this error: '%s'\n", strerror( errno ) );
- }
- }
- }
+ if( !mute && vidin->volume > 0 ) {
+ videoinput_set_control_v4l2( vidin, V4L2_CID_AUDIO_VOLUME, ((double) vidin->volume) / 100.0 );
+ }
vidin->hw_muted = mute;
}
}
-void videoinput_set_audio_mode( videoinput_t *vidin, int mode )
-{
- if( mode == VIDEOINPUT_LANG1 && vidin->norm == VIDEOINPUT_NTSC ) {
- mode = VIDEOINPUT_LANG2;
- }
-
- if( mode > VIDEOINPUT_LANG2 ) {
- mode = VIDEOINPUT_MONO;
- }
-
- if( vidin->audiomode != mode ) {
- if( vidin->isv4l2 ) {
- if( vidin->hastuner ) {
- struct v4l2_tuner tuner;
-
- memset( &tuner, 0, sizeof( struct v4l2_tuner ) );
- tuner.index = vidin->tunerid;
- tuner.audmode = videoinput_get_audmode_v4l2( mode );
- if( ioctl( vidin->grab_fd, VIDIOC_S_TUNER, &tuner ) < 0 ) {
- fprintf( stderr, "videoinput: Can't set tuner audio mode: %s\n",
- strerror( errno ) );
- } else {
- vidin->audiomode = mode;
- }
- }
- } else {
- struct video_audio audio;
-
- if( ioctl( vidin->grab_fd, VIDIOCGAUDIO, &audio ) < 0 ) {
- if( vidin->verbose ) {
- fprintf( stderr, "videoinput: Audio state query failed (got '%s').\n",
- strerror( errno ) );
- }
- } else {
- int was_muted = (audio.flags & VIDEO_AUDIO_MUTE);
-
- /* Set the mode. */
- audio.mode = mode;
- if( ioctl( vidin->grab_fd, VIDIOCSAUDIO, &audio ) < 0 ) {
- fprintf( stderr, "videoinput: Can't set audio mode setting. I have no idea what "
- "might cause this. Post a bug report with your driver info to "
- PACKAGE_BUGREPORT "\n" );
- fprintf( stderr, "videoinput: Include this error: '%s'\n", strerror( errno ) );
- } else {
- vidin->audiomode = mode;
- }
-
- if( was_muted & !(audio.flags & VIDEO_AUDIO_MUTE) ) {
- /* Stupid card dropped the mute state, have to go back to being muted. */
- vidin->hw_muted = 0;
- videoinput_do_mute( vidin, 1 );
- }
- }
- }
- }
-}
-
/* freqKHz is in KHz (duh) */
void videoinput_set_tuner_freq( videoinput_t *vidin, int freqKHz )
{
unsigned long frequency = freqKHz;
+ struct v4l2_frequency freqinfo;
+ int wasstreaming;
if( videoinput_has_tuner( vidin ) ) {
if( frequency < 0 ) {
@@ -1275,32 +766,24 @@ void videoinput_set_tuner_freq( videoinput_t *vidin, int freqKHz )
vidin->signal_acquire_wait = SIGNAL_ACQUIRE_DELAY;
vidin->signal_recover_wait = 0;
- if( vidin->isv4l2 ) {
- struct v4l2_frequency freqinfo;
- int wasstreaming = vidin->is_streaming;
- memset( &freqinfo, 0, sizeof( struct v4l2_frequency ) );
- freqinfo.tuner = vidin->tunerid;
- freqinfo.type = V4L2_TUNER_ANALOG_TV;
- freqinfo.frequency = frequency;
+ wasstreaming = vidin->is_streaming;
- videoinput_stop_capture_v4l2( vidin );
- if( ioctl( vidin->grab_fd, VIDIOC_S_FREQUENCY, &freqinfo ) < 0 ) {
- fprintf( stderr, "videoinput: Tuner present, but our request to change to\n"
- "videoinput: frequency %d failed with this error: %s.\n", freqKHz, strerror( errno ) );
- fprintf( stderr, "videoinput: Please file a bug report at " PACKAGE_BUGREPORT "\n" );
- }
- if( wasstreaming ) {
- videoinput_free_all_frames( vidin );
- videoinput_start_capture_v4l2( vidin );
- }
- } else {
- if( ioctl( vidin->grab_fd, VIDIOCSFREQ, &frequency ) < 0 ) {
- fprintf( stderr, "videoinput: Tuner present, but our request to change "
- "to frequency %d failed with this error: %s.\n", freqKHz, strerror( errno ) );
- fprintf( stderr, "videoinput: Please file a bug report at " PACKAGE_BUGREPORT "\n" );
- }
- }
+ memset( &freqinfo, 0, sizeof( struct v4l2_frequency ) );
+ freqinfo.tuner = vidin->tunerid;
+ freqinfo.type = V4L2_TUNER_ANALOG_TV;
+ freqinfo.frequency = frequency;
+
+ videoinput_stop_capture_v4l2( vidin );
+ if( ioctl( vidin->grab_fd, VIDIOC_S_FREQUENCY, &freqinfo ) < 0 ) {
+ fprintf( stderr, "videoinput: Tuner present, but our request to change to\n"
+ "videoinput: frequency %d failed with this error: %s.\n", freqKHz, strerror( errno ) );
+ fprintf( stderr, "videoinput: Please file a bug report at " PACKAGE_BUGREPORT "\n" );
+ }
+ if( wasstreaming ) {
+ videoinput_free_all_frames( vidin );
+ videoinput_start_capture_v4l2( vidin );
+ }
}
}
@@ -1308,28 +791,18 @@ int videoinput_get_tuner_freq( videoinput_t *vidin )
{
if( vidin->hastuner ) {
unsigned long frequency;
+ struct v4l2_frequency freqinfo;
- if( vidin->isv4l2 ) {
- struct v4l2_frequency freqinfo;
-
- freqinfo.tuner = vidin->tunerid;
- freqinfo.type = V4L2_TUNER_ANALOG_TV;
+ freqinfo.tuner = vidin->tunerid;
+ freqinfo.type = V4L2_TUNER_ANALOG_TV;
- if( ioctl( vidin->grab_fd, VIDIOC_G_FREQUENCY, &freqinfo ) < 0 ) {
- fprintf( stderr, "videoinput: Tuner refuses to tell us the current frequency: %s\n",
- strerror( errno ) );
- fprintf( stderr, "videoinput: Please file a bug report at " PACKAGE_BUGREPORT "\n" );
- return 0;
- }
- frequency = freqinfo.frequency;
- } else {
- if( ioctl( vidin->grab_fd, VIDIOCGFREQ, &frequency ) < 0 ) {
- fprintf( stderr, "videoinput: Tuner refuses to tell us the current frequency: %s\n",
- strerror( errno ) );
- fprintf( stderr, "videoinput: Please file a bug report at " PACKAGE_BUGREPORT "\n" );
- return 0;
- }
- }
+ if( ioctl( vidin->grab_fd, VIDIOC_G_FREQUENCY, &freqinfo ) < 0 ) {
+ fprintf( stderr, "videoinput: Tuner refuses to tell us the current frequency: %s\n",
+ strerror( errno ) );
+ fprintf( stderr, "videoinput: Please file a bug report at " PACKAGE_BUGREPORT "\n" );
+ return 0;
+ }
+ frequency = freqinfo.frequency;
if( !vidin->tunerlow ) {
frequency *= 1000; /* switch from MHz to KHz */
@@ -1343,30 +816,17 @@ int videoinput_get_tuner_freq( videoinput_t *vidin )
int videoinput_freq_present( videoinput_t *vidin )
{
if( videoinput_has_tuner( vidin ) ) {
- if( vidin->isv4l2 ) {
- struct v4l2_tuner tuner;
-
- tuner.index = vidin->tunerid;
- if( ioctl( vidin->grab_fd, VIDIOC_G_TUNER, &tuner ) < 0 ) {
- if( vidin->verbose ) {
- fprintf( stderr, "videoinput: Cannot detect signal from tuner: %s\n",
- strerror( errno ) );
- }
- } else if( !tuner.signal ) {
- return 0;
- }
- } else {
- struct video_tuner tuner;
-
- if( ioctl( vidin->grab_fd, VIDIOCGTUNER, &tuner ) < 0 ) {
- if( vidin->verbose ) {
- fprintf( stderr, "videoinput: Cannot detect signal from tuner: %s\n",
- strerror( errno ) );
- }
- } else if( !tuner.signal ) {
- return 0;
- }
- }
+ struct v4l2_tuner tuner;
+
+ tuner.index = vidin->tunerid;
+ if( ioctl( vidin->grab_fd, VIDIOC_G_TUNER, &tuner ) < 0 ) {
+ if( vidin->verbose ) {
+ fprintf( stderr, "videoinput: Cannot detect signal from tuner: %s\n",
+ strerror( errno ) );
+ }
+ } else if( !tuner.signal ) {
+ return 0;
+ }
}
return 1;
}
@@ -1376,224 +836,75 @@ int videoinput_freq_present( videoinput_t *vidin )
*/
static void videoinput_find_and_set_tuner( videoinput_t *vidin )
{
- if( vidin->isv4l2 ) {
- struct v4l2_tuner tuner;
+ struct v4l2_tuner tuner;
- tuner.index = vidin->tunerid;
- if( ioctl( vidin->grab_fd, VIDIOC_G_TUNER, &tuner ) < 0 ) {
- fprintf( stderr, "videoinput: Can't get tuner info: %s\n",
- strerror( errno ) );
- } else {
- vidin->tunerlow = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 1 : 0;
- }
+ tuner.index = vidin->tunerid;
+ if( ioctl( vidin->grab_fd, VIDIOC_G_TUNER, &tuner ) < 0 ) {
+ fprintf( stderr, "videoinput: Can't get tuner info: %s\n",
+ strerror( errno ) );
} else {
- struct video_tuner tuner;
- int tuner_number = -1;
- int found = 0;
- int i;
-
- for( i = 0; i < vidin->numtuners; i++ ) {
- tuner.tuner = i;
-
- if( ioctl( vidin->grab_fd, VIDIOCGTUNER, &tuner ) >= 0 ) {
- if( ((vidin->norm == VIDEOINPUT_PAL || vidin->norm == VIDEOINPUT_PAL_NC || vidin->norm == VIDEOINPUT_PAL_N) && tuner.flags & VIDEO_TUNER_PAL) ||
- (vidin->norm == VIDEOINPUT_SECAM && tuner.flags & VIDEO_TUNER_SECAM) ||
- ((vidin->norm == VIDEOINPUT_NTSC || vidin->norm == VIDEOINPUT_NTSC_JP || vidin->norm == VIDEOINPUT_PAL_M) && tuner.flags & VIDEO_TUNER_NTSC) ) {
- found = 1;
- tuner_number = i;
- break;
- }
- }
- }
-
- if( found ) {
- int mustchange = 0;
-
- tuner.tuner = tuner_number;
-
- if( vidin->norm == VIDEOINPUT_PAL || vidin->norm == VIDEOINPUT_PAL_NC || vidin->norm == VIDEOINPUT_PAL_N ) {
- if( tuner.mode != VIDEO_MODE_PAL ) {
- mustchange = 1;
- tuner.mode = VIDEO_MODE_PAL;
- }
- } else if( vidin->norm == VIDEOINPUT_SECAM ) {
- if( tuner.mode != VIDEO_MODE_SECAM ) {
- mustchange = 1;
- tuner.mode = VIDEO_MODE_SECAM;
- }
- } else {
- if( tuner.mode != VIDEO_MODE_NTSC ) {
- mustchange = 1;
- tuner.mode = VIDEO_MODE_NTSC;
- }
- }
-
- if( mustchange ) {
- struct video_channel grab_chan;
-
- if( ioctl( vidin->grab_fd, VIDIOCSTUNER, &tuner ) < 0 ) {
- fprintf( stderr, "videoinput: Tuner is not in the correct mode, and we can't set it.\n"
- " Please file a bug report at " PACKAGE_BUGREPORT "\n"
- " indicating your card, driver and this error message: %s.\n",
- strerror( errno ) );
- }
-
- /**
- * After setting the tuner, we need to re-set the norm on our channel.
- * Doing this fixes PAL-M, at least with the bttv driver in 2.4.20.
- * I am not happy with this, as I haven't seen it documented anywhere.
- * Please correct me if I'm wrong.
- */
- grab_chan.channel = vidin->curinput;
- grab_chan.norm = videoinput_get_v4l1_norm( vidin->norm );
-
- if( ioctl( vidin->grab_fd, VIDIOCSCHAN, &grab_chan ) < 0 ) {
- fprintf( stderr, "videoinput: Card refuses to re-set the channel.\n"
- "Please post a bug report to " PACKAGE_BUGREPORT "\n"
- "indicating your card, driver, and this error message: %s.\n", strerror( errno ) );
- } else {
- vidin->numtuners = grab_chan.tuners;
- }
- }
- }
-
- if( vidin->numtuners > 0 ) {
- tuner.tuner = tuner_number;
-
- if( ioctl( vidin->grab_fd, VIDIOCGTUNER, &tuner ) < 0 ) {
- fprintf( stderr, "videoinput: Input indicates that tuners are available, but "
- "driver refuses to give information about them.\n"
- "videoinput: Please file a bug report at " PACKAGE_BUGREPORT
- " and indicate that card and driver you have.\n" );
- fprintf( stderr, "videoinput: Also include this error: '%s'\n", strerror( errno ) );
- return;
- }
-
- if( vidin->verbose ) {
- fprintf( stderr, "videoinput: Tuner %s (",
- tuner.name );
-
- switch (tuner.mode) {
- case VIDEO_MODE_PAL: fprintf( stderr, "PAL" ); break;
- case VIDEO_MODE_NTSC: fprintf( stderr, "NTSC" ); break;
- case VIDEO_MODE_SECAM: fprintf( stderr, "SECAM" ); break;
- case VIDEO_MODE_AUTO: fprintf( stderr, "AUTO" ); break;
- default: fprintf( stderr, "UNDEFINED" ); break;
- }
-
- fprintf( stderr, "), flags: " );
-
- if( tuner.flags & VIDEO_TUNER_PAL ) fprintf( stderr, "PAL " );
- if( tuner.flags & VIDEO_TUNER_NTSC ) fprintf( stderr, "NTSC " );
- if( tuner.flags & VIDEO_TUNER_SECAM ) fprintf( stderr, "SECAM " );
- if( tuner.flags & VIDEO_TUNER_LOW ) fprintf( stderr, "LOW " );
- if( tuner.flags & VIDEO_TUNER_NORM ) fprintf( stderr, "NORM " );
- if( tuner.flags & VIDEO_TUNER_STEREO_ON ) fprintf( stderr, "STEREO_ON " );
- if( tuner.flags & VIDEO_TUNER_RDS_ON ) fprintf( stderr, "RDS_ON " );
- if( tuner.flags & VIDEO_TUNER_MBS_ON ) fprintf( stderr, "MBS_ON" );
- fprintf( stderr, "\n" );
- }
-
- vidin->tunerlow = (tuner.flags & VIDEO_TUNER_LOW) ? 1 : 0;
- vidin->hastuner = 1;
- }
+ vidin->tunerlow = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 1 : 0;
}
}
void videoinput_set_input_num( videoinput_t *vidin, int inputnum )
{
- if( vidin->isv4l2 ) {
- v4l2_std_id std;
- int index = inputnum;
- int wasstreaming = vidin->is_streaming;
+ v4l2_std_id std;
+ int index = inputnum;
+ int wasstreaming = vidin->is_streaming;
- videoinput_stop_capture_v4l2( vidin );
+ videoinput_stop_capture_v4l2( vidin );
- if( ioctl( vidin->grab_fd, VIDIOC_S_INPUT, &index ) < 0 ) {
- fprintf( stderr, "videoinput: Card refuses to set its input.\n"
- "Please post a bug report to " PACKAGE_BUGREPORT "\n"
- "indicating your card, driver, and this error message: %s.\n",
- strerror( errno ) );
- } else {
- struct v4l2_input input;
-
- if( ioctl( vidin->grab_fd, VIDIOC_G_INPUT, &input.index ) < 0 ) {
- fprintf( stderr, "videoinput: Driver won't tell us its input: %s\n",
- strerror( errno ) );
- } else if( input.index != inputnum ) {
- fprintf( stderr, "videoinput: Driver refuses to switch to input %d.\n",
- inputnum );
- inputnum = input.index;
- }
- vidin->curinput = inputnum;
-
- if( ioctl( vidin->grab_fd, VIDIOC_ENUMINPUT, &input ) < 0 ) {
- fprintf( stderr, "videoinput: Driver won't tell us input info: %s\n",
- strerror( errno ) );
- } else {
- snprintf( vidin->inputname, sizeof( vidin->inputname ), "%s", input.name );
- vidin->hastuner = input.type == V4L2_INPUT_TYPE_TUNER;
- vidin->tunerid = input.tuner;
- }
- }
-
- if( ioctl( vidin->grab_fd, VIDIOC_G_STD, &std ) < 0 ) {
- fprintf( stderr, "videoinput: Driver won't tell us its norm: %s\n",
- strerror( errno ) );
- } else {
- std = videoinput_get_v4l2_norm( vidin->norm );
- if( std == V4L2_STD_PAL ) {
- if( vidin->amode == VIDEOINPUT_PAL_DK_AUDIO ) {
- std = V4L2_STD_PAL_DK;
- } else if( vidin->amode == VIDEOINPUT_PAL_I_AUDIO ) {
- std = V4L2_STD_PAL_I;
- }
- }
- if( ioctl( vidin->grab_fd, VIDIOC_S_STD, &std ) < 0 ) {
- fprintf( stderr, "videoinput: Driver refuses to set norm: %s\n",
- strerror( errno ) );
- }
- }
+ if( ioctl( vidin->grab_fd, VIDIOC_S_INPUT, &index ) < 0 ) {
+ fprintf( stderr, "videoinput: Card refuses to set its input.\n"
+ "Please post a bug report to " PACKAGE_BUGREPORT "\n"
+ "indicating your card, driver, and this error message: %s.\n",
+ strerror( errno ) );
+ } else {
+ struct v4l2_input input;
+
+ if( ioctl( vidin->grab_fd, VIDIOC_G_INPUT, &input.index ) < 0 ) {
+ fprintf( stderr, "videoinput: Driver won't tell us its input: %s\n",
+ strerror( errno ) );
+ } else if( input.index != inputnum ) {
+ fprintf( stderr, "videoinput: Driver refuses to switch to input %d.\n",
+ inputnum );
+ inputnum = input.index;
+ }
+ vidin->curinput = inputnum;
+
+ if( ioctl( vidin->grab_fd, VIDIOC_ENUMINPUT, &input ) < 0 ) {
+ fprintf( stderr, "videoinput: Driver won't tell us input info: %s\n",
+ strerror( errno ) );
+ } else {
+ snprintf( vidin->inputname, sizeof( vidin->inputname ), "%s", input.name );
+ vidin->hastuner = input.type == V4L2_INPUT_TYPE_TUNER;
+ vidin->tunerid = input.tuner;
+ }
+ }
- if( wasstreaming ) {
- videoinput_free_all_frames( vidin );
- videoinput_start_capture_v4l2( vidin );
- }
+ if( ioctl( vidin->grab_fd, VIDIOC_G_STD, &std ) < 0 ) {
+ fprintf( stderr, "videoinput: Driver won't tell us its norm: %s\n",
+ strerror( errno ) );
} else {
- if( inputnum >= vidin->numinputs ) {
- fprintf( stderr, "videoinput: Requested input number %d not valid, "
- "max is %d.\n", inputnum, vidin->numinputs );
- } else {
- struct video_channel grab_chan;
-
- grab_chan.channel = inputnum;
- if( ioctl( vidin->grab_fd, VIDIOCGCHAN, &grab_chan ) < 0 ) {
- fprintf( stderr, "videoinput: Card refuses to give information on its current input.\n"
- "Please post a bug report to " PACKAGE_BUGREPORT "\n"
- "indicating your card, driver, and this error message: %s.\n", strerror( errno ) );
- } else {
- grab_chan.channel = inputnum;
- grab_chan.norm = videoinput_get_v4l1_norm( vidin->norm );
-
- if( ioctl( vidin->grab_fd, VIDIOCSCHAN, &grab_chan ) < 0 ) {
- fprintf( stderr, "videoinput: Card refuses to set the channel.\n"
- "Please post a bug report to " PACKAGE_BUGREPORT "\n"
- "indicating your card, driver, and this error message: %s.\n", strerror( errno ) );
- }
-
- vidin->curinput = inputnum;
- if( ioctl( vidin->grab_fd, VIDIOCGCHAN, &grab_chan ) < 0 ) {
- fprintf( stderr, "videoinput: Card refuses to give information on its current input.\n"
- "Please post a bug report to " PACKAGE_BUGREPORT "\n"
- "indicating your card, driver, and this error message: %s.\n", strerror( errno ) );
- } else {
- snprintf( vidin->inputname, sizeof( vidin->inputname ), "%s", grab_chan.name );
- vidin->numtuners = grab_chan.tuners;
- vidin->hastuner = (vidin->numtuners > 0);
- }
- }
- }
+ std = videoinput_get_v4l2_norm( vidin->norm );
+ if( std == V4L2_STD_PAL ) {
+ if( vidin->amode == VIDEOINPUT_PAL_DK_AUDIO ) {
+ std = V4L2_STD_PAL_DK;
+ } else if( vidin->amode == VIDEOINPUT_PAL_I_AUDIO ) {
+ std = V4L2_STD_PAL_I;
+ }
+ }
+ if( ioctl( vidin->grab_fd, VIDIOC_S_STD, &std ) < 0 ) {
+ fprintf( stderr, "videoinput: Driver refuses to set norm: %s\n",
+ strerror( errno ) );
+ }
+ }
+
+ if( wasstreaming ) {
+ videoinput_free_all_frames( vidin );
+ videoinput_start_capture_v4l2( vidin );
}
/* Once we've set the input, go look for a tuner. */
@@ -1676,15 +987,6 @@ int videoinput_get_muted( videoinput_t *vidin )
return vidin->user_muted;
}
-int videoinput_get_audio_mode( videoinput_t *vidin )
-{
- if( !vidin->audiomode || vidin->audiomode > VIDEO_SOUND_LANG2 ) {
- return VIDEO_SOUND_MONO;
- } else {
- return vidin->audiomode;
- }
-}
-
void videoinput_set_pal_audio_mode( videoinput_t *vidin, int amode )
{
if( amode != vidin->amode && vidin->norm == VIDEOINPUT_PAL ) {
@@ -1734,11 +1036,6 @@ int videoinput_get_num_inputs( videoinput_t *vidin )
return vidin->numinputs;
}
-int videoinput_is_bttv( videoinput_t *vidin )
-{
- return vidin->isbttv;
-}
-
int videoinput_is_uyvy( videoinput_t *vidin )
{
return vidin->isuyvy;
@@ -1768,28 +1065,8 @@ void videoinput_set_capture_volume( videoinput_t *vidin, int volume )
{
vidin->volume = volume;
if( vidin->volume >= 0 ) {
- if( vidin->isv4l2 ) {
- videoinput_set_control_v4l2( vidin, V4L2_CID_AUDIO_VOLUME,
- ((double) vidin->volume) / 100.0 );
- } else {
- struct video_audio audio;
-
- if( ioctl( vidin->grab_fd, VIDIOCGAUDIO, &audio ) < 0 ) {
- fprintf( stderr, "videoinput: Audio state query failed (got '%s').\n",
- strerror( errno ) );
- } else {
- if( vidin->volume > 0 ) {
- audio.volume = (vidin->volume * 65535) / 100;
- }
-
- if( ioctl( vidin->grab_fd, VIDIOCSAUDIO, &audio ) < 0 ) {
- fprintf( stderr, "videoinput: Can't set audio settings. I have no idea what "
- "might cause this. Post a bug report with your driver info to "
- PACKAGE_BUGREPORT "\n" );
- fprintf( stderr, "videoinput: Include this error: '%s'\n", strerror( errno ) );
- }
- }
- }
+ videoinput_set_control_v4l2( vidin, V4L2_CID_AUDIO_VOLUME,
+ ((double) vidin->volume) / 100.0 );
}
}

Privacy Policy