cat.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (c) 2013 - Andre Roth <neolynx@gmail.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 cat.h
  22. * @ingroup dvb_table
  23. * @brief Provides the table parser for the CAT (Conditional Access Table)
  24. * @copyright GNU General Public License version 2 (GPLv2)
  25. * @author Andre Roth
  26. *
  27. * @par Bug Report
  28. * Please submit bug reports and patches to linux-media@vger.kernel.org
  29. */
  30. #ifndef _CAT_H
  31. #define _CAT_H
  32. #include <stdint.h>
  33. #include <unistd.h> /* ssize_t */
  34. #include <libdvbv5/header.h>
  35. /**
  36. * @def DVB_TABLE_CAT
  37. * @brief ATSC CAT table ID
  38. * @ingroup dvb_table
  39. * @def DVB_TABLE_CAT_PID
  40. * @brief ATSC PID table ID
  41. * @ingroup dvb_table
  42. */
  43. #define DVB_TABLE_CAT 0x01
  44. #define DVB_TABLE_CAT_PID 0x0001
  45. /**
  46. * @struct dvb_table_cat
  47. * @brief ATSC CAT table
  48. *
  49. * @param header struct dvb_table_header content
  50. * @param descriptor pointer to struct dvb_desc
  51. */
  52. struct dvb_table_cat {
  53. struct dvb_table_header header;
  54. struct dvb_desc *descriptor;
  55. } __attribute__((packed));
  56. struct dvb_v5_fe_parms;
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60. /**
  61. * @brief Initializes and parses CAT table
  62. *
  63. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  64. * @param buf buffer containing the CAT raw data
  65. * @param buflen length of the buffer
  66. * @param table pointer to struct dvb_table_cat to be allocated and filled
  67. *
  68. * This function allocates an CAT table and fills the fields inside
  69. * the struct. It also makes sure that all fields will follow the CPU
  70. * endianness. Due to that, the content of the buffer may change.
  71. *
  72. * @return On success, it returns the size of the allocated struct.
  73. * A negative value indicates an error.
  74. */
  75. ssize_t dvb_table_cat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
  76. ssize_t buflen, struct dvb_table_cat **table);
  77. /**
  78. * @brief Frees all data allocated by the CAT table parser
  79. *
  80. * @param table pointer to struct dvb_table_cat to be freed
  81. */
  82. void dvb_table_cat_free(struct dvb_table_cat *table);
  83. /**
  84. * @brief Prints the content of the CAT table
  85. *
  86. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  87. * @param table pointer to struct dvb_table_cat
  88. */
  89. void dvb_table_cat_print(struct dvb_v5_fe_parms *parms,
  90. struct dvb_table_cat *table);
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif