stt_section.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_ATSC_STT_SECTION_H
  22. #define _UCSI_ATSC_STT_SECTION_H 1
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #include <libucsi/atsc/section.h>
  28. #include <libucsi/atsc/types.h>
  29. /**
  30. * atsc_stt_section structure.
  31. */
  32. struct atsc_stt_section {
  33. struct atsc_section_psip head;
  34. atsctime_t system_time;
  35. uint8_t gps_utc_offset;
  36. EBIT4(uint16_t DS_status : 1; ,
  37. uint16_t reserved : 2; ,
  38. uint16_t DS_day_of_month : 5; ,
  39. uint16_t DS_hour : 8; );
  40. /* struct descriptor descriptors[] */
  41. } __ucsi_packed;
  42. /**
  43. * Process a atsc_stt_section.
  44. *
  45. * @param section Pointer to an atsc_section_psip structure.
  46. * @return atsc_stt_section pointer, or NULL on error.
  47. */
  48. struct atsc_stt_section *atsc_stt_section_codec(struct atsc_section_psip *section);
  49. /**
  50. * Iterator for the services field in a atsc_stt_section.
  51. *
  52. * @param stt atsc_stt_section pointer.
  53. * @param pos Variable containing a pointer to the current descriptor.
  54. */
  55. #define atsc_stt_section_descriptors_for_each(stt, pos) \
  56. for ((pos) = atsc_stt_section_descriptors_first(stt); \
  57. (pos); \
  58. (pos) = atsc_stt_section_descriptors_next(stt, pos))
  59. /******************************** PRIVATE CODE ********************************/
  60. static inline struct descriptor *
  61. atsc_stt_section_descriptors_first(struct atsc_stt_section *stt)
  62. {
  63. size_t pos = sizeof(struct atsc_stt_section);
  64. if (pos >= section_ext_length(&stt->head.ext_head))
  65. return NULL;
  66. return (struct descriptor*) ((uint8_t *) stt + pos);
  67. }
  68. static inline struct descriptor *
  69. atsc_stt_section_descriptors_next(struct atsc_stt_section *stt,
  70. struct descriptor *pos)
  71. {
  72. int len = section_ext_length(&stt->head.ext_head);
  73. len -= sizeof(struct atsc_stt_section);
  74. return next_descriptor((uint8_t*) stt + sizeof(struct atsc_stt_section),
  75. len,
  76. pos);
  77. }
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif