desc_logical_channel.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation version 2
  7. * of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  18. *
  19. * Described on IEC/CENELEC DS/EN 62216-1:2011
  20. *
  21. * I couldn't find the original version, so I used what's there at:
  22. * http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf
  23. */
  24. /**
  25. * @file desc_logical_channel.h
  26. * @ingroup descriptors
  27. * @brief Provides the descriptors for the LCN - Logican Channel Number
  28. * @copyright GNU General Public License version 2 (GPLv2)
  29. * @author Mauro Carvalho Chehab
  30. *
  31. * @par Relevant specs
  32. * The descriptor described herein is defined at:
  33. * - IEC/CENELEC DS/EN 62216-1:2011
  34. *
  35. * @see http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf
  36. *
  37. * @par Bug Report
  38. * Please submit bug reports and patches to linux-media@vger.kernel.org
  39. */
  40. #ifndef _LCN_DESC_H
  41. #define _LCN_DESC_H
  42. #include <libdvbv5/descriptors.h>
  43. /**
  44. * @struct dvb_desc_logical_channel_number
  45. * @ingroup descriptors
  46. * @brief Structure containing the logical channel number entires
  47. *
  48. * @param service_id service id
  49. * @param visible_service_flag visible service flag
  50. * @param logical_channel_number logical channel number
  51. */
  52. struct dvb_desc_logical_channel_number {
  53. uint16_t service_id;
  54. union {
  55. uint16_t bitfield;
  56. struct {
  57. uint16_t logical_channel_number:10;
  58. uint16_t reserved:5;
  59. uint16_t visible_service_flag:1;
  60. } __attribute__((packed));
  61. } __attribute__((packed));
  62. } __attribute__((packed));
  63. /**
  64. * @struct dvb_desc_logical_channel
  65. * @ingroup descriptors
  66. * @brief Structure containing the logical channel number descriptor
  67. *
  68. * @param type descriptor tag
  69. * @param length descriptor length
  70. * @param next pointer to struct dvb_desc
  71. * @param lcn pointer to struct dvb_desc_logical_channel_number
  72. */
  73. struct dvb_desc_logical_channel {
  74. uint8_t type;
  75. uint8_t length;
  76. struct dvb_desc *next;
  77. struct dvb_desc_logical_channel_number *lcn;
  78. } __attribute__((packed));
  79. struct dvb_v5_fe_parms;
  80. #ifdef __cplusplus
  81. extern "C" {
  82. #endif
  83. /**
  84. * @brief Initializes and parses the logical channel number descriptor
  85. * @ingroup descriptors
  86. *
  87. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  88. * @param buf buffer containing the descriptor's raw data
  89. * @param desc pointer to struct dvb_desc to be allocated and filled
  90. *
  91. * This function allocates a the descriptor and fills the fields inside
  92. * the struct. It also makes sure that all fields will follow the CPU
  93. * endianness. Due to that, the content of the buffer may change.
  94. *
  95. * @return On success, it returns the size of the allocated struct.
  96. * A negative value indicates an error.
  97. */
  98. int dvb_desc_logical_channel_init(struct dvb_v5_fe_parms *parms,
  99. const uint8_t *buf, struct dvb_desc *desc);
  100. /**
  101. * @brief Prints the content of the logical channel number descriptor
  102. * @ingroup descriptors
  103. *
  104. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  105. * @param desc pointer to struct dvb_desc
  106. */
  107. void dvb_desc_logical_channel_print(struct dvb_v5_fe_parms *parms,
  108. const struct dvb_desc *desc);
  109. /**
  110. * @brief Frees all data allocated by the logical channel number descriptor
  111. * @ingroup descriptors
  112. *
  113. * @param desc pointer to struct dvb_desc to be freed
  114. */
  115. void dvb_desc_logical_channel_free(struct dvb_desc *desc);
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif