dvb-demux.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation version 2
  7. * of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * These routines were originally written as part of the dvb-apps, as:
  15. * util functions for various ?zap implementations
  16. *
  17. * Copyright (C) 2001 Johannes Stezenbach (js@convergence.de)
  18. * for convergence integrated media
  19. *
  20. * Originally licensed as GPLv2 or upper
  21. */
  22. /**
  23. * @file dvb-demux.h
  24. * @ingroup demux
  25. * @brief Provides interfaces to deal with DVB demux.
  26. * @copyright GNU General Public License version 2 (GPLv2)
  27. * @author Mauro Carvalho Chehab
  28. *
  29. * @par Bug Report
  30. * Please submit bug reports and patches to linux-media@vger.kernel.org
  31. */
  32. #ifndef _DVB_DEMUX_H
  33. #define _DVB_DEMUX_H
  34. #include <linux/dvb/dmx.h>
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /**
  39. * @brief Opens a DVB demux in read/write mode
  40. * @ingroup demux
  41. *
  42. * @param adapter DVB adapter number to open
  43. * @param demux DVB demux number to open
  44. *
  45. * @details This is a wrapper function to open. File is always opened in blocking mode.
  46. *
  47. * @return Returns a file descriptor on success, -1 otherwise.
  48. */
  49. int dvb_dmx_open(int adapter, int demux);
  50. /**
  51. * @brief Stops the DMX filter for the file descriptor and closes
  52. * @ingroup demux
  53. *
  54. * @param dmx_fd File descriptor to close
  55. *
  56. * This is a wrapper function to open.
  57. */
  58. void dvb_dmx_close(int dmx_fd);
  59. /**
  60. * @brief Stops the DMX filter for a given file descriptor
  61. * @ingroup demux
  62. *
  63. * @param dmx_fd File descriptor to close
  64. *
  65. * This is a wrapper function to open.
  66. */
  67. void dvb_dmx_stop(int dmx_fd);
  68. /**
  69. * @brief Start a filter for a MPEG-TS Packetized Elementary
  70. * Stream (PES)
  71. * @ingroup demux
  72. *
  73. * @param dmxfd File descriptor for the demux device
  74. * @param pid Program ID to filter. Use 0x2000 to select all PIDs
  75. * @param type type of the PID (DMX_PES_VIDEO, DMX_PES_AUDIO,
  76. * DMX_PES_OTHER, etc).
  77. * @param output Where the data will be output (DMX_OUT_TS_TAP,
  78. * DMX_OUT_DECODER, etc).
  79. * @param buffersize Size of the buffer to be allocated to store the filtered data.
  80. *
  81. * This is a wrapper function for DMX_SET_PES_FILTER ioctl.
  82. * See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
  83. * for more details.
  84. *
  85. * @return Retuns zero on success, -1 otherwise.
  86. */
  87. int dvb_set_pesfilter(int dmxfd, int pid, dmx_pes_type_t type,
  88. dmx_output_t output, int buffersize);
  89. /**
  90. * @brief Sets a MPEG-TS section filter
  91. * @ingroup demux
  92. *
  93. * @param dmxfd File descriptor for the demux device
  94. * @param pid Program ID to filter. Use 0x2000 to select all PIDs
  95. * @param filtsize Size of the filter (up to 18 btyes)
  96. * @param filter data to filter. Can be NULL or should have filtsize length
  97. * @param mask filter mask. Can be NULL or should have filtsize length
  98. * @param mode mode mask. Can be NULL or should have filtsize length
  99. * @param flags flags for set filter (DMX_CHECK_CRC,DMX_ONESHOT,
  100. * DMX_IMMEDIATE_START).
  101. *
  102. * This is a wrapper function for DMX_SET_FILTER ioctl.
  103. * See http://linuxtv.org/downloads/v4l-dvb-apis/dvb_demux.html
  104. * for more details.
  105. *
  106. * @return Retuns zero on success, -1 otherwise.
  107. */
  108. int dvb_set_section_filter(int dmxfd, int pid, unsigned filtsize,
  109. unsigned char *filter,
  110. unsigned char *mask,
  111. unsigned char *mode,
  112. unsigned int flags);
  113. /**
  114. * @brief read the contents of the MPEG-TS PAT table, seeking for
  115. * an specific service ID
  116. * @ingroup demux
  117. *
  118. * @param dmxfd File descriptor for the demux device
  119. * @param sid Session ID to seeking
  120. *
  121. * @warning This function currently assumes that the PAT fits into one session.
  122. *
  123. * @return At return, it returns a negative value if error or the PID associated with
  124. * the desired Session ID.
  125. */
  126. int dvb_get_pmt_pid(int dmxfd, int sid);
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130. #endif