[dvblast-devel] [PATCH 05/17] dvb/si: Add support for BAT (Bouquet Association Table).
Georgi Chorbadzhiyski
gf at unixsol.org
Fri Sep 9 23:28:27 CEST 2011
---
dvb/si.h | 41 +++++++++++++++++++++++++++++++++
dvb/si_print.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+), 0 deletions(-)
diff --git a/dvb/si.h b/dvb/si.h
index a983498..a83c9a7 100644
--- a/dvb/si.h
+++ b/dvb/si.h
@@ -1478,6 +1478,47 @@ static inline bool nit_table_validate(uint8_t **pp_sections)
}
/*****************************************************************************
+ * Bouquet Association Table
+ *****************************************************************************/
+#define BAT_PID 0x11
+#define BAT_TABLE_ID 0x4a
+#define BAT_HEADER_SIZE (PSI_HEADER_SIZE_SYNTAX1 + 2)
+#define BAT_HEADER2_SIZE 2
+#define NAT_TS_SIZE 6
+
+#define bat_set_bouquet_id psi_set_tableidext
+#define bat_get_bouquet_id psi_get_tableidext
+
+static inline void bat_init(uint8_t *p_bat)
+{
+ psi_init(p_bat, true);
+ psi_set_tableid(p_bat, BAT_TABLE_ID);
+ p_bat[8] = 0xf0;
+}
+
+#define bat_set_length nit_set_length
+#define bat_set_desclength nit_set_desclength
+#define bat_get_desclength nit_get_desclength
+#define bat_get_descs nit_get_descs
+#define bath_init nith_init
+#define bath_set_tslength nith_set_tslength
+#define bath_get_tslength nith_get_tslength
+#define batn_init nitn_init
+#define batn_set_tsid nitn_set_tsid
+#define batn_get_tsid nitn_get_tsid
+#define batn_set_onid nitn_set_onid
+#define batn_get_onid nitn_get_onid
+#define batn_set_desclength nitn_set_desclength
+#define batn_get_desclength nitn_get_desclength
+#define batn_get_descs nitn_get_descs
+#define batn_get_header2 nitn_get_header2
+#define bat_get_ts nit_get_ts
+#define bat_validate_ts nit_validate_ts
+#define bat_validate nit_validate
+#define bat_table_find_ts nit_table_find_ts
+#define bat_table_validate nit_table_validate
+
+/*****************************************************************************
* Service Description Table
*****************************************************************************/
#define SDT_PID 0x11
diff --git a/dvb/si_print.h b/dvb/si_print.h
index f0b02d9..fab2608 100644
--- a/dvb/si_print.h
+++ b/dvb/si_print.h
@@ -198,6 +198,74 @@ static inline void nit_table_print(uint8_t **pp_sections,
}
/*****************************************************************************
+ * Bouquet Association Table
+ *****************************************************************************/
+static inline void bat_table_print(uint8_t **pp_sections,
+ f_print pf_print, void *print_opaque,
+ f_iconv pf_iconv, void *iconv_opaque,
+ print_type_t i_print_type)
+{
+ uint8_t i_last_section = psi_table_get_lastsection(pp_sections);
+ uint8_t i;
+
+ switch (i_print_type) {
+ case PRINT_XML:
+ pf_print(print_opaque, "<BAT tid=\"%hhu\" networkid=\"%hu\" version=\"%hhu\" current_next=\"%d\">",
+ psi_table_get_tableid(pp_sections),
+ psi_table_get_tableidext(pp_sections),
+ psi_table_get_version(pp_sections),
+ !psi_table_get_current(pp_sections) ? 0 : 1);
+ break;
+ default:
+ pf_print(print_opaque, "new BAT networkid=%hu version=%hhu%s",
+ psi_table_get_tableidext(pp_sections),
+ psi_table_get_version(pp_sections),
+ !psi_table_get_current(pp_sections) ? " (next)" : "");
+ }
+
+ descs_print(bat_get_descs(psi_table_get_section(pp_sections, 0)),
+ pf_print, print_opaque, pf_iconv, iconv_opaque, i_print_type);
+
+ for (i = 0; i <= i_last_section; i++) {
+ uint8_t *p_section = psi_table_get_section(pp_sections, i);
+ uint8_t *p_ts;
+ int j = 0;
+
+ while ((p_ts = bat_get_ts(p_section, j)) != NULL) {
+ j++;
+ switch (i_print_type) {
+ case PRINT_XML:
+ pf_print(print_opaque, "<TS tsid=\"%hu\" onid=\"%hu\">",
+ batn_get_tsid(p_ts), batn_get_onid(p_ts));
+ break;
+ default:
+ pf_print(print_opaque, " * ts tsid=%hu onid=%hu",
+ batn_get_tsid(p_ts), batn_get_onid(p_ts));
+ }
+
+ descs_print(batn_get_descs(p_ts), pf_print, print_opaque,
+ pf_iconv, iconv_opaque, i_print_type);
+
+ switch (i_print_type) {
+ case PRINT_XML:
+ pf_print(print_opaque, "</TS>");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ switch (i_print_type) {
+ case PRINT_XML:
+ pf_print(print_opaque, "</BAT>");
+ break;
+ default:
+ pf_print(print_opaque, "end BAT");
+ }
+}
+
+/*****************************************************************************
* Service Description Table
*****************************************************************************/
static inline void sdt_table_print(uint8_t **pp_sections,
--
1.7.5.1
More information about the dvblast-devel
mailing list