dcc_departing_request_descriptor.h 3.1 KB

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