diff options
-rw-r--r-- | DOCS/man/en/mplayer.1 | 4 | ||||
-rw-r--r-- | cfg-common.h | 1 | ||||
-rw-r--r-- | stream/tv.c | 1 | ||||
-rw-r--r-- | stream/tv.h | 1 | ||||
-rw-r--r-- | stream/tvi_def.h | 38 | ||||
-rw-r--r-- | stream/tvi_v4l.c | 25 | ||||
-rw-r--r-- | stream/tvi_v4l2.c | 10 |
7 files changed, 80 insertions, 0 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 345911aee8..5220d31a1b 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -1722,6 +1722,10 @@ Available options are: .RSs .IPs noaudio no sound +.IPs automute=<0-255> (v4l and v4l2 only) +If signal strength reported by device is less then this value, +audio and video will be muted. In most cases automute=100 will be enough. +Default is 0 (automute disabled). .IPs driver=<value> See \-tv driver=help for a list of compiled-in TV input drivers. available: dummy, v4l, v4l2, bsdbt848 diff --git a/cfg-common.h b/cfg-common.h index b250fe9286..d1817e3d04 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -429,6 +429,7 @@ m_option_t tvopts_conf[]={ {"channel", &tv_param_channel, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"chanlist", &tv_param_chanlist, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"norm", &tv_param_norm, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"automute", &tv_param_automute, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL}, #ifdef HAVE_TV_V4L2 {"normid", &tv_param_normid, CONF_TYPE_INT, 0, 0, 0, NULL}, #endif diff --git a/stream/tv.c b/stream/tv.c index d6a6552832..a3fbaeeb02 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -55,6 +55,7 @@ int tv_param_outfmt = -1; float tv_param_fps = -1.0; char **tv_param_channels = NULL; int tv_param_audio_id = 0; +int tv_param_automute = 0; #if defined(HAVE_TV_V4L) int tv_param_amode = -1; int tv_param_volume = -1; diff --git a/stream/tv.h b/stream/tv.h index 404e258401..4335605ae8 100644 --- a/stream/tv.h +++ b/stream/tv.h @@ -12,6 +12,7 @@ extern char *tv_param_freq; extern char *tv_param_channel; extern char *tv_param_chanlist; extern char *tv_param_norm; +extern int tv_param_automute; #ifdef HAVE_TV_V4L2 extern int tv_param_normid; #endif diff --git a/stream/tvi_def.h b/stream/tvi_def.h index 7a77dd3a50..72b7bd5101 100644 --- a/stream/tvi_def.h +++ b/stream/tvi_def.h @@ -52,3 +52,41 @@ static void free_handle(tvi_handle_t *h) free(h); } } + +/** + Fills video frame in given buffer with blue color for yv12,i420,uyvy,yuy2. + Other formats will be filled with 0xC0 +*/ +static inline void fill_blank_frame(char* buffer,int len,int fmt){ + int i; + + switch(fmt){ + case IMGFMT_YV12: + memset(buffer, 0xFF,5*len/6); + memset(buffer+5*len/6, 0xFF,len/6); + break; + case IMGFMT_I420: + memset(buffer, 0xFF,4*len/6); + memset(buffer+4*len/6, 0xFF,len/6); + memset(buffer+5*len/6, 0xFF,len/6); + break; + case IMGFMT_UYVY: + for(i=0;i<len;i+=4){ + buffer[i]=0xFF; + buffer[i+1]=0; + buffer[i+2]=0; + buffer[i+3]=0; + } + break; + case IMGFMT_YUY2: + for(i=0;i<len;i+=4){ + buffer[i]=0; + buffer[i+1]=0xFF; + buffer[i+2]=0; + buffer[i+3]=0; + } + break; + default: + memset(buffer,0xC0,len); + } +} diff --git a/stream/tvi_v4l.c b/stream/tvi_v4l.c index 30621b8e8f..3d19122868 100644 --- a/stream/tvi_v4l.c +++ b/stream/tvi_v4l.c @@ -1381,6 +1381,21 @@ static int control(priv_t *priv, int cmd, void *arg) return(TVI_CONTROL_UNKNOWN); } +static int set_mute(priv_t* priv,int value) +{ + if (!priv->capability.audios) { + return 0; + + if(value) + priv->audio[priv->audio_id].flags |=VIDEO_AUDIO_MUTE; + else + priv->audio[priv->audio_id].flags &= ~VIDEO_AUDIO_MUTE; + } + if(ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id])<0) + return 0; + return 1; +} + // copies a video frame // for RGB (i.e. BGR in mplayer) flips the image upside down // for YV12 swaps the 2nd and 3rd plane @@ -1389,6 +1404,16 @@ static inline void copy_frame(priv_t *priv, unsigned char *dest, unsigned char * int i; unsigned char *sptr; + if(tv_param_automute>0){ + if (ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) >= 0) { + if(tv_param_automute<<8>priv->tuner.signal){ + fill_blank_frame(dest,priv->bytesperline * priv->height,priv->format); + set_mute(priv,1); + return; + } + } + set_mute(priv,0); + } // YV12 uses VIDEO_PALETTE_YUV420P, but the planes are swapped if (priv->format == IMGFMT_YV12) { memcpy(dest, source, priv->width * priv->height); diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c index 43656fae01..5646e0d146 100644 --- a/stream/tvi_v4l2.c +++ b/stream/tvi_v4l2.c @@ -1321,6 +1321,16 @@ static inline void copy_frame(priv_t *priv, unsigned char *dest, unsigned char * int d = pixfmt2depth(priv->format.fmt.pix.pixelformat); int bytesperline = w*d/8; + if(tv_param_automute>0){ + if (ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) >= 0) { + if(tv_param_automute<<8>priv->tuner.signal){ + fill_blank_frame(dest,bytesperline * h,fcc_vl2mp(priv->format.fmt.pix.pixelformat)); + set_mute(priv,1); + return; + } + } + set_mute(priv,0); + } memcpy(dest, source, bytesperline * h); } |