tot_section.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * section and descriptor parser
  3. *
  4. * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org)
  5. * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net)
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  20. */
  21. #ifndef _UCSI_DVB_TOT_SECTION_H
  22. #define _UCSI_DVB_TOT_SECTION_H 1
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #include <libucsi/section.h>
  28. #include <libucsi/dvb/types.h>
  29. /**
  30. * dvb_tot_section structure.
  31. */
  32. struct dvb_tot_section {
  33. struct section head;
  34. dvbdate_t utc_time;
  35. EBIT2(uint16_t reserved : 4; ,
  36. uint16_t descriptors_loop_length:12; );
  37. /* struct descriptor descriptors[] */
  38. } __ucsi_packed;
  39. /**
  40. * Process a dvb_tot_section.
  41. *
  42. * @param section Pointer to generic section structure.
  43. * @return dvb_tot_section pointer, or NULL on error.
  44. */
  45. struct dvb_tot_section * dvb_tot_section_codec(struct section *section);
  46. /**
  47. * Iterator for descriptors field of dvb_tot_section.
  48. *
  49. * @param tot dvb_tot_section pointer.
  50. * @param pos Variable holding a pointer to the current descriptor.
  51. */
  52. #define dvb_tot_section_descriptors_for_each(tot, pos) \
  53. for ((pos) = dvb_tot_section_descriptors_first(tot); \
  54. (pos); \
  55. (pos) = dvb_tot_section_descriptors_next(tot, pos))
  56. /******************************** PRIVATE CODE ********************************/
  57. static inline struct descriptor *
  58. dvb_tot_section_descriptors_first(struct dvb_tot_section * tot)
  59. {
  60. if (tot->descriptors_loop_length == 0)
  61. return NULL;
  62. return (struct descriptor *)
  63. ((uint8_t *) tot + sizeof(struct dvb_tot_section));
  64. }
  65. static inline struct descriptor *
  66. dvb_tot_section_descriptors_next(struct dvb_tot_section *tot,
  67. struct descriptor* pos)
  68. {
  69. return next_descriptor((uint8_t *) tot + sizeof(struct dvb_tot_section),
  70. tot->descriptors_loop_length,
  71. pos);
  72. }
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif