[dvblast-devel] [PATCH 2/5] dvb/si: Add support for descriptor 0x4d (Short event descriptor).
Georgi Chorbadzhiyski
gf at unixsol.org
Mon Sep 19 19:57:25 CEST 2011
---
dvb/si.h | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
dvb/si_print.h | 1 +
2 files changed, 103 insertions(+), 0 deletions(-)
diff --git a/dvb/si.h b/dvb/si.h
index bb88112..5541556 100644
--- a/dvb/si.h
+++ b/dvb/si.h
@@ -875,6 +875,108 @@ static inline void desc4a_print(const uint8_t *p_desc, f_print pf_print,
}
/*****************************************************************************
+ * Descriptor 0x4d: Short event descriptor
+ *****************************************************************************/
+#define DESC4D_HEADER_SIZE (DESC_HEADER_SIZE + 3)
+
+static inline void desc4d_init(uint8_t *p_desc)
+{
+ desc_set_tag(p_desc, 0x4d);
+}
+
+static inline const uint8_t *desc4d_get_lang(const uint8_t *p_desc)
+{
+ return p_desc + DESC_HEADER_SIZE;
+}
+
+static inline void desc4d_set_lang(uint8_t *p_desc, const uint8_t p_lang[3])
+{
+ p_desc[2] = p_lang[0];
+ p_desc[3] = p_lang[1];
+ p_desc[4] = p_lang[2];
+}
+
+static inline const uint8_t *desc4d_get_event_name(const uint8_t *p_desc,
+ uint8_t *pi_length)
+{
+ const uint8_t *p = p_desc + DESC4D_HEADER_SIZE;
+ *pi_length = p[0];
+ return p + 1;
+}
+
+static inline void desc4d_set_event_name(uint8_t *p_desc,
+ const uint8_t *p_event_name,
+ uint8_t i_length)
+{
+ uint8_t *p = p_desc + DESC4D_HEADER_SIZE;
+ p[0] = i_length;
+ memcpy(p + 1, p_event_name, i_length);
+}
+
+static inline uint8_t *desc4d_get_text(const uint8_t *p_desc,
+ uint8_t *pi_length)
+{
+ const uint8_t *p = (uint8_t *)p_desc + DESC4D_HEADER_SIZE + 1 + p_desc[5];
+ *pi_length = p[0];
+ return (uint8_t *)p + 1;
+}
+
+static inline void desc4d_set_text(uint8_t *p_desc,
+ const uint8_t *p_text,
+ uint8_t i_length)
+{
+ uint8_t *p = p_desc + DESC4D_HEADER_SIZE + 1 + p_desc[5];
+ p[0] = i_length;
+ memcpy(p + 1, p_text, i_length);
+}
+
+static inline bool desc4d_validate(const uint8_t *p_desc)
+{
+ uint8_t i_length = desc_get_length(p_desc);
+ const uint8_t *p = p_desc + DESC4D_HEADER_SIZE;
+
+ p += *p + 1;
+ if (DESC4D_HEADER_SIZE + 2 > i_length + DESC_HEADER_SIZE ||
+ p + 1 - p_desc > i_length + DESC_HEADER_SIZE)
+ return false;
+
+ p += *p + 1;
+ if (p - p_desc > i_length + DESC_HEADER_SIZE)
+ return false;
+
+ return true;
+}
+
+static inline void desc4d_print(const uint8_t *p_desc,
+ f_print pf_print, void *print_opaque,
+ f_iconv pf_iconv, void *iconv_opaque,
+ print_type_t i_print_type)
+{
+ uint8_t i_event_name_length, i_text_length;
+ const uint8_t *p_event_name = desc4d_get_event_name(p_desc, &i_event_name_length);
+ const uint8_t *p_text = desc4d_get_text(p_desc, &i_text_length);
+ char *psz_event_name = dvb_string_get(p_event_name, i_event_name_length,
+ pf_iconv, iconv_opaque);
+ char *psz_text = dvb_string_get(p_text, i_text_length,
+ pf_iconv, iconv_opaque);
+ switch (i_print_type) {
+ case PRINT_XML:
+ psz_event_name = dvb_string_xml_escape(psz_event_name);
+ psz_text = dvb_string_xml_escape(psz_text);
+ pf_print(print_opaque,
+ "<SHORT_EVENT_DESC lang=\"%3.3s\" event_name=\"%s\" text=\"%s\"/>",
+ (char *)desc4d_get_lang(p_desc), psz_event_name, psz_text);
+ break;
+ default:
+ pf_print(print_opaque,
+ " - desc 4d short_event lang=%3.3s event_name=\"%s\" text=\"%s\"",
+ (char *)desc4d_get_lang(p_desc), psz_event_name, psz_text);
+ }
+ free(psz_event_name);
+ free(psz_text);
+}
+
+/*****************************************************************************
* Descriptor 0x52: Stream identifier descriptor
*****************************************************************************/
#define DESC52_HEADER_SIZE (DESC_HEADER_SIZE + 1)
diff --git a/dvb/si_print.h b/dvb/si_print.h
index 058f332..dfe8acf 100644
--- a/dvb/si_print.h
+++ b/dvb/si_print.h
@@ -112,6 +112,7 @@ static inline void descs_print(uint8_t *p_descs,
CASE_DESC_ICONV(47)
CASE_DESC_ICONV(48)
CASE_DESC(4a)
+ CASE_DESC_ICONV(4d)
CASE_DESC(52)
CASE_DESC(56)
CASE_DESC(59)
--
1.7.5.1
More information about the dvblast-devel
mailing list