[dvblast-devel] [PATCH 08/17] mpeg/psi: Add support for descriptor 0x03 (Audio stream).

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


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

diff --git a/dvb/si_print.h b/dvb/si_print.h
index 9989f54..1361923 100644
--- a/dvb/si_print.h
+++ b/dvb/si_print.h
@@ -92,6 +92,7 @@ static inline void descs_print(uint8_t *p_descs,
             break;
 
         CASE_DESC(02)
+        CASE_DESC(03)
         CASE_DESC(05)
         CASE_DESC(09)
         CASE_DESC(0a)
diff --git a/mpeg/psi.h b/mpeg/psi.h
index 410d98a..fe49180 100644
--- a/mpeg/psi.h
+++ b/mpeg/psi.h
@@ -234,6 +234,56 @@ static inline void desc02_print(const uint8_t *p_desc, f_print pf_print,
 }
 
 /*****************************************************************************
+ * Descriptor 0x03: Audio stream descriptor
+ *****************************************************************************/
+#define DESC03_HEADER_SIZE      (DESC_HEADER_SIZE + 1)
+
+static inline bool desc03_validate(const uint8_t *p_desc)
+{
+    return desc_get_length(p_desc) >= DESC02_HEADER_SIZE - DESC_HEADER_SIZE;
+}
+
+static inline const char *desc03_get_layer_txt(const uint8_t layer) {
+    return layer == 0 ? "reserved" :
+           layer == 1 ? "Layer III" :
+           layer == 2 ? "Layer II" :
+           layer == 3 ? "Layer I" : "reserved";
+}
+
+static inline const char *desc03_get_ID_txt(const uint8_t ID) {
+    return ID ? "MPEG Audio" : "Other";
+}
+
+static inline void desc03_print(const uint8_t *p_desc, f_print pf_print,
+                                void *opaque, print_type_t i_print_type)
+{
+    uint8_t free_format_flag = (p_desc[2] & 0x80) == 0x80;  // bit_8
+    uint8_t ID               = (p_desc[2] & 0x40) == 0x40;  // bit_7
+    uint8_t layer            = (p_desc[2] &~ 0xcf) >> 4;    // 11xx1111
+    uint8_t vbr_flag         = (p_desc[2] & 0x08) == 0x08;  // bit_4
+
+    switch (i_print_type) {
+    case PRINT_XML:
+        pf_print(opaque,
+            "<AUDIO_STREAM_DESC free_format_tag=\"%u\" ID=\"%u\" layer=\"%u\""
+            " ID_txt=\"%s\" layer_txt=\"%s\" vbr_audio_flag=\"%u\"/>",
+                 free_format_flag, ID, layer,
+                 desc03_get_ID_txt(ID), desc03_get_layer_txt(layer),
+                 vbr_flag
+        );
+        break;
+    default:
+        pf_print(opaque,
+            "    - desc 03 free_format_tag=%u ID=%u layer=%u"
+            " ID_txt=%s layer_txt=%s vbr_audio_flag=%u",
+                 free_format_flag, ID, layer,
+                 desc03_get_ID_txt(ID), desc03_get_layer_txt(layer),
+                 vbr_flag
+        );
+    }
+}
+
+/*****************************************************************************
  * Descriptor 0x05: Registration descriptor
  *****************************************************************************/
 #define DESC05_HEADER_SIZE      (DESC_HEADER_SIZE + 4)
-- 
1.7.5.1



More information about the dvblast-devel mailing list