desc_extension.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * Copyright (c) 2013-2014 - 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. */
  20. /**
  21. * @file desc_extension.h
  22. * @ingroup descriptors
  23. * @brief Provides the descriptors for the extension descriptor.
  24. * The extension descriptor is used to extend the 8-bit namespace
  25. * of the descriptor_tag field.
  26. * @copyright GNU General Public License version 2 (GPLv2)
  27. * @author Mauro Carvalho Chehab
  28. *
  29. * @par Relevant specs
  30. * The descriptor described herein is defined at:
  31. *
  32. * @see
  33. * - ETSI EN 300 468 V1.11.1
  34. *
  35. * @par Bug Report
  36. * Please submit bug reports and patches to linux-media@vger.kernel.org
  37. */
  38. #ifndef _EXTENSION_DESC_H
  39. #define _EXTENSION_DESC_H
  40. #include <libdvbv5/descriptors.h>
  41. struct dvb_v5_fe_parms;
  42. /**
  43. * @enum extension_descriptors
  44. * @brief List containing all extended descriptors used by Digital TV MPEG-TS
  45. * as defined at ETSI EN 300 468 V1.11.1
  46. * @ingroup descriptors
  47. *
  48. * @var image_icon_descriptor
  49. * @brief image icon descriptor
  50. *
  51. * @var cpcm_delivery_signalling_descriptor
  52. * @brief Content Protection/Copy Management (CPCM) delivery signalling
  53. * descriptor
  54. *
  55. * @var CP_descriptor
  56. * @brief Content Protection descriptor
  57. *
  58. * @var CP_identifier_descriptor
  59. * @brief Content Protection identifier descriptor
  60. *
  61. * @var T2_delivery_system_descriptor
  62. * @brief DVB-T2 delivery system descriptor
  63. *
  64. * @var SH_delivery_system_descriptor
  65. * @brief DVB-SH delivery system descriptor
  66. *
  67. * @var supplementary_audio_descriptor
  68. * @brief supplementary audio descriptor
  69. *
  70. * @var network_change_notify_descriptor
  71. * @brief network change notify descriptor
  72. *
  73. * @var message_descriptor
  74. * @brief message descriptor
  75. *
  76. * @var target_region_descriptor
  77. * @brief target region descriptor
  78. *
  79. * @var target_region_name_descriptor
  80. * @brief target region name descriptor
  81. *
  82. * @var service_relocated_descriptor
  83. * @brief service relocated descriptor
  84. */
  85. enum extension_descriptors {
  86. image_icon_descriptor = 0x00,
  87. cpcm_delivery_signalling_descriptor = 0x01,
  88. CP_descriptor = 0x02,
  89. CP_identifier_descriptor = 0x03,
  90. T2_delivery_system_descriptor = 0x04,
  91. SH_delivery_system_descriptor = 0x05,
  92. supplementary_audio_descriptor = 0x06,
  93. network_change_notify_descriptor = 0x07,
  94. message_descriptor = 0x08,
  95. target_region_descriptor = 0x09,
  96. target_region_name_descriptor = 0x0a,
  97. service_relocated_descriptor = 0x0b,
  98. };
  99. /**
  100. * @struct dvb_extension_descriptor
  101. * @ingroup descriptors
  102. * @brief Structure containing the extended descriptors
  103. *
  104. * @param type Descriptor type
  105. * @param length Length of the descriptor
  106. * @param next pointer to the dvb_desc descriptor
  107. * @param extension_code extension code
  108. * @param descriptor pointer to struct dvb_desc
  109. */
  110. struct dvb_extension_descriptor {
  111. uint8_t type;
  112. uint8_t length;
  113. struct dvb_desc *next;
  114. uint8_t extension_code;
  115. struct dvb_desc *descriptor;
  116. } __attribute__((packed));
  117. /**
  118. * @brief Function prototype for the extended descriptors parsing init code
  119. * @ingroup dvb_table
  120. *
  121. * @param parms Struct dvb_v5_fe_parms pointer
  122. * @param buf buffer with the content of the descriptor
  123. * @param ext struct dvb_extension_descriptor pointer
  124. * @param desc struct dvb_desc pointer
  125. */
  126. typedef int (*dvb_desc_ext_init_func) (struct dvb_v5_fe_parms *parms,
  127. const uint8_t *buf,
  128. struct dvb_extension_descriptor *ext,
  129. void *desc);
  130. /**
  131. * @brief Function prototype for the extended descriptors parsing print code
  132. * @ingroup dvb_table
  133. *
  134. * @param parms Struct dvb_v5_fe_parms pointer
  135. * @param buf buffer with the content of the descriptor
  136. * @param ext struct dvb_extension_descriptor pointer
  137. * @param desc struct dvb_desc pointer
  138. */
  139. typedef void (*dvb_desc_ext_print_func)(struct dvb_v5_fe_parms *parms,
  140. const struct dvb_extension_descriptor *ext,
  141. const void *desc);
  142. /**
  143. * @brief Function prototype for the extended descriptors parsing free code
  144. * @ingroup dvb_table
  145. *
  146. * @param desc struct dvb_desc pointer
  147. */
  148. typedef void (*dvb_desc_ext_free_func) (const void *desc);
  149. /**
  150. * @struct dvb_ext_descriptor
  151. * @ingroup descriptors
  152. * @brief Structure that describes the parser functions for the extended
  153. * descriptors. Works on a similar way as struct dvb_descriptor.
  154. *
  155. * @param name name of the descriptor
  156. * @param init init dvb_desc_ext_init_func pointer
  157. * @param print print dvb_desc_ext_print_func pointer
  158. * @param free free dvb_desc_ext_free_func pointer
  159. * @param size size of the descriptor
  160. */
  161. struct dvb_ext_descriptor {
  162. const char *name;
  163. dvb_desc_ext_init_func init;
  164. dvb_desc_ext_print_func print;
  165. dvb_desc_ext_free_func free;
  166. ssize_t size;
  167. };
  168. #ifdef __cplusplus
  169. extern "C" {
  170. #endif
  171. /**
  172. * @brief Initializes and parses the extended descriptor
  173. * @ingroup descriptors
  174. *
  175. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  176. * @param buf buffer containing the descriptor's raw data
  177. * @param desc pointer to struct dvb_desc to be allocated and filled
  178. *
  179. * This function allocates a the descriptor and fills the fields inside
  180. * the struct. It also makes sure that all fields will follow the CPU
  181. * endianness. Due to that, the content of the buffer may change.
  182. *
  183. * @return On success, it returns the size of the allocated struct.
  184. * A negative value indicates an error.
  185. */
  186. int dvb_extension_descriptor_init(struct dvb_v5_fe_parms *parms,
  187. const uint8_t *buf, struct dvb_desc *desc);
  188. /**
  189. * @brief Prints the content of the extended descriptor
  190. * @ingroup descriptors
  191. *
  192. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  193. * @param desc pointer to struct dvb_desc
  194. */
  195. void dvb_extension_descriptor_print(struct dvb_v5_fe_parms *parms,
  196. const struct dvb_desc *desc);
  197. /**
  198. * @brief Frees all data allocated by the extended descriptor
  199. * @ingroup descriptors
  200. *
  201. * @param desc pointer to struct dvb_desc to be freed
  202. */
  203. void dvb_extension_descriptor_free(struct dvb_desc *desc);
  204. #ifdef __cplusplus
  205. }
  206. #endif
  207. #endif