[libdvbpsi-devel] add support for parsing caption service descriptor 0x86

Michael Krufky git at videolan.org
Tue Feb 4 11:21:56 CET 2014


libdvbpsi | branch: master | Michael Krufky <mkrufky at linuxtv.org> | Sat May 18 09:27:45 2013 -0400| [be8f6af07463dadc75b65e980d9d46b3b891cab1] | committer: Jean-Paul Saman

add support for parsing caption service descriptor 0x86

Signed-off-by: Michael Krufky <mkrufky at linuxtv.org>

> http://git.videolan.org/gitweb.cgi/libdvbpsi.git/?a=commit;h=be8f6af07463dadc75b65e980d9d46b3b891cab1
---

 src/Makefile.am         |    2 +
 src/descriptors/dr_86.c |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 src/descriptors/dr_86.h |   98 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 203 insertions(+)

diff --git a/src/Makefile.am b/src/Makefile.am
index 459c1aa..e8a0b6c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -67,6 +67,7 @@ pkginclude_HEADERS = dvbpsi.h psi.h descriptor.h demux.h \
                      descriptors/dr_76.h \
                      descriptors/dr_7c.h \
 		     descriptors/dr_83.h \
+		     descriptors/dr_86.h \
 		     descriptors/dr_8a.h \
                      descriptors/dr.h
 
@@ -117,6 +118,7 @@ descriptors_src = descriptors/dr_02.c \
                   descriptors/dr_76.c \
                   descriptors/dr_7c.c \
                   descriptors/dr_83.c \
+                  descriptors/dr_86.c \
 		  descriptors/dr_8a.c
 
 tables_src = tables/pat.c tables/pat_private.h \
diff --git a/src/descriptors/dr_86.c b/src/descriptors/dr_86.c
new file mode 100644
index 0000000..4d781a4
--- /dev/null
+++ b/src/descriptors/dr_86.c
@@ -0,0 +1,103 @@
+/*
+Copyright (C) 2013  Michael Krufky
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+dr_86.c
+
+Decode Caption Service Descriptor.
+
+*/
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+#if defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#elif defined(HAVE_STDINT_H)
+#include <stdint.h>
+#endif
+
+#include "../dvbpsi.h"
+#include "../dvbpsi_private.h"
+#include "../descriptor.h"
+
+#include "dr_86.h"
+
+/*****************************************************************************
+ * dvbpsi_DecodeCaptionServiceDr
+ *****************************************************************************/
+dvbpsi_caption_service_dr_t *dvbpsi_DecodeCaptionServiceDr(dvbpsi_descriptor_t *p_descriptor)
+{
+    dvbpsi_caption_service_dr_t *p_decoded;
+    uint8_t * buf = p_descriptor->p_data;
+
+    /* Check the tag */
+    if (p_descriptor->i_tag != 0x86)
+        return NULL;
+
+    /* Don't decode twice */
+    if (p_descriptor->p_decoded)
+        return p_descriptor->p_decoded;
+
+    /* Check length */
+    if ((p_descriptor->i_length - 1) % 6)
+        return NULL;
+
+    p_decoded = (dvbpsi_caption_service_dr_t*)malloc(sizeof(dvbpsi_caption_service_dr_t));
+    if (!p_decoded)
+        return NULL;
+
+    p_descriptor->p_decoded = (void*)p_decoded;
+
+    p_decoded->p_first_service = NULL;
+
+    p_decoded->i_number_of_services = 0x1f & buf[0];
+    buf++;
+
+    for (int i = 0; i < p_decoded->i_number_of_services; i++)
+    {
+        dvbpsi_caption_service_t * p_service =
+            (dvbpsi_caption_service_t*)malloc(sizeof(dvbpsi_caption_service_t));
+
+        if (!p_service) return NULL;
+
+        memset(p_service, 0, sizeof(dvbpsi_caption_service_t));
+
+        memcpy(p_service->i_iso_639_code, buf, 3);
+        buf += 3;
+        p_service->b_digital_cc             = 0x01 & (buf[0] >> 7);
+        p_service->b_line21_field           = 0x01 &  buf[0];
+        p_service->i_caption_service_number = (p_service->b_digital_cc) ? 0x3F &  buf[0] : 0;
+        buf++;
+        p_service->b_easy_reader            = 0x01 & (buf[0] >> 7);
+        p_service->b_wide_aspect_ratio      = 0x01 & (buf[0] >> 6);
+
+        if (p_decoded->p_first_service == NULL)
+            p_decoded->p_first_service = p_service;
+        else
+        {
+            dvbpsi_caption_service_t* p_last_service = p_decoded->p_first_service;
+            while (p_last_service->p_next != NULL)
+              p_last_service = p_last_service->p_next;
+            p_last_service->p_next = p_service;
+        }
+        buf += 2;
+    }
+    return p_decoded;
+}
diff --git a/src/descriptors/dr_86.h b/src/descriptors/dr_86.h
new file mode 100644
index 0000000..ceaf80d
--- /dev/null
+++ b/src/descriptors/dr_86.h
@@ -0,0 +1,98 @@
+/*
+Copyright (C) 2013  Michael Krufky
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+dr_86.h
+
+Decode Caption Service Descriptor.
+
+*/
+
+/*!
+ * \file dr_86.h
+ * \author Michael Krufky
+ * \brief Decode Caption Service Descriptor.
+ */
+
+#ifndef _DR_86_H
+#define _DR_86_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ * dvbpsi_caption_service_t
+ *****************************************************************************/
+/*!
+ * \struct dvbpsi_caption_service_s
+ * \brief Caption Service
+ *
+ * This structure is used to store a decoded Caption Service.
+ */
+/*!
+ * \typedef struct dvbpsi_caption_service_s dvbpsi_caption_service_t
+ * \brief dvbpsi_caption_service_t type definition.
+ */
+typedef struct dvbpsi_caption_service_s
+{
+    char     i_iso_639_code[3];
+    int      b_digital_cc;
+    int      b_line21_field;
+    uint16_t i_caption_service_number;
+    int      b_easy_reader;
+    int      b_wide_aspect_ratio;
+
+    struct dvbpsi_caption_service_s *p_next;
+}dvbpsi_caption_service_t;
+
+/*****************************************************************************
+ * dvbpsi_caption_service_dr_s
+ *****************************************************************************/
+/*!
+ * \struct dvbpsi_caption_service_dr_s
+ * \brief Caption Service Descriptor
+ *
+ * This structure is used to store a decoded Caption Service descriptor.
+ */
+/*!
+ * \typedef struct dvbpsi_caption_service_dr_s dvbpsi_caption_service_dr_t
+ * \brief dvbpsi_caption_service_dr_t type definition.
+ */
+typedef struct dvbpsi_caption_service_dr_s
+{
+    uint8_t i_number_of_services;
+    dvbpsi_caption_service_t *p_first_service;
+}dvbpsi_caption_service_dr_t;
+
+/*****************************************************************************
+ * dvbpsi_DecodeCaptionServiceDr
+ *****************************************************************************/
+/*!
+ * \fn dvbpsi_caption_service_dr_t dvbpsi_DecodeCaptionServiceDr(dvbpsi_descriptor_t *p_descriptor)
+ * \brief Decode a Caption Service descriptor (tag 0x86)
+ * \param p_descriptor Raw descriptor to decode.
+ * \return NULL if the descriptor could not be decoded or a pointer to a
+ *         dvbpsi_caption_service_dr_t structure.
+ */
+dvbpsi_caption_service_dr_t *dvbpsi_DecodeCaptionServiceDr(dvbpsi_descriptor_t *p_descriptor);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+



More information about the libdvbpsi-devel mailing list