Mercurial > mplayer.hg
changeset 29806:a5e7590ffdbd
Separate teletext from tv support.
Path by Francesco Lavra, francescolavra interfree it
author | cehoyos |
---|---|
date | Sat, 07 Nov 2009 12:31:05 +0000 |
parents | b9350576d4fc |
children | fe38b68ae9f4 |
files | cfg-common.h command.c configure libmpcodecs/dec_teletext.c libmpcodecs/dec_teletext.h libmpdemux/demuxer.h mpcommon.c stream/tv.c stream/tv.h stream/tvi_dshow.c stream/tvi_v4l.c stream/tvi_v4l2.c |
diffstat | 12 files changed, 81 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/cfg-common.h Sat Nov 07 11:15:26 2009 +0000 +++ b/cfg-common.h Sat Nov 07 12:31:05 2009 +0000 @@ -126,10 +126,10 @@ #endif /* defined(CONFIG_TV_V4L) || defined(CONFIG_TV_V4L2) */ {"adevice", &stream_tv_defaults.adevice, CONF_TYPE_STRING, 0, 0, 0, NULL}, #ifdef CONFIG_TV_TELETEXT - {"tdevice", &stream_tv_defaults.tdevice, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"tpage", &stream_tv_defaults.tpage, CONF_TYPE_INT, CONF_RANGE, 100, 899, NULL}, - {"tformat", &stream_tv_defaults.tformat, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL}, - {"tlang", &stream_tv_defaults.tlang, CONF_TYPE_INT, CONF_RANGE, -1, 0x7f, NULL}, + {"tdevice", &stream_tv_defaults.teletext.device, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"tpage", &stream_tv_defaults.teletext.page, CONF_TYPE_INT, CONF_RANGE, 100, 899, NULL}, + {"tformat", &stream_tv_defaults.teletext.format, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL}, + {"tlang", &stream_tv_defaults.teletext.lang, CONF_TYPE_INT, CONF_RANGE, -1, 0x7f, NULL}, #endif /* CONFIG_TV_TELETEXT */ {"audioid", &stream_tv_defaults.audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL}, #ifdef CONFIG_TV_DSHOW
--- a/command.c Sat Nov 07 11:15:26 2009 +0000 +++ b/command.c Sat Nov 07 12:31:05 2009 +0000 @@ -1889,8 +1889,7 @@ SET is GET+1 STEP is GET+2 */ - tvi_handle_t *tvh = mpctx->demuxer->priv; - if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh) + if (!mpctx->demuxer->teletext) return M_PROPERTY_UNAVAILABLE; if(!base_ioctl) return M_PROPERTY_ERROR; @@ -1899,31 +1898,30 @@ case M_PROPERTY_GET: if (!arg) return M_PROPERTY_ERROR; - result=tvh->functions->control(tvh->priv, base_ioctl, arg); + result=teletext_control(mpctx->demuxer->teletext, base_ioctl, arg); break; case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; M_PROPERTY_CLAMP(prop, *(int *) arg); - result=tvh->functions->control(tvh->priv, base_ioctl+1, arg); + result=teletext_control(mpctx->demuxer->teletext, base_ioctl+1, arg); break; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - result=tvh->functions->control(tvh->priv, base_ioctl, &val); + result=teletext_control(mpctx->demuxer->teletext, base_ioctl, &val); val += (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1); - result=tvh->functions->control(tvh->priv, base_ioctl+1, &val); + result=teletext_control(mpctx->demuxer->teletext, base_ioctl+1, &val); break; default: return M_PROPERTY_NOT_IMPLEMENTED; } - return result == TVI_CONTROL_TRUE ? M_PROPERTY_OK : M_PROPERTY_ERROR; + return result == VBI_CONTROL_TRUE ? M_PROPERTY_OK : M_PROPERTY_ERROR; } static int mp_property_teletext_mode(m_option_t * prop, int action, void *arg, MPContext * mpctx) { - tvi_handle_t *tvh = mpctx->demuxer->priv; int result; int val; @@ -1932,7 +1930,8 @@ if(result!=M_PROPERTY_OK) return result; - if(tvh->functions->control(tvh->priv, prop->priv, &val)==TVI_CONTROL_TRUE && val) + if(teletext_control(mpctx->demuxer->teletext, + (int)prop->priv, &val)==VBI_CONTROL_TRUE && val) mp_input_set_section("teletext"); else mp_input_set_section("tv"); @@ -1942,17 +1941,17 @@ static int mp_property_teletext_page(m_option_t * prop, int action, void *arg, MPContext * mpctx) { - tvi_handle_t *tvh = mpctx->demuxer->priv; int result; int val; - if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh) + if (!mpctx->demuxer->teletext) return M_PROPERTY_UNAVAILABLE; switch(action){ case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: //This should be handled separately val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1); - result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_STEP_PAGE, &val); + result=teletext_control(mpctx->demuxer->teletext, + TV_VBI_CONTROL_STEP_PAGE, &val); break; default: result=mp_property_teletext_common(prop,action,arg,mpctx); @@ -2870,23 +2869,23 @@ if (mpctx->file_format == DEMUXER_TYPE_TV) tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv)); break; +#endif /* CONFIG_TV */ #ifdef CONFIG_TV_TELETEXT case MP_CMD_TV_TELETEXT_ADD_DEC: { - tvi_handle_t* tvh=(tvi_handle_t *)(mpctx->demuxer->priv); - if (mpctx->file_format == DEMUXER_TYPE_TV) - tvh->functions->control(tvh->priv,TV_VBI_CONTROL_ADD_DEC,&(cmd->args[0].v.s)); + if (mpctx->demuxer->teletext) + teletext_control(mpctx->demuxer->teletext,TV_VBI_CONTROL_ADD_DEC, + &(cmd->args[0].v.s)); break; } case MP_CMD_TV_TELETEXT_GO_LINK: { - tvi_handle_t* tvh=(tvi_handle_t *)(mpctx->demuxer->priv); - if (mpctx->file_format == DEMUXER_TYPE_TV) - tvh->functions->control(tvh->priv,TV_VBI_CONTROL_GO_LINK,&(cmd->args[0].v.i)); + if (mpctx->demuxer->teletext) + teletext_control(mpctx->demuxer->teletext,TV_VBI_CONTROL_GO_LINK, + &(cmd->args[0].v.i)); break; } #endif /* CONFIG_TV_TELETEXT */ -#endif /* CONFIG_TV */ case MP_CMD_SUB_LOAD: if (sh_video) {
--- a/configure Sat Nov 07 11:15:26 2009 +0000 +++ b/configure Sat Nov 07 12:31:05 2009 +0000 @@ -7620,7 +7620,7 @@ if test "$_tv_teletext" = auto ; then _tv_teletext=no if test "$_freetype" = yes && test "$_pthreads" = yes; then - if test "$_tv_v4l2" = yes || test "$_v4l" = yes || test "$_tv_dshow" = yes; then + if test "$_tv_v4l2" = yes || test "$_v4l" = yes || test "$_tv_dshow" = yes || test "$_dvbin" = yes; then _tv_teletext=yes fi fi
--- a/libmpcodecs/dec_teletext.c Sat Nov 07 11:15:26 2009 +0000 +++ b/libmpcodecs/dec_teletext.c Sat Nov 07 12:31:05 2009 +0000 @@ -90,7 +90,6 @@ #include <pthread.h> -#include "stream/tv.h" #include "dec_teletext.h" #include "mp_msg.h" #include "help_mp.h" @@ -1653,15 +1652,15 @@ case TV_VBI_CONTROL_RESET: { int i; - tv_param_t* tv_param=arg; + struct tt_param* tt_param=arg; pthread_mutex_lock(&(priv->buffer_mutex)); priv->pagenumdec=0; clear_cache(priv); - priv->pagenum=steppage(0,tv_param->tpage&0x7ff,1); - priv->tformat=tv_param->tformat; + priv->pagenum=steppage(0,tt_param->page&0x7ff,1); + priv->tformat=tt_param->format; priv->subpagenum=0x3f7f; pll_reset(priv,fine_tune); - if(tv_param->tlang==-1){ + if(tt_param->lang==-1){ mp_msg(MSGT_TELETEXT,MSGL_INFO,MSGTR_TV_TTSupportedLanguages); for(i=0; tt_languages[i].lang_code; i++){ mp_msg(MSGT_TELETEXT,MSGL_INFO," %3d %s\n", @@ -1671,7 +1670,7 @@ tt_languages[i].lang_code, tt_languages[i].lang_name); }else{ for(i=0; tt_languages[i].lang_code; i++){ - if(tt_languages[i].lang_code==tv_param->tlang) + if(tt_languages[i].lang_code==tt_param->lang) break; } if (priv->primary_language!=tt_languages[i].lang_code){
--- a/libmpcodecs/dec_teletext.h Sat Nov 07 11:15:26 2009 +0000 +++ b/libmpcodecs/dec_teletext.h Sat Nov 07 12:31:05 2009 +0000 @@ -23,11 +23,22 @@ #ifndef MPLAYER_DEC_TELETEXT_H #define MPLAYER_DEC_TELETEXT_H +struct tt_param { + char *device; ///< teletext device + int format; ///< teletext display format + int page; ///< start teletext page + int lang; ///< primary language code +}; + #define VBI_CONTROL_FALSE 0 #define VBI_CONTROL_TRUE 1 #define VBI_CONTROL_UNKNOWN -1 +#ifdef CONFIG_TV_TELETEXT int teletext_control(void* p, int cmd, void *arg); +#else +#define teletext_control(p, cmd, arg) VBI_CONTROL_FALSE +#endif /* TELETEXT controls (through teletext_control() )
--- a/libmpdemux/demuxer.h Sat Nov 07 11:15:26 2009 +0000 +++ b/libmpdemux/demuxer.h Sat Nov 07 12:31:05 2009 +0000 @@ -242,6 +242,9 @@ void* v_streams[MAX_V_STREAMS]; // video sterams (sh_video_t) void *s_streams[MAX_S_STREAMS]; // dvd subtitles (flag) + // pointer to teletext decoder private data, if demuxer stream contains teletext + void *teletext; + demux_chapter_t* chapters; int num_chapters;
--- a/mpcommon.c Sat Nov 07 11:15:26 2009 +0000 +++ b/mpcommon.c Sat Nov 07 12:31:05 2009 +0000 @@ -11,7 +11,6 @@ #include "spudec.h" #include "version.h" #include "vobsub.h" -#include "stream/tv.h" #include "libmpcodecs/dec_teletext.h" #include "libavutil/intreadwrite.h" #include "m_option.h" @@ -209,29 +208,29 @@ void update_teletext(sh_video_t *sh_video, demuxer_t *demuxer, int reset) { #ifdef CONFIG_TV_TELETEXT - tvi_handle_t* tvh=demuxer->priv; int page_changed; - if (demuxer->type != DEMUXER_TYPE_TV || !tvh) return; + if (!demuxer->teletext) + return; //Also forcing page update when such ioctl is not supported or call error occured - if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_IS_CHANGED,&page_changed)!=VBI_CONTROL_TRUE) + if(teletext_control(demuxer->teletext,TV_VBI_CONTROL_IS_CHANGED,&page_changed)!=VBI_CONTROL_TRUE) page_changed=1; if(!page_changed) return; - if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_GET_VBIPAGE,&vo_osd_teletext_page)!=VBI_CONTROL_TRUE) + if(teletext_control(demuxer->teletext,TV_VBI_CONTROL_GET_VBIPAGE,&vo_osd_teletext_page)!=VBI_CONTROL_TRUE) vo_osd_teletext_page=NULL; - if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_GET_HALF_PAGE,&vo_osd_teletext_half)!=VBI_CONTROL_TRUE) + if(teletext_control(demuxer->teletext,TV_VBI_CONTROL_GET_HALF_PAGE,&vo_osd_teletext_half)!=VBI_CONTROL_TRUE) vo_osd_teletext_half=0; - if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_GET_MODE,&vo_osd_teletext_mode)!=VBI_CONTROL_TRUE) + if(teletext_control(demuxer->teletext,TV_VBI_CONTROL_GET_MODE,&vo_osd_teletext_mode)!=VBI_CONTROL_TRUE) vo_osd_teletext_mode=0; - if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_GET_FORMAT,&vo_osd_teletext_format)!=VBI_CONTROL_TRUE) + if(teletext_control(demuxer->teletext,TV_VBI_CONTROL_GET_FORMAT,&vo_osd_teletext_format)!=VBI_CONTROL_TRUE) vo_osd_teletext_format=0; vo_osd_changed(OSDTYPE_TELETEXT); - tvh->functions->control(tvh->priv,TV_VBI_CONTROL_MARK_UNCHANGED,NULL); + teletext_control(demuxer->teletext,TV_VBI_CONTROL_MARK_UNCHANGED,NULL); #endif }
--- a/stream/tv.c Sat Nov 07 11:15:26 2009 +0000 +++ b/stream/tv.c Sat Nov 07 12:31:05 2009 +0000 @@ -334,7 +334,8 @@ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm); return 0; } - tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param); + teletext_control(tvh->demuxer->teletext,TV_VBI_CONTROL_RESET, + &tvh->tv_param->teletext); return 1; } @@ -348,7 +349,8 @@ return 0; } - tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param); + teletext_control(tvh->demuxer->teletext,TV_VBI_CONTROL_RESET, + &tvh->tv_param->teletext); return 1; } @@ -669,7 +671,11 @@ if(!(tvh=tv_begin(demuxer->stream->priv))) return NULL; if (!tvh->functions->init(tvh->priv)) return NULL; - tvh->functions->control(tvh->priv,TVI_CONTROL_VBI_INIT,&(tvh->tv_param->tdevice)); + tvh->demuxer = demuxer; + tvh->functions->control(tvh->priv,TVI_CONTROL_VBI_INIT, + &(tvh->tv_param->teletext.device)); + tvh->functions->control(tvh->priv,TVI_CONTROL_GET_VBI_PTR, + &demuxer->teletext); if (!open_tv(tvh)){ tv_uninit(tvh); @@ -812,7 +818,8 @@ if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE) mp_msg(MSGT_TV,MSGL_WARN,"Unable to set gain control!\n"); - funcs->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param); + teletext_control(demuxer->teletext,TV_VBI_CONTROL_RESET, + &tvh->tv_param->teletext); return demuxer; } @@ -893,7 +900,8 @@ mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_CurrentFrequency, freq, (float)freq/16); } - tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param); + teletext_control(tvh->demuxer->teletext,TV_VBI_CONTROL_RESET, + &tvh->tv_param->teletext); return 1; } @@ -1074,7 +1082,8 @@ return 0; } } - tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param); + teletext_control(tvh->demuxer->teletext,TV_VBI_CONTROL_RESET, + &tvh->tv_param->teletext); return 1; }
--- a/stream/tv.h Sat Nov 07 11:15:26 2009 +0000 +++ b/stream/tv.h Sat Nov 07 12:31:05 2009 +0000 @@ -25,6 +25,9 @@ #ifndef MPLAYER_TV_H #define MPLAYER_TV_H +#include "libmpcodecs/dec_teletext.h" +#include "libmpdemux/demuxer.h" + typedef struct tv_param_s { char *freq; char *channel; @@ -62,10 +65,7 @@ int hue; int saturation; int gain; - char *tdevice; ///< teletext device - int tformat; ///< teletext display format - int tpage; ///< start teletext page - int tlang; ///< primary language code + struct tt_param teletext; int scan; int scan_threshold; @@ -125,6 +125,7 @@ const tvi_functions_t *functions; void *priv; int seq; + demuxer_t *demuxer; /* specific */ int norm; @@ -220,6 +221,7 @@ //tvi_* ioctl (not dec_teletext.c !!!) #define TVI_CONTROL_VBI_INIT 0x501 ///< vbi init +#define TVI_CONTROL_GET_VBI_PTR 0x502 ///< get teletext private pointer int tv_set_color_options(tvi_handle_t *tvh, int opt, int val); int tv_get_color_options(tvi_handle_t *tvh, int opt, int* val);
--- a/stream/tvi_dshow.c Sat Nov 07 11:15:26 2009 +0000 +++ b/stream/tvi_dshow.c Sat Nov 07 12:31:05 2009 +0000 @@ -2552,7 +2552,7 @@ if(priv->chains[2]->rbuf) return S_OK; - if(priv->tv_param->tdevice) + if(priv->tv_param->teletext.device) { priv->chains[2]->rbuf=calloc(1,sizeof(grabber_ringbuffer_t)); if(!priv->chains[2]->rbuf) @@ -3493,8 +3493,9 @@ priv->priv_vbi=NULL; return TVI_CONTROL_TRUE; } - default: - return teletext_control(priv->priv_vbi,cmd,arg); + case TVI_CONTROL_GET_VBI_PTR: + *(void **)arg=priv->priv_vbi; + return TVI_CONTROL_TRUE; #endif } return TVI_CONTROL_UNKNOWN;
--- a/stream/tvi_v4l.c Sat Nov 07 11:15:26 2009 +0000 +++ b/stream/tvi_v4l.c Sat Nov 07 12:31:05 2009 +0000 @@ -1530,8 +1530,9 @@ } return TVI_CONTROL_TRUE; } - default: - return teletext_control(priv->priv_vbi,cmd,arg); + case TVI_CONTROL_GET_VBI_PTR: + *(void **)arg=priv->priv_vbi; + return TVI_CONTROL_TRUE; #endif }
--- a/stream/tvi_v4l2.c Sat Nov 07 11:15:26 2009 +0000 +++ b/stream/tvi_v4l2.c Sat Nov 07 12:31:05 2009 +0000 @@ -1057,8 +1057,9 @@ } return TVI_CONTROL_TRUE; } - default: - return teletext_control(priv->priv_vbi,cmd,arg); + case TVI_CONTROL_GET_VBI_PTR: + *(void **)arg=priv->priv_vbi; + return TVI_CONTROL_TRUE; #endif } mp_msg(MSGT_TV, MSGL_V, "%s: unknown control: %d\n", info.short_name, cmd);