component_descriptor.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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_COMPONENT_DESCRIPTOR
  22. #define _UCSI_DVB_COMPONENT_DESCRIPTOR 1
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #include <libucsi/descriptor.h>
  28. #include <libucsi/endianops.h>
  29. #include <libucsi/types.h>
  30. /**
  31. * Possible values for stream_content.
  32. */
  33. enum {
  34. DVB_STREAM_CONTENT_VIDEO = 0x01,
  35. DVB_STREAM_CONTENT_AUDIO = 0x02,
  36. DVB_STREAM_CONTENT_SUBTITLE = 0x03,
  37. DVB_STREAM_CONTENT_AC3 = 0x04,
  38. };
  39. /**
  40. * Possible values for component_type.
  41. */
  42. enum {
  43. DVB_COMPONENT_TYPE_VIDEO_43_25Hz = 0x01,
  44. DVB_COMPONENT_TYPE_VIDEO_169_PAN_25Hz = 0x02,
  45. DVB_COMPONENT_TYPE_VIDEO_169_NOPAN_25Hz = 0x03,
  46. DVB_COMPONENT_TYPE_VIDEO_GT169_25Hz = 0x04,
  47. DVB_COMPONENT_TYPE_VIDEO_43_30Hz = 0x05,
  48. DVB_COMPONENT_TYPE_VIDEO_169_PAN_30Hz = 0x06,
  49. DVB_COMPONENT_TYPE_VIDEO_169_NOPAN_30Hz = 0x07,
  50. DVB_COMPONENT_TYPE_VIDEO_GT169_30Hz = 0x08,
  51. DVB_COMPONENT_TYPE_HDVIDEO_43_25Hz = 0x09,
  52. DVB_COMPONENT_TYPE_HDVIDEO_169_PAN_25Hz = 0x0a,
  53. DVB_COMPONENT_TYPE_HDVIDEO_169_NOPAN_25Hz = 0x0b,
  54. DVB_COMPONENT_TYPE_HDVIDEO_GT169_25Hz = 0x0c,
  55. DVB_COMPONENT_TYPE_HDVIDEO_43_30Hz = 0x0d,
  56. DVB_COMPONENT_TYPE_HDVIDEO_169_PAN_30Hz = 0x0e,
  57. DVB_COMPONENT_TYPE_HDVIDEO_169_NOPAN_30Hz = 0x0f,
  58. DVB_COMPONENT_TYPE_HDVIDEO_GT169_30Hz = 0x10,
  59. DVB_COMPONENT_TYPE_AUDIO_SINGLE_MONO = 0x01,
  60. DVB_COMPONENT_TYPE_AUDIO_DUAL_MONO = 0x02,
  61. DVB_COMPONENT_TYPE_AUDIO_STEREO = 0x03,
  62. DVB_COMPONENT_TYPE_AUDIO_MULTI_LINGUAL_MULTI_CHAN= 0x04,
  63. DVB_COMPONENT_TYPE_AUDIO_SURROUND = 0x05,
  64. DVB_COMPONENT_TYPE_AUDIO_VISUAL_IMPAIRED = 0x40,
  65. DVB_COMPONENT_TYPE_AUDIO_HARDHEAR = 0x41,
  66. DVB_COMPONENT_TYPE_AUDIO_SUPPLEMENTARY = 0x42,
  67. DVB_COMPONENT_TYPE_SUBTITLE_TELETEXT = 0x01,
  68. DVB_COMPONENT_TYPE_SUBTITLE_ASSOC_TELETEXT = 0x02,
  69. DVB_COMPONENT_TYPE_SUBTITLE_VBI = 0x03,
  70. DVB_COMPONENT_TYPE_SUBTITLE_DVB = 0x10,
  71. DVB_COMPONENT_TYPE_SUBTITLE_DVB_43 = 0x11,
  72. DVB_COMPONENT_TYPE_SUBTITLE_DVB_169 = 0x12,
  73. DVB_COMPONENT_TYPE_SUBTITLE_DVB_2211 = 0x13,
  74. DVB_COMPONENT_TYPE_SUBTITLE_DVB_HARDHEAR = 0x20,
  75. DVB_COMPONENT_TYPE_SUBTITLE_DVB_HARDHEAR_43 = 0x21,
  76. DVB_COMPONENT_TYPE_SUBTITLE_DVB_HARDHEAR_169 = 0x22,
  77. DVB_COMPONENT_TYPE_SUBTITLE_DVB_HARDHEAR_2211 = 0x23,
  78. };
  79. /**
  80. * dvb_component_descriptor structure.
  81. */
  82. struct dvb_component_descriptor {
  83. struct descriptor d;
  84. EBIT2(uint8_t reserved : 4; ,
  85. uint8_t stream_content : 4; );
  86. uint8_t component_type;
  87. uint8_t component_tag;
  88. iso639lang_t language_code;
  89. /* uint8_t text[] */
  90. } __ucsi_packed;
  91. /**
  92. * Process a dvb_component_descriptor.
  93. *
  94. * @param d Pointer to a generic descriptor.
  95. * @return dvb_component_descriptor pointer, or NULL on error.
  96. */
  97. static inline struct dvb_component_descriptor*
  98. dvb_component_descriptor_codec(struct descriptor* d)
  99. {
  100. if (d->len < (sizeof(struct dvb_component_descriptor) - 2))
  101. return NULL;
  102. return (struct dvb_component_descriptor*) d;
  103. }
  104. /**
  105. * Accessor for the text field of a dvb_component_descriptor.
  106. *
  107. * @param d dvb_component_descriptor pointer.
  108. * @return Pointer to the field.
  109. */
  110. static inline uint8_t *
  111. dvb_component_descriptor_text(struct dvb_component_descriptor *d)
  112. {
  113. return (uint8_t *) d + sizeof(struct dvb_component_descriptor);
  114. }
  115. /**
  116. * Determine the length of the text field of a dvb_component_descriptor.
  117. *
  118. * @param d dvb_component_descriptor pointer.
  119. * @return Length of the field in bytes.
  120. */
  121. static inline int
  122. dvb_component_descriptor_text_length(struct dvb_component_descriptor *d)
  123. {
  124. return d->d.len - 6;
  125. }
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129. #endif