PageRenderTime 26ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/include/linux/dvb/dmx.h

https://github.com/ChangYeoun/OptimusG
C Header | 434 lines | 210 code | 88 blank | 136 comment | 0 complexity | 7a68e2ddd5c21149b82f58df93884783 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /*
  2. * dmx.h
  3. *
  4. * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
  5. * & Ralph Metzler <ralph@convergence.de>
  6. * for convergence integrated media GmbH
  7. *
  8. * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public License
  12. * as published by the Free Software Foundation; either version 2.1
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. *
  24. */
  25. #ifndef _DVBDMX_H_
  26. #define _DVBDMX_H_
  27. #include <linux/types.h>
  28. #ifdef __KERNEL__
  29. #include <linux/time.h>
  30. #else
  31. #include <time.h>
  32. #endif
  33. #define DMX_FILTER_SIZE 16
  34. /* Min recording chunk upon which event is generated */
  35. #define DMX_REC_BUFF_CHUNK_MIN_SIZE (100*188)
  36. typedef enum
  37. {
  38. DMX_OUT_DECODER, /* Streaming directly to decoder. */
  39. DMX_OUT_TAP, /* Output going to a memory buffer */
  40. /* (to be retrieved via the read command).*/
  41. DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */
  42. /* (to be retrieved by reading from the */
  43. /* logical DVR device). */
  44. DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */
  45. } dmx_output_t;
  46. typedef enum
  47. {
  48. DMX_IN_FRONTEND, /* Input from a front-end device. */
  49. DMX_IN_DVR /* Input from the logical DVR device. */
  50. } dmx_input_t;
  51. typedef enum
  52. {
  53. DMX_PES_AUDIO0,
  54. DMX_PES_VIDEO0,
  55. DMX_PES_TELETEXT0,
  56. DMX_PES_SUBTITLE0,
  57. DMX_PES_PCR0,
  58. DMX_PES_AUDIO1,
  59. DMX_PES_VIDEO1,
  60. DMX_PES_TELETEXT1,
  61. DMX_PES_SUBTITLE1,
  62. DMX_PES_PCR1,
  63. DMX_PES_AUDIO2,
  64. DMX_PES_VIDEO2,
  65. DMX_PES_TELETEXT2,
  66. DMX_PES_SUBTITLE2,
  67. DMX_PES_PCR2,
  68. DMX_PES_AUDIO3,
  69. DMX_PES_VIDEO3,
  70. DMX_PES_TELETEXT3,
  71. DMX_PES_SUBTITLE3,
  72. DMX_PES_PCR3,
  73. DMX_PES_OTHER
  74. } dmx_pes_type_t;
  75. #define DMX_PES_AUDIO DMX_PES_AUDIO0
  76. #define DMX_PES_VIDEO DMX_PES_VIDEO0
  77. #define DMX_PES_TELETEXT DMX_PES_TELETEXT0
  78. #define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
  79. #define DMX_PES_PCR DMX_PES_PCR0
  80. typedef struct dmx_filter
  81. {
  82. __u8 filter[DMX_FILTER_SIZE];
  83. __u8 mask[DMX_FILTER_SIZE];
  84. __u8 mode[DMX_FILTER_SIZE];
  85. } dmx_filter_t;
  86. /* Filter flags */
  87. #define DMX_CHECK_CRC 0x01
  88. #define DMX_ONESHOT 0x02
  89. #define DMX_IMMEDIATE_START 0x04
  90. #define DMX_ENABLE_INDEXING 0x08
  91. #define DMX_KERNEL_CLIENT 0x8000
  92. struct dmx_sct_filter_params
  93. {
  94. __u16 pid;
  95. dmx_filter_t filter;
  96. __u32 timeout;
  97. __u32 flags;
  98. };
  99. /* Indexing: supported video standards */
  100. enum dmx_indexing_video_standard {
  101. DMX_INDEXING_MPEG2,
  102. DMX_INDEXING_H264,
  103. DMX_INDEXING_VC1
  104. };
  105. /* Indexing: Supported video profiles */
  106. enum dmx_indexing_video_profile {
  107. DMX_INDEXING_MPEG2_ANY,
  108. DMX_INDEXING_H264_ANY,
  109. DMX_INDEXING_VC1_ANY
  110. };
  111. /* Indexing: video configuration parameters */
  112. struct dmx_indexing_video_params {
  113. enum dmx_indexing_video_standard standard;
  114. enum dmx_indexing_video_profile profile;
  115. };
  116. struct dmx_pes_filter_params
  117. {
  118. __u16 pid;
  119. dmx_input_t input;
  120. dmx_output_t output;
  121. dmx_pes_type_t pes_type;
  122. __u32 flags;
  123. /*
  124. * The following configures when the event
  125. * DMX_EVENT_NEW_REC_CHUNK will be triggered.
  126. * When new recorded data is received with size
  127. * equal or larger than this value a new event
  128. * will be triggered. This is relevent when
  129. * output is DMX_OUT_TS_TAP or DMX_OUT_TSDEMUX_TAP,
  130. * size must be at least DMX_REC_BUFF_CHUNK_MIN_SIZE
  131. * and smaller than buffer size.
  132. */
  133. __u32 rec_chunk_size;
  134. struct dmx_indexing_video_params video_params;
  135. };
  136. struct dmx_buffer_status {
  137. /* size of buffer in bytes */
  138. unsigned int size;
  139. /* fullness of buffer in bytes */
  140. unsigned int fullness;
  141. /*
  142. * How many bytes are free
  143. * It's the same as: size-fullness-1
  144. */
  145. unsigned int free_bytes;
  146. /* read pointer offset in bytes */
  147. unsigned int read_offset;
  148. /* write pointer offset in bytes */
  149. unsigned int write_offset;
  150. /* non-zero if data error occured */
  151. int error;
  152. };
  153. /* Events associated with each demux filter */
  154. enum dmx_event {
  155. /* New PES packet is ready to be consumed */
  156. DMX_EVENT_NEW_PES,
  157. /* New section is ready to be consumed */
  158. DMX_EVENT_NEW_SECTION,
  159. /* New recording chunk is ready to be consumed */
  160. DMX_EVENT_NEW_REC_CHUNK,
  161. /* New PCR value is ready */
  162. DMX_EVENT_NEW_PCR,
  163. /* Overflow */
  164. DMX_EVENT_BUFFER_OVERFLOW,
  165. /* Section was dropped due to CRC error */
  166. DMX_EVENT_SECTION_CRC_ERROR,
  167. /* End-of-stream, no more data from this filter */
  168. DMX_EVENT_EOS
  169. };
  170. /* Flags passed in filter events */
  171. /* Continuity counter error was detected */
  172. #define DMX_FILTER_CC_ERROR 0x01
  173. /* Discontinuity indicator was set */
  174. #define DMX_FILTER_DISCONTINUITY_INDEICATOR 0x02
  175. /* PES legnth in PES header is not correct */
  176. #define DMX_FILTER_PES_LENGTH_ERROR 0x04
  177. /* PES info associated with DMX_EVENT_NEW_PES event */
  178. struct dmx_pes_event_info {
  179. /* Offset at which PES information starts */
  180. __u32 base_offset;
  181. /*
  182. * Start offset at which PES data
  183. * from the stream starts.
  184. * Equal to base_offset if PES data
  185. * starts from the beginning.
  186. */
  187. __u32 start_offset;
  188. /* Total length holding the PES information */
  189. __u32 total_length;
  190. /* Actual length holding the PES data */
  191. __u32 actual_length;
  192. /* Local receiver timestamp in 27MHz */
  193. __u64 stc;
  194. /* Flags passed in filter events */
  195. __u32 flags;
  196. };
  197. /* Section info associated with DMX_EVENT_NEW_SECTION event */
  198. struct dmx_section_event_info {
  199. /* Offset at which section information starts */
  200. __u32 base_offset;
  201. /*
  202. * Start offset at which section data
  203. * from the stream starts.
  204. * Equal to base_offset if section data
  205. * starts from the beginning.
  206. */
  207. __u32 start_offset;
  208. /* Total length holding the section information */
  209. __u32 total_length;
  210. /* Actual length holding the section data */
  211. __u32 actual_length;
  212. /* Flags passed in filter events */
  213. __u32 flags;
  214. };
  215. /* Recording info associated with DMX_EVENT_NEW_REC_CHUNK event */
  216. struct dmx_rec_chunk_event_info {
  217. /* Offset at which recording chunk starts */
  218. __u32 offset;
  219. /* Size of recording chunk in bytes */
  220. __u32 size;
  221. };
  222. /* PCR info associated with DMX_EVENT_NEW_PCR event */
  223. struct dmx_pcr_event_info {
  224. /* Local timestamp in 27MHz
  225. * when PCR packet was received
  226. */
  227. __u64 stc;
  228. /* PCR value in 27MHz */
  229. __u64 pcr;
  230. /* Flags passed in filter events */
  231. __u32 flags;
  232. };
  233. /*
  234. * Filter's event returned through DMX_GET_EVENT.
  235. * poll with POLLPRI would block until events are available.
  236. */
  237. struct dmx_filter_event {
  238. enum dmx_event type;
  239. union {
  240. struct dmx_pes_event_info pes;
  241. struct dmx_section_event_info section;
  242. struct dmx_rec_chunk_event_info recording_chunk;
  243. struct dmx_pcr_event_info pcr;
  244. } params;
  245. };
  246. typedef struct dmx_caps {
  247. __u32 caps;
  248. /* Indicates whether demux support playback from memory in pull mode */
  249. #define DMX_CAP_PULL_MODE 0x01
  250. /* Indicates whether demux support indexing of recorded video stream */
  251. #define DMX_CAP_VIDEO_INDEXING 0x02
  252. /* Indicates whether demux support sending data directly to video decoder */
  253. #define DMX_CAP_VIDEO_DECODER_DATA 0x04
  254. /* Indicates whether demux support sending data directly to audio decoder */
  255. #define DMX_CAP_AUDIO_DECODER_DATA 0x08
  256. /* Indicates whether demux support sending data directly to subtitle decoder */
  257. #define DMX_CAP_SUBTITLE_DECODER_DATA 0x10
  258. /* Number of decoders demux can output data to */
  259. int num_decoders;
  260. /* Number of demux devices */
  261. int num_demux_devices;
  262. /* Max number of PID filters */
  263. int num_pid_filters;
  264. /* Max number of section filters */
  265. int num_section_filters;
  266. /*
  267. * Max number of section filters using same PID,
  268. * 0 if not supported
  269. */
  270. int num_section_filters_per_pid;
  271. /*
  272. * Length of section filter, not including section
  273. * length field (2 bytes).
  274. */
  275. int section_filter_length;
  276. /* Max number of demod based input */
  277. int num_demod_inputs;
  278. /* Max number of memory based input */
  279. int num_memory_inputs;
  280. /* Overall bitrate from all inputs concurrently. Mbit/sec */
  281. int max_bitrate;
  282. /* Max bitrate from single demod input. Mbit/sec */
  283. int demod_input_max_bitrate;
  284. /* Max bitrate from single memory input. Mbit/sec */
  285. int memory_input_max_bitrate;
  286. } dmx_caps_t;
  287. typedef enum {
  288. DMX_SOURCE_FRONT0 = 0,
  289. DMX_SOURCE_FRONT1,
  290. DMX_SOURCE_FRONT2,
  291. DMX_SOURCE_FRONT3,
  292. DMX_SOURCE_DVR0 = 16,
  293. DMX_SOURCE_DVR1,
  294. DMX_SOURCE_DVR2,
  295. DMX_SOURCE_DVR3
  296. } dmx_source_t;
  297. enum dmx_tsp_format_t {
  298. DMX_TSP_FORMAT_188 = 0,
  299. DMX_TSP_FORMAT_192_TAIL,
  300. DMX_TSP_FORMAT_192_HEAD,
  301. DMX_TSP_FORMAT_204,
  302. };
  303. enum dmx_playback_mode_t {
  304. /*
  305. * In push mode, if one of output buffers
  306. * is full, the buffer would overflow
  307. * and demux continue processing incoming stream.
  308. * This is the default mode. When playing from frontend,
  309. * this is the only mode that is allowed.
  310. */
  311. DMX_PB_MODE_PUSH = 0,
  312. /*
  313. * In pull mode, if one of output buffers
  314. * is full, demux stalls waiting for free space,
  315. * this would cause DVR input buffer fullness
  316. * to accumulate.
  317. * This mode is possible only when playing
  318. * from DVR.
  319. */
  320. DMX_PB_MODE_PULL,
  321. };
  322. struct dmx_stc {
  323. unsigned int num; /* input : which STC? 0..N */
  324. unsigned int base; /* output: divisor for stc to get 90 kHz clock */
  325. __u64 stc; /* output: stc in 'base'*90 kHz units */
  326. };
  327. #define DMX_START _IO('o', 41)
  328. #define DMX_STOP _IO('o', 42)
  329. #define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
  330. #define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
  331. #define DMX_SET_BUFFER_SIZE _IO('o', 45)
  332. #define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
  333. #define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
  334. #define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
  335. #define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
  336. #define DMX_ADD_PID _IOW('o', 51, __u16)
  337. #define DMX_REMOVE_PID _IOW('o', 52, __u16)
  338. #define DMX_SET_TS_PACKET_FORMAT _IOW('o', 53, enum dmx_tsp_format_t)
  339. #define DMX_SET_TS_OUT_FORMAT _IOW('o', 54, enum dmx_tsp_format_t)
  340. #define DMX_SET_DECODER_BUFFER_SIZE _IO('o', 55)
  341. #define DMX_GET_BUFFER_STATUS _IOR('o', 56, struct dmx_buffer_status)
  342. #define DMX_RELEASE_DATA _IO('o', 57)
  343. #define DMX_FEED_DATA _IO('o', 58)
  344. #define DMX_SET_PLAYBACK_MODE _IOW('o', 59, enum dmx_playback_mode_t)
  345. #define DMX_GET_EVENT _IOR('o', 60, struct dmx_filter_event)
  346. #endif /*_DVBDMX_H_*/