ett_section.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_ETT_SECTION_H
  22. #define _UCSI_ATSC_ETT_SECTION_H 1
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #include <libucsi/atsc/section.h>
  28. enum atsc_etm_type {
  29. ATSC_ETM_CHANNEL = 0x00,
  30. ATSC_ETM_EVENT = 0x02,
  31. };
  32. /**
  33. * atsc_ett_section structure.
  34. */
  35. struct atsc_ett_section {
  36. struct atsc_section_psip head;
  37. EBIT3(uint32_t ETM_source_id :16; ,
  38. uint32_t ETM_sub_id :14; ,
  39. uint32_t ETM_type : 2; );
  40. /* struct atsc_text extended_text_message */
  41. } __ucsi_packed;
  42. /**
  43. * Process a atsc_ett_section.
  44. *
  45. * @param section Pointer to an atsc_section_psip structure.
  46. * @return atsc_ett_section pointer, or NULL on error.
  47. */
  48. struct atsc_ett_section *atsc_ett_section_codec(struct atsc_section_psip *section);
  49. /**
  50. * Accessor for the extended_text_message part of an atsc_ett_section.
  51. *
  52. * @param ett atsc_ett_section pointer.
  53. * @return atsc_text pointer, or NULL on error.
  54. */
  55. static inline struct atsc_text*
  56. atsc_ett_section_extended_text_message(struct atsc_ett_section *ett)
  57. {
  58. int pos = sizeof(struct atsc_ett_section);
  59. int len = section_ext_length(&ett->head.ext_head) - sizeof(struct atsc_ett_section);
  60. if (len == 0)
  61. return NULL;
  62. return (struct atsc_text*)(((uint8_t*) ett) + pos);
  63. }
  64. /**
  65. * Accessor for the extended_text_message part of an atsc_ett_section.
  66. *
  67. * @param ett atsc_ett_section pointer.
  68. * @return The length.
  69. */
  70. static inline int
  71. atsc_ett_section_extended_text_message_length(struct atsc_ett_section *ett)
  72. {
  73. return section_ext_length(&ett->head.ext_head) - sizeof(struct atsc_ett_section);
  74. }
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif