[MPlayer-dev-eng] [PATCH] Teletext support try3 (4/5, configure, slaves, etc)
Vladimir Voroshilov
voroshil at gmail.com
Mon Jul 16 20:44:47 CEST 2007
Hi, Alban.
Check attached version.
--
Regards,
Vladimir Voroshilov mailto:voroshil at gmail.com
JID: voroshil at gmail.com, voroshil at jabber.ru
ICQ: 95587719
-------------- next part --------------
Index: stream/Makefile
===================================================================
--- stream/Makefile (revision 23790)
+++ stream/Makefile (working copy)
@@ -51,6 +51,7 @@
SRCS_COMMON-$(TV_BSDBT848) += tvi_bsdbt848.c
SRCS_COMMON-$(TV_V4L1) += tvi_v4l.c audio_in.c
SRCS_COMMON-$(TV_V4L2) += tvi_v4l2.c audio_in.c
+SRCS_COMMON-$(TV_TELETEXT) += tvi_vbi.c
SRCS_COMMON-$(VCD) += stream_vcd.c
SRCS_COMMON-$(VSTREAM) += stream_vstream.c
Index: stream/tv.c
===================================================================
--- stream/tv.c (revision 23790)
+++ stream/tv.c (working copy)
@@ -72,6 +72,7 @@
int tv_param_alsa = 0;
#endif
#endif
+char* tv_param_tdevice=NULL; ///< teletext vbi device
char* tv_param_adevice = NULL;
int tv_param_brightness = 0;
int tv_param_contrast = 0;
@@ -515,6 +516,9 @@
demuxer->priv=NULL;
if(!(tvh=tv_begin())) return NULL;
if (!tvh->functions->init(tvh->priv)) return NULL;
+
+ tvh->functions->control(tvh->priv,TVI_CONTROL_VBI_INIT,&tv_param_tdevice);
+
if (!open_tv(tvh)){
tv_uninit(tvh);
return NULL;
@@ -774,6 +778,7 @@
mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_CurrentFrequency,
freq, (float)freq/16);
}
+ tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,(void*)1);
return(1);
}
@@ -933,6 +938,7 @@
return 0;
}
}
+ tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,(void*)1);
return(1);
}
@@ -950,6 +956,7 @@
mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);
return 0;
}
+ tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,(void*)1);
return(1);
}
Index: stream/tv.h
===================================================================
--- stream/tv.h (revision 23790)
+++ stream/tv.h (working copy)
@@ -42,6 +42,11 @@
#endif
extern char* tv_param_adevice;
#endif
+extern char* tv_param_tdevice; ///< teletext vbi device
+#ifdef HAVE_TV_TELETEXT
+extern char* tv_param_tformat; ///< format: text,bw,gray,color
+extern int tv_param_tpage; ///< page number
+#endif
extern int tv_param_brightness;
extern int tv_param_contrast;
extern int tv_param_hue;
@@ -152,6 +157,43 @@
#define TVI_CONTROL_SPC_SET_INPUT 0x402 /* set input channel (tv,s-video,composite..) */
#define TVI_CONTROL_SPC_GET_NORMID 0x403 /* get normid from norm name */
+//tvi_* ioctl (not tvi_vbi.c !!!)
+#define TVI_CONTROL_VBI_INIT 0x501 ///< vbi init
+
+/*
+ TELETEXT controls (through tv_teletext_control() )
+ NOTE:
+ _SET_ should be _GET_ +1
+ _STEP_ should be _GET_ +2
+*/
+#define TV_VBI_CONTROL_GET_MODE 0x510 ///< get current mode teletext
+#define TV_VBI_CONTROL_SET_MODE 0x511 ///< on/off grab teletext
+#define TV_VBI_CONTROL_STEP_MODE 0x512 ///< step teletext mode
+
+#define TV_VBI_CONTROL_GET_PAGE 0x513 ///< get grabbed teletext page
+#define TV_VBI_CONTROL_SET_PAGE 0x514 ///< set grab teletext page number
+#define TV_VBI_CONTROL_STEP_PAGE 0x515 ///< step grab teletext page number
+
+#define TV_VBI_CONTROL_GET_SUBPAGE 0x516 ///< get grabbed teletext page
+#define TV_VBI_CONTROL_SET_SUBPAGE 0x517 ///< set grab teletext page number
+#define TV_VBI_CONTROL_STEP_SUBPAGE 0x518 ///< step grab teletext page number
+
+#define TV_VBI_CONTROL_GET_FORMAT 0x519 ///< get eletext format
+#define TV_VBI_CONTROL_SET_FORMAT 0x51a ///< set teletext format
+#define TV_VBI_CONTROL_STEP_FORMAT 0x51b ///< step teletext format
+
+#define TV_VBI_CONTROL_GET_HALF_PAGE 0x51c ///< get current half page
+#define TV_VBI_CONTROL_SET_HALF_PAGE 0x51d ///< switch half page
+#define TV_VBI_CONTROL_STEP_HALF_PAGE 0x51e ///< switch half page
+
+#define TV_VBI_CONTROL_ADD_DEC 0x550 ///< add page number with dec
+#define TV_VBI_CONTROL_GO_LINK 0x551 ///< go link (1..6) NYI
+#define TV_VBI_CONTROL_GET_VBIPAGE 0x552 ///< get vbi_image for grabbed teletext page
+#define TV_VBI_CONTROL_RESET 0x553 ///< vbi reset
+#define TV_VBI_CONTROL_START 0x554 ///< vbi start
+#define TV_VBI_CONTROL_STOP 0x555 ///< vbi stop
+#define TV_VBI_CONTROL_DECODE_PAGE 0x556 ///< decode vbi page
+
extern tvi_handle_t *tv_begin(void);
extern int tv_init(tvi_handle_t *tvh);
extern int tv_uninit(tvi_handle_t *tvh);
@@ -190,4 +232,60 @@
#define TV_NORM_PALN 6
#define TV_NORM_NTSCJP 7
+#define VBI_TFORMAT_TEXT 0 ///< text mode
+#define VBI_TFORMAT_BW 1 ///< back&white mode
+#define VBI_TFORMAT_GRAY 2 ///< grayscale mode
+#define VBI_TFORMAT_COLOR 3 ///< color mode (require color_spu patch!)
+
+#define VBI_MAX_PAGES 0x800 ///< max sub pages number
+#define VBI_MAX_SUBPAGES 64 ///< max sub pages number
+
+#define VBI_ROWS 24 ///< teletext page width in chars
+#define VBI_COLUMNS 40 ///< teletext page height in chars
+#define VBI_TIME_LINEPOS 32 ///< time line pos in page header
+
+typedef
+enum{
+ TT_MODE_OFF=0, ///< off
+ TT_MODE_OPAQUE, ///< opaque
+ TT_MODE_TRANSPARENT, ///< translarent
+ TT_MODE_OPAQUE_INV, ///< opaque with inverted colors
+ TT_MODE_TRANSPARENT_INV ///< translarent with inverted colors
+} teletext_mode;
+
+typedef
+enum{
+ TT_ZOOM_NORMAL=0,
+ TT_ZOOM_TOP_HALF,
+ TT_ZOOM_BOTTOM_HALF
+} teletext_zoom;
+
+typedef struct tt_char_s{
+ unsigned int unicode; ///< unicode (utf8) character
+ unsigned char fg; ///< foreground color
+ unsigned char bg; ///< background color
+ unsigned char gfx; ///< 0-no gfx, 1-solid gfx, 2-separated gfx
+ unsigned char ctl; ///< control character
+ unsigned char lng; ///< lang: 0-lating,1-national
+ unsigned char raw; ///< raw character (as received from device)
+} tt_char;
+
+typedef struct tt_page_s{
+ int pagenum; ///< page number
+ int subpagenum; ///< subpage number
+ unsigned char lang; ///< language code
+ unsigned char active; ///< page is complete and ready for rendering
+ unsigned char flags; ///< page flags, not used
+ tt_char text[VBI_ROWS*VBI_COLUMNS]; ///< page data
+} tt_page;
+
+typedef struct tt_stream_props_s{
+ int sampling_rate;
+ int samples_per_line;
+ int offset;
+ int count[2]; ///< number of lines in first and second fields
+ int interlaced; ///< vbi data are interlaced
+ int bufsize; ///< required buffer size
+} tt_stream_props;
+
#endif /* TV_H */
Index: input/input.c
===================================================================
--- input/input.c (revision 23790)
+++ input/input.c (working copy)
@@ -139,6 +139,9 @@
{ MP_CMD_LOADLIST, "loadlist", 1, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
{ MP_CMD_RUN, "run", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } },
{ MP_CMD_VF_CHANGE_RECTANGLE, "change_rectangle", 2, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}}}},
+#ifdef HAVE_TV_TELETEXT
+ { MP_CMD_TV_TELETEXT_ADD_DEC, "teletext_add_dec", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } },
+#endif
#ifdef HAVE_NEW_GUI
{ MP_CMD_GUI_LOADFILE, "gui_loadfile", 0, { {-1,{0}} } },
@@ -391,6 +394,12 @@
{ { 'n', 0 }, "tv_step_norm" },
{ { 'u', 0 }, "tv_step_chanlist" },
#endif
+#ifdef HAVE_TV_TELETEXT
+ { { 'X', 0 }, "step_property teletext_mode 1" },
+ { { 'E', 0 }, "step_property teletext_half_page 1" },
+ { { 'W', 0 }, "step_property teletext_page 1" },
+ { { 'Q', 0 }, "step_property teletext_page -1" },
+#endif
#ifdef HAVE_JOYSTICK
{ { JOY_AXIS0_PLUS, 0 }, "seek 10" },
{ { JOY_AXIS0_MINUS, 0 }, "seek -10" },
Index: input/input.h
===================================================================
--- input/input.h (revision 23790)
+++ input/input.h (working copy)
@@ -96,6 +96,8 @@
#define MP_CMD_LOOP 94
#define MP_CMD_BALANCE 96
#define MP_CMD_SUB_SCALE 97
+#define MP_CMD_TV_TELETEXT_ADD_DEC 98
+#define MP_CMD_TV_TELETEXT_GO_LINK 99
#define MP_CMD_GUI_EVENTS 5000
#define MP_CMD_GUI_LOADFILE 5001
Index: configure
===================================================================
--- configure (revision 23790)
+++ configure (working copy)
@@ -240,6 +240,7 @@
--disable-tv-v4l1 disable Video4Linux TV interface [autodetect]
--disable-tv-v4l2 disable Video4Linux2 TV interface [autodetect]
--disable-tv-bsdbt848 disable BSD BT848 interface [autodetect]
+ --disable-tv-teletex disable TV teletext interface [autodetect]
--disable-pvr disable Video4Linux2 MPEG PVR [autodetect]
--disable-rtc disable RTC (/dev/rtc) on Linux [autodetect]
--disable-network disable networking [enable]
@@ -589,6 +590,7 @@
_tv_v4l1=auto
_tv_v4l2=auto
_tv_bsdbt848=auto
+_tv_teletext=auto
_pvr=auto
_network=yes
_winsock2=auto
@@ -937,6 +939,8 @@
--disable-tv-v4l1) _tv_v4l1=no ;;
--enable-tv-v4l2) _tv_v4l2=yes ;;
--disable-tv-v4l2) _tv_v4l2=no ;;
+ --enable-tv-teletext) _tv_teletext=yes ;;
+ --disable-tv-teletext) _tv_teletext=no ;;
--enable-radio) _radio=yes ;;
--enable-radio-capture) _radio_capture=yes ;;
--disable-radio-capture) _radio_capture=no ;;
@@ -6702,7 +6706,24 @@
fi
echores "$_tv_v4l2"
+echocheck "TV teletext interface"
+if test "$_tv_teletext" = auto ; then
+ if test "$_tv_v4l2" = yes; then
+ _tv_teletext=yes
+ else
+ _tv_teletext=no
+ fi
+fi
+if test "$_tv_teletext" = yes ; then
+ _def_tv_teletext='#define HAVE_TV_TELETEXT 1'
+ _inputmodules="tv-teletext $_inputmodules"
+else
+ _noinputmodules="tv-teletext $_noinputmodules"
+ _def_tv_teletext='#undef HAVE_TV_TELETEXT'
+fi
+echores "$_tv_teletext"
+
echocheck "Radio interface"
if test "$_radio" = yes ; then
_def_radio='#define USE_RADIO 1'
@@ -7459,6 +7480,7 @@
TV_V4L1 = $_tv_v4l1
TV_V4L2 = $_tv_v4l2
TV_BSDBT848 = $_tv_bsdbt848
+TV_TELETEXT = $_tv_teletext
AUDIO_INPUT = $_audio_input
PVR = $_pvr
VCD = $_vcd
@@ -8004,6 +8026,9 @@
/* Enable *BSD BrookTree TV interface support */
$_def_tv_bsdbt848
+/* Enable TV Teletext Interface support */
+$_def_tv_teletext
+
/* Enable Radio Interface support */
$_def_radio
Index: cfg-common.h
===================================================================
--- cfg-common.h (revision 23790)
+++ cfg-common.h (working copy)
@@ -460,6 +460,10 @@
#endif
{"adevice", &tv_param_adevice, CONF_TYPE_STRING, 0, 0, 0, NULL},
#endif
+#ifdef HAVE_TV_TELETEXT
+ {"tdevice", &tv_param_tdevice, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"tpage", &tv_param_tpage, CONF_TYPE_INT, CONF_RANGE, 100, 899, NULL},
+#endif
{"audioid", &tv_param_audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
Index: command.c
===================================================================
--- command.c (revision 23790)
+++ command.c (working copy)
@@ -1511,6 +1511,68 @@
#endif
+#ifdef HAVE_TV_TELETEXT
+static int mp_property_teletext_common(m_option_t * prop, int action, void *arg,
+ MPContext * mpctx)
+{
+ int val,result;
+ int base_ioctl=(int)prop->priv;
+ /*
+ for teletext's GET,SET,STEP ioctls this is not 0
+ SET is GET+1
+ STEP is GET+2
+ */
+ tvi_handle_t *tvh = mpctx->demuxer->priv;
+ if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
+ return M_PROPERTY_UNAVAILABLE;
+ if(!base_ioctl)
+ return M_PROPERTY_ERROR;
+
+ switch (action) {
+ case M_PROPERTY_GET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ result=tvh->functions->control(tvh->priv, 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);
+ break;
+ case M_PROPERTY_STEP_UP:
+ case M_PROPERTY_STEP_DOWN:
+ val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
+ result=tvh->functions->control(tvh->priv, base_ioctl+2, &val);
+ break;
+ default:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+
+ return (result==TVI_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;
+
+ //with tvh==NULL will fail too
+ result=mp_property_teletext_common(prop,action,arg,mpctx);
+ if(result!=M_PROPERTY_OK)
+ return result;
+
+ if(tvh->functions->control(tvh->priv, prop->priv, &val)==TVI_CONTROL_TRUE && val)
+ mp_input_set_section("teletext");
+ else
+ mp_input_set_section("tv");
+ return M_PROPERTY_OK;
+}
+
+#endif /* HAVE_TV_TELETEXT */
+
///@}
/// All properties available in MPlayer.
@@ -1644,6 +1706,19 @@
M_OPT_RANGE, -100, 100, (void *) TV_COLOR_HUE },
#endif
+#ifdef HAVE_TV_TELETEXT
+ { "teletext_page", mp_property_teletext_common, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 799, (void*)TV_VBI_CONTROL_GET_PAGE },
+ { "teletext_subpage", mp_property_teletext_common, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE },
+ { "teletext_mode", mp_property_teletext_mode, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 3, (void*)TV_VBI_CONTROL_GET_MODE },
+ { "teletext_format", mp_property_teletext_common, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT },
+ { "teletext_half_page", mp_property_teletext_common, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE },
+#endif
+
{ NULL, NULL, NULL, 0, 0, 0, NULL }
};
@@ -2343,6 +2418,15 @@
if (mpctx->file_format == DEMUXER_TYPE_TV)
tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv));
break;
+#ifdef HAVE_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));
+ break;
+ }
+#endif /* HAVE_TV_TELETEXT */
#endif /* USE_TV */
case MP_CMD_SUB_LOAD:
More information about the MPlayer-dev-eng
mailing list