rnt_rar_over_ip_descriptor.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_RNT_RAR_OVER_IP_DESCRIPTOR
  22. #define _UCSI_DVB_RNT_RAR_OVER_IP_DESCRIPTOR 1
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #include <libucsi/descriptor.h>
  28. #include <libucsi/endianops.h>
  29. /**
  30. * dvb_rnt_rar_over_ip_descriptor structure.
  31. */
  32. struct dvb_rnt_rar_over_ip_descriptor {
  33. struct descriptor d;
  34. dvbdate_t first_valid_date;
  35. dvbdate_t last_valid_date;
  36. EBIT3(uint8_t weighting : 6; ,
  37. uint8_t complete_flag : 1; ,
  38. uint8_t reserved : 1; );
  39. uint8_t url_length;
  40. /* uint8_t url[] */
  41. } __ucsi_packed;
  42. /**
  43. * Process a dvb_rnt_rar_over_ip_descriptor.
  44. *
  45. * @param d Generic descriptor pointer.
  46. * @return dvb_rnt_rar_over_ip_descriptor pointer, or NULL on error.
  47. */
  48. static inline struct dvb_rnt_rar_over_ip_descriptor*
  49. dvb_rnt_rar_over_ip_descriptor_codec(struct descriptor* d)
  50. {
  51. uint8_t *buf = (uint8_t*) d;
  52. uint32_t len = d->len + 2;
  53. struct dvb_rnt_rar_over_ip_descriptor *ret =
  54. (struct dvb_rnt_rar_over_ip_descriptor *) buf;
  55. if (len < sizeof(struct dvb_rnt_rar_over_ip_descriptor))
  56. return NULL;
  57. if (len < (sizeof(struct dvb_rnt_rar_over_ip_descriptor) + buf[13]))
  58. return NULL;
  59. return ret;
  60. }
  61. /**
  62. * Accessor for the url field of a dvb_rnt_rar_over_ip_descriptor.
  63. *
  64. * @param d dvb_rnt_rar_over_ip_descriptor pointer.
  65. * @return Pointer.
  66. */
  67. static inline uint8_t*
  68. dvb_rnt_rar_over_ip_descriptor_url(struct dvb_rnt_rar_over_ip_descriptor *d)
  69. {
  70. return (uint8_t*)
  71. ((uint8_t*) d + sizeof(struct dvb_rnt_rar_over_ip_descriptor));
  72. }
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif