rst_section.h 2.7 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_RST_SECTION_H
  22. #define _UCSI_DVB_RST_SECTION_H 1
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #include <libucsi/section.h>
  28. /**
  29. * dvb_rst_section structure.
  30. */
  31. struct dvb_rst_section {
  32. struct section head;
  33. /* struct dvb_rst_status statuses[] */
  34. };
  35. /**
  36. * An entry in the statuses field of a dvb_rst_section structure.
  37. */
  38. struct dvb_rst_status {
  39. uint16_t transport_stream_id;
  40. uint16_t original_network_id;
  41. uint16_t service_id;
  42. uint16_t event_id;
  43. EBIT2(uint8_t reserved : 5; ,
  44. uint8_t running_status : 3; );
  45. };
  46. /**
  47. * Process a dvb_rst_section.
  48. *
  49. * @param section Pointer to a generic section strcuture.
  50. * @return dvb_rst_section pointer, or NULL on error.
  51. */
  52. struct dvb_rst_section *dvb_rst_section_codec(struct section *section);
  53. /**
  54. * Iterator for entries in the statuses field of a dvb_rst_section.
  55. *
  56. * @param rst dvb_rst_section pointer.
  57. * @param pos Variable containing a pointer to the current dvb_rst_status.
  58. */
  59. #define dvb_rst_section_statuses_for_each(rst, pos) \
  60. for ((pos) = dvb_rst_section_statuses_first(rst); \
  61. (pos); \
  62. (pos) = dvb_rst_section_statuses_next(rst, pos))
  63. /******************************** PRIVATE CODE ********************************/
  64. static inline struct dvb_rst_status *
  65. dvb_rst_section_statuses_first(struct dvb_rst_section *rst)
  66. {
  67. size_t pos = sizeof(struct dvb_rst_section);
  68. if (pos >= section_length(&rst->head))
  69. return NULL;
  70. return (struct dvb_rst_status*) ((uint8_t *) rst + pos);
  71. }
  72. static inline struct dvb_rst_status *
  73. dvb_rst_section_statuses_next(struct dvb_rst_section * rst,
  74. struct dvb_rst_status * pos)
  75. {
  76. uint8_t *end = (uint8_t*) rst + section_length(&rst->head);
  77. uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_rst_status);
  78. if (next >= end)
  79. return NULL;
  80. return (struct dvb_rst_status *) next;
  81. }
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif