[MPlayer-dev-eng] [PATCH] Teletext support try3 (4/5, configure, slaves, etc)
Vladimir Voroshilov
voroshil at gmail.com
Sun Jul 15 12:59:19 CEST 2007
Hi, All
Here is fourth of 5 teletext patches.
--
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 23784)
+++ 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 23784)
+++ 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 23784)
+++ 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,37 @@
#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() ) */
+#define TV_VBI_CONTROL_SET_MODE 0x510 ///< on/off grab teletext
+#define TV_VBI_CONTROL_GET_MODE 0x511 ///< get current mode teletext
+#define TV_VBI_CONTROL_STEP_MODE 0x512 ///< step teletext mode
+
+#define TV_VBI_CONTROL_SET_PAGE 0x513 ///< set grab teletext page number
+#define TV_VBI_CONTROL_STEP_PAGE 0x514 ///< step grab teletext page number
+#define TV_VBI_CONTROL_GET_PAGE 0x515 ///< get grabbed teletext page
+
+#define TV_VBI_CONTROL_SET_SUBPAGE 0x516 ///< set grab teletext page number
+#define TV_VBI_CONTROL_STEP_SUBPAGE 0x517 ///< step grab teletext page number
+#define TV_VBI_CONTROL_GET_SUBPAGE 0x518 ///< get grabbed teletext page
+
+#define TV_VBI_CONTROL_SET_FORMAT 0x519 ///< set teletext format
+#define TV_VBI_CONTROL_STEP_FORMAT 0x51a ///< step teletext format
+#define TV_VBI_CONTROL_GET_FORMAT 0x51b ///< get eletext format
+
+#define TV_VBI_CONTROL_GET_HALF_PAGE 0x51c ///< get current half page
+#define TV_VBI_CONTROL_STEP_HALF_PAGE 0x51d ///< switch half page
+#define TV_VBI_CONTROL_SET_HALF_PAGE 0x51e ///< switch half page
+
+#define TV_VBI_CONTROL_ADD_DEC 0x51f ///< add page number with dec
+#define TV_VBI_CONTROL_GO_LINK 0x520 ///< go link (1..6) NYI
+#define TV_VBI_CONTROL_GET_VBIPAGE 0x521 ///< get vbi_image for grabbed teletext page
+#define TV_VBI_CONTROL_RESET 0x522 ///< vbi reset
+#define TV_VBI_CONTROL_START 0x523 ///< vbi start
+#define TV_VBI_CONTROL_STOP 0x524 ///< vbi stop
+#define TV_VBI_CONTROL_DECODE_PAGE 0x525 ///< 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 +226,44 @@
#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 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 pgno; ///< page number
+ int subno; ///< 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 23784)
+++ 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 23784)
+++ 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 23784)
+++ 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]
@@ -588,6 +589,7 @@
_tv_v4l1=auto
_tv_v4l2=auto
_tv_bsdbt848=auto
+_tv_teletext=auto
_pvr=auto
_network=yes
_winsock2=auto
@@ -935,6 +937,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 ;;
@@ -6686,7 +6690,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'
@@ -7442,6 +7463,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
@@ -7987,6 +8009,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 23784)
+++ cfg-common.h (working copy)
@@ -460,6 +460,11 @@
#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},
+ {"tformat", &tv_param_tformat, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"tpage", &tv_param_tpage, CONF_TYPE_INT, CONF_RANGE, 100, 999, 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 23784)
+++ command.c (working copy)
@@ -1508,6 +1508,165 @@
#endif
+#ifdef HAVE_TV_TELETEXT
+/// teletext page (RW)
+static int mp_property_teletext_page(m_option_t * prop, int action, void *arg,
+ MPContext * mpctx)
+{
+ int val,result;
+ tvi_handle_t *tvh = mpctx->demuxer->priv;
+ if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
+ return M_PROPERTY_UNAVAILABLE;
+
+ switch (action) {
+ case M_PROPERTY_SET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ M_PROPERTY_CLAMP(prop, *(int *) arg);
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_SET_PAGE, arg);
+ break;
+ case M_PROPERTY_GET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_GET_PAGE, 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, TV_VBI_CONTROL_STEP_PAGE, &val);
+ break;
+ default:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+ return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+/// teletext subpage (RW)
+static int mp_property_teletext_subpage(m_option_t * prop, int action, void *arg,
+ MPContext * mpctx)
+{
+ int val,result;
+ tvi_handle_t *tvh = mpctx->demuxer->priv;
+ if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
+ return M_PROPERTY_UNAVAILABLE;
+
+ switch (action) {
+ case M_PROPERTY_SET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ M_PROPERTY_CLAMP(prop, *(int *) arg);
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_SET_SUBPAGE, arg);
+ break;
+ case M_PROPERTY_GET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_GET_SUBPAGE, 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, TV_VBI_CONTROL_STEP_SUBPAGE, &val);
+ break;
+ default:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+ return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+/// VBI teletext mode (RW)
+static int mp_property_teletext_mode(m_option_t * prop, int action, void *arg,
+ MPContext * mpctx)
+{
+ int val,result;
+ tvi_handle_t *tvh = mpctx->demuxer->priv;
+ if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
+ return M_PROPERTY_UNAVAILABLE;
+
+ switch (action) {
+ case M_PROPERTY_SET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ M_PROPERTY_CLAMP(prop, *(int *) arg);
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_SET_MODE, arg);
+ break;
+ case M_PROPERTY_GET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_GET_MODE, 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, TV_VBI_CONTROL_STEP_MODE, &val);
+ break;
+ default:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+ return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+/// VBI teletext format (R)
+static int mp_property_teletext_format(m_option_t * prop, int action, void *arg,
+ MPContext * mpctx)
+{
+ int val,result;
+ tvi_handle_t *tvh = mpctx->demuxer->priv;
+ if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
+ return M_PROPERTY_UNAVAILABLE;
+
+ switch (action) {
+ case M_PROPERTY_GET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_GET_FORMAT, arg);
+ break;
+ case M_PROPERTY_SET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ M_PROPERTY_CLAMP(prop, *(int *) arg);
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_SET_FORMAT, 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, TV_VBI_CONTROL_STEP_FORMAT, &val);
+ break;
+ default:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+ return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+
+/// VBI teletext half-page mode (RW)
+static int mp_property_teletext_half_page(m_option_t * prop, int action, void *arg,
+ MPContext * mpctx)
+{
+ int val,result;
+ tvi_handle_t *tvh = mpctx->demuxer->priv;
+ if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
+ return M_PROPERTY_UNAVAILABLE;
+
+ switch (action) {
+ case M_PROPERTY_GET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_GET_HALF_PAGE, arg);
+ break;
+ case M_PROPERTY_SET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ M_PROPERTY_CLAMP(prop, *(int *) arg);
+ result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_SET_HALF_PAGE, 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, TV_VBI_CONTROL_STEP_HALF_PAGE, &val);
+ break;
+ default:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+ return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+#endif /* HAVE_TV_TELETEXT */
+
///@}
/// All properties available in MPlayer.
@@ -1641,6 +1800,19 @@
M_OPT_RANGE, -100, 100, (void *) TV_COLOR_HUE },
#endif
+#ifdef HAVE_TV_TELETEXT
+ { "teletext_page", mp_property_teletext_page, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 799, NULL },
+ { "teletext_subpage", mp_property_teletext_subpage, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 64, NULL },
+ { "teletext_mode", mp_property_teletext_mode, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 3, NULL },
+ { "teletext_format", mp_property_teletext_format, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 3, NULL },
+ { "teletext_half_page", mp_property_teletext_half_page, CONF_TYPE_INT,
+ M_OPT_RANGE, 0, 2, NULL },
+#endif
+
{ NULL, NULL, NULL, 0, 0, 0, NULL }
};
@@ -2340,6 +2512,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:
Index: mencoder.c
===================================================================
--- mencoder.c (revision 23784)
+++ mencoder.c (working copy)
@@ -237,6 +237,18 @@
//static int vo_w=0, vo_h=0;
+/**
+ \ Empty input section function because don't link libinput.a
+*/
+void mp_input_set_section(char *name) {
+ return;
+}
+
+char* mp_input_get_section(void) {
+ return "default";
+}
+
+
//-------------------------- config stuff:
m_config_t* mconfig;
More information about the MPlayer-dev-eng
mailing list