dmx.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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-2013, The Linux Foundation. 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. #define DMX_MAX_DECODER_BUFFER_NUM (64)
  37. typedef enum
  38. {
  39. DMX_OUT_DECODER, /* Streaming directly to decoder. */
  40. DMX_OUT_TAP, /* Output going to a memory buffer */
  41. /* (to be retrieved via the read command).*/
  42. DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */
  43. /* (to be retrieved by reading from the */
  44. /* logical DVR device). */
  45. DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */
  46. } dmx_output_t;
  47. typedef enum
  48. {
  49. DMX_IN_FRONTEND, /* Input from a front-end device. */
  50. DMX_IN_DVR /* Input from the logical DVR device. */
  51. } dmx_input_t;
  52. typedef enum
  53. {
  54. DMX_PES_AUDIO0,
  55. DMX_PES_VIDEO0,
  56. DMX_PES_TELETEXT0,
  57. DMX_PES_SUBTITLE0,
  58. DMX_PES_PCR0,
  59. DMX_PES_AUDIO1,
  60. DMX_PES_VIDEO1,
  61. DMX_PES_TELETEXT1,
  62. DMX_PES_SUBTITLE1,
  63. DMX_PES_PCR1,
  64. DMX_PES_AUDIO2,
  65. DMX_PES_VIDEO2,
  66. DMX_PES_TELETEXT2,
  67. DMX_PES_SUBTITLE2,
  68. DMX_PES_PCR2,
  69. DMX_PES_AUDIO3,
  70. DMX_PES_VIDEO3,
  71. DMX_PES_TELETEXT3,
  72. DMX_PES_SUBTITLE3,
  73. DMX_PES_PCR3,
  74. DMX_PES_OTHER
  75. } dmx_pes_type_t;
  76. #define DMX_PES_AUDIO DMX_PES_AUDIO0
  77. #define DMX_PES_VIDEO DMX_PES_VIDEO0
  78. #define DMX_PES_TELETEXT DMX_PES_TELETEXT0
  79. #define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
  80. #define DMX_PES_PCR DMX_PES_PCR0
  81. typedef struct dmx_filter
  82. {
  83. __u8 filter[DMX_FILTER_SIZE];
  84. __u8 mask[DMX_FILTER_SIZE];
  85. __u8 mode[DMX_FILTER_SIZE];
  86. } dmx_filter_t;
  87. /* Filter flags */
  88. #define DMX_CHECK_CRC 0x01
  89. #define DMX_ONESHOT 0x02
  90. #define DMX_IMMEDIATE_START 0x04
  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. enum dmx_video_codec {
  100. DMX_VIDEO_CODEC_MPEG2,
  101. DMX_VIDEO_CODEC_H264,
  102. DMX_VIDEO_CODEC_VC1
  103. };
  104. /* Index entries types */
  105. #define DMX_IDX_RAI 0x00000001
  106. #define DMX_IDX_PUSI 0x00000002
  107. #define DMX_IDX_MPEG_SEQ_HEADER 0x00000004
  108. #define DMX_IDX_MPEG_GOP 0x00000008
  109. #define DMX_IDX_MPEG_FIRST_SEQ_FRAME_START 0x00000010
  110. #define DMX_IDX_MPEG_FIRST_SEQ_FRAME_END 0x00000020
  111. #define DMX_IDX_MPEG_I_FRAME_START 0x00000040
  112. #define DMX_IDX_MPEG_I_FRAME_END 0x00000080
  113. #define DMX_IDX_MPEG_P_FRAME_START 0x00000100
  114. #define DMX_IDX_MPEG_P_FRAME_END 0x00000200
  115. #define DMX_IDX_MPEG_B_FRAME_START 0x00000400
  116. #define DMX_IDX_MPEG_B_FRAME_END 0x00000800
  117. #define DMX_IDX_H264_SPS 0x00001000
  118. #define DMX_IDX_H264_PPS 0x00002000
  119. #define DMX_IDX_H264_FIRST_SPS_FRAME_START 0x00004000
  120. #define DMX_IDX_H264_FIRST_SPS_FRAME_END 0x00008000
  121. #define DMX_IDX_H264_IDR_START 0x00010000
  122. #define DMX_IDX_H264_IDR_END 0x00020000
  123. #define DMX_IDX_H264_NON_IDR_START 0x00040000
  124. #define DMX_IDX_H264_NON_IDR_END 0x00080000
  125. #define DMX_IDX_VC1_SEQ_HEADER 0x00100000
  126. #define DMX_IDX_VC1_ENTRY_POINT 0x00200000
  127. #define DMX_IDX_VC1_FIRST_SEQ_FRAME_START 0x00400000
  128. #define DMX_IDX_VC1_FIRST_SEQ_FRAME_END 0x00800000
  129. #define DMX_IDX_VC1_FRAME_START 0x01000000
  130. #define DMX_IDX_VC1_FRAME_END 0x02000000
  131. #define DMX_IDX_H264_ACCESS_UNIT_DEL 0x04000000
  132. #define DMX_IDX_H264_SEI 0x08000000
  133. struct dmx_pes_filter_params
  134. {
  135. __u16 pid;
  136. dmx_input_t input;
  137. dmx_output_t output;
  138. dmx_pes_type_t pes_type;
  139. __u32 flags;
  140. /*
  141. * The following configures when the event
  142. * DMX_EVENT_NEW_REC_CHUNK will be triggered.
  143. * When new recorded data is received with size
  144. * equal or larger than this value a new event
  145. * will be triggered. This is relevant when
  146. * output is DMX_OUT_TS_TAP or DMX_OUT_TSDEMUX_TAP,
  147. * size must be at least DMX_REC_BUFF_CHUNK_MIN_SIZE
  148. * and smaller than buffer size.
  149. */
  150. __u32 rec_chunk_size;
  151. enum dmx_video_codec video_codec;
  152. };
  153. struct dmx_buffer_status {
  154. /* size of buffer in bytes */
  155. unsigned int size;
  156. /* fullness of buffer in bytes */
  157. unsigned int fullness;
  158. /*
  159. * How many bytes are free
  160. * It's the same as: size-fullness-1
  161. */
  162. unsigned int free_bytes;
  163. /* read pointer offset in bytes */
  164. unsigned int read_offset;
  165. /* write pointer offset in bytes */
  166. unsigned int write_offset;
  167. /* non-zero if data error occurred */
  168. int error;
  169. };
  170. /* Events associated with each demux filter */
  171. enum dmx_event {
  172. /* New PES packet is ready to be consumed */
  173. DMX_EVENT_NEW_PES = 0x00000001,
  174. /* New section is ready to be consumed */
  175. DMX_EVENT_NEW_SECTION = 0x00000002,
  176. /* New recording chunk is ready to be consumed */
  177. DMX_EVENT_NEW_REC_CHUNK = 0x00000004,
  178. /* New PCR value is ready */
  179. DMX_EVENT_NEW_PCR = 0x00000008,
  180. /* Overflow */
  181. DMX_EVENT_BUFFER_OVERFLOW = 0x00000010,
  182. /* Section was dropped due to CRC error */
  183. DMX_EVENT_SECTION_CRC_ERROR = 0x00000020,
  184. /* End-of-stream, no more data from this filter */
  185. DMX_EVENT_EOS = 0x00000040,
  186. /* New Elementary Stream data is ready */
  187. DMX_EVENT_NEW_ES_DATA = 0x00000080,
  188. /* Data markers */
  189. DMX_EVENT_MARKER = 0x00000100,
  190. /* New indexing entry is ready */
  191. DMX_EVENT_NEW_INDEX_ENTRY = 0x00000200,
  192. /*
  193. * Section filter timer expired. This is notified
  194. * when timeout is configured to section filter
  195. * (dmx_sct_filter_params) and no sections were
  196. * received for the given time.
  197. */
  198. DMX_EVENT_SECTION_TIMEOUT = 0x00000400,
  199. /* Scrambling bits change between clear and scrambled */
  200. DMX_EVENT_SCRAMBLING_STATUS_CHANGE = 0x00000800
  201. };
  202. enum dmx_oob_cmd {
  203. /* End-of-stream, no more data from this filter */
  204. DMX_OOB_CMD_EOS,
  205. /* Data markers */
  206. DMX_OOB_CMD_MARKER,
  207. };
  208. /* Flags passed in filter events */
  209. /* Continuity counter error was detected */
  210. #define DMX_FILTER_CC_ERROR 0x01
  211. /* Discontinuity indicator was set */
  212. #define DMX_FILTER_DISCONTINUITY_INDICATOR 0x02
  213. /* PES length in PES header is not correct */
  214. #define DMX_FILTER_PES_LENGTH_ERROR 0x04
  215. /* PES info associated with DMX_EVENT_NEW_PES event */
  216. struct dmx_pes_event_info {
  217. /* Offset at which PES information starts */
  218. __u32 base_offset;
  219. /*
  220. * Start offset at which PES data
  221. * from the stream starts.
  222. * Equal to base_offset if PES data
  223. * starts from the beginning.
  224. */
  225. __u32 start_offset;
  226. /* Total length holding the PES information */
  227. __u32 total_length;
  228. /* Actual length holding the PES data */
  229. __u32 actual_length;
  230. /* Local receiver timestamp in 27MHz */
  231. __u64 stc;
  232. /* Flags passed in filter events */
  233. __u32 flags;
  234. /*
  235. * Number of TS packets with Transport Error Indicator (TEI)
  236. * found while constructing the PES.
  237. */
  238. __u32 transport_error_indicator_counter;
  239. /* Number of continuity errors found while constructing the PES */
  240. __u32 continuity_error_counter;
  241. /* Total number of TS packets holding the PES */
  242. __u32 ts_packets_num;
  243. };
  244. /* Section info associated with DMX_EVENT_NEW_SECTION event */
  245. struct dmx_section_event_info {
  246. /* Offset at which section information starts */
  247. __u32 base_offset;
  248. /*
  249. * Start offset at which section data
  250. * from the stream starts.
  251. * Equal to base_offset if section data
  252. * starts from the beginning.
  253. */
  254. __u32 start_offset;
  255. /* Total length holding the section information */
  256. __u32 total_length;
  257. /* Actual length holding the section data */
  258. __u32 actual_length;
  259. /* Flags passed in filter events */
  260. __u32 flags;
  261. };
  262. /* Recording info associated with DMX_EVENT_NEW_REC_CHUNK event */
  263. struct dmx_rec_chunk_event_info {
  264. /* Offset at which recording chunk starts */
  265. __u32 offset;
  266. /* Size of recording chunk in bytes */
  267. __u32 size;
  268. };
  269. /* PCR info associated with DMX_EVENT_NEW_PCR event */
  270. struct dmx_pcr_event_info {
  271. /* Local timestamp in 27MHz
  272. * when PCR packet was received
  273. */
  274. __u64 stc;
  275. /* PCR value in 27MHz */
  276. __u64 pcr;
  277. /* Flags passed in filter events */
  278. __u32 flags;
  279. };
  280. /*
  281. * Elementary stream data information associated
  282. * with DMX_EVENT_NEW_ES_DATA event
  283. */
  284. struct dmx_es_data_event_info {
  285. /* Buffer user-space handle */
  286. int buf_handle;
  287. /*
  288. * Cookie to provide when releasing the buffer
  289. * using the DMX_RELEASE_DECODER_BUFFER ioctl command
  290. */
  291. int cookie;
  292. /* Offset of data from the beginning of the buffer */
  293. __u32 offset;
  294. /* Length of data in buffer (in bytes) */
  295. __u32 data_len;
  296. /* Indication whether PTS value is valid */
  297. int pts_valid;
  298. /* PTS value associated with the buffer */
  299. __u64 pts;
  300. /* Indication whether DTS value is valid */
  301. int dts_valid;
  302. /* DTS value associated with the buffer */
  303. __u64 dts;
  304. /* STC value associated with the buffer in 27MHz */
  305. __u64 stc;
  306. /*
  307. * Number of TS packets with Transport Error Indicator (TEI) set
  308. * in the TS packet header since last reported event
  309. */
  310. __u32 transport_error_indicator_counter;
  311. /* Number of continuity errors since last reported event */
  312. __u32 continuity_error_counter;
  313. /* Total number of TS packets processed since last reported event */
  314. __u32 ts_packets_num;
  315. /*
  316. * Number of dropped bytes due to insufficient buffer space,
  317. * since last reported event
  318. */
  319. __u32 ts_dropped_bytes;
  320. };
  321. /* Marker details associated with DMX_EVENT_MARKER event */
  322. struct dmx_marker_event_info {
  323. /* Marker id */
  324. __u64 id;
  325. };
  326. /* Indexing information associated with DMX_EVENT_NEW_INDEX_ENTRY event */
  327. struct dmx_index_event_info {
  328. /* Index entry type, one of of DMX_IDX_* */
  329. __u64 type;
  330. /*
  331. * The PID the index entry belongs to.
  332. * In case of recording filter, multiple PIDs may exist in the same
  333. * filter through DMX_ADD_PID ioctl and each can be indexed separately.
  334. */
  335. __u16 pid;
  336. /*
  337. * The TS packet number in the recorded data at which
  338. * the indexing event is found.
  339. */
  340. __u64 match_tsp_num;
  341. /*
  342. * The TS packet number in the recorded data preceding
  343. * match_tsp_num and has PUSI set.
  344. */
  345. __u64 last_pusi_tsp_num;
  346. /* STC associated with match_tsp_num, in 27MHz */
  347. __u64 stc;
  348. };
  349. /* Scrambling information associated with DMX_EVENT_SCRAMBLING_STATUS_CHANGE */
  350. struct dmx_scrambling_status_event_info {
  351. /*
  352. * The PID which its scrambling bit status changed.
  353. * In case of recording filter, multiple PIDs may exist in the same
  354. * filter through DMX_ADD_PID ioctl, each may have
  355. * different scrambling bits status.
  356. */
  357. __u16 pid;
  358. /* old value of scrambling bits */
  359. __u8 old_value;
  360. /* new value of scrambling bits */
  361. __u8 new_value;
  362. };
  363. /*
  364. * Filter's event returned through DMX_GET_EVENT.
  365. * poll with POLLPRI would block until events are available.
  366. */
  367. struct dmx_filter_event {
  368. enum dmx_event type;
  369. union {
  370. struct dmx_pes_event_info pes;
  371. struct dmx_section_event_info section;
  372. struct dmx_rec_chunk_event_info recording_chunk;
  373. struct dmx_pcr_event_info pcr;
  374. struct dmx_es_data_event_info es_data;
  375. struct dmx_marker_event_info marker;
  376. struct dmx_index_event_info index;
  377. struct dmx_scrambling_status_event_info scrambling_status;
  378. } params;
  379. };
  380. /* Filter's buffer requirement returned in dmx_caps */
  381. struct dmx_buffer_requirement {
  382. /* Buffer size alignment, 0 means no special requirement */
  383. __u32 size_alignment;
  384. /* Maximum buffer size allowed */
  385. __u32 max_size;
  386. /* Maximum number of linear buffers handled by demux */
  387. __u32 max_buffer_num;
  388. /* Feature support bitmap as detailed below */
  389. __u32 flags;
  390. /* Buffer must be allocated as physically contiguous memory */
  391. #define DMX_BUFFER_CONTIGUOUS_MEM 0x1
  392. /* If the filter's data is decrypted, the buffer should be secured one */
  393. #define DMX_BUFFER_SECURED_IF_DECRYPTED 0x2
  394. /* Buffer can be allocated externally */
  395. #define DMX_BUFFER_EXTERNAL_SUPPORT 0x4
  396. /* Buffer can be allocated internally */
  397. #define DMX_BUFFER_INTERNAL_SUPPORT 0x8
  398. /* Filter output can be output to a linear buffer group */
  399. #define DMX_BUFFER_LINEAR_GROUP_SUPPORT 0x10
  400. };
  401. /* Out-of-band (OOB) command */
  402. struct dmx_oob_command {
  403. enum dmx_oob_cmd type;
  404. union {
  405. struct dmx_marker_event_info marker;
  406. } params;
  407. };
  408. typedef struct dmx_caps {
  409. __u32 caps;
  410. /* Indicates whether demux support playback from memory in pull mode */
  411. #define DMX_CAP_PULL_MODE 0x01
  412. /* Indicates whether demux support indexing of recorded video stream */
  413. #define DMX_CAP_VIDEO_INDEXING 0x02
  414. /* Indicates whether demux support sending data directly to video decoder */
  415. #define DMX_CAP_VIDEO_DECODER_DATA 0x04
  416. /* Indicates whether demux support sending data directly to audio decoder */
  417. #define DMX_CAP_AUDIO_DECODER_DATA 0x08
  418. /* Indicates whether demux support sending data directly to subtitle decoder */
  419. #define DMX_CAP_SUBTITLE_DECODER_DATA 0x10
  420. /* Indicates whether TS insertion is supported */
  421. #define DMX_CAP_TS_INSERTION 0x20
  422. /* Indicates whether playback from secured input is supported */
  423. #define DMX_CAP_SECURED_INPUT_PLAYBACK 0x40
  424. /* Number of decoders demux can output data to */
  425. int num_decoders;
  426. /* Number of demux devices */
  427. int num_demux_devices;
  428. /* Max number of PID filters */
  429. int num_pid_filters;
  430. /* Max number of section filters */
  431. int num_section_filters;
  432. /*
  433. * Max number of section filters using same PID,
  434. * 0 if not supported
  435. */
  436. int num_section_filters_per_pid;
  437. /*
  438. * Length of section filter, not including section
  439. * length field (2 bytes).
  440. */
  441. int section_filter_length;
  442. /* Max number of demod based input */
  443. int num_demod_inputs;
  444. /* Max number of memory based input */
  445. int num_memory_inputs;
  446. /* Overall bitrate from all inputs concurrently. Mbit/sec */
  447. int max_bitrate;
  448. /* Max bitrate from single demod input. Mbit/sec */
  449. int demod_input_max_bitrate;
  450. /* Max bitrate from single memory input. Mbit/sec */
  451. int memory_input_max_bitrate;
  452. /* Max number of supported cipher operations per PID */
  453. int num_cipher_ops;
  454. /* Max possible value of STC reported by demux, in 27MHz */
  455. __u64 max_stc;
  456. struct dmx_buffer_requirement section;
  457. /* For PES not sent to decoder */
  458. struct dmx_buffer_requirement pes;
  459. /* For PES sent to decoder */
  460. struct dmx_buffer_requirement decoder;
  461. /* Recording buffer for recording of 188 bytes packets */
  462. struct dmx_buffer_requirement recording_188_tsp;
  463. /* Recording buffer for recording of 192 bytes packets */
  464. struct dmx_buffer_requirement recording_192_tsp;
  465. /* DVR input buffer for playback of 188 bytes packets */
  466. struct dmx_buffer_requirement playback_188_tsp;
  467. /* DVR input buffer for playback of 192 bytes packets */
  468. struct dmx_buffer_requirement playback_192_tsp;
  469. } dmx_caps_t;
  470. typedef enum {
  471. DMX_SOURCE_FRONT0 = 0,
  472. DMX_SOURCE_FRONT1,
  473. DMX_SOURCE_FRONT2,
  474. DMX_SOURCE_FRONT3,
  475. DMX_SOURCE_DVR0 = 16,
  476. DMX_SOURCE_DVR1,
  477. DMX_SOURCE_DVR2,
  478. DMX_SOURCE_DVR3
  479. } dmx_source_t;
  480. enum dmx_tsp_format_t {
  481. DMX_TSP_FORMAT_188 = 0,
  482. DMX_TSP_FORMAT_192_TAIL,
  483. DMX_TSP_FORMAT_192_HEAD,
  484. DMX_TSP_FORMAT_204,
  485. };
  486. enum dmx_playback_mode_t {
  487. /*
  488. * In push mode, if one of output buffers
  489. * is full, the buffer would overflow
  490. * and demux continue processing incoming stream.
  491. * This is the default mode. When playing from frontend,
  492. * this is the only mode that is allowed.
  493. */
  494. DMX_PB_MODE_PUSH = 0,
  495. /*
  496. * In pull mode, if one of output buffers
  497. * is full, demux stalls waiting for free space,
  498. * this would cause DVR input buffer fullness
  499. * to accumulate.
  500. * This mode is possible only when playing
  501. * from DVR.
  502. */
  503. DMX_PB_MODE_PULL,
  504. };
  505. struct dmx_stc {
  506. unsigned int num; /* input : which STC? 0..N */
  507. unsigned int base; /* output: divisor for stc to get 90 kHz clock */
  508. __u64 stc; /* output: stc in 'base'*90 kHz units */
  509. };
  510. enum dmx_buffer_mode {
  511. /*
  512. * demux buffers are allocated internally
  513. * by the demux driver. This is the default mode.
  514. * DMX_SET_BUFFER_SIZE can be used to set the size of
  515. * this buffer.
  516. */
  517. DMX_BUFFER_MODE_INTERNAL,
  518. /*
  519. * demux buffers are allocated externally and provided
  520. * to demux through DMX_SET_BUFFER.
  521. * When this mode is used DMX_SET_BUFFER_SIZE and
  522. * mmap are prohibited.
  523. */
  524. DMX_BUFFER_MODE_EXTERNAL,
  525. };
  526. struct dmx_buffer {
  527. unsigned int size;
  528. int handle;
  529. /*
  530. * The following indication is relevant only when setting
  531. * DVR input buffer. It indicates whether the input buffer
  532. * being set is secured one or not. Secured (locked) buffers
  533. * are required for playback from secured input. In such case
  534. * write() syscall is not allowed.
  535. */
  536. int is_protected;
  537. };
  538. struct dmx_decoder_buffers {
  539. /*
  540. * Specify if linear buffer support is requested. If set, buffers_num
  541. * must be greater than 1
  542. */
  543. int is_linear;
  544. /*
  545. * Specify number of external buffers allocated by user.
  546. * If set to 0 means internal buffer allocation is requested
  547. */
  548. __u32 buffers_num;
  549. /* Specify buffer size, either external or internal */
  550. __u32 buffers_size;
  551. /* Array of externally allocated buffer handles */
  552. int handles[DMX_MAX_DECODER_BUFFER_NUM];
  553. };
  554. struct dmx_secure_mode {
  555. /*
  556. * Specifies whether the filter is secure or not.
  557. * Filter should be set as secured if the filter's data *may* include
  558. * encrypted data that would require decryption configured through
  559. * DMX_SET_CIPHER ioctl. The setting may be done while
  560. * filter is in idle state only.
  561. */
  562. int is_secured;
  563. };
  564. struct dmx_cipher_operation {
  565. /* Indication whether the operation is encryption or decryption */
  566. int encrypt;
  567. /* The ID of the key used for decryption or encryption */
  568. __u32 key_ladder_id;
  569. };
  570. #define DMX_MAX_CIPHER_OPERATIONS_COUNT 5
  571. struct dmx_cipher_operations {
  572. /*
  573. * The PID to perform the cipher operations on.
  574. * In case of recording filter, multiple PIDs may exist in the same
  575. * filter through DMX_ADD_PID ioctl, each may have different
  576. * cipher operations.
  577. */
  578. __u16 pid;
  579. /* Total number of operations */
  580. __u8 operations_count;
  581. /*
  582. * Cipher operation to perform on the given PID.
  583. * The operations are performed in the order they are given.
  584. */
  585. struct dmx_cipher_operation operations[DMX_MAX_CIPHER_OPERATIONS_COUNT];
  586. };
  587. struct dmx_events_mask {
  588. /*
  589. * Bitmask of events to be disabled (dmx_event).
  590. * Disabled events will not be notified to the user.
  591. * By default all events are enabled except for
  592. * DMX_EVENT_NEW_ES_DATA.
  593. * Overflow event can't be disabled.
  594. */
  595. __u32 disable_mask;
  596. /*
  597. * Bitmask of events that will not wake-up the user
  598. * when user calls poll with POLLPRI flag.
  599. * Events that are used as wake-up source should not be
  600. * disabled in disable_mask or they would not be used
  601. * as a wake-up source.
  602. * By default all enabled events are set as wake-up events.
  603. * Overflow event can't be disabled as a wake-up source.
  604. */
  605. __u32 no_wakeup_mask;
  606. /*
  607. * Number of ready wake-up events which will trigger
  608. * a wake-up when user calls poll with POLLPRI flag.
  609. * Default is set to 1.
  610. */
  611. __u32 wakeup_threshold;
  612. };
  613. struct dmx_indexing_params {
  614. /*
  615. * PID to index. In case of recording filter, multiple PIDs
  616. * may exist in the same filter through DMX_ADD_PID ioctl.
  617. * It is assumed that the PID was already added using DMX_ADD_PID
  618. * or an error will be reported.
  619. */
  620. __u16 pid;
  621. /* enable or disable indexing, default is disabled */
  622. int enable;
  623. /* combination of DMX_IDX_* bits */
  624. __u64 types;
  625. };
  626. struct dmx_set_ts_insertion {
  627. /*
  628. * Unique identifier managed by the caller.
  629. * This identifier can be used later to remove the
  630. * insertion using DMX_ABORT_TS_INSERTION ioctl.
  631. */
  632. __u32 identifier;
  633. /*
  634. * Repetition time in msec, minimum allowed value is 25msec.
  635. * 0 repetition time means one-shot insertion is done.
  636. * Insertion done based on wall-clock.
  637. */
  638. __u32 repetition_time;
  639. /*
  640. * TS packets buffer to be inserted.
  641. * The buffer is inserted as-is to the recording buffer
  642. * without any modification.
  643. * It is advised to set discontinuity flag in the very
  644. * first TS packet in the buffer.
  645. */
  646. const __u8 *ts_packets;
  647. /*
  648. * Size in bytes of the TS packets buffer to be inserted.
  649. * Should be in multiples of 188 or 192 bytes
  650. * depending on recording filter output format.
  651. */
  652. size_t size;
  653. };
  654. struct dmx_abort_ts_insertion {
  655. /*
  656. * Identifier of the insertion buffer previously set
  657. * using DMX_SET_TS_INSERTION.
  658. */
  659. __u32 identifier;
  660. };
  661. struct dmx_scrambling_bits {
  662. /*
  663. * The PID to return its scrambling bit value.
  664. * In case of recording filter, multiple PIDs may exist in the same
  665. * filter through DMX_ADD_PID ioctl, each may have different
  666. * scrambling bits status.
  667. */
  668. __u16 pid;
  669. /* Current value of scrambling bits: 0, 1, 2 or 3 */
  670. __u8 value;
  671. };
  672. #define DMX_START _IO('o', 41)
  673. #define DMX_STOP _IO('o', 42)
  674. #define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
  675. #define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
  676. #define DMX_SET_BUFFER_SIZE _IO('o', 45)
  677. #define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
  678. #define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
  679. #define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
  680. #define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
  681. #define DMX_ADD_PID _IOW('o', 51, __u16)
  682. #define DMX_REMOVE_PID _IOW('o', 52, __u16)
  683. #define DMX_SET_TS_PACKET_FORMAT _IOW('o', 53, enum dmx_tsp_format_t)
  684. #define DMX_SET_TS_OUT_FORMAT _IOW('o', 54, enum dmx_tsp_format_t)
  685. #define DMX_SET_DECODER_BUFFER_SIZE _IO('o', 55)
  686. #define DMX_GET_BUFFER_STATUS _IOR('o', 56, struct dmx_buffer_status)
  687. #define DMX_RELEASE_DATA _IO('o', 57)
  688. #define DMX_FEED_DATA _IO('o', 58)
  689. #define DMX_SET_PLAYBACK_MODE _IOW('o', 59, enum dmx_playback_mode_t)
  690. #define DMX_GET_EVENT _IOR('o', 60, struct dmx_filter_event)
  691. #define DMX_SET_BUFFER_MODE _IOW('o', 61, enum dmx_buffer_mode)
  692. #define DMX_SET_BUFFER _IOW('o', 62, struct dmx_buffer)
  693. #define DMX_SET_DECODER_BUFFER _IOW('o', 63, struct dmx_decoder_buffers)
  694. #define DMX_REUSE_DECODER_BUFFER _IO('o', 64)
  695. #define DMX_SET_SECURE_MODE _IOW('o', 65, struct dmx_secure_mode)
  696. #define DMX_SET_EVENTS_MASK _IOW('o', 66, struct dmx_events_mask)
  697. #define DMX_GET_EVENTS_MASK _IOR('o', 67, struct dmx_events_mask)
  698. #define DMX_PUSH_OOB_COMMAND _IOW('o', 68, struct dmx_oob_command)
  699. #define DMX_SET_INDEXING_PARAMS _IOW('o', 69, struct dmx_indexing_params)
  700. #define DMX_SET_TS_INSERTION _IOW('o', 70, struct dmx_set_ts_insertion)
  701. #define DMX_ABORT_TS_INSERTION _IOW('o', 71, struct dmx_abort_ts_insertion)
  702. #define DMX_GET_SCRAMBLING_BITS _IOWR('o', 72, struct dmx_scrambling_bits)
  703. #define DMX_SET_CIPHER _IOW('o', 73, struct dmx_cipher_operations)
  704. #define DMX_FLUSH_BUFFER _IO('o', 74)
  705. #define DMX_GET_PCR_TS_INSERTED _IOR('o', 75, unsigned long long int)
  706. #endif /*_DVBDMX_H_*/