libdvb_rs/dmx/
sys.rs

1use bitflags::bitflags;
2use strum::FromRepr;
3
4pub use {
5    DmxOutput::*,
6    DmxInput::*,
7    DmxTsPes::*,
8};
9
10
11/// Output for the demux
12#[repr(u32)]
13#[allow(non_camel_case_types)]
14#[derive(Debug, Copy, Clone, PartialEq, Eq, FromRepr)]
15pub enum DmxOutput {
16    /// Streaming directly to decoder
17    DMX_OUT_DECODER = 0,
18    /// Output going to a memory buffer (to be retrieved via the read command).
19    /// Delivers the stream output to the demux device on which the ioctl
20    /// is called.
21    DMX_OUT_TAP = 1,
22    /// Output multiplexed into a new TS (to be retrieved by reading from the
23    /// logical DVR device). Routes output to the logical DVR device
24    /// `/dev/dvb/adapter?/dvr?`, which delivers a TS multiplexed from all
25    /// filters for which DMX_OUT_TS_TAP was specified.
26    DMX_OUT_TS_TAP = 2,
27    /// Like DMX_OUT_TS_TAP but retrieved from the DMX device.
28    DMX_OUT_TSDEMUX_TAP = 3
29}
30
31
32/// Input from the demux
33#[repr(u32)]
34#[allow(non_camel_case_types)]
35#[derive(Debug, Copy, Clone, PartialEq, Eq, FromRepr)]
36pub enum DmxInput {
37    /// Input from a front-end device
38    DMX_IN_FRONTEND = 0,
39    /// Input from the logical DVR device
40    DMX_IN_DVR = 1
41}
42
43
44/// type of the PES filter
45#[repr(u32)]
46#[allow(non_camel_case_types)]
47#[derive(Debug, Copy, Clone, PartialEq, Eq, FromRepr)]
48pub enum DmxTsPes {
49    /// first audio PID
50    DMX_PES_AUDIO0               = 0,
51    /// first video PID
52    DMX_PES_VIDEO0               = 1,
53    /// first teletext PID
54    DMX_PES_TELETEXT0            = 2,
55    /// first subtitle PID
56    DMX_PES_SUBTITLE0            = 3,
57    /// first Program Clock Reference PID
58    DMX_PES_PCR0                 = 4,
59
60    /// second audio PID.
61    DMX_PES_AUDIO1               = 5,
62    /// second video PID.
63    DMX_PES_VIDEO1               = 6,
64    /// second teletext PID.
65    DMX_PES_TELETEXT1            = 7,
66    /// second subtitle PID.
67    DMX_PES_SUBTITLE1            = 8,
68    /// second Program Clock Reference PID.
69    DMX_PES_PCR1                 = 9,
70
71    /// third audio PID.
72    DMX_PES_AUDIO2               = 10,
73    /// third video PID.
74    DMX_PES_VIDEO2               = 11,
75    /// third teletext PID.
76    DMX_PES_TELETEXT2            = 12,
77    /// third subtitle PID.
78    DMX_PES_SUBTITLE2            = 13,
79    /// third Program Clock Reference PID.
80    DMX_PES_PCR2                 = 14,
81
82    /// fourth audio PID.
83    DMX_PES_AUDIO3               = 15,
84    /// fourth video PID.
85    DMX_PES_VIDEO3               = 16,
86    /// fourth teletext PID.
87    DMX_PES_TELETEXT3            = 17,
88    /// fourth subtitle PID.
89    DMX_PES_SUBTITLE3            = 18,
90    /// fourth Program Clock Reference PID.
91    DMX_PES_PCR3                 = 19,
92
93    /// any other PID.
94    DMX_PES_OTHER                = 20,
95}
96
97
98bitflags! {
99    /// Flags for the demux filter
100    #[repr(C)]
101    pub struct DmxFilterFlags : u32 {
102        /// Only deliver sections where the CRC check succeeded
103        const DMX_CHECK_CRC                = 1;
104        /// Disable the section filter after one section has been delivered
105        const DMX_ONESHOT                  = 2;
106        /// Start filter immediately without requiring a `DMX_START`
107        const DMX_IMMEDIATE_START          = 4;
108    }
109}
110
111
112/// Specifies Packetized Elementary Stream (PES) filter parameters
113#[repr(C)]
114#[derive(Debug, Copy, Clone)]
115pub struct DmxPesFilterParams {
116    /// PID to be filtered. 8192 to pass all PID's
117    pub pid: u16,
118    /// Demux input, as specified by `DMX_IN_*`
119    pub input: DmxInput,
120    /// Demux output, as specified by `DMX_OUT_*`
121    pub output: DmxOutput,
122    /// Type of the pes filter, as specified by `DMX_PES_*`
123    pub pes_type: DmxTsPes,
124    /// Demux PES flags
125    pub flags: DmxFilterFlags,
126}
127
128pub const DMX_FILTER_SIZE: usize = 16;
129
130/// Specifies demux section header filter parameters
131#[repr(C)]
132#[derive(Debug, Copy, Clone)]
133pub struct DmxFilter {
134    /// Bit array with bits to be matched at the section header
135    pub filter: [u8; DMX_FILTER_SIZE],
136    /// Bits that are valid at the filter bit array
137    pub mask: [u8; DMX_FILTER_SIZE],
138    /// Mode of match: if bit is zero, it will match if equal (positive match); if bit is one, it will match if the bit is negated.
139    pub mode: [u8; DMX_FILTER_SIZE],
140}
141
142/// Specifies Section header (SCT) filter parameters
143#[repr(C)]
144#[derive(Debug, Copy, Clone)]
145pub struct DmxSctFilterParams {
146    /// PID to be filtered. 8192 to pass all PID's
147    pub pid: u16,
148    /// Section header filter, as defined by DmxFilter
149    pub filter: DmxFilter,
150    /// Maximum time to filter, in milliseconds
151    pub timeout: u32,
152    /// Extra flags for the section filter, as specified by DmxFilterFlags
153    pub flags: DmxFilterFlags
154}