blob: 1ba71eeb3c3dc899c5f8b1597ff5958b3646518a
1 | /* |
2 | * libzvbi -- Events |
3 | * |
4 | * Copyright (C) 2000, 2001, 2002 Michael H. Schimek |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public |
17 | * License along with this library; if not, write to the |
18 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | * Boston, MA 02110-1301 USA. |
20 | */ |
21 | |
22 | /* $Id: event.h,v 1.14 2008/02/19 00:35:15 mschimek Exp $ */ |
23 | |
24 | #ifndef EVENT_H |
25 | #define EVENT_H |
26 | |
27 | #include "bcd.h" |
28 | |
29 | #ifndef VBI_DECODER |
30 | #define VBI_DECODER |
31 | typedef struct vbi_decoder vbi_decoder; |
32 | #endif |
33 | |
34 | /* Public */ |
35 | |
36 | #include <inttypes.h> |
37 | |
38 | /** |
39 | * @addtogroup Event Events |
40 | * @ingroup HiDec |
41 | * |
42 | * Typically the transmission of VBI data like a Teletext or Closed |
43 | * Caption page spans several VBI lines or even video frames. So internally |
44 | * the data service decoder maintains caches accumulating data. When a page |
45 | * or other object is complete it calls the respective event handler to |
46 | * notify the application. |
47 | * |
48 | * Clients can register any number of handlers needed, also different |
49 | * handlers for the same event. They will be called in the order registered |
50 | * from the vbi_decode() function. Since they block decoding, they should |
51 | * return as soon as possible. The event structure and all data |
52 | * pointed to from there must be read only. The data is only valid until |
53 | * the handler returns. |
54 | */ |
55 | |
56 | /** |
57 | * @ingroup Event |
58 | * @brief Unique network id (a libzvbi thing). |
59 | * |
60 | * 0 = unknown network, bit 31 reserved for preliminary nuids. |
61 | * Other network codes are arbitrary. |
62 | */ |
63 | typedef unsigned int vbi_nuid; |
64 | |
65 | /** |
66 | * @ingroup Event |
67 | * @brief Network description. |
68 | * |
69 | * All strings are ISO 8859-1 encoded (yes that's stupid, sorry) |
70 | * and @c NUL terminated. Prepare for empty strings. Read only. |
71 | */ |
72 | typedef struct { |
73 | vbi_nuid nuid; |
74 | |
75 | /** |
76 | * Name of the network from XDS or from a table lookup of |
77 | * CNIs in Teletext packet 8/30 or VPS. |
78 | */ |
79 | signed char name[64]; |
80 | |
81 | /** |
82 | * Network call letters, from XDS. Empty if unknown or |
83 | * not applicable. |
84 | */ |
85 | signed char call[40]; |
86 | |
87 | /** |
88 | * Tape delay in minutes, from XDS. Zero if unknown or |
89 | * not applicable. |
90 | **/ |
91 | int tape_delay; |
92 | |
93 | /** |
94 | * The European Broadcasting Union (EBU) maintains several tables |
95 | * of Country and Network Identification (CNI) codes. CNIs of type |
96 | * VPS, 8/30-1 and 8/30-2 can be used to identify networks during |
97 | * a channel scan. |
98 | * |
99 | * This field contains the CNI of the network found in a VPS |
100 | * packet. It can be zero if unknown or CNI's are not applicable. |
101 | * Note VPS has room for only 4 lsb of the country code (0xCNN). |
102 | * |
103 | * For example ZDF: 0xDC2. |
104 | */ |
105 | int cni_vps; |
106 | |
107 | /** |
108 | * CNI of the network from Teletext packet 8/30 format 1, |
109 | * zero if unknown or not applicable. The country code is |
110 | * stored in the MSB, the network code in the LSB (0xCCNN). |
111 | * Note these CNIs may use different country and network codes |
112 | * than the PDC (VPS, 8/30-2) CNIs. |
113 | * |
114 | * For example BBC1: 0x447F, ZDF: 0x4902. |
115 | */ |
116 | int cni_8301; |
117 | |
118 | /** |
119 | * CNI of the network from Teletext packet 8/30 format 2, |
120 | * zero if unknown or not applicable. The country code is |
121 | * stored in the MSB, the network code in the LSB (0xCCNN). |
122 | * |
123 | * For example BBC1: 0x2C7F, ZDF: 0x1DC2. |
124 | */ |
125 | int cni_8302; |
126 | |
127 | int reserved; |
128 | |
129 | /** Private. */ |
130 | int cycle; |
131 | |
132 | /** Transmission Signal ID */ |
133 | int ts_id; |
134 | } vbi_network; |
135 | |
136 | /* |
137 | * Link |
138 | */ |
139 | |
140 | /** |
141 | * @ingroup Event |
142 | * @brief Link type. |
143 | */ |
144 | typedef enum { |
145 | /** |
146 | * vbi_resolve_link() may return a link of this type on failure. |
147 | */ |
148 | VBI_LINK_NONE = 0, |
149 | /** |
150 | * Not really a link, only vbi_link->name will be set. (Probably |
151 | * something like "Help! Help! The station is on fire!") |
152 | */ |
153 | VBI_LINK_MESSAGE, |
154 | /** |
155 | * Points to a Teletext page, vbi_link->pgno and vbi_link->subno, |
156 | * eventually vbi_link->nuid and a descriptive text in vbi_link->name. |
157 | */ |
158 | VBI_LINK_PAGE, |
159 | /** |
160 | * Also a Teletext page link, but this one is used exclusively |
161 | * to link subpages of the page containing the link. |
162 | */ |
163 | VBI_LINK_SUBPAGE, |
164 | /** |
165 | * vbi_link->url is a HTTP URL (like "http://zapping.sf.net"), |
166 | * eventually accompanied by a descriptive text vbi_link->name. |
167 | */ |
168 | VBI_LINK_HTTP, |
169 | /** |
170 | * vbi_link->url is a FTP URL (like "ftp://foo.bar.com/baz"), |
171 | * eventually accompanied by a descriptive text vbi_link->name. |
172 | */ |
173 | VBI_LINK_FTP, |
174 | /** |
175 | * vbi_link->url is an e-mail address (like "mailto:foo@bar"), |
176 | * eventually accompanied by a descriptive text vbi_link->name. |
177 | */ |
178 | VBI_LINK_EMAIL, |
179 | /** Is a trigger link id. Not useful, just ignore. */ |
180 | VBI_LINK_LID, |
181 | /** Is a SuperTeletext link, ignore. */ |
182 | VBI_LINK_TELEWEB |
183 | } vbi_link_type; |
184 | |
185 | /** |
186 | * @ingroup Event |
187 | * @brief ITV link type. |
188 | * |
189 | * Some ITV (WebTV, ATVEF) triggers include a type id intended |
190 | * to filter relevant information. The names should speak for |
191 | * themselves. EACEM triggers always have type @c VBI_WEBLINK_UNKNOWN. |
192 | **/ |
193 | typedef enum { |
194 | VBI_WEBLINK_UNKNOWN = 0, |
195 | VBI_WEBLINK_PROGRAM_RELATED, |
196 | VBI_WEBLINK_NETWORK_RELATED, |
197 | VBI_WEBLINK_STATION_RELATED, |
198 | VBI_WEBLINK_SPONSOR_MESSAGE, |
199 | VBI_WEBLINK_OPERATOR |
200 | } vbi_itv_type; |
201 | |
202 | /** |
203 | * @ingroup Event |
204 | * |
205 | * General purpose link description for ATVEF (ITV, WebTV in the |
206 | * United States) and EACEM (SuperTeletext et al in Europe) triggers, |
207 | * Teletext TOP and FLOF navigation, and for links "guessed" by |
208 | * libzvbi from the text (e. g. page numbers and URLs). Usually |
209 | * not all fields will be used. |
210 | */ |
211 | typedef struct vbi_link { |
212 | /** |
213 | * See vbi_link_type. |
214 | */ |
215 | vbi_link_type type; |
216 | /** |
217 | * Links can be obtained two ways, via @ref VBI_EVENT_TRIGGER, |
218 | * then it arrived either through the EACEM or ATVEF transport |
219 | * method as flagged by this field. Or it is a navigational link |
220 | * returned by vbi_resolve_link(), then this field does not apply. |
221 | */ |
222 | vbi_bool eacem; |
223 | /** |
224 | * Some descriptive text, Latin-1, possibly blank. |
225 | */ |
226 | signed char name[80]; |
227 | signed char url[256]; |
228 | /** |
229 | * A piece of ECMA script (Javascript), this may be |
230 | * used on WebTV or SuperTeletext pages to trigger some action. |
231 | * Usually blank. |
232 | */ |
233 | signed char script[256]; |
234 | /** |
235 | * Teletext page links (no Closed Caption counterpart) can |
236 | * can actually reach across networks. That happens for example |
237 | * when vbi_resolve_link() picked up a link on a page after we |
238 | * switch away from that channel, or with EACEM triggers |
239 | * deliberately pointing to a page on another network (sic!). |
240 | * So the network id (if known, otherwise 0) is part of the |
241 | * page number. See vbi_nuid. |
242 | */ |
243 | vbi_nuid nuid; |
244 | /** |
245 | * @a pgno and @a subno Teletext page number, see vbi_pgno, vbi_subno. |
246 | */ |
247 | vbi_pgno pgno; |
248 | vbi_subno subno; |
249 | /** |
250 | * The time in seconds and fractions since |
251 | * 1970-01-01 00:00 when the link should no longer be offered |
252 | * to the user, similar to a HTTP cache expiration date. |
253 | */ |
254 | double expires; |
255 | /** |
256 | * See vbi_itv_type. This field applies only to |
257 | * ATVEF triggers, is otherwise @c VBI_WEBLINK_UNKNOWN. |
258 | */ |
259 | vbi_itv_type itv_type; |
260 | /** |
261 | * Trigger priority. 0 = emergency, should never be |
262 | * blocked. 1 or 2 = "high", 3 ... 5 = "medium", 6 ... 9 = |
263 | * "low". The default is 9. Apart of filtering triggers, this |
264 | * is also used to determine at which priority multiple links |
265 | * should be presented to the user. This field applies only to |
266 | * EACEM triggers, is otherwise 9. |
267 | */ |
268 | int priority; |
269 | /** |
270 | * Open the target without user confirmation. (Supposedly |
271 | * this flag will be used to trigger scripts, not to open pages, |
272 | * but I have yet to see such a trigger.) |
273 | */ |
274 | vbi_bool autoload; |
275 | } vbi_link; |
276 | |
277 | /* |
278 | * Aspect ratio information. |
279 | */ |
280 | |
281 | /** |
282 | * @ingroup Event |
283 | * @brief Open subtitle information. |
284 | * |
285 | * Open because they have been inserted into the picture, as |
286 | * opposed to closed subtitles (closed caption) encoded in the vbi. |
287 | */ |
288 | typedef enum { |
289 | VBI_SUBT_NONE, /**< No open subtitles. */ |
290 | VBI_SUBT_ACTIVE, /**< Inserted in active picture. */ |
291 | VBI_SUBT_MATTE, /**< Inserted in upper or lower letterbox bar. */ |
292 | VBI_SUBT_UNKNOWN /**< Presence of open subtitles unknown. */ |
293 | } vbi_subt; |
294 | |
295 | /** |
296 | * @ingroup Event |
297 | * @brief Information about the picture aspect ratio and open subtitles. |
298 | * |
299 | * This is available via @ref VBI_EVENT_ASPECT. |
300 | */ |
301 | typedef struct { |
302 | /** |
303 | * @a first_line and @a last_line, inclusive, describe the bounds of active |
304 | * video, i. e. without the black bars in letterbox mode. These are |
305 | * <em>first field</em> line numbers according to the ITU-R line |
306 | * numbering scheme, see vbi_sliced. For example PAL 23 ... 310 (288 lines), |
307 | * NTSC 22 ... 262 (240 lines). |
308 | */ |
309 | int first_line; |
310 | int last_line; |
311 | /** |
312 | * The picture aspect ratio in <em>anamorphic</em> mode, |
313 | * 16/9 for example. Normal or letterboxed video has aspect ratio 1/1. |
314 | */ |
315 | double ratio; |
316 | /** |
317 | * @c TRUE when the source is known to be film transferred to |
318 | * video, as opposed to interlaced video from a video camera. (This is |
319 | * actually a helper flag for PALPlus decoders, but it may assist |
320 | * deinterlacers too.) |
321 | */ |
322 | vbi_bool film_mode; |
323 | /** |
324 | * Describes how subtitles are inserted into the picture, |
325 | * see vbi_subt for details. |
326 | */ |
327 | vbi_subt open_subtitles; |
328 | } vbi_aspect_ratio; |
329 | |
330 | /* |
331 | * Program Info |
332 | * |
333 | * ATTN this is new stuff and subject to change |
334 | */ |
335 | |
336 | /** |
337 | * @ingroup Event |
338 | * @brief Program rating source. |
339 | * |
340 | * If program rating information is available (also known in the |
341 | * U. S. as V-Chip data), this describes which rating scheme is |
342 | * being used: U. S. film, U. S. TV, Canadian English or French TV. |
343 | * You can convert the rating code to a string with |
344 | * vbi_rating_string(). |
345 | * |
346 | * When the scheme is @c VBI_RATING_TV_US, additionally the |
347 | * DLSV rating flags will be set. |
348 | */ |
349 | typedef enum { |
350 | VBI_RATING_AUTH_NONE = 0, |
351 | VBI_RATING_AUTH_MPAA, |
352 | VBI_RATING_AUTH_TV_US, |
353 | VBI_RATING_AUTH_TV_CA_EN, |
354 | VBI_RATING_AUTH_TV_CA_FR |
355 | } vbi_rating_auth; |
356 | |
357 | /** |
358 | * @ingroup Event |
359 | * @name US TV rating flags |
360 | * @{ |
361 | */ |
362 | #define VBI_RATING_D 0x08 /**< "sexually suggestive dialog" */ |
363 | #define VBI_RATING_L 0x04 /**< "indecent language" */ |
364 | #define VBI_RATING_S 0x02 /**< "sexual situations" */ |
365 | #define VBI_RATING_V 0x01 /**< "violence" */ |
366 | /** @} */ |
367 | |
368 | extern const char * vbi_rating_string(vbi_rating_auth auth, int id); |
369 | |
370 | /** |
371 | * @ingroup Event |
372 | * @brief Program classification schemes. |
373 | * |
374 | * libzvbi understands two different program classification schemes, |
375 | * the EIA-608 based in the United States and the ETS 300 231 based |
376 | * one in Europe. You can convert the program type code into a |
377 | * string with vbi_prog_type_string(). |
378 | **/ |
379 | typedef enum { |
380 | VBI_PROG_CLASSF_NONE = 0, |
381 | VBI_PROG_CLASSF_EIA_608, |
382 | VBI_PROG_CLASSF_ETS_300231 |
383 | } vbi_prog_classf; |
384 | |
385 | /** |
386 | * @addtogroup Event |
387 | * @{ |
388 | */ |
389 | extern const char * vbi_prog_type_string(vbi_prog_classf classf, int id); |
390 | /** @} */ |
391 | |
392 | /** |
393 | * @ingroup Event |
394 | * @brief Type of audio transmitted on one (mono or stereo) |
395 | * audio track. |
396 | */ |
397 | /* code depends on order, don't change */ |
398 | typedef enum { |
399 | VBI_AUDIO_MODE_NONE = 0, /**< No sound. */ |
400 | VBI_AUDIO_MODE_MONO, /**< Mono audio. */ |
401 | VBI_AUDIO_MODE_STEREO, /**< Stereo audio. */ |
402 | VBI_AUDIO_MODE_STEREO_SURROUND, /**< Surround. */ |
403 | VBI_AUDIO_MODE_SIMULATED_STEREO, /**< ? */ |
404 | /** |
405 | * Spoken descriptions of the program for the blind, on a secondary audio track. |
406 | */ |
407 | VBI_AUDIO_MODE_VIDEO_DESCRIPTIONS, |
408 | /** |
409 | * Unrelated to the current program. |
410 | */ |
411 | VBI_AUDIO_MODE_NON_PROGRAM_AUDIO, |
412 | |
413 | VBI_AUDIO_MODE_SPECIAL_EFFECTS, /**< ? */ |
414 | VBI_AUDIO_MODE_DATA_SERVICE, /**< ? */ |
415 | /** |
416 | * We have no information what is transmitted. |
417 | */ |
418 | VBI_AUDIO_MODE_UNKNOWN |
419 | } vbi_audio_mode; |
420 | typedef struct vbi_rating{ |
421 | /* |
422 | * For details STFW for "v-chip" |
423 | * If unknown rating_auth == VBI_RATING_NONE |
424 | */ |
425 | vbi_rating_auth auth; |
426 | int id; |
427 | /* Only valid when auth == VBI_RATING_TV_US */ |
428 | int dlsv; |
429 | }vbi_rating; |
430 | /** |
431 | * @ingroup Event |
432 | * |
433 | * Information about the current program, preliminary. |
434 | */ |
435 | typedef struct vbi_program_info { |
436 | /* |
437 | * Refers to the current or next program. |
438 | * (No [2] to allow clients filtering current data more easily.) |
439 | */ |
440 | unsigned int future : 1; |
441 | |
442 | /* 01 Program Identification Number */ |
443 | |
444 | /* If unknown all these fields are -1 */ |
445 | signed char month; /* 0 ... 11 */ |
446 | signed char day; /* 0 ... 30 */ |
447 | signed char hour; /* 0 ... 23 */ |
448 | signed char min; /* 0 ... 59 */ |
449 | |
450 | /* |
451 | * VD: "T indicates if a program is routinely tape delayed for the |
452 | * Mountain and Pacific time zones." |
453 | */ |
454 | signed char tape_delayed; |
455 | |
456 | /* 02 Program Length */ |
457 | |
458 | /* If unknown all these fields are -1 */ |
459 | signed char length_hour; /* 0 ... 63 */ |
460 | signed char length_min; /* 0 ... 59 */ |
461 | |
462 | signed char elapsed_hour; /* 0 ... 63 */ |
463 | signed char elapsed_min; /* 0 ... 59 */ |
464 | signed char elapsed_sec; /* 0 ... 59 */ |
465 | |
466 | /* 03 Program name */ |
467 | |
468 | /* If unknown title[0] == 0 */ |
469 | signed char title[64]; /* ASCII + '\0' */ |
470 | |
471 | /* 04 Program type */ |
472 | |
473 | /* |
474 | * If unknown type_classf == VBI_PROG_CLASSF_NONE. |
475 | * VBI_PROG_CLASSF_EIA_608 can have up to 32 tags |
476 | * identifying 96 keywords. Their numerical value |
477 | * is given here instead of composing a string for |
478 | * easier filtering. Use vbi_prog_type_str_by_id to |
479 | * get the keywords. A zero marks the end. |
480 | */ |
481 | vbi_prog_classf type_classf; |
482 | int type_id[33]; |
483 | |
484 | /* 05 Program rating */ |
485 | vbi_rating rating; |
486 | |
487 | /* 06 Program Audio Services */ |
488 | |
489 | /* |
490 | * BTSC audio (two independent tracks) is flagged according to XDS, |
491 | * Zweiton/NICAM/EIA-J audio is flagged mono/none, stereo/none or |
492 | * mono/mono for bilingual transmissions. |
493 | */ |
494 | struct { |
495 | /* If unknown mode == VBI_AUDIO_MODE_UNKNOWN */ |
496 | vbi_audio_mode mode; |
497 | /* If unknown language == NULL */ |
498 | unsigned char * language; /* Latin-1 */ |
499 | } audio[2]; /* primary and secondary */ |
500 | |
501 | /* 07 Program Caption Services */ |
502 | |
503 | /* |
504 | * Bits 0...7 corresponding to Caption page 1...8. |
505 | * Note for the current program this information is also |
506 | * available via vbi_classify_page(). |
507 | * |
508 | * If unknown caption_services == -1, _language[] = NULL |
509 | */ |
510 | int caption_services; |
511 | unsigned char * caption_language[8]; /* Latin-1 */ |
512 | |
513 | /* 08 Copy Generation Management System */ |
514 | |
515 | /* If unknown cgms_a == -1 */ |
516 | int cgms_a; /* XXX */ |
517 | |
518 | /* 09 Aspect Ratio */ |
519 | |
520 | /* |
521 | * Note for the current program this information is also |
522 | * available via VBI_EVENT_ASPECT. |
523 | * |
524 | * If unknown first_line == last_line == -1, ratio == 0.0 |
525 | */ |
526 | vbi_aspect_ratio aspect; |
527 | |
528 | /* 10 - 17 Program Description */ |
529 | |
530 | /* |
531 | * 8 rows of 0...32 ASCII chars + '\0', |
532 | * if unknown description[0...7][0] == 0 |
533 | */ |
534 | signed char description[8][33]; |
535 | } vbi_program_info; |
536 | |
537 | /** |
538 | * @addtogroup Event |
539 | * @{ |
540 | */ |
541 | extern void vbi_reset_prog_info(vbi_program_info *pi); |
542 | /** @} */ |
543 | |
544 | /** |
545 | * @ingroup Event |
546 | * @name Event types. |
547 | * @{ |
548 | */ |
549 | |
550 | /** |
551 | * @anchor VBI_EVENT_ |
552 | * No event. |
553 | */ |
554 | #define VBI_EVENT_NONE 0x0000 |
555 | /** |
556 | * The vbi decoding context is about to be closed. This event is |
557 | * sent by vbi_decoder_delete() and can be used to clean up |
558 | * event handlers. |
559 | */ |
560 | #define VBI_EVENT_CLOSE 0x0001 |
561 | /** |
562 | * The vbi decoder received and cached another Teletext page |
563 | * designated by ev.ttx_page.pgno and ev.ttx_page.subno. |
564 | * |
565 | * ev.ttx_page.roll_header flags the page header as suitable for |
566 | * rolling page numbers, e. g. excluding pages transmitted out |
567 | * of order. |
568 | * |
569 | * The ev.ttx_page.header_update flag is set when the header, |
570 | * excluding the page number and real time clock, changed since the |
571 | * last @c VBI_EVENT_TTX_PAGE. Note this may happen at midnight when the |
572 | * date string changes. The ev.ttx_page.clock_update flag is set when |
573 | * the real time clock changed since the last @c VBI_EVENT_TTX_PAGE (that is |
574 | * at most once per second). They are both set at the first |
575 | * @c VBI_EVENT_TTX_PAGE sent and unset while the received header |
576 | * or clock field is corrupted. |
577 | * |
578 | * If any of the roll_header, header_update or clock_update flags |
579 | * are set ev.ttx_page.raw_header is a pointer to the raw header data |
580 | * (40 bytes), which remains valid until the event handler returns. |
581 | * ev.ttx_page.pn_offset will be the offset (0 ... 37) of the three |
582 | * digit page number in the raw or formatted header. Allways call |
583 | * vbi_fetch_vt_page() for proper translation of national characters |
584 | * and character attributes, the raw header is only provided here |
585 | * as a means to quickly detect changes. |
586 | */ |
587 | #define VBI_EVENT_TTX_PAGE 0x0002 |
588 | /** |
589 | * A Closed Caption page has changed and needs visual update. |
590 | * The page or "CC channel" is designated by ev.caption.pgno, |
591 | * see vbi_pgno for details. |
592 | * |
593 | * When the client is monitoring this page, the expected action is |
594 | * to call vbi_fetch_cc_page(). To speed up rendering more detailed |
595 | * update information is provided in vbi_page.dirty, see #vbi_page. |
596 | * The vbi_page will be a snapshot of the status at fetch time |
597 | * and not event time, vbi_page.dirty accumulates all changes since |
598 | * the last fetch. |
599 | */ |
600 | #define VBI_EVENT_CAPTION 0x0004 |
601 | /** |
602 | * Some station/network identifier has been received or is no longer |
603 | * transmitted (vbi_network all zero, eg. after a channel switch). |
604 | * ev.network is a vbi_network object, read only. The event will not |
605 | * repeat*) unless a different identifier has been received and confirmed. |
606 | * |
607 | * Minimum time to identify network, when data service is transmitted: |
608 | * <table> |
609 | * <tr><td>VPS (DE/AT/CH only):</td><td>0.08 s</td></tr> |
610 | * <tr><td>Teletext PDC, 8/30:</td><td>2 s</td></tr> |
611 | * <tr><td>XDS (US only):</td><td>unknown, between 0.1x to 10x seconds</td></tr> |
612 | * </table> |
613 | * |
614 | * *) VPS/TTX and XDS will not combine in real life, feeding the decoder |
615 | * with artificial data can confuse the logic. |
616 | */ |
617 | #define VBI_EVENT_NETWORK 0x0008 |
618 | /** |
619 | * @anchor VBI_EVENT_TRIGGER |
620 | * |
621 | * Triggers are sent by broadcasters to start some action on the |
622 | * user interface of modern TVs. Until libzvbi implements all ;-) of |
623 | * WebTV and SuperTeletext the information available are program |
624 | * related (or unrelated) URLs, short messages and Teletext |
625 | * page links. |
626 | * |
627 | * This event is sent when a trigger has fired, ev.trigger |
628 | * points to a vbi_link structure describing the link in detail. |
629 | * The structure must be read only. |
630 | */ |
631 | #define VBI_EVENT_TRIGGER 0x0010 |
632 | /** |
633 | * @anchor VBI_EVENT_ASPECT |
634 | * |
635 | * The vbi decoder received new information (potentially from |
636 | * PAL WSS, NTSC XDS or EIA-J CPR-1204) about the program |
637 | * aspect ratio. ev.ratio is a pointer to a vbi_ratio structure. |
638 | * The structure must be read only. |
639 | */ |
640 | #define VBI_EVENT_ASPECT 0x0040 |
641 | /** |
642 | * We have new information about the current or next program. |
643 | * ev.prog_info is a vbi_program_info pointer (due to size), read only. |
644 | * |
645 | * Preliminary. |
646 | * |
647 | * XXX Info from Teletext not implemented yet. |
648 | * XXX Change to get_prog_info. network ditto? |
649 | */ |
650 | #define VBI_EVENT_PROG_INFO 0x0080 |
651 | /** |
652 | * Like @a VBI_EVENT_NETWORK, but this event will also be sent |
653 | * when the decoder cannot determine a network name. |
654 | * |
655 | * @since 0.2.20 |
656 | */ |
657 | #define VBI_EVENT_NETWORK_ID 0x0100 |
658 | #define VBI_EVENT_RATING 0x0200 |
659 | /** @} */ |
660 | |
661 | /** |
662 | * @example examples/network.c |
663 | * Network identification example. |
664 | */ |
665 | |
666 | #include <inttypes.h> |
667 | |
668 | /** |
669 | * @ingroup Event |
670 | * @brief Event union. |
671 | */ |
672 | /* XXX network, aspect, prog_info: should only notify about |
673 | * changes and provide functions to query current value. |
674 | */ |
675 | typedef struct vbi_event { |
676 | int type; |
677 | union { |
678 | struct { |
679 | int pgno; |
680 | int subno; |
681 | uint8_t * raw_header; |
682 | int pn_offset; |
683 | unsigned int roll_header : 1; |
684 | unsigned int header_update : 1; |
685 | unsigned int clock_update : 1; |
686 | } ttx_page; |
687 | struct { |
688 | int pgno; |
689 | } caption; |
690 | vbi_network network; |
691 | vbi_link * trigger; |
692 | vbi_aspect_ratio aspect; |
693 | vbi_program_info * prog_info; |
694 | } ev; |
695 | } vbi_event; |
696 | |
697 | /** |
698 | * @addtogroup Event |
699 | * @{ |
700 | */ |
701 | typedef void (* vbi_event_handler)(vbi_event *event, void *user_data); |
702 | |
703 | extern vbi_bool vbi_event_handler_add(vbi_decoder *vbi, int event_mask, |
704 | vbi_event_handler handler, |
705 | void *user_data); |
706 | extern void vbi_event_handler_remove(vbi_decoder *vbi, |
707 | vbi_event_handler handler); |
708 | extern vbi_bool vbi_event_handler_register(vbi_decoder *vbi, int event_mask, |
709 | vbi_event_handler handler, |
710 | void *user_data); |
711 | extern void vbi_event_handler_unregister(vbi_decoder *vbi, |
712 | vbi_event_handler handler, |
713 | void *user_data); |
714 | /** @} */ |
715 | |
716 | /* Private */ |
717 | |
718 | extern void vbi_send_event(vbi_decoder *vbi, vbi_event *ev); |
719 | |
720 | #endif /* EVENT_H */ |
721 | |
722 | /* |
723 | Local variables: |
724 | c-set-style: K&R |
725 | c-basic-offset: 8 |
726 | End: |
727 | */ |
728 |