[dvblast-devel] [PATCH 3/5] dvb/si: Add support for descriptor 0x54 (Content descriptor).

Georgi Chorbadzhiyski gf at unixsol.org
Mon Sep 19 19:57:26 CEST 2011


---
 dvb/si.h       |   93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 dvb/si_print.h |    1 +
 2 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/dvb/si.h b/dvb/si.h
index 5541556..6f8a530 100644
--- a/dvb/si.h
+++ b/dvb/si.h
@@ -1017,6 +1017,99 @@ static inline void desc52_print(const uint8_t *p_desc, f_print pf_print,
 }
 
 /*****************************************************************************
+ * Descriptor 0x54: Content descriptor
+ *****************************************************************************/
+#define DESC54_HEADER_SIZE      DESC_HEADER_SIZE
+#define DESC54_CONTENT_SIZE     2
+
+static inline void desc54_init(uint8_t *p_desc)
+{
+    desc_set_tag(p_desc, 0x54);
+}
+
+static inline uint8_t *desc54_get_content(uint8_t *p_desc, uint8_t n)
+{
+    uint8_t *p_desc_n = p_desc + DESC54_HEADER_SIZE + n * DESC54_CONTENT_SIZE;
+    if (p_desc_n + DESC54_CONTENT_SIZE - p_desc
+         > desc_get_length(p_desc) + DESC54_HEADER_SIZE)
+        return NULL;
+    return p_desc_n;
+}
+
+static inline uint8_t desc54n_get_content_l1(uint8_t *p_desc_n)
+{
+    return p_desc_n[0] >> 4;
+}
+
+static inline void desc54n_set_content_l1(uint8_t *p_desc_n, uint8_t i_content_l1)
+{
+    p_desc_n[0] |= i_content_l1 << 4;
+}
+
+static inline uint8_t desc54n_get_content_l2(uint8_t *p_desc_n)
+{
+    return p_desc_n[0] & 0x0f;
+}
+
+static inline void desc54n_set_content_l2(uint8_t *p_desc_n, uint8_t i_content_l2)
+{
+    p_desc_n[0] |= i_content_l2 & 0x0f;
+}
+
+static inline uint8_t desc54n_get_user_l1(uint8_t *p_desc_n)
+{
+    return p_desc_n[1] >> 4;
+}
+
+static inline void desc54n_set_user_l1(uint8_t *p_desc_n, uint8_t i_user_l1)
+{
+    p_desc_n[1] |= i_user_l1 << 4;
+}
+
+static inline uint8_t desc54n_get_user_l2(uint8_t *p_desc_n)
+{
+    return p_desc_n[1] & 0x0f;
+}
+
+static inline void desc54n_set_user_l2(uint8_t *p_desc_n, uint8_t i_user_l2)
+{
+    p_desc_n[1] |= i_user_l2 & 0x0f;
+}
+
+static inline bool desc54_validate(const uint8_t *p_desc)
+{
+    return !(desc_get_length(p_desc) % DESC54_CONTENT_SIZE);
+}
+
+static inline void desc54_print(uint8_t *p_desc, f_print pf_print,
+                                void *opaque, print_type_t i_print_type)
+{
+    uint8_t j = 0;
+    uint8_t *p_desc_n;
+
+    while ((p_desc_n = desc54_get_content(p_desc, j)) != NULL) {
+        j++;
+        switch (i_print_type) {
+        case PRINT_XML:
+            pf_print(opaque, "<CONTENT_DESC content_l1=\"%u\" content_l2=\"%u\" user_l1=\"%u\" user_l2=\"%u\"/>",
+                     desc54n_get_content_l1(p_desc_n),
+                     desc54n_get_content_l2(p_desc_n),
+                     desc54n_get_user_l1(p_desc_n),
+                     desc54n_get_user_l2(p_desc_n)
+                    );
+            break;
+        default:
+            pf_print(opaque,"    - desc 54 content content_l1=%u content_l2=%u user_l1=%u user_l2=%u",
+                     desc54n_get_content_l1(p_desc_n),
+                     desc54n_get_content_l2(p_desc_n),
+                     desc54n_get_user_l1(p_desc_n),
+                     desc54n_get_user_l2(p_desc_n)
+                    );
+        }
+    }
+}
+
+/*****************************************************************************
  * Descriptor 0x56: Teletext descriptor
  *****************************************************************************/
 #define DESC56_HEADER_SIZE      DESC46_HEADER_SIZE
diff --git a/dvb/si_print.h b/dvb/si_print.h
index dfe8acf..e45a3a6 100644
--- a/dvb/si_print.h
+++ b/dvb/si_print.h
@@ -114,6 +114,7 @@ static inline void descs_print(uint8_t *p_descs,
         CASE_DESC(4a)
         CASE_DESC_ICONV(4d)
         CASE_DESC(52)
+        CASE_DESC(54)
         CASE_DESC(56)
         CASE_DESC(59)
         CASE_DESC(5a)
-- 
1.7.5.1



More information about the dvblast-devel mailing list