dcc_arriving_request_descriptor.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_DCC_ARRIVING_REQUEST_DESCRIPTOR
  22. #define _UCSI_ATSC_DCC_ARRIVING_REQUEST_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. enum atsc_dcc_arriving_request_type {
  31. DCC_ARRIVAL_TYPE_DEFER_10SEC = 0x01,
  32. DCC_ARRIVAL_TYPE_DEFER = 0x02,
  33. };
  34. /**
  35. * atsc_dcc_arriving_request_descriptor structure.
  36. */
  37. struct atsc_dcc_arriving_request_descriptor {
  38. struct descriptor d;
  39. uint8_t dcc_arriving_request_type;
  40. uint8_t dcc_arriving_request_text_length;
  41. /* struct atsc_text text[] */
  42. } __ucsi_packed;
  43. /**
  44. * Process an atsc_dcc_arriving_request_descriptor.
  45. *
  46. * @param d Generic descriptor pointer.
  47. * @return atsc_dcc_arriving_request_descriptor pointer, or NULL on error.
  48. */
  49. static inline struct atsc_dcc_arriving_request_descriptor*
  50. atsc_dcc_arriving_request_descriptor_codec(struct descriptor* d)
  51. {
  52. struct atsc_dcc_arriving_request_descriptor *ret =
  53. (struct atsc_dcc_arriving_request_descriptor *) d;
  54. if (d->len < 2)
  55. return NULL;
  56. if (d->len != 2 + ret->dcc_arriving_request_text_length)
  57. return NULL;
  58. if (atsc_text_validate((uint8_t*) d + sizeof(struct atsc_dcc_arriving_request_descriptor),
  59. ret->dcc_arriving_request_text_length))
  60. return NULL;
  61. return (struct atsc_dcc_arriving_request_descriptor*) d;
  62. }
  63. /**
  64. * Accessor for the text field of an atsc_dcc_arriving_request_descriptor.
  65. *
  66. * @param d atsc_dcc_arriving_request_descriptor pointer.
  67. * @return Pointer to the atsc_text data, or NULL on error.
  68. */
  69. static inline struct atsc_text*
  70. atsc_dcc_arriving_request_descriptor_text(struct atsc_dcc_arriving_request_descriptor *d)
  71. {
  72. uint8_t *txt = ((uint8_t*) d) + sizeof(struct atsc_dcc_arriving_request_descriptor);
  73. return (struct atsc_text*) txt;
  74. }
  75. /**
  76. * Accessor for the length of the text field of an atsc_dcc_arriving_request_descriptor.
  77. *
  78. * @param d atsc_dcc_arriving_request_descriptor pointer.
  79. * @return The length in bytes.
  80. */
  81. static inline int
  82. atsc_dcc_arriving_request_descriptor_text_length(struct
  83. atsc_dcc_arriving_request_descriptor *d)
  84. {
  85. return d->d.len - 2;
  86. }
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif