new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:

- multithreaded audio/video buffering (I know mplayer crew hates threads
  but it seems to me as the only way of doing reliable a/v capture)
- a/v timebase synchronization (sample count vs. gettimeofday)
- "immediate" mode support for mplayer
- fixed colorspace stuff - RGB?? and YUY2 modes now work as expected
- native ALSA audio capture
- separated audio input layer


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7059 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2002-08-21 21:31:20 +00:00
parent 1dd16637fb
commit a5bd36cf4b
12 changed files with 803 additions and 282 deletions

View File

@ -308,7 +308,24 @@ Available options are:
chanlist=<value> available: europe-east,
europe-west, us-bcast,
us-cable, etc
audiorate=<value> set audio capture bitrate
alsa capture from ALSA
mono force mono audio
adevice=<value> set an audio device
/dev/... for OSS,
hardware ID for ALSA
audioid=<value> choose an audio output
of the capture card, if it
has more of them
.TP
.I NOTE:
Mplayer doesn't accept colons so type commas instead in the device ID,
eg. hw,0,0 instead of hw:0:0)
Be advised that although you can select any samplerate when using ALSA,
the LAME audio codec is able to encode only the "standard" samplerates.
You'll get an .avi file with no sound when you choose an odd
samplerate and use this codec.
.TP
.B \-vcd <track>
Play video CD track from device instead of plain file.

View File

@ -197,6 +197,14 @@ struct config tvopts_conf[]={
{"input", &tv_param_input, CONF_TYPE_INT, 0, 0, 20, NULL},
{"outfmt", &tv_param_outfmt, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"fps", &tv_param_fps, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL},
#ifdef HAVE_TV_V4L
{"mono", &tv_param_mono, CONF_TYPE_FLAG, 0, 0, 1, NULL},
#ifdef HAVE_ALSA9
{"alsa", &tv_param_alsa, CONF_TYPE_FLAG, 0, 0, 1, NULL},
#endif
{"adevice", &tv_param_adevice, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"audioid", &tv_param_audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
#endif
{NULL, NULL, 0, 0, 0, 0, NULL}
};
#endif

22
configure vendored
View File

@ -1975,6 +1975,25 @@ else
fi
echores "$_vsscanf"
echocheck "sys/sysinfo.h"
cat > $TMPC << EOF
#include <sys/sysinfo.h>
int main(void) {
struct sysinfo s_info;
sysinfo(&s_info);
return 0;
}
EOF
_sys_sysinfo=no
cc_check && _sys_sysinfo=yes
if test "$_sys_sysinfo" = yes ; then
_def_sys_sysinfo='#define HAVE_SYS_SYSINFO_H 1'
_inc_sysinfo='#include <sys/sysinfo.h>'
else
_def_sys_sysinfo='#undef HAVE_SYS_SYSINFO_H'
fi
echores "$_sys_sysinfo"
#########
# VIDEO #
@ -4420,6 +4439,9 @@ $_def_sys_soundcard
* in /usr/include */
$_def_soundcard
/* Define this if your system has the sysinfo header */
$_def_sys_sysinfo
/* Define this if your system uses ftello() for off_t seeking */
$_def_ftello

View File

@ -3,7 +3,7 @@ LIBNAME = libmpdemux.a
include ../config.mak
SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c mpdemux.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c cddb.c demux_rawdv.c
SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c opt-reg.c mpdemux.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c cddb.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c
ifeq ($(STREAMING),yes)
SRCS += asf_streaming.c url.c http.c network.c asf_mmst_streaming.c
ifeq ($(STREAMING_LIVE_DOT_COM),yes)

View File

@ -155,6 +155,18 @@ extern void demux_close_demuxers(demuxer_t* demuxer);
extern void demux_close_avi(demuxer_t *demuxer);
extern void demux_close_rawdv(demuxer_t* demuxer);
#ifdef USE_TV
#include "tv.h"
extern tvi_handle_t *tv_handler;
extern int tv_param_on;
extern int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds, tvi_handle_t *tvh);
extern int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
#if defined(USE_TV) && defined(HAVE_TV_V4L)
extern void demux_close_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
#endif
#endif
void free_demuxer(demuxer_t *demuxer){
int i;
mp_msg(MSGT_DEMUXER,MSGL_V,"DEMUXER: freeing demuxer at %p \n",demuxer);
@ -177,6 +189,10 @@ void free_demuxer(demuxer_t *demuxer){
demux_close_fli(demuxer); break;
case DEMUXER_TYPE_NUV:
demux_close_nuv(demuxer); break;
#if defined(USE_TV) && defined(HAVE_TV_V4L)
case DEMUXER_TYPE_TV:
demux_close_tv(demuxer, tv_handler); break;
#endif
#ifdef HAVE_LIBDV095
case DEMUXER_TYPE_RAWDV:
demux_close_rawdv(demuxer); break;
@ -267,15 +283,6 @@ int demux_real_fill_buffer(demuxer_t *demuxer);
int demux_nuv_fill_buffer(demuxer_t *demux);
int demux_rtp_fill_buffer(demuxer_t *demux, demux_stream_t* ds);
int demux_rawdv_fill_buffer(demuxer_t *demuxer);
#ifdef USE_TV
#include "tv.h"
extern tvi_handle_t *tv_handler;
extern int tv_param_on;
extern int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds, tvi_handle_t *tvh);
extern int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
#endif
int demux_y4m_fill_buffer(demuxer_t *demux);
int demux_audio_fill_buffer(demux_stream_t *ds);
extern int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds);

View File

@ -39,9 +39,7 @@ int tv_param_on = 0;
/* some default values */
int tv_param_audiorate = 44100;
int tv_param_noaudio = 0;
#ifdef HAVE_TV_BSDBT848
int tv_param_immediate = 0;
#endif
char *tv_param_freq = NULL;
char *tv_param_channel = NULL;
char *tv_param_norm = "pal";
@ -53,6 +51,14 @@ int tv_param_height = -1;
int tv_param_input = 0; /* used in v4l and bttv */
char *tv_param_outfmt = "yv12";
float tv_param_fps = -1.0;
#ifdef HAVE_TV_V4L
int tv_param_mono = 0;
int tv_param_audio_id = 0;
#ifdef HAVE_ALSA9
int tv_param_alsa = 0;
#endif
char* tv_param_adevice = NULL;
#endif
/* ================== DEMUX_TV ===================== */
/*
@ -135,6 +141,21 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
}
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &picture_format);
/* set some params got from cmdline */
funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input);
/* select video norm */
if (!strcasecmp(tv_param_norm, "pal"))
tvh->norm = TV_NORM_PAL;
else if (!strcasecmp(tv_param_norm, "ntsc"))
tvh->norm = TV_NORM_NTSC;
else if (!strcasecmp(tv_param_norm, "secam"))
tvh->norm = TV_NORM_SECAM;
mp_msg(MSGT_TV, MSGL_INFO, "Selected norm: %s\n", tv_param_norm);
funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm);
/* limits on w&h are norm-dependent -- JM */
/* set width */
if (tv_param_width != -1)
{
@ -159,20 +180,6 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
}
}
/* set some params got from cmdline */
funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input);
/* select video norm */
if (!strcasecmp(tv_param_norm, "pal"))
tvh->norm = TV_NORM_PAL;
else if (!strcasecmp(tv_param_norm, "ntsc"))
tvh->norm = TV_NORM_NTSC;
else if (!strcasecmp(tv_param_norm, "secam"))
tvh->norm = TV_NORM_SECAM;
mp_msg(MSGT_TV, MSGL_INFO, "Selected norm: %s\n", tv_param_norm);
funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm);
if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
{
mp_msg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n");
@ -272,14 +279,12 @@ int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh)
printf("fps: %f, frametime: %f\n", sh_video->fps, sh_video->frametime);
#ifdef HAVE_TV_BSDBT848
/* If playback only mode, go to immediate mode, fail silently */
if(tv_param_immediate == 1)
{
funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0);
tv_param_noaudio = 1;
}
#endif
/* set width */
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
@ -371,9 +376,16 @@ no_audio:
return(funcs->start(tvh->priv));
}
#if defined(USE_TV) && defined(HAVE_TV_V4L)
int demux_close_tv(demuxer_t *demuxer, tvi_handle_t *tvh)
{
return(tvh->functions->uninit(tvh->priv));
}
#endif
/* ================== STREAM_TV ===================== */
tvi_handle_t *tvi_init_dummy(char *device);
tvi_handle_t *tvi_init_v4l(char *device);
tvi_handle_t *tvi_init_v4l(char *device, char *adevice);
tvi_handle_t *tvi_init_bsdbt848(char *device);
tvi_handle_t *tv_begin(void)
@ -382,7 +394,7 @@ tvi_handle_t *tv_begin(void)
return tvi_init_dummy(tv_param_device);
#ifdef HAVE_TV_V4L
if (!strcmp(tv_param_driver, "v4l"))
return tvi_init_v4l(tv_param_device);
return tvi_init_v4l(tv_param_device, tv_param_adevice);
#endif
#ifdef HAVE_TV_BSDBT848
if (!strcmp(tv_param_driver, "bsdbt848"))

View File

@ -23,6 +23,14 @@ extern float tv_param_fps;
extern int tv_param_noaudio;
extern int tv_param_immediate;
extern int tv_param_audiorate;
#ifdef HAVE_TV_V4L
extern int tv_param_mono;
extern int tv_param_audio_id;
#ifdef HAVE_ALSA9
extern int tv_param_alsa;
#endif
extern char* tv_param_adevice;
#endif
typedef struct tvi_info_s
{
@ -72,9 +80,7 @@ typedef struct tvi_handle_s {
#define TVI_CONTROL_IS_AUDIO 0x1
#define TVI_CONTROL_IS_VIDEO 0x2
#define TVI_CONTROL_IS_TUNER 0x3
#ifdef HAVE_TV_BSDBT848
#define TVI_CONTROL_IMMEDIATE 0x4
#endif
#define TVI_CONTROL_IMMEDIATE 0x4
/* VIDEO controls */
#define TVI_CONTROL_VID_GET_FPS 0x101

File diff suppressed because it is too large Load Diff

View File

@ -1126,7 +1126,7 @@ if(sh_audio && !demuxer2){
if(verbose) {
mp_msg(MSGT_AVSYNC,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb A-V:%5.3f [%d:%d] A/Vms %d/%d D/S %d/%d \r",
mux_v->timer, decoded_frameno, (int)(p*100),
(t>1) ? (int)(decoded_frameno/t) : 0,
(t>1) ? (int)(decoded_frameno/t+0.5) : 0,
(p>0.001) ? (int)((t/p-t)/60) : 0,
(p>0.001) ? (int)(ftello(muxer_f)/p/1024/1024) : 0,
v_pts_corr,
@ -1138,7 +1138,7 @@ if(sh_audio && !demuxer2){
} else
mp_msg(MSGT_AVSYNC,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb A-V:%5.3f [%d:%d]\r",
mux_v->timer, decoded_frameno, (int)(p*100),
(t>1) ? (int)(decoded_frameno/t) : 0,
(t>1) ? (int)(decoded_frameno/t+0.5) : 0,
(p>0.001) ? (int)((t/p-t)/60) : 0,
(p>0.001) ? (int)(ftell(muxer_f)/p/1024/1024) : 0,
v_pts_corr,
@ -1187,6 +1187,8 @@ if(sh_audio && !demuxer2){
} // while(!at_eof)
if (demuxer) free_demuxer(demuxer);
#ifdef HAVE_MP3LAME
// fixup CBR mp3 audio header:
if(sh_audio && mux_a->codec==ACODEC_VBRMP3 && !lame_param_vbr){

View File

@ -40,6 +40,11 @@ void mp_msg_set_level(int verbose){
}
}
int mp_msg_test(int mod, int lev)
{
return lev <= mp_msg_levels[mod];
}
void mp_msg_c( int x, const char *format, ... ){
#if 1
va_list va;

View File

@ -85,6 +85,7 @@ extern int verbose; // defined in mplayer.c
void mp_msg_init();
void mp_msg_set_level(int verbose);
int mp_msg_test(int mod, int lev);
#include "config.h"

View File

@ -268,6 +268,8 @@ extern char *ao_subdevice;
static stream_t* stream=NULL;
static demuxer_t *demuxer=NULL;
char* current_module=NULL; // for debugging
int vo_gamma_brightness = 1000;
@ -291,6 +293,7 @@ static unsigned int inited_flags=0;
#define INITED_STREAM 64
#define INITED_INPUT 128
#define INITED_VOBSUB 256
#define INITED_DEMUXER 512
#define INITED_ALL 0xFFFF
void uninit_player(unsigned int mask){
@ -306,6 +309,12 @@ void uninit_player(unsigned int mask){
stream=NULL;
}
if(mask&INITED_DEMUXER){
current_module="uninit_demuxer";
if(demuxer) free_demuxer(demuxer);
demuxer=NULL;
}
if(mask&INITED_VO){
inited_flags&=~INITED_VO;
current_module="uninit_vo";
@ -489,8 +498,6 @@ static subtitle* subtitles=NULL;
float sub_last_pts = -303;
#endif
static demuxer_t *demuxer=NULL;
static demux_stream_t *d_audio=NULL;
static demux_stream_t *d_video=NULL;
static demux_stream_t *d_dvdsub=NULL;
@ -565,9 +572,7 @@ int gui_no_filename=0;
#endif
#ifdef HAVE_TV_BSDBT848
tv_param_immediate = 1;
#endif
if ( argv[0] )
if(!strcmp(argv[0],"gmplayer") ||
@ -1077,6 +1082,8 @@ current_module="demux_open";
demuxer=demux_open(stream,file_format,audio_id,video_id,dvdsub_id);
if(!demuxer) goto goto_next_file; // exit_player(MSGTR_Exit_error); // ERROR
inited_flags|=INITED_DEMUXER;
current_module="demux_open2";
//file_format=demuxer->file_format;