[dvblast-devel] [PATCH 11/17] mpeg/psi: Add support for descriptor 0x0C (Multiplex buffer).

Georgi Chorbadzhiyski gf at unixsol.org
Fri Sep 9 23:28:33 CEST 2011


---
 dvb/si_print.h |    1 +
 mpeg/psi.h     |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/dvb/si_print.h b/dvb/si_print.h
index a22765d..ddccad3 100644
--- a/dvb/si_print.h
+++ b/dvb/si_print.h
@@ -98,6 +98,7 @@ static inline void descs_print(uint8_t *p_descs,
         CASE_DESC(09)
         CASE_DESC(0a)
         CASE_DESC(0b)
+        CASE_DESC(0c)
         CASE_DESC_ICONV(40)
         CASE_DESC(41)
         CASE_DESC(43)
diff --git a/mpeg/psi.h b/mpeg/psi.h
index 1a057b9..0bd9929 100644
--- a/mpeg/psi.h
+++ b/mpeg/psi.h
@@ -517,6 +517,72 @@ static inline void desc0b_print(const uint8_t *p_desc, f_print pf_print,
 }
 
 /*****************************************************************************
+ * Descriptor 0x0C: Multiplex buffer utilization descriptor
+ *****************************************************************************/
+#define DESC0C_HEADER_SIZE      (DESC_HEADER_SIZE + 4)
+
+static inline void desc0c_init(uint8_t *p_desc)
+{
+    desc_set_tag(p_desc, 0x0c);
+    desc_set_length(p_desc, DESC0C_HEADER_SIZE - DESC_HEADER_SIZE);
+}
+
+static inline bool desc0c_get_bound_valid(const uint8_t *p_desc)
+{
+    return ((p_desc[2] & 0x80) == 0x80);
+}
+
+static inline void desc0c_set_bound_valid(uint8_t *p_desc, bool bound_valid)
+{
+    p_desc[2] |= (!!bound_valid << 7);
+}
+
+static inline uint16_t desc0c_get_LTW_offset_lower_bound(const uint8_t *p_desc)
+{
+    return ((p_desc[2] & 0x7f) << 8) | p_desc[3]; // 1xxxxxxx xxxxxxxx
+}
+
+static inline void desc0c_set_LTW_offset_lower_bound(uint8_t *p_desc, uint16_t LTW_offset_lower_bound)
+{
+    p_desc[2] = (LTW_offset_lower_bound & 0xff00) >> 8 | 0xf0;
+    p_desc[3] = (LTW_offset_lower_bound & 0xff);
+}
+
+static inline uint16_t desc0c_get_LTW_offset_upper_bound(const uint8_t *p_desc)
+{
+    return ((p_desc[4] & 0x7f) << 8) | p_desc[5]; // 1xxxxxxx xxxxxxxx
+}
+
+static inline void desc0c_set_LTW_offset_upper_bound(uint8_t *p_desc, uint16_t LTW_offset_upper_bound)
+{
+    p_desc[4] = (LTW_offset_upper_bound & 0xff00) >> 8 | 0xf0;
+    p_desc[5] = (LTW_offset_upper_bound & 0xff);
+}
+
+static inline bool desc0c_validate(const uint8_t *p_desc)
+{
+    return desc_get_length(p_desc) >= DESC0C_HEADER_SIZE - DESC_HEADER_SIZE;
+}
+
+static inline void desc0c_print(const uint8_t *p_desc, f_print pf_print,
+                                void *opaque, print_type_t i_print_type)
+{
+    switch (i_print_type) {
+    case PRINT_XML:
+        pf_print(opaque, "<MULTIPLEX_BUFFER_UTILIZATION_DESC bound_valid=\"%u\" LTW_offset_lower_bound=\"%u\" LTW_offset_upper_bound=\"%u\"/>",
+                 desc0c_get_bound_valid(p_desc),
+                 desc0c_get_LTW_offset_lower_bound(p_desc),
+                 desc0c_get_LTW_offset_upper_bound(p_desc));
+        break;
+    default:
+        pf_print(opaque, "    - desc 0c bound_valid=%u LTW_offset_lower_bound=%u LTW_offset_upper_bound=%u",
+                 desc0c_get_bound_valid(p_desc),
+                 desc0c_get_LTW_offset_lower_bound(p_desc),
+                 desc0c_get_LTW_offset_upper_bound(p_desc));
+    }
+}
+
+/*****************************************************************************
  * Descriptors list
  *****************************************************************************/
 #define DESCS_HEADER_SIZE       2
-- 
1.7.5.1



More information about the dvblast-devel mailing list