time_slice_fec_identifier_descriptor.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * Copyright (C) 2008 Patrick Boettcher (pb@linuxtv.org)
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  21. */
  22. #ifndef _UCSI_DVB_TIME_SLICE_FEC_IDENTIFIER_DESCRIPTOR
  23. #define _UCSI_DVB_TIME_SLICE_FEC_IDENTIFIER_DESCRIPTOR 1
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. #include <libucsi/descriptor.h>
  29. #include <libucsi/types.h>
  30. /*
  31. * dvb_time_slice_fec_identifier_descriptor structure.
  32. */
  33. struct dvb_time_slice_fec_identifier_descriptor {
  34. struct descriptor d;
  35. EBIT4(uint8_t time_slicing :1; ,
  36. uint8_t mpe_fec :2; ,
  37. uint8_t reserved :2; ,
  38. uint8_t frame_size :3; );
  39. uint8_t max_burst_duration;
  40. EBIT2(uint8_t max_average_rate :4; ,
  41. uint8_t time_slice_fec_id :4; );
  42. /* id_selector_bytes[] */
  43. };
  44. static inline struct dvb_time_slice_fec_identifier_descriptor *
  45. dvb_time_slice_fec_identifier_descriptor_codec(struct descriptor* d)
  46. {
  47. if (d->len < 3)
  48. return NULL;
  49. return (struct dvb_time_slice_fec_identifier_descriptor *) d;
  50. }
  51. static inline uint8_t dvb_time_slice_fec_identifier_selector_byte_length(struct dvb_time_slice_fec_identifier_descriptor *d)
  52. {
  53. return d->d.len - 3;
  54. }
  55. static inline uint8_t * dvb_time_slice_fec_identifier_selector_bytes(struct dvb_time_slice_fec_identifier_descriptor *d)
  56. {
  57. if (d->d.len < 3)
  58. return NULL;
  59. else
  60. return ((uint8_t *) d) + 2 + 3;
  61. }
  62. static inline uint16_t dvb_time_slice_fec_identifier_max_burst_duration_msec(struct dvb_time_slice_fec_identifier_descriptor *d)
  63. {
  64. return (d->max_burst_duration + 1) * 20;
  65. }
  66. static inline uint16_t dvb_time_slice_fec_identifier_frame_size_kbits(struct dvb_time_slice_fec_identifier_descriptor *d)
  67. {
  68. if (d->frame_size > 3)
  69. return 0;
  70. return (d->frame_size+1) * 512;
  71. }
  72. static inline uint16_t dvb_time_slice_fec_identifier_frame_size_rows(struct dvb_time_slice_fec_identifier_descriptor *d)
  73. {
  74. return dvb_time_slice_fec_identifier_frame_size_kbits(d) / 2;
  75. }
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif