Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * dvb_demux.h: DVB kernel demux API |
| 3 | * |
| 4 | * Copyright (C) 2000-2001 Marcus Metzler & Ralph Metzler |
| 5 | * for convergence integrated media GmbH |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public License |
| 9 | * as published by the Free Software Foundation; either version 2.1 |
| 10 | * of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 | * |
| 21 | */ |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #ifndef _DVB_DEMUX_H_ |
| 24 | #define _DVB_DEMUX_H_ |
| 25 | |
| 26 | #include <linux/time.h> |
| 27 | #include <linux/timer.h> |
| 28 | #include <linux/spinlock.h> |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 29 | #include <linux/mutex.h> |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 30 | #include <linux/debugfs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | #include "demux.h" |
| 33 | |
| 34 | #define DMX_TYPE_TS 0 |
| 35 | #define DMX_TYPE_SEC 1 |
| 36 | #define DMX_TYPE_PES 2 |
| 37 | |
| 38 | #define DMX_STATE_FREE 0 |
| 39 | #define DMX_STATE_ALLOCATED 1 |
| 40 | #define DMX_STATE_SET 2 |
| 41 | #define DMX_STATE_READY 3 |
| 42 | #define DMX_STATE_GO 4 |
| 43 | |
| 44 | #define DVB_DEMUX_MASK_MAX 18 |
| 45 | |
Abylay Ospan | 0d83463 | 2009-06-06 09:31:34 -0300 | [diff] [blame] | 46 | #define MAX_PID 0x1fff |
| 47 | |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 48 | #define TIMESTAMP_LEN 4 |
| 49 | |
Abylay Ospan | 26b9d6c | 2009-11-01 18:46:53 -0300 | [diff] [blame] | 50 | #define SPEED_PKTS_INTERVAL 50000 |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | struct dvb_demux_filter { |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 53 | struct dmx_section_filter filter; |
| 54 | u8 maskandmode[DMX_MAX_FILTER_SIZE]; |
| 55 | u8 maskandnotmode[DMX_MAX_FILTER_SIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | int doneq; |
| 57 | |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 58 | struct dvb_demux_filter *next; |
| 59 | struct dvb_demux_feed *feed; |
| 60 | int index; |
| 61 | int state; |
| 62 | int type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 64 | u16 hw_handle; |
| 65 | struct timer_list timer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head) |
| 69 | |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 70 | |
| 71 | struct dmx_index_entry { |
| 72 | struct dmx_index_event_info event; |
| 73 | struct list_head next; |
| 74 | }; |
| 75 | |
| 76 | #define DMX_IDX_EVENT_QUEUE_SIZE DMX_EVENT_QUEUE_SIZE |
| 77 | |
| 78 | struct dvb_demux_rec_info { |
| 79 | /* Reference counter for number of feeds using this information */ |
| 80 | int ref_count; |
| 81 | |
| 82 | /* Counter for number of TS packets output to recording buffer */ |
| 83 | u64 ts_output_count; |
| 84 | |
| 85 | /* Indexing information */ |
| 86 | struct { |
| 87 | /* |
| 88 | * Minimum TS packet number encountered in recording filter |
| 89 | * among all feeds that search for video patterns |
| 90 | */ |
| 91 | u64 min_pattern_tsp_num; |
| 92 | |
| 93 | /* Number of indexing-enabled feeds */ |
| 94 | u8 indexing_feeds_num; |
| 95 | |
| 96 | /* Number of feeds with video pattern search request */ |
| 97 | u8 pattern_search_feeds_num; |
| 98 | |
| 99 | /* Index entries pool */ |
| 100 | struct dmx_index_entry events[DMX_IDX_EVENT_QUEUE_SIZE]; |
| 101 | |
| 102 | /* List of free entries that can be used for new index events */ |
| 103 | struct list_head free_list; |
| 104 | |
| 105 | /* List holding ready index entries not notified to user yet */ |
| 106 | struct list_head ready_list; |
| 107 | } idx_info; |
| 108 | }; |
| 109 | |
| 110 | #define DVB_DMX_MAX_PATTERN_LEN 6 |
| 111 | struct dvb_dmx_video_patterns { |
| 112 | /* the byte pattern to look for */ |
| 113 | u8 pattern[DVB_DMX_MAX_PATTERN_LEN]; |
| 114 | |
| 115 | /* the byte mask to use (same length as pattern) */ |
| 116 | u8 mask[DVB_DMX_MAX_PATTERN_LEN]; |
| 117 | |
| 118 | /* the length of the pattern, in bytes */ |
| 119 | size_t size; |
| 120 | |
| 121 | /* the type of the pattern. One of DMX_IDX_* definitions */ |
| 122 | u64 type; |
| 123 | }; |
| 124 | |
| 125 | #define DVB_DMX_MAX_FOUND_PATTERNS 20 |
| 126 | #define DVB_DMX_MAX_SEARCH_PATTERN_NUM 20 |
| 127 | struct dvb_dmx_video_prefix_size_masks { |
| 128 | /* |
| 129 | * a bit mask (per pattern) of possible prefix sizes to use |
| 130 | * when searching for a pattern that started in the previous TS packet. |
| 131 | * Updated by dvb_dmx_video_pattern_search for use in the next lookup. |
| 132 | */ |
| 133 | u32 size_mask[DVB_DMX_MAX_FOUND_PATTERNS]; |
| 134 | }; |
| 135 | |
| 136 | struct dvb_dmx_video_patterns_results { |
| 137 | struct { |
| 138 | /* |
| 139 | * The offset in the buffer where the pattern was found. |
| 140 | * If a pattern is found using a prefix (i.e. started on the |
| 141 | * previous buffer), offset is zero. |
| 142 | */ |
| 143 | u32 offset; |
| 144 | |
| 145 | /* |
| 146 | * The type of the pattern found. |
| 147 | * One of DMX_IDX_* definitions. |
| 148 | */ |
| 149 | u64 type; |
| 150 | |
| 151 | /* The prefix size that was used to find this pattern */ |
| 152 | u32 used_prefix_size; |
| 153 | } info[DVB_DMX_MAX_FOUND_PATTERNS]; |
| 154 | }; |
| 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | struct dvb_demux_feed { |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 157 | union { |
| 158 | struct dmx_ts_feed ts; |
| 159 | struct dmx_section_feed sec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | } feed; |
| 161 | |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 162 | union { |
| 163 | dmx_ts_cb ts; |
| 164 | dmx_section_cb sec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | } cb; |
| 166 | |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 167 | union { |
| 168 | dmx_ts_data_ready_cb ts; |
| 169 | dmx_section_data_ready_cb sec; |
| 170 | } data_ready_cb; |
| 171 | |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 172 | struct dvb_demux *demux; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | void *priv; |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 174 | int type; |
| 175 | int state; |
| 176 | u16 pid; |
| 177 | u8 *buffer; |
| 178 | int buffer_size; |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 179 | enum dmx_tsp_format_t tsp_out_format; |
| 180 | struct dmx_secure_mode secure_mode; |
| 181 | struct dmx_cipher_operations cipher_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Arnd Bergmann | e95be15 | 2016-06-17 17:46:28 -0300 | [diff] [blame] | 183 | ktime_t timeout; |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 184 | struct dvb_demux_filter *filter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 186 | int ts_type; |
| 187 | enum dmx_ts_pes pes_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 189 | int cc; |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 190 | int first_cc; |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 191 | int pusi_seen; /* prevents feeding of garbage from previous section */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 193 | u8 scrambling_bits; |
| 194 | |
| 195 | struct dvb_demux_rec_info *rec_info; |
| 196 | u64 prev_tsp_num; |
| 197 | u64 prev_stc; |
| 198 | u64 curr_pusi_tsp_num; |
| 199 | u64 prev_pusi_tsp_num; |
| 200 | int prev_frame_valid; |
| 201 | u64 prev_frame_type; |
| 202 | int first_frame_in_seq; |
| 203 | int first_frame_in_seq_notified; |
| 204 | u64 last_pattern_tsp_num; |
| 205 | int pattern_num; |
| 206 | const struct dvb_dmx_video_patterns *patterns[DVB_DMX_MAX_SEARCH_PATTERN_NUM]; |
| 207 | struct dvb_dmx_video_prefix_size_masks prefix_size; |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 208 | u16 peslen; |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 209 | u32 pes_tei_counter; |
| 210 | u32 pes_cont_err_counter; |
| 211 | u32 pes_ts_packets_num; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | |
| 213 | struct list_head list_head; |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 214 | unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 215 | |
| 216 | enum dmx_video_codec video_codec; |
| 217 | struct dmx_indexing_params idx_params; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | }; |
| 219 | |
| 220 | struct dvb_demux { |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 221 | struct dmx_demux dmx; |
| 222 | void *priv; |
| 223 | int filternum; |
| 224 | int feednum; |
| 225 | int (*start_feed)(struct dvb_demux_feed *feed); |
| 226 | int (*stop_feed)(struct dvb_demux_feed *feed); |
| 227 | int (*write_to_decoder)(struct dvb_demux_feed *feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | const u8 *buf, size_t len); |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 229 | int (*decoder_fullness_init)(struct dvb_demux_feed *feed); |
| 230 | int (*decoder_fullness_wait)(struct dvb_demux_feed *feed, |
| 231 | size_t required_space); |
| 232 | int (*decoder_fullness_abort)(struct dvb_demux_feed *feed); |
| 233 | int (*decoder_buffer_status)(struct dvb_demux_feed *feed, |
| 234 | struct dmx_buffer_status *dmx_buffer_status); |
| 235 | int (*reuse_decoder_buffer)(struct dvb_demux_feed *feed, |
| 236 | int cookie); |
| 237 | int (*set_cipher_op)(struct dvb_demux_feed *feed, |
| 238 | struct dmx_cipher_operations *cipher_ops); |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 239 | u32 (*check_crc32)(struct dvb_demux_feed *feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | const u8 *buf, size_t len); |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 241 | void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | const u8 *src, size_t len); |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 243 | int (*oob_command)(struct dvb_demux_feed *feed, |
| 244 | struct dmx_oob_command *cmd); |
| 245 | void (*convert_ts)(struct dvb_demux_feed *feed, |
| 246 | const u8 timestamp[TIMESTAMP_LEN], |
| 247 | u64 *timestampIn27Mhz); |
| 248 | int (*set_indexing)(struct dvb_demux_feed *feed); |
| 249 | int (*flush_decoder_buffer)(struct dvb_demux_feed *feed, size_t length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 251 | int users; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | #define MAX_DVB_DEMUX_USERS 10 |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 253 | struct dvb_demux_filter *filter; |
| 254 | struct dvb_demux_feed *feed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 256 | struct list_head frontend_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
Mauro Carvalho Chehab | fde04ab | 2013-04-04 13:25:30 -0300 | [diff] [blame] | 258 | struct dvb_demux_feed *pesfilter[DMX_PES_OTHER]; |
| 259 | u16 pids[DMX_PES_OTHER]; |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 260 | int playing; |
| 261 | int recording; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
| 263 | #define DMX_MAX_PID 0x2000 |
| 264 | struct list_head feed_list; |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 265 | u8 tsbuf[204]; |
| 266 | int tsbufp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 268 | struct mutex mutex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | spinlock_t lock; |
Abylay Ospan | 0d83463 | 2009-06-06 09:31:34 -0300 | [diff] [blame] | 270 | |
| 271 | uint8_t *cnt_storage; /* for TS continuity check */ |
Abylay Ospan | 26b9d6c | 2009-11-01 18:46:53 -0300 | [diff] [blame] | 272 | |
Arnd Bergmann | e95be15 | 2016-06-17 17:46:28 -0300 | [diff] [blame] | 273 | ktime_t speed_last_time; /* for TS speed check */ |
Abylay Ospan | 26b9d6c | 2009-11-01 18:46:53 -0300 | [diff] [blame] | 274 | uint32_t speed_pkts_cnt; /* for TS speed check */ |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 275 | |
| 276 | enum dmx_tsp_format_t tsp_format; |
| 277 | size_t ts_packet_size; |
| 278 | |
| 279 | enum dmx_playback_mode_t playback_mode; |
| 280 | int sw_filter_abort; |
| 281 | |
| 282 | struct { |
| 283 | dmx_ts_fullness ts; |
| 284 | dmx_section_fullness sec; |
| 285 | } buffer_ctrl; |
| 286 | |
| 287 | struct dvb_demux_rec_info *rec_info_pool; |
| 288 | |
| 289 | /* |
| 290 | * the following is used for debugfs exposing info |
| 291 | * about dvb demux performance. |
| 292 | */ |
| 293 | #define MAX_DVB_DEMUX_NAME_LEN 10 |
| 294 | char alias[MAX_DVB_DEMUX_NAME_LEN]; |
| 295 | |
| 296 | u32 total_process_time; |
| 297 | u32 total_crc_time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | }; |
| 299 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | int dvb_dmx_init(struct dvb_demux *dvbdemux); |
Andreas Oberritter | 9365346 | 2005-09-09 13:02:23 -0700 | [diff] [blame] | 301 | void dvb_dmx_release(struct dvb_demux *dvbdemux); |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 302 | int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf, |
| 303 | int should_lock); |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 304 | void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, |
| 305 | size_t count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); |
Andreas Oberritter | dad4a73 | 2005-09-09 13:02:26 -0700 | [diff] [blame] | 307 | void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, |
| 308 | size_t count); |
Michael Krufky | 8e15670 | 2011-08-27 18:46:37 -0300 | [diff] [blame] | 309 | void dvb_dmx_swfilter_raw(struct dvb_demux *demux, const u8 *buf, |
| 310 | size_t count); |
Udaya Bhaskara Reddy Mallavarapu | ba29a3e8 | 2017-06-12 14:57:05 +0530 | [diff] [blame] | 311 | void dvb_dmx_swfilter_format( |
| 312 | struct dvb_demux *demux, const u8 *buf, |
| 313 | size_t count, |
| 314 | enum dmx_tsp_format_t tsp_format); |
| 315 | void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf, |
| 316 | const u8 timestamp[TIMESTAMP_LEN]); |
| 317 | const struct dvb_dmx_video_patterns *dvb_dmx_get_pattern(u64 dmx_idx_pattern); |
| 318 | int dvb_dmx_video_pattern_search( |
| 319 | const struct dvb_dmx_video_patterns |
| 320 | *patterns[DVB_DMX_MAX_SEARCH_PATTERN_NUM], |
| 321 | int patterns_num, |
| 322 | const u8 *buf, size_t buf_size, |
| 323 | struct dvb_dmx_video_prefix_size_masks *prefix_size_masks, |
| 324 | struct dvb_dmx_video_patterns_results *results); |
| 325 | int dvb_demux_push_idx_event(struct dvb_demux_feed *feed, |
| 326 | struct dmx_index_event_info *idx_event, int should_lock); |
| 327 | void dvb_dmx_process_idx_pattern(struct dvb_demux_feed *feed, |
| 328 | struct dvb_dmx_video_patterns_results *patterns, int pattern, |
| 329 | u64 curr_stc, u64 prev_stc, |
| 330 | u64 curr_match_tsp, u64 prev_match_tsp, |
| 331 | u64 curr_pusi_tsp, u64 prev_pusi_tsp); |
| 332 | void dvb_dmx_notify_idx_events(struct dvb_demux_feed *feed, int should_lock); |
| 333 | int dvb_dmx_notify_section_event(struct dvb_demux_feed *feed, |
| 334 | struct dmx_data_ready *event, int should_lock); |
| 335 | void dvbdmx_ts_reset_pes_state(struct dvb_demux_feed *feed); |
| 336 | |
| 337 | /** |
| 338 | * dvb_dmx_is_video_feed - Returns whether the PES feed |
| 339 | * is video one. |
| 340 | * |
| 341 | * @feed: The feed to be checked. |
| 342 | * |
| 343 | * Return 1 if feed is video feed, 0 otherwise. |
| 344 | */ |
| 345 | static inline int dvb_dmx_is_video_feed(struct dvb_demux_feed *feed) |
| 346 | { |
| 347 | if (feed->type != DMX_TYPE_TS) |
| 348 | return 0; |
| 349 | |
| 350 | if (feed->ts_type & (~TS_DECODER)) |
| 351 | return 0; |
| 352 | |
| 353 | if ((feed->pes_type == DMX_PES_VIDEO0) || |
| 354 | (feed->pes_type == DMX_PES_VIDEO1) || |
| 355 | (feed->pes_type == DMX_PES_VIDEO2) || |
| 356 | (feed->pes_type == DMX_PES_VIDEO3)) |
| 357 | return 1; |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | /** |
| 363 | * dvb_dmx_is_audio_feed - Returns whether the PES feed |
| 364 | * is audio one. |
| 365 | * |
| 366 | * @feed: The feed to be checked. |
| 367 | * |
| 368 | * Return 1 if feed is audio feed, 0 otherwise. |
| 369 | */ |
| 370 | static inline int dvb_dmx_is_audio_feed(struct dvb_demux_feed *feed) |
| 371 | { |
| 372 | if (feed->type != DMX_TYPE_TS) |
| 373 | return 0; |
| 374 | |
| 375 | if (feed->ts_type & (~TS_DECODER)) |
| 376 | return 0; |
| 377 | |
| 378 | if ((feed->pes_type == DMX_PES_AUDIO0) || |
| 379 | (feed->pes_type == DMX_PES_AUDIO1) || |
| 380 | (feed->pes_type == DMX_PES_AUDIO2) || |
| 381 | (feed->pes_type == DMX_PES_AUDIO3)) |
| 382 | return 1; |
| 383 | |
| 384 | return 0; |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * dvb_dmx_is_pcr_feed - Returns whether the PES feed |
| 389 | * is PCR one. |
| 390 | * |
| 391 | * @feed: The feed to be checked. |
| 392 | * |
| 393 | * Return 1 if feed is PCR feed, 0 otherwise. |
| 394 | */ |
| 395 | static inline int dvb_dmx_is_pcr_feed(struct dvb_demux_feed *feed) |
| 396 | { |
| 397 | if (feed->type != DMX_TYPE_TS) |
| 398 | return 0; |
| 399 | |
| 400 | if (feed->ts_type & (~TS_DECODER)) |
| 401 | return 0; |
| 402 | |
| 403 | if ((feed->pes_type == DMX_PES_PCR0) || |
| 404 | (feed->pes_type == DMX_PES_PCR1) || |
| 405 | (feed->pes_type == DMX_PES_PCR2) || |
| 406 | (feed->pes_type == DMX_PES_PCR3)) |
| 407 | return 1; |
| 408 | |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * dvb_dmx_is_sec_feed - Returns whether this is a section feed |
| 414 | * |
| 415 | * @feed: The feed to be checked. |
| 416 | * |
| 417 | * Return 1 if feed is a section feed, 0 otherwise. |
| 418 | */ |
| 419 | static inline int dvb_dmx_is_sec_feed(struct dvb_demux_feed *feed) |
| 420 | { |
| 421 | return (feed->type == DMX_TYPE_SEC); |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * dvb_dmx_is_rec_feed - Returns whether this is a recording feed |
| 426 | * |
| 427 | * @feed: The feed to be checked. |
| 428 | * |
| 429 | * Return 1 if feed is recording feed, 0 otherwise. |
| 430 | */ |
| 431 | static inline int dvb_dmx_is_rec_feed(struct dvb_demux_feed *feed) |
| 432 | { |
| 433 | if (feed->type != DMX_TYPE_TS) |
| 434 | return 0; |
| 435 | |
| 436 | if (feed->ts_type & (TS_DECODER | TS_PAYLOAD_ONLY)) |
| 437 | return 0; |
| 438 | |
| 439 | return 1; |
| 440 | } |
| 441 | |
| 442 | static inline u16 ts_pid(const u8 *buf) |
| 443 | { |
| 444 | return ((buf[1] & 0x1f) << 8) + buf[2]; |
| 445 | } |
| 446 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
| 448 | #endif /* _DVB_DEMUX_H_ */ |