[linux-dvb] libdvbapi clarification

Marcel Siegert mws at linuxtv.org
Tue Jul 10 10:56:37 CEST 2007

On Tuesday 10 July 2007, David Härdeman wrote:
> I'm trying to understand the dvbdemux_set_section_filter function in
> dvp-apps/lib/libdvbapi/dvbdemux.c (lines 74 - 93).
> It used to take 16 filter and 16 mask parameters, but then it was changed
> 15 months ago to take 18 filter and 18 mask parameters, then it throws
> away 2 of each:
> int dvbdemux_set_section_filter(int fd, int pid,
> 				uint8_t filter[18], uint8_t mask[18],
>  				int start, int checkcrc)
> {
> 	struct dmx_sct_filter_params sctfilter;
> 	memset(&sctfilter, 0, sizeof(sctfilter));
> 	sctfilter.pid = pid;
> 	memcpy(sctfilter.filter.filter, filter, 1);
> 	memcpy(sctfilter.filter.filter+1, filter+3, 15);
> 	memcpy(sctfilter.filter.mask, mask, 1);
> 	memcpy(sctfilter.filter.mask+1, mask+3, 15);


i think it was done due to following knowledge of the developer

if you filter a section you can filter on e.g. the table id but NOT on the size ect.
(those are used as byte 2 + 3 of a section)

so if you would read the source normally, you would think you can filter on those values.
having the two "unused" values within the filter array it makes life easier to count the bytes
you want to filter and to set the right mask. 
it can be more irretating than usefull, i must admit.

> What is the purpose of this?
> Second, how is the mask used? Would for example a filter value of 0x50 and
> a mask of 0xf0 mean that all sections 0x50 - 0x5f would pass through the
> section filter?
yes, the mask is used in that way. 

best regards

More information about the linux-dvb mailing list