[linux-dvb] [PATCH] dvb-kernel-v4 demux.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marcel, 

Mws writes:
> attached find a patch for linux/include/linux/dvb/demux.h 
> 
> reason - re-establish compatibility with c++. 
> 
> if you use enum datatypes as flags / events c++ compiler
> will cause an invalid conversion from int to enum datatype 
> if you try to bitwise or the flags or event filter masks.

Thank you for your patch. 

I have been thinking about this for some time now and I've come to the 
conclusion that neither enums nor defines are suitable here. The reason is 
that some combinations of these flags don't make sense (in contrast to the 
recording filter events which can be combined in any way). So IMO these 
flags should be split up into logical sections, like this. 

Instead of having one "flags" member for the pid filter, we should have a 
whole structure for defining special filter properties. It should be able to 
memset() the whole structure to 0 and then get the default behaviour. 

enum dvb_demux_pid_filter_packet_selection {
	DVB_DEMUX_TS_PACKET       = (1 << 0), /*!< default: process the whole TS 
packet */
	DVB_DEMUX_PAYLOAD_ONLY    = (1 << 1), /*!< only deliver the payload (ie. 
strip off the TS header) */
	DVB_DEMUX_ADAPTATION_ONLY = (1 << 2), /*!< only deliver the TS header and 
any adaptation fields if present */
}; 

enum dvb_demux_pid_filter_prio_selection {
	DVB_DEMUX_PRIO_IGNORE  = (1 << 0), /*!< default: ignore priorities of TS 
packets */
	DVB_DEMUX_PRIO_NORMAL  = (1 << 1), /*!< only deliver low priority packets 
on the specified pid */
	DVB_DEMUX_PRIO_HIGH    = (1 << 2), /*!< only deliver high priority packets 
on the specified pid */
}; 

struct dvb_demux_pid_filter_prop {
	enum dvb_demux_pid_filter_packet_selection packet;
	enum dvb_demux_pid_filter_prio_selection prio;
	int wait_for_pusi:1;
	int output_dupes:1;
	int output_errpkts:1;
}; 

Then the PID filter structure can look like this:
struct dvb_demux_pid_filter {
	uint16_t pid;                          /*!< PID to filter (unless 
DVB_DEMUX_FULL_TS is specified for the flags) */
	struct dvb_demux_pid_filter_prop prop; /*!< special filtering properties */
	uint32_t buffer_size;                  /*!< in bytes, size of internal 
buffer */
	uint32_t buffer_threshold;             /*!< in bytes, notify threshold, 
must be <= buffer_size */
}; 

The user just needs to make sure to zero out the prop member to get the 
default behaviour. 

Unfortunately, this has a side effect on capabilities. Before, we just 
returned the enum when the user queried DVB_DEMUX_CAP_PID_FILTER_FLAGS. 

Now, this is not possible anymore. One solution would be to split up the one 
pid filter flags capability to more detailied individual flags, like this: 

	DVB_DEMUX_CAP_NUM_PID_FILTERS,             /*!< integer, number of 
available pid filters (\ref DVB_DEMUX_SET_PID_FILTER)*/
	DVB_DEMUX_CAP_PID_FILTER_PAYLOAD_ONLY_SELECTION, /*!< */
	DVB_DEMUX_CAP_PID_FILTER_ADAPTATION_ONLY_SELECTION, /*!< */
	DVB_DEMUX_CAP_PID_FILTER_PRIO_NORMAL_SELECTION,   /*!< */
	DVB_DEMUX_CAP_PID_FILTER_PRIO_HIGH_SELECTION,   /*!< */
	DVB_DEMUX_CAP_PID_FILTER_WAIT_FOR_PUSI,    /*!< */
	DVB_DEMUX_CAP_PID_FILTER_OUTPUT_DUPES,     /*!< */
	DVB_DEMUX_CAP_PID_FILTER_OUTPUT_ERRPKTS,   /*!< */ 

What do you think? 

> regards
> marcel

CU
Michael. 




[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux