2
* libdvbdemux - a DVB demux library
4
* Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net)
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
#define LIBDVBDEMUX_H 1
32
* Source of the data to be demuxed.
34
* FRONTEND. The data will be read from the frontend on the adapter.
36
* DVR. The data will be read from the DVR device of the adapter (of course,
37
* you need to write data TO the DVR device as well).
39
#define DVBDEMUX_INPUT_FRONTEND 0
40
#define DVBDEMUX_INPUT_DVR 1
43
* Destination of the demuxed data.
45
* DECODER. Sends the data directly to a hardware decoder (if present).
47
* DEMUX. Sends the PID stream to the current demux file descriptor. HOWEVER, the
48
* data will be the payload *only* - transport stream headers will be stripped.
50
* DVR sends the data to the DVR device. The data will be the complete transport
51
* stream packets with headers intact. Note: if multiple filters specify
52
* DVBDEMUX_OUTPUT_DVR, the individual PID streams will be re-multiplexed
55
#define DVBDEMUX_OUTPUT_DECODER 0
56
#define DVBDEMUX_OUTPUT_DEMUX 1
57
#define DVBDEMUX_OUTPUT_DVR 2
62
#define DVBDEMUX_PESTYPE_AUDIO 0
63
#define DVBDEMUX_PESTYPE_VIDEO 1
64
#define DVBDEMUX_PESTYPE_TELETEXT 2
65
#define DVBDEMUX_PESTYPE_SUBTITLE 3
66
#define DVBDEMUX_PESTYPE_PCR 4
69
* Open a demux device. Can be called multiple times. These let you setup a
70
* single filter per FD. It can can also be read() from if you use a section
71
* filter, or create a pes_filter or raw_filter with output DVBDEMUX_OUTPUT_DEMUX.
73
* @param adapter Index of the DVB adapter.
74
* @param demuxdevice Index of the demux device on that adapter (usually 0).
75
* @param nonblocking If 1, frontend will be opened in nonblocking mode.
76
* @return A unix file descriptor on success, or -1 on failure.
78
extern int dvbdemux_open_demux(int adapter, int demuxdevice, int nonblocking);
81
* Open a DVR device. May be opened for writing once, or multiple times in readonly
82
* mode. It is used to either write() transport stream data to be demuxed
83
* (if input == DVBDEMUX_INPUT_DVR), or to read() a stream of demuxed data
84
* (if output == DVBDEMUX_OUTPUT_DVR).
86
* Note, all demux filters with output set to DVBDEMUX_OUTPUT_DVR will be
87
* multiplexed together and output their data on this device.
89
* @param adapter Index of the DVB adapter.
90
* @param dvrdevice Index of the dvr device on that adapter (usually 0)
91
* @param readonly If 1, frontend will be opened in readonly mode only.
92
* @param nonblocking If 1, frontend will be opened in nonblocking mode.
93
* @return A unix file descriptor on success, or -1 on failure.
95
extern int dvbdemux_open_dvr(int adapter, int dvrdevice, int readonly, int nonblocking);
98
* Set filter for the first 18 bytes of decoded SI table sections. Note that
99
* bytes 1 and 2 are _not_ filtered since they contain the length field.
101
* Conceptually, the driver computes the following for each filtered bit.
103
* (filter[X].bit[Y] & mask[X].bit[Y]) == (header[X].bit[Y] & mask[X].bit[Y])
105
* Any sections which do not match this criteria for every bit will be discarded.
107
* The SI data is always read from the frontend, and is always returned by
108
* read()ing the demux fd. FIXME: check this statement!
110
* @param fd FD as opened with dvbdemux_open_demux() above.
111
* @param pid PID of the stream.
112
* @param filter The filter values of the first 18 bytes of the desired sections.
113
* @param mask Bitmask indicating which bits in the filter array should be tested
114
* (if a bit is 1, it will be tested).
115
* @param start If 1, the filter will be started immediately. Otherwise you must
116
* call dvbdemux_start() manually.
117
* @param checkcrc If 1, the driver will check the CRC on the table sections.
118
* Any bad sections will be dropped.
119
* @return 0 on success, nonzero on failure.
121
extern int dvbdemux_set_section_filter(int fd, int pid,
122
uint8_t filter[18], uint8_t mask[18],
123
int start, int checkcrc);
126
* Set filter for a stream of PES data. This call can only used for cards
127
* equipped with a hardware decoder.
129
* @param fd FD as opened with dvbdemux_open_demux() above.
130
* @param pid PID of the stream.
131
* @param input One of DVBDEMUX_INPUT_*.
132
* @param output One of DVBDEMUX_OUTPUT_*.
133
* @param pestype One of DVBDEMUX_PESTYPE_* - this tells the decoder the type
134
* of data in this stream.
135
* @param start If 1, the filter will be started immediately. Otherwise you must
136
* call dvbdemux_start() manually.
137
* @return 0 on success, nonzero on failure.
139
extern int dvbdemux_set_pes_filter(int fd, int pid,
140
int input, int output,
145
* Create a pid filter - this will extract transport stream packets for a
148
* Note: The wildcard PID can only be used on "budget" cards.
150
* @param fd FD as opened with dvbdemux_open_demux() above.
151
* @param pid PID to retrieve, or use -1 as a wildcard for ALL PIDs.
152
* @param input One of DVBDEMUX_INPUT_*.
153
* @param output One of DVBDEMUX_OUTPUT_*.
154
* @param start If 1, the filter will be started immediately. Otherwise you must
155
* call dvbdemux_start() manually.
156
* @return 0 on success, nonzero on failure.
158
extern int dvbdemux_set_pid_filter(int fd, int pid,
159
int input, int output,
163
* Start a demux going.
165
* @param fd FD as opened with dvbdemux_open_demux() above.
166
* @return 0 on success, nonzero on failure.
168
extern int dvbdemux_start(int fd);
173
* @param fd FD as opened with dvbdemux_open_demux() above.
174
* @return 0 on success, nonzero on failure.
176
extern int dvbdemux_stop(int fd);
179
* Retrieve the current STC from the demux. This call can only used for cards
180
* equipped with a hardware decoder.
182
* @param fd FD as opened with dvbdemux_open_demux() above.
183
* @param stc Where to put the retrieved STC value (in 90kHz clock).
184
* @return 0 on success, nonzero on failure.
186
extern int dvbdemux_get_stc(int fd, uint64_t *stc);
189
* Change the internal buffer size used by the demuxer. The default buffer size
190
* is 8192 bytes. Can only be used if the demux in question is stopped.
192
* @param fd FD as opened with dvbdemux_open_demux() above.
193
* @param bufsize New buffer size to use.
194
* @return 0 on success, nonzero on failure.
196
extern int dvbdemux_set_buffer(int fd, int bufsize);
202
#endif // LIBDVBDEMUX_H