desc_atsc_service_location.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. #ifndef _ATSC_SERVICE_LOCATION_H
  21. #define _ATSC_SERVICE_LOCATION_H
  22. #include <libdvbv5/descriptors.h>
  23. /**
  24. * @file desc_atsc_service_location.h
  25. * @ingroup descriptors
  26. * @brief Provides the descriptors for ATSC service location
  27. * @copyright GNU General Public License version 2 (GPLv2)
  28. * @author Mauro Carvalho Chehab
  29. *
  30. * @par Relevant specs
  31. * The descriptor described herein is defined at:
  32. * - ATSC A/53
  33. *
  34. * @see http://www.etherguidesystems.com/help/sdos/atsc/semantics/descriptors/ServiceLocation.aspx
  35. *
  36. * @par Bug Report
  37. * Please submit bug reports and patches to linux-media@vger.kernel.org
  38. */
  39. /**
  40. * @struct atsc_desc_service_location_elementary
  41. * @ingroup descriptors
  42. * @brief service location elementary descriptors
  43. *
  44. * @param stream_type stream type
  45. * @param elementary_pid elementary pid
  46. * @param ISO_639_language_code ISO 639 language code
  47. */
  48. struct atsc_desc_service_location_elementary {
  49. uint8_t stream_type;
  50. union {
  51. uint16_t bitfield;
  52. struct {
  53. uint16_t elementary_pid:13;
  54. uint16_t reserved:3;
  55. } __attribute__((packed));
  56. } __attribute__((packed));
  57. char ISO_639_language_code[3];
  58. } __attribute__((packed));
  59. /**
  60. * @struct atsc_desc_service_location
  61. * @ingroup descriptors
  62. * @brief Describes the elementary streams inside a PAT table for ATSC
  63. *
  64. * @param type descriptor tag
  65. * @param length descriptor length
  66. * @param next pointer to struct dvb_desc
  67. * @param elementary pointer to struct atsc_desc_service_location_elementary
  68. * @param pcr_pid PCR pid
  69. * @param number_elements number elements
  70. */
  71. struct atsc_desc_service_location {
  72. uint8_t type;
  73. uint8_t length;
  74. struct dvb_desc *next;
  75. struct atsc_desc_service_location_elementary *elementary;
  76. union {
  77. uint16_t bitfield;
  78. struct {
  79. uint16_t pcr_pid:13;
  80. uint16_t reserved:3;
  81. } __attribute__((packed));
  82. } __attribute__((packed));
  83. uint8_t number_elements;
  84. } __attribute__((packed));
  85. struct dvb_v5_fe_parms;
  86. #ifdef __cplusplus
  87. extern "C" {
  88. #endif
  89. /**
  90. * @brief Initializes and parses the service location descriptor
  91. * @ingroup descriptors
  92. *
  93. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  94. * @param buf buffer containing the descriptor's raw data
  95. * @param desc pointer to struct dvb_desc to be allocated and filled
  96. *
  97. * This function allocates a the descriptor and fills the fields inside
  98. * the struct. It also makes sure that all fields will follow the CPU
  99. * endianness. Due to that, the content of the buffer may change.
  100. *
  101. * @return On success, it returns the size of the allocated struct.
  102. * A negative value indicates an error.
  103. */
  104. int atsc_desc_service_location_init(struct dvb_v5_fe_parms *parms,
  105. const uint8_t *buf,
  106. struct dvb_desc *desc);
  107. /**
  108. * @brief Prints the content of the service location descriptor
  109. * @ingroup descriptors
  110. *
  111. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  112. * @param desc pointer to struct dvb_desc
  113. */
  114. void atsc_desc_service_location_print(struct dvb_v5_fe_parms *parms,
  115. const struct dvb_desc *desc);
  116. /**
  117. * @brief Frees all data allocated by the service location descriptor
  118. * @ingroup descriptors
  119. *
  120. * @param desc pointer to struct dvb_desc to be freed
  121. */
  122. void atsc_desc_service_location_free(struct dvb_desc *desc);
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. #endif