[libdvbpsi-devel] descriptors/dr_83: Add support for generation of Logical Channel Number descriptor

mbenoit git at videolan.org
Wed Dec 24 12:51:56 CET 2014


libdvbpsi | branch: master | mbenoit <mbenoit at anevia.com> | Mon Dec 15 22:01:59 2014 +0100| [dc60d88e8b2a61eabfb2c15d4e2a13120a32711d] | committer: Jean-Paul Saman

descriptors/dr_83: Add support for generation of Logical Channel Number descriptor

Signed-off-by: Jean-Paul Saman <jpsaman at videolan.org>

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

 src/descriptors/dr_83.c |   31 +++++++++++++++++++++++++++++++
 src/descriptors/dr_83.h |   17 ++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/src/descriptors/dr_83.c b/src/descriptors/dr_83.c
index ce7bc27..6b1fa5e 100644
--- a/src/descriptors/dr_83.c
+++ b/src/descriptors/dr_83.c
@@ -83,3 +83,34 @@ dvbpsi_lcn_dr_t *dvbpsi_DecodeLCNDr(dvbpsi_descriptor_t *p_descriptor)
 
     return p_decoded;
 }
+
+/*****************************************************************************
+ * dvbpsi_GenLCNDr
+ *****************************************************************************/
+dvbpsi_descriptor_t* dvbpsi_GenLCNDr(dvbpsi_lcn_dr_t* p_decoded,
+                                       bool b_duplicate)
+{
+  dvbpsi_descriptor_t* p_descriptor = dvbpsi_NewDescriptor(0x83, p_decoded->i_number_of_entries * 4, 0);
+  if (NULL == p_descriptor) {
+    return NULL;
+  }
+
+  for (int i = 0; i < p_decoded->i_number_of_entries; i++ )
+  {
+    p_descriptor->p_data[4 * i] = p_decoded->p_entries[i].i_service_id >> 8;
+    p_descriptor->p_data[4 * i + 1] = p_decoded->p_entries[i].i_service_id;
+    p_descriptor->p_data[4 * i + 2] = (p_decoded->p_entries[i].b_visible_service_flag << 7);
+    p_descriptor->p_data[4 * i + 2] |= (p_decoded->p_entries[i].i_logical_channel_number >> 8);
+    p_descriptor->p_data[4 * i + 3] = p_decoded->p_entries[i].i_logical_channel_number;
+  }
+
+  if (b_duplicate)
+  {
+    dvbpsi_lcn_dr_t * p_dup = (dvbpsi_lcn_dr_t*) malloc(sizeof (dvbpsi_lcn_dr_t));
+    if (NULL != p_dup)
+      memcpy(p_dup, p_decoded, sizeof(dvbpsi_lcn_dr_t));
+    p_descriptor->p_decoded = (void*)p_dup;
+  }
+
+  return p_descriptor;
+}
\ No newline at end of file
diff --git a/src/descriptors/dr_83.h b/src/descriptors/dr_83.h
index 0ec4f6a..f0bd762 100644
--- a/src/descriptors/dr_83.h
+++ b/src/descriptors/dr_83.h
@@ -85,9 +85,24 @@ typedef struct dvbpsi_lcn_dr_s
  */
 dvbpsi_lcn_dr_t *dvbpsi_DecodeLCNDr(dvbpsi_descriptor_t *p_descriptor);
 
+/*****************************************************************************
+ * dvbpsi_GenLCNDr
+ *****************************************************************************/
+/*!
+ * \fn dvbpsi_descriptor_t * dvbpsi_GenLogicalChannelDr(
+                        dvbpsi_lcn_dr_t* p_decoded, bool b_duplicate)
+ * \brief "logical_channel" descriptor generator.
+ * \param p_decoded pointer to a decoded "logical_channel" descriptor
+ * structure
+ * \param b_duplicate if true then duplicate the p_decoded structure into
+ * the descriptor
+ * \return a pointer to a new descriptor structure which contains encoded data.
+ */
+dvbpsi_descriptor_t* dvbpsi_GenLCNDr(dvbpsi_lcn_dr_t* p_decoded, bool b_duplicate);
+
 #ifdef __cplusplus
 };
 #endif
 
-#endif
+#endif // _DR_83_H
 



More information about the libdvbpsi-devel mailing list