metadata_section.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_MPEG_METADATA_SECTION_H
  22. #define _UCSI_MPEG_METADATA_SECTION_H 1
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #include <libucsi/section.h>
  28. /**
  29. * mpeg_metadata_section structure.
  30. */
  31. struct mpeg_metadata_section {
  32. struct section_ext head;
  33. /* uint8_t data[] */
  34. } __ucsi_packed;
  35. /**
  36. * Process an mpeg_metadata_section structure.
  37. *
  38. * @param section Pointer to the section_ext structure.
  39. * @return Pointer to the mpeg_metadata_section structure, or NULL on error.
  40. */
  41. extern struct mpeg_metadata_section *mpeg_metadata_section_codec(struct section_ext *section);
  42. /**
  43. * Accessor for the random_access_indicator field of a metadata section.
  44. *
  45. * @param metadata metadata section pointer.
  46. * @return The random_access_indicator.
  47. */
  48. static inline uint8_t mpeg_metadata_section_random_access_indicator(struct mpeg_metadata_section *metadata)
  49. {
  50. return metadata->head.reserved >> 1;
  51. }
  52. /**
  53. * Accessor for the decoder_config_flag field of a metadata section.
  54. *
  55. * @param metadata metadata section pointer.
  56. * @return The decoder_config_flag.
  57. */
  58. static inline uint8_t mpeg_metadata_section_decoder_config_flag(struct mpeg_metadata_section *metadata)
  59. {
  60. return metadata->head.reserved & 1;
  61. }
  62. /**
  63. * Accessor for the fragment_indicator field of a metadata section.
  64. *
  65. * @param metadata metadata section pointer.
  66. * @return The fragment_indicator.
  67. */
  68. static inline uint8_t mpeg_metadata_section_fragment_indicator(struct mpeg_metadata_section *metadata)
  69. {
  70. return metadata->head.reserved1;
  71. }
  72. /**
  73. * Accessor for the service_id field of a metadata section.
  74. *
  75. * @param metadata metadata section pointer.
  76. * @return The service_id.
  77. */
  78. static inline uint16_t mpeg_metadata_section_service_id(struct mpeg_metadata_section *metadata)
  79. {
  80. return metadata->head.table_id_ext >> 8;
  81. }
  82. /**
  83. * Retrieve pointer to data field of an mpeg_metadata_section.
  84. *
  85. * @param s mpeg_metadata_section pointer.
  86. * @return Pointer to the field.
  87. */
  88. static inline uint8_t *
  89. mpeg_metadata_section_data(struct mpeg_metadata_section *s)
  90. {
  91. return (uint8_t *) s + sizeof(struct mpeg_metadata_section);
  92. }
  93. /**
  94. * Determine length of the data field of an mpeg_copyright_descriptor.
  95. *
  96. * @param s mpeg_metadata_section_data pointer.
  97. * @return Length of field in bytes.
  98. */
  99. static inline int
  100. mpeg_metadata_section_data_length(struct mpeg_metadata_section *s)
  101. {
  102. return section_ext_length(&s->head) - sizeof(struct mpeg_metadata_section);
  103. }
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif