1 /*****************************************************************************
2 * zvbi.c : VBI and Teletext PES demux and decoder using libzvbi
3 *****************************************************************************
4 * Copyright (C) 2007, M2X
7 * Authors: Derk-Jan Hartman <djhartman at m2x dot nl>
8 * Jean-Paul Saman <jpsaman at m2x dot nl>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24 /*****************************************************************************
26 * information on teletext format can be found here :
27 * http://pdc.ro.nu/teletext.html
29 *****************************************************************************/
31 /* This module implements:
32 * ETSI EN 301 775: VBI data in PES
33 * ETSI EN 300 472: EBU Teletext data in PES
34 * ETSI EN 300 706: Enhanced Teletext (libzvbi)
35 * ETSI EN 300 231: Video Programme System [VPS] (libzvbi)
36 * ETSI EN 300 294: 625-line Wide Screen Signaling [WSS] (libzvbi)
37 * EIA-608 Revision A: Closed Captioning [CC] (libzvbi)
44 #include <vlc_common.h>
45 #include <vlc_plugin.h>
50 #include <vlc_codec.h>
53 /*****************************************************************************
55 *****************************************************************************/
56 static int Open ( vlc_object_t
* );
57 static void Close( vlc_object_t
* );
59 #define PAGE_TEXT N_("Teletext page")
60 #define PAGE_LONGTEXT N_("Open the indicated Teletext page." \
61 "Default page is index 100")
63 #define OPAQUE_TEXT N_("Text is always opaque")
64 #define OPAQUE_LONGTEXT N_("Setting vbi-opaque to false " \
65 "makes the boxed text transparent." )
67 #define POS_TEXT N_("Teletext alignment")
68 #define POS_LONGTEXT N_( \
69 "You can enforce the teletext position on the video " \
70 "(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \
71 "also use combinations of these values, eg. 6 = top-right).")
73 #define TELX_TEXT N_("Teletext text subtitles")
74 #define TELX_LONGTEXT N_( "Output teletext subtitles as text " \
75 "instead of as RGBA" )
77 static const int pi_pos_values
[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
78 static const char *const ppsz_pos_descriptions
[] =
79 { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
80 N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
83 set_description( N_("VBI and Teletext decoder") );
84 set_shortname( N_("VBI & Teletext") );
85 set_capability( "decoder", 51 );
86 set_category( CAT_INPUT
);
87 set_subcategory( SUBCAT_INPUT_SCODEC
);
88 set_callbacks( Open
, Close
);
90 add_integer( "vbi-page", 100, NULL
,
91 PAGE_TEXT
, PAGE_LONGTEXT
, false );
92 add_bool( "vbi-opaque", true, NULL
,
93 OPAQUE_TEXT
, OPAQUE_LONGTEXT
, false );
94 add_integer( "vbi-position", 4, NULL
, POS_TEXT
, POS_LONGTEXT
, false );
95 change_integer_list( pi_pos_values
, ppsz_pos_descriptions
, NULL
);
96 add_bool( "vbi-text", false, NULL
,
97 TELX_TEXT
, TELX_LONGTEXT
, false );
100 /****************************************************************************
102 ****************************************************************************/
104 // #define ZVBI_DEBUG
106 //Guessing table for missing "default region triplet"
107 static const int pi_default_triplet
[] = {
110 24,24,24,24, //ssc scr slv rum
111 32,32,32,32,32, //est lit rus bul ukr
116 static const char *const ppsz_default_triplet
[] = {
119 "ssc", "scr", "slv", "rum",
120 "est", "lit", "rus", "bul", "ukr",
128 ZVBI_KEY_RED
= 'r' << 16,
129 ZVBI_KEY_GREEN
= 'g' << 16,
130 ZVBI_KEY_YELLOW
= 'y' << 16,
131 ZVBI_KEY_BLUE
= 'b' << 16,
132 ZVBI_KEY_INDEX
= 'i' << 16,
136 DATA_UNIT_EBU_TELETEXT_NON_SUBTITLE
= 0x02,
137 DATA_UNIT_EBU_TELETEXT_SUBTITLE
= 0x03,
138 DATA_UNIT_EBU_TELETEXT_INVERTED
= 0x0C,
140 DATA_UNIT_ZVBI_WSS_CPR1204
= 0xB4,
141 DATA_UNIT_ZVBI_CLOSED_CAPTION_525
= 0xB5,
142 DATA_UNIT_ZVBI_MONOCHROME_SAMPLES_525
= 0xB6,
144 DATA_UNIT_VPS
= 0xC3,
145 DATA_UNIT_WSS
= 0xC4,
146 DATA_UNIT_CLOSED_CAPTION
= 0xC5,
147 DATA_UNIT_MONOCHROME_SAMPLES
= 0xC6,
149 DATA_UNIT_STUFFING
= 0xFF,
154 vbi_decoder
* p_vbi_dec
;
155 vbi_dvb_demux
* p_dvb_demux
;
156 unsigned int i_last_page
;
158 bool b_text
; /* Subtitles as text */
160 vlc_mutex_t lock
; /* Lock to protect the following variables */
161 /* Positioning of Teletext images */
164 unsigned int i_wanted_page
;
165 unsigned int i_wanted_subpage
;
174 static subpicture_t
*Decode( decoder_t
*, block_t
** );
176 static subpicture_t
*Subpicture( decoder_t
*p_dec
, video_format_t
*p_fmt
,
178 int i_columns
, int i_rows
,
179 int i_align
, mtime_t i_pts
);
181 static void EventHandler( vbi_event
*ev
, void *user_data
);
182 static int OpaquePage( picture_t
*p_src
, const vbi_page p_page
,
183 const video_format_t fmt
, bool b_opaque
);
185 /* Properties callbacks */
186 static int RequestPage( vlc_object_t
*p_this
, char const *psz_cmd
,
187 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
);
188 static int Opaque( vlc_object_t
*p_this
, char const *psz_cmd
,
189 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
);
190 static int Position( vlc_object_t
*p_this
, char const *psz_cmd
,
191 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
);
192 static int EventKey( vlc_object_t
*p_this
, char const *psz_cmd
,
193 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
);
195 /*****************************************************************************
196 * Open: probe the decoder and return score
197 *****************************************************************************
198 * Tries to launch a decoder and return score so that the interface is able
200 *****************************************************************************/
201 static int Open( vlc_object_t
*p_this
)
203 decoder_t
*p_dec
= (decoder_t
*) p_this
;
204 decoder_sys_t
*p_sys
= NULL
;
206 if( p_dec
->fmt_in
.i_codec
!= VLC_FOURCC('t','e','l','x') )
209 p_dec
->pf_decode_sub
= Decode
;
210 p_sys
= p_dec
->p_sys
= malloc( sizeof(decoder_sys_t
) );
213 memset( p_sys
, 0, sizeof(decoder_sys_t
) );
215 p_sys
->i_key
[0] = p_sys
->i_key
[1] = p_sys
->i_key
[2] = '*' - '0';
216 p_sys
->b_update
= false;
217 p_sys
->p_vbi_dec
= vbi_decoder_new();
218 p_sys
->p_dvb_demux
= vbi_dvb_pes_demux_new( NULL
, NULL
);
219 vlc_mutex_init( &p_sys
->lock
);
221 if( (p_sys
->p_vbi_dec
== NULL
) || (p_sys
->p_dvb_demux
== NULL
) )
223 msg_Err( p_dec
, "VBI decoder/demux could not be created." );
228 /* Some broadcasters in countries with level 1 and level 1.5 still not send a G0 to do
229 * matches against table 32 of ETSI 300 706. We try to do some best effort guessing
230 * This is not perfect, but might handle some cases where we know the vbi language
231 * is known. It would be better if people started sending G0 */
232 for( int i
= 0; ppsz_default_triplet
[i
] != NULL
; i
++ )
234 if( p_dec
->fmt_in
.psz_language
&& !strcasecmp( p_dec
->fmt_in
.psz_language
, ppsz_default_triplet
[i
] ) )
236 vbi_teletext_set_default_region( p_sys
->p_vbi_dec
, pi_default_triplet
[i
]);
237 msg_Dbg( p_dec
, "overwriting default zvbi region: %d", pi_default_triplet
[i
] );
241 vbi_event_handler_register( p_sys
->p_vbi_dec
, VBI_EVENT_TTX_PAGE
| VBI_EVENT_NETWORK
|
243 VBI_EVENT_CAPTION
| VBI_EVENT_TRIGGER
|
244 VBI_EVENT_ASPECT
| VBI_EVENT_PROG_INFO
| VBI_EVENT_NETWORK_ID
|
246 0 , EventHandler
, p_dec
);
248 /* Create the var on vlc_global. */
249 p_sys
->i_wanted_page
= var_CreateGetInteger( p_dec
, "vbi-page" );
250 var_AddCallback( p_dec
, "vbi-page",
251 RequestPage
, p_sys
);
253 /* Check if the Teletext track has a known "initial page". */
254 if( p_sys
->i_wanted_page
== 100 && p_dec
->fmt_in
.subs
.dvb
.i_id
!= -1 )
256 int i_wanted_magazine
= p_dec
->fmt_in
.subs
.dvb
.i_id
>> 16;
257 if( i_wanted_magazine
== 0 )
258 i_wanted_magazine
= 8;
259 p_sys
->i_wanted_page
= vbi_bcd2dec(p_dec
->fmt_in
.subs
.dvb
.i_id
& 0xff);
260 p_sys
->i_wanted_page
+= 100*i_wanted_magazine
;
262 p_sys
->i_wanted_subpage
= VBI_ANY_SUBNO
;
264 p_sys
->b_opaque
= var_CreateGetBool( p_dec
, "vbi-opaque" );
265 var_AddCallback( p_dec
, "vbi-opaque", Opaque
, p_sys
);
267 p_sys
->i_align
= var_CreateGetInteger( p_dec
, "vbi-position" );
268 var_AddCallback( p_dec
, "vbi-position", Position
, p_sys
);
270 p_sys
->b_text
= var_CreateGetBool( p_dec
, "vbi-text" );
271 // var_AddCallback( p_dec, "vbi-text", Text, p_sys );
273 /* Listen for keys */
274 var_AddCallback( p_dec
->p_libvlc
, "key-pressed", EventKey
, p_sys
);
276 es_format_Init( &p_dec
->fmt_out
, SPU_ES
, VLC_FOURCC( 's','p','u',' ' ) );
278 p_dec
->fmt_out
.video
.i_chroma
= VLC_FOURCC('T','E','X','T');
280 p_dec
->fmt_out
.video
.i_chroma
= VLC_FOURCC('R','G','B','A');
284 /*****************************************************************************
286 *****************************************************************************/
287 static void Close( vlc_object_t
*p_this
)
289 decoder_t
*p_dec
= (decoder_t
*) p_this
;
290 decoder_sys_t
*p_sys
= p_dec
->p_sys
;
292 var_DelCallback( p_dec
, "vbi-position", Position
, p_sys
);
293 var_DelCallback( p_dec
, "vbi-opaque", Opaque
, p_sys
);
294 var_DelCallback( p_dec
, "vbi-page", RequestPage
, p_sys
);
295 var_DelCallback( p_dec
->p_libvlc
, "key-pressed", EventKey
, p_sys
);
297 vlc_mutex_destroy( &p_sys
->lock
);
299 if( p_sys
->p_vbi_dec
)
300 vbi_decoder_delete( p_sys
->p_vbi_dec
);
301 if( p_sys
->p_dvb_demux
)
302 vbi_dvb_demux_delete( p_sys
->p_dvb_demux
);
306 #define MAX_SLICES 32
308 #ifdef WORDS_BIGENDIAN
309 # define ZVBI_PIXFMT_RGBA32 VBI_PIXFMT_RGBA32_BE
311 # define ZVBI_PIXFMT_RGBA32 VBI_PIXFMT_RGBA32_LE
315 /*****************************************************************************
317 *****************************************************************************/
318 static subpicture_t
*Decode( decoder_t
*p_dec
, block_t
**pp_block
)
320 decoder_sys_t
*p_sys
= p_dec
->p_sys
;
322 subpicture_t
*p_spu
= NULL
;
324 bool b_cached
= false;
326 const uint8_t *p_pos
;
329 if( (pp_block
== NULL
) || (*pp_block
== NULL
) )
335 p_pos
= p_block
->p_buffer
;
336 i_left
= p_block
->i_buffer
;
340 vbi_sliced p_sliced
[MAX_SLICES
];
341 unsigned int i_lines
= 0;
344 i_lines
= vbi_dvb_demux_cor( p_sys
->p_dvb_demux
, p_sliced
,
345 MAX_SLICES
, &i_pts
, &p_pos
, &i_left
);
348 vbi_decode( p_sys
->p_vbi_dec
, p_sliced
, i_lines
, i_pts
/ 90000.0 );
352 vlc_mutex_lock( &p_sys
->lock
);
353 const int i_align
= p_sys
->i_align
;
354 const unsigned int i_wanted_page
= p_sys
->i_wanted_page
;
355 const unsigned int i_wanted_subpage
= p_sys
->i_wanted_subpage
;
356 const bool b_opaque
= p_sys
->b_opaque
;
357 vlc_mutex_unlock( &p_sys
->lock
);
359 /* Try to see if the page we want is in the cache yet */
360 b_cached
= vbi_fetch_vt_page( p_sys
->p_vbi_dec
, &p_page
,
361 vbi_dec2bcd( i_wanted_page
),
362 i_wanted_subpage
, VBI_WST_LEVEL_3p5
,
365 if( i_wanted_page
== p_sys
->i_last_page
&& !p_sys
->b_update
)
370 if( p_sys
->i_last_page
!= i_wanted_page
)
372 /* We need to reset the subtitle */
373 p_spu
= Subpicture( p_dec
, &fmt
, true,
374 p_page
.columns
, p_page
.rows
,
375 i_align
, p_block
->i_pts
);
378 p_spu
->p_region
->psz_text
= strdup("");
380 p_sys
->b_update
= true;
381 p_sys
->i_last_page
= i_wanted_page
;
387 p_sys
->b_update
= false;
388 p_sys
->i_last_page
= i_wanted_page
;
390 msg_Dbg( p_dec
, "we now have page: %d ready for display",
393 /* If there is a page or sub to render, then we do that here */
394 /* Create the subpicture unit */
395 p_spu
= Subpicture( p_dec
, &fmt
, p_sys
->b_text
,
396 p_page
.columns
, p_page
.rows
,
397 i_align
, p_block
->i_pts
);
403 unsigned int i_textsize
= 7000;
405 char p_text
[i_textsize
+1];
407 i_total
= vbi_print_page_region( &p_page
, p_text
, i_textsize
,
408 "UTF-8", 0, 0, 0, 0, p_page
.columns
, p_page
.rows
);
409 p_text
[i_total
] = '\0';
410 /* Strip off the pagenumber */
413 p_spu
->p_region
->psz_text
= strdup( &p_text
[8] );
416 msg_Info( p_dec
, "page %x-%x(%d)\n%s", p_page
.pgno
, p_page
.subno
, i_total
, p_text
);
421 picture_t
*p_pic
= p_spu
->p_region
->p_picture
;
423 /* ZVBI is stupid enough to assume pitch == width */
424 p_pic
->p
->i_pitch
= 4 * fmt
.i_width
;
425 vbi_draw_vt_page( &p_page
, ZVBI_PIXFMT_RGBA32
,
426 p_spu
->p_region
->p_picture
->p
->p_pixels
, 1, 1 );
428 vlc_mutex_lock( &p_sys
->lock
);
429 memcpy( p_sys
->nav_link
, &p_page
.nav_link
, sizeof( p_sys
->nav_link
)) ;
430 vlc_mutex_unlock( &p_sys
->lock
);
432 OpaquePage( p_pic
, p_page
, fmt
, b_opaque
);
436 vbi_unref_page( &p_page
);
437 block_Release( p_block
);
441 vbi_unref_page( &p_page
);
444 p_dec
->pf_spu_buffer_del( p_dec
, p_spu
);
448 block_Release( p_block
);
452 static subpicture_t
*Subpicture( decoder_t
*p_dec
, video_format_t
*p_fmt
,
454 int i_columns
, int i_rows
, int i_align
,
460 /* If there is a page or sub to render, then we do that here */
461 /* Create the subpicture unit */
462 p_spu
= p_dec
->pf_spu_buffer_new( p_dec
);
465 msg_Warn( p_dec
, "can't get spu buffer" );
469 memset( &fmt
, 0, sizeof(video_format_t
) );
470 fmt
.i_chroma
= b_text
? VLC_FOURCC('T','E','X','T') :
471 VLC_FOURCC('R','G','B','A');
472 fmt
.i_aspect
= b_text
? 0 : VOUT_ASPECT_FACTOR
;
475 fmt
.i_bits_per_pixel
= 0;
479 fmt
.i_sar_num
= fmt
.i_sar_den
= 1;
480 fmt
.i_width
= fmt
.i_visible_width
= i_columns
* 12;
481 fmt
.i_height
= fmt
.i_visible_height
= i_rows
* 10;
482 fmt
.i_bits_per_pixel
= 32;
484 fmt
.i_x_offset
= fmt
.i_y_offset
= 0;
486 p_spu
->p_region
= subpicture_region_New( &fmt
);
487 if( p_spu
->p_region
== NULL
)
489 msg_Err( p_dec
, "cannot allocate SPU region" );
490 p_dec
->pf_spu_buffer_del( p_dec
, p_spu
);
494 p_spu
->p_region
->i_x
= 0;
495 p_spu
->p_region
->i_y
= 0;
496 p_spu
->p_region
->i_align
= i_align
;
498 p_spu
->i_start
= i_pts
;
500 p_spu
->b_ephemer
= true;
501 p_spu
->b_absolute
= false;
505 p_spu
->i_original_picture_width
= fmt
.i_width
;
506 p_spu
->i_original_picture_height
= fmt
.i_height
;
514 static void EventHandler( vbi_event
*ev
, void *user_data
)
516 decoder_t
*p_dec
= (decoder_t
*)user_data
;
517 decoder_sys_t
*p_sys
= p_dec
->p_sys
;
519 if( ev
->type
== VBI_EVENT_TTX_PAGE
)
522 msg_Info( p_dec
, "Page %03x.%02x ",
523 ev
->ev
.ttx_page
.pgno
,
524 ev
->ev
.ttx_page
.subno
& 0xFF);
526 if( p_sys
->i_last_page
== vbi_bcd2dec( ev
->ev
.ttx_page
.pgno
) )
527 p_sys
->b_update
= true;
529 if( ev
->ev
.ttx_page
.clock_update
)
530 msg_Dbg( p_dec
, "clock" );
531 if( ev
->ev
.ttx_page
.header_update
)
532 msg_Dbg( p_dec
, "header" );
535 else if( ev
->type
== VBI_EVENT_CLOSE
)
536 msg_Dbg( p_dec
, "Close event" );
537 else if( ev
->type
== VBI_EVENT_CAPTION
)
538 msg_Dbg( p_dec
, "Caption line: %x", ev
->ev
.caption
.pgno
);
539 else if( ev
->type
== VBI_EVENT_NETWORK
)
541 msg_Dbg( p_dec
, "Network change");
542 vbi_network n
= ev
->ev
.network
;
543 msg_Dbg( p_dec
, "Network id:%d name: %s, call: %s ", n
.nuid
, n
.name
, n
.call
);
545 else if( ev
->type
== VBI_EVENT_TRIGGER
)
546 msg_Dbg( p_dec
, "Trigger event" );
547 else if( ev
->type
== VBI_EVENT_ASPECT
)
548 msg_Dbg( p_dec
, "Aspect update" );
549 else if( ev
->type
== VBI_EVENT_PROG_INFO
)
550 msg_Dbg( p_dec
, "Program info received" );
551 else if( ev
->type
== VBI_EVENT_NETWORK_ID
)
552 msg_Dbg( p_dec
, "Network ID changed" );
555 static int OpaquePage( picture_t
*p_src
, const vbi_page p_page
,
556 const video_format_t fmt
, bool b_opaque
)
560 assert( fmt
.i_chroma
== VLC_FOURCC('R','G','B','A' ) );
562 /* Kludge since zvbi doesn't provide an option to specify opacity. */
563 for( y
= 0; y
< fmt
.i_height
; y
++ )
565 for( x
= 0; x
< fmt
.i_width
; x
++ )
567 const vbi_opacity opacity
= p_page
.text
[ y
/10 * p_page
.columns
+ x
/12 ].opacity
;
568 const int background
= p_page
.text
[ y
/10 * p_page
.columns
+ x
/12 ].background
;
569 uint32_t *p_pixel
= (uint32_t*)&p_src
->p
->p_pixels
[y
* p_src
->p
->i_pitch
+ 4*x
];
573 /* Show video instead of this character */
574 case VBI_TRANSPARENT_SPACE
:
577 /* Display foreground and background color */
578 /* To make the boxed text "closed captioning" transparent
579 * change true to false.
582 /* alpha blend video into background color */
583 case VBI_SEMI_TRANSPARENT
:
586 /* Full text transparency. only foreground color is show */
587 case VBI_TRANSPARENT_FULL
:
588 if( (*p_pixel
) == (0xff000000 | p_page
.color_map
[background
] ) )
599 static int RequestPage( vlc_object_t
*p_this
, char const *psz_cmd
,
600 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
602 decoder_sys_t
*p_sys
= p_data
;
603 VLC_UNUSED(p_this
); VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
);
605 vlc_mutex_lock( &p_sys
->lock
);
606 switch( newval
.i_int
)
609 p_sys
->i_wanted_page
= vbi_bcd2dec( p_sys
->nav_link
[0].pgno
);
610 p_sys
->i_wanted_subpage
= p_sys
->nav_link
[0].subno
;
613 p_sys
->i_wanted_page
= vbi_bcd2dec( p_sys
->nav_link
[1].pgno
);
614 p_sys
->i_wanted_subpage
= p_sys
->nav_link
[1].subno
;
616 case ZVBI_KEY_YELLOW
:
617 p_sys
->i_wanted_page
= vbi_bcd2dec( p_sys
->nav_link
[2].pgno
);
618 p_sys
->i_wanted_subpage
= p_sys
->nav_link
[2].subno
;
621 p_sys
->i_wanted_page
= vbi_bcd2dec( p_sys
->nav_link
[3].pgno
);
622 p_sys
->i_wanted_subpage
= p_sys
->nav_link
[3].subno
;
625 p_sys
->i_wanted_page
= vbi_bcd2dec( p_sys
->nav_link
[5].pgno
); /* #4 is SKIPPED */
626 p_sys
->i_wanted_subpage
= p_sys
->nav_link
[5].subno
;
629 if( newval
.i_int
> 0 && newval
.i_int
< 999 )
631 p_sys
->i_wanted_page
= newval
.i_int
;
632 p_sys
->i_wanted_subpage
= VBI_ANY_SUBNO
;
634 vlc_mutex_unlock( &p_sys
->lock
);
639 static int Opaque( vlc_object_t
*p_this
, char const *psz_cmd
,
640 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
642 decoder_sys_t
*p_sys
= p_data
;
643 VLC_UNUSED(p_this
); VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
);
645 vlc_mutex_lock( &p_sys
->lock
);
646 p_sys
->b_opaque
= newval
.b_bool
;
647 p_sys
->b_update
= true;
648 vlc_mutex_unlock( &p_sys
->lock
);
653 static int Position( vlc_object_t
*p_this
, char const *psz_cmd
,
654 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
656 decoder_sys_t
*p_sys
= p_data
;
657 VLC_UNUSED(p_this
); VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
);
659 vlc_mutex_lock( &p_sys
->lock
);
660 p_sys
->i_align
= newval
.i_int
;
661 vlc_mutex_unlock( &p_sys
->lock
);
666 static int EventKey( vlc_object_t
*p_this
, char const *psz_cmd
,
667 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
669 decoder_sys_t
*p_sys
= p_data
;
670 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
);
672 /* FIXME: Capture + and - key for subpage browsing */
673 if( newval
.i_int
== '-' || newval
.i_int
== '+' )
675 vlc_mutex_lock( &p_sys
->lock
);
676 if( p_sys
->i_wanted_subpage
== VBI_ANY_SUBNO
&& newval
.i_int
== '+' )
677 p_sys
->i_wanted_subpage
= vbi_dec2bcd(1);
678 else if ( newval
.i_int
== '+' )
679 p_sys
->i_wanted_subpage
= vbi_add_bcd( p_sys
->i_wanted_subpage
, 1);
680 else if( newval
.i_int
== '-')
681 p_sys
->i_wanted_subpage
= vbi_add_bcd( p_sys
->i_wanted_subpage
, 0xF9999999); /* BCD complement - 1 */
683 if ( !vbi_bcd_digits_greater( p_sys
->i_wanted_subpage
, 0x00 ) || vbi_bcd_digits_greater( p_sys
->i_wanted_subpage
, 0x99 ) )
684 p_sys
->i_wanted_subpage
= VBI_ANY_SUBNO
;
686 vout_OSDMessage( p_this
, DEFAULT_CHAN
, "%s: %d", _("Subpage"), vbi_bcd2dec( p_sys
->i_wanted_subpage
) );
688 p_sys
->b_update
= true;
689 vlc_mutex_unlock( &p_sys
->lock
);
692 /* Capture 0-9 for page selection */
693 if( newval
.i_int
< '0' || newval
.i_int
> '9' )
696 vlc_mutex_lock( &p_sys
->lock
);
697 p_sys
->i_key
[0] = p_sys
->i_key
[1];
698 p_sys
->i_key
[1] = p_sys
->i_key
[2];
699 p_sys
->i_key
[2] = (int)(newval
.i_int
- '0');
700 vout_OSDMessage( p_this
, DEFAULT_CHAN
, "%s: %c%c%c", _("Page"), (char)(p_sys
->i_key
[0]+'0'), (char)(p_sys
->i_key
[1]+'0'), (char)(p_sys
->i_key
[2]+'0') );
702 if( p_sys
->i_key
[0] > 0 && p_sys
->i_key
[0] <= 8 &&
703 p_sys
->i_key
[1] >= 0 && p_sys
->i_key
[1] <= 9 &&
704 p_sys
->i_key
[2] >= 0 && p_sys
->i_key
[2] <= 9 )
706 p_sys
->i_wanted_page
= p_sys
->i_key
[0]*100 + p_sys
->i_key
[1]*10 + p_sys
->i_key
[2];
707 p_sys
->i_wanted_subpage
= VBI_ANY_SUBNO
;
708 p_sys
->i_key
[0] = p_sys
->i_key
[1] = p_sys
->i_key
[2] = '*' - '0';
710 vlc_mutex_unlock( &p_sys
->lock
);