mhp_data_broadcast_id_descriptor.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_MHP_DATA_BROADCAST_ID_DESCRIPTOR
  22. #define _UCSI_DVB_MHP_DATA_BROADCAST_ID_DESCRIPTOR 1
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #ifndef _UCSI_DVB_DATA_BROADCAST_ID_DESCRIPTOR
  28. #error Must include dvb/data_broadcast_id_descriptor.h first
  29. #endif
  30. /**
  31. * Broadcast IDs for MHP.
  32. */
  33. enum {
  34. DVB_BROADCAST_ID_MHP_OBJECT_CAROUSEL = 0x00f0,
  35. DVB_BROADCAST_ID_MHP_MPE = 0x00f1,
  36. };
  37. /**
  38. * dvb_mhp_data_broadcast_id_descriptor structure.
  39. */
  40. struct dvb_mhp_data_broadcast_id_descriptor {
  41. struct dvb_data_broadcast_id_descriptor d;
  42. /* uint16_t application_type[] */
  43. } __ucsi_packed;
  44. /**
  45. * Process a dvb_mhp_data_broadcast_id_descriptor.
  46. *
  47. * @param d Generic descriptor structure.
  48. * @return dvb_mhp_data_broadcast_id_descriptor pointer, or NULL on error.
  49. */
  50. static inline struct dvb_mhp_data_broadcast_id_descriptor*
  51. dvb_mhp_data_broadcast_id_descriptor_codec(struct dvb_data_broadcast_id_descriptor* d)
  52. {
  53. uint8_t * buf;
  54. int len;
  55. int pos = 0;
  56. struct dvb_mhp_data_broadcast_id_descriptor *res =
  57. (struct dvb_mhp_data_broadcast_id_descriptor *) d;
  58. if ((res->d.data_broadcast_id < 0xf0) || (res->d.data_broadcast_id > 0xfe))
  59. return NULL;
  60. buf = dvb_data_broadcast_id_descriptor_id_selector_byte(d);
  61. len = dvb_data_broadcast_id_descriptor_id_selector_byte_length(d);
  62. if (len % 2)
  63. return NULL;
  64. while(pos < len) {
  65. bswap16(buf+pos);
  66. pos+=2;
  67. }
  68. return res;
  69. }
  70. /**
  71. * Accessor for the application_type field of a dvb_mhp_data_broadcast_id_descriptor.
  72. *
  73. * @param d dvb_mhp_data_broadcast_id_descriptor pointer.
  74. * @return Pointer to the field.
  75. */
  76. static inline uint16_t *
  77. dvb_mhp_data_broadcast_id_descriptor_id_application_type(struct dvb_mhp_data_broadcast_id_descriptor *d)
  78. {
  79. return (uint16_t *) dvb_data_broadcast_id_descriptor_id_selector_byte((struct dvb_data_broadcast_id_descriptor*) d);
  80. }
  81. /**
  82. * Determine the number of entries in the application_type field of a dvb_mhp_data_broadcast_id_descriptor.
  83. *
  84. * @param d dvb_data_broadcast_id_descriptor pointer.
  85. * @return Length of the field in bytes.
  86. */
  87. static inline int
  88. dvb_mhp_data_broadcast_id_descriptor_id_application_type_count(struct dvb_mhp_data_broadcast_id_descriptor *d)
  89. {
  90. return dvb_data_broadcast_id_descriptor_id_selector_byte_length((struct dvb_data_broadcast_id_descriptor*) d) >> 1;
  91. }
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif