[Mplayer-cvslog] CVS: main/libmpdemux Makefile,1.32,1.33 demuxer.c,1.108,1.109 tv.c,1.28,1.29 tv.h,1.14,1.15 tvi_v4l.c,1.24,1.25

Arpi of Ize arpi at mplayerhq.hu
Wed Aug 21 23:31:23 CEST 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv29706/libmpdemux

Modified Files:
	Makefile demuxer.c tv.c tv.h tvi_v4l.c 
Log Message:
new v4l capture patch by Jindrich Makovicka <makovick at 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


Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Makefile	5 Aug 2002 17:21:35 -0000	1.32
+++ Makefile	21 Aug 2002 21:31:20 -0000	1.33
@@ -3,7 +3,7 @@
 
 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)

Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- demuxer.c	14 Aug 2002 21:55:48 -0000	1.108
+++ demuxer.c	21 Aug 2002 21:31:20 -0000	1.109
@@ -155,6 +155,18 @@
 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 @@
       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_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);

Index: tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- tv.c	23 May 2002 14:53:11 -0000	1.28
+++ tv.c	21 Aug 2002 21:31:20 -0000	1.29
@@ -39,9 +39,7 @@
 /* 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_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 @@
     }
     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 @@
 	}    
     }
 
-    /* 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 @@
 
     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 @@
     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 @@
 	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"))

Index: tv.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- tv.h	12 Apr 2002 10:40:38 -0000	1.14
+++ tv.h	21 Aug 2002 21:31:20 -0000	1.15
@@ -23,6 +23,14 @@
 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 @@
 #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

Index: tvi_v4l.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- tvi_v4l.c	24 Jun 2002 16:37:18 -0000	1.24
+++ tvi_v4l.c	21 Aug 2002 21:31:20 -0000	1.25
@@ -6,6 +6,9 @@
   Some ideas are based on xawtv/libng's grab-v4l.c written by
     Gerd Knorr <kraxel at bytesex.org>
 
+  Multithreading, a/v sync and native ALSA support by
+    Jindrich Makovicka <makovick at kmlinux.fjfi.cvut.cz>
+
   CODE IS UNDER DEVELOPMENT, NO FEATURE REQUESTS PLEASE!
 */
 
@@ -21,11 +24,14 @@
 #include <sys/types.h>
[...1164 lines suppressed...]
+    }
+
+    while (priv->audio_head == priv->audio_tail) {
+	usleep(10000);
+    }
+    memcpy(buffer, priv->audio_ringbuffer+priv->audio_head*priv->audio_in.blocksize, len);
+    priv->audio_head = (++priv->audio_head) % priv->audio_buffer_size;
+    priv->audio_cnt--;
+    priv->audio_sent_blocks_total++;
+    return (double)priv->audio_sent_blocks_total*priv->audio_secs_per_block;
 }
 
 static int get_audio_framesize(priv_t *priv)
 {
-    return(priv->audio_blocksize);
-//    return(priv->audio_samplesize[priv->audio_id]);
+    return(priv->audio_in.blocksize);
 }
 
 #endif /* USE_TV */




More information about the MPlayer-cvslog mailing list