| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2008, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bsettop_message.h $ |
|---|
| 11 | * $brcm_Revision: 9 $ |
|---|
| 12 | * $brcm_Date: 2/27/08 5:38p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /BSEAV/api/include/bsettop_message.h $ |
|---|
| 19 | * |
|---|
| 20 | * 9 2/27/08 5:38p vsilyaev |
|---|
| 21 | * PR 32470: clarified use of bmessage_format_pes |
|---|
| 22 | * |
|---|
| 23 | * 8 1/18/07 11:36a vsilyaev |
|---|
| 24 | * PR 27186: Differentiate between parser and input bands. AKA, fixing |
|---|
| 25 | * bmessage from playback source |
|---|
| 26 | * |
|---|
| 27 | * 7 11/20/06 3:12p ahulse |
|---|
| 28 | * PR25212: Add psf_crc_disabled to bmessage_stream_params, so crc |
|---|
| 29 | * checking can be en/disabled on Private short form sections |
|---|
| 30 | * |
|---|
| 31 | * 6 8/12/05 3:30p erickson |
|---|
| 32 | * PR16659: added bmessage_stream_params.filter_group and reworked |
|---|
| 33 | * bmessage to handle wrapping correctly. now I'm copying a whole message |
|---|
| 34 | * into a intermediate buffer. this greatly simplifies the logic and |
|---|
| 35 | * removes the possibility of overwrite. |
|---|
| 36 | * |
|---|
| 37 | * 5 7/11/05 3:00p erickson |
|---|
| 38 | * PR15064: added bmessage_stream_params.psi_crc_disabled, which defaults |
|---|
| 39 | * false |
|---|
| 40 | * |
|---|
| 41 | * 4 7/11/05 2:27p erickson |
|---|
| 42 | * PR16044: updated documentation for bmessage |
|---|
| 43 | * |
|---|
| 44 | * 3 3/15/05 2:53p erickson |
|---|
| 45 | * PR13415: added notes on bmessage_format types |
|---|
| 46 | * |
|---|
| 47 | * 2 3/11/05 6:19p erickson |
|---|
| 48 | * PR13415: added support for multiple bmessage_stream_t's on the same |
|---|
| 49 | * band/pid using FilterGroups |
|---|
| 50 | * |
|---|
| 51 | * 1 2/7/05 7:05p dlwin |
|---|
| 52 | * Merge down for release 2005_REFSW_MERGETOMAIN: |
|---|
| 53 | * |
|---|
| 54 | * Irvine_BSEAVSW_Devel/32 8/10/04 4:23p erickson |
|---|
| 55 | * PR12152: added buffer_size |
|---|
| 56 | * |
|---|
| 57 | * Irvine_BSEAVSW_Devel/31 7/27/04 3:11p erickson |
|---|
| 58 | * PR11771: doc changes |
|---|
| 59 | * |
|---|
| 60 | * Irvine_BSEAVSW_Devel/30 7/9/04 1:34p erickson |
|---|
| 61 | * PR11771: removed size_is hint because it's not an array |
|---|
| 62 | * |
|---|
| 63 | * Irvine_BSEAVSW_Devel/29 7/6/04 3:53p erickson |
|---|
| 64 | * PR11771: settop api dataflow redesign |
|---|
| 65 | * |
|---|
| 66 | * Irvine_BSEAVSW_Devel/28 6/29/04 11:28a erickson |
|---|
| 67 | * PR11135: updated deprecation notices for settop api |
|---|
| 68 | * |
|---|
| 69 | * Irvine_BSEAVSW_Devel/27 5/25/04 11:43a erickson |
|---|
| 70 | * PR11135: clarified usage of bmessage_Read |
|---|
| 71 | * |
|---|
| 72 | * Irvine_BSEAVSW_Devel/26 12/9/03 12:14p erickson |
|---|
| 73 | * PR8892: added a bit more clarification |
|---|
| 74 | * |
|---|
| 75 | * Irvine_BSEAVSW_Devel/25 12/8/03 5:18p marcusk |
|---|
| 76 | * PR 8892: Furthur clarified documentation. |
|---|
| 77 | * |
|---|
| 78 | * Irvine_BSEAVSW_Devel/24 12/8/03 5:06p marcusk |
|---|
| 79 | * PR 8892: Updated documention regarding bmessage_filter usage. |
|---|
| 80 | * |
|---|
| 81 | * Irvine_BSEAVSW_Devel/23 11/7/03 4:28p erickson |
|---|
| 82 | * PR8583: removing, fixing or implementing TODO's |
|---|
| 83 | * |
|---|
| 84 | * Irvine_BSEAVSW_Devel/22 11/5/03 5:07p erickson |
|---|
| 85 | * PR8560: moved dss code back. this isn't the right solution. |
|---|
| 86 | * |
|---|
| 87 | ***************************************************************************/ |
|---|
| 88 | #ifndef BSETTOP_MESSAGE_H__ |
|---|
| 89 | #define BSETTOP_MESSAGE_H__ |
|---|
| 90 | |
|---|
| 91 | #ifdef __cplusplus |
|---|
| 92 | extern "C" { |
|---|
| 93 | #endif |
|---|
| 94 | |
|---|
| 95 | /*=**************************** |
|---|
| 96 | The message api allows you to collect transport messages from a variety of |
|---|
| 97 | data sources, including MPEG2 transport streams. |
|---|
| 98 | |
|---|
| 99 | We provide higher level libraries to parse PSI or PSIP message |
|---|
| 100 | formats. Please refer to BSEAV/lib/mpeg2_ts_parse and BSEAV/linux/lib/tspsi. |
|---|
| 101 | *******************************/ |
|---|
| 102 | |
|---|
| 103 | /* |
|---|
| 104 | Summary: |
|---|
| 105 | Handle returned by bmessage_open which represents one PID parser channel. |
|---|
| 106 | */ |
|---|
| 107 | typedef struct bmessage_struct *bmessage_stream_t; |
|---|
| 108 | |
|---|
| 109 | /* |
|---|
| 110 | Summary: |
|---|
| 111 | Format of data which you're parsing. |
|---|
| 112 | Description: |
|---|
| 113 | This maps to eSingleChannelRecordType in bcmtranshw.h. |
|---|
| 114 | */ |
|---|
| 115 | typedef enum bmessage_format { |
|---|
| 116 | bmessage_format_ts, /* capture all transport packets in the pid, no filtering. transport header are captured. */ |
|---|
| 117 | bmessage_format_pes, /* capture all PES packets (i.e. all transport payload) in the pid, no filtering. transport headers are stripped. */ |
|---|
| 118 | bmessage_format_psi, /* capture PSI message using filter */ |
|---|
| 119 | bmessage_format_dss_mpt, /* capture DSS MPT messages using filter */ |
|---|
| 120 | bmessage_format_dss_aux, /* capture DSS AUX messages using filter */ |
|---|
| 121 | bmessage_format_dss_regular /* capture DSS packets, no filtering (?) */ |
|---|
| 122 | } bmessage_format; |
|---|
| 123 | |
|---|
| 124 | /* |
|---|
| 125 | Summary: |
|---|
| 126 | Open a message stream for a particular format of data. |
|---|
| 127 | |
|---|
| 128 | Description: |
|---|
| 129 | Message data does not start being collected until you call bmessage_start. |
|---|
| 130 | */ |
|---|
| 131 | bmessage_stream_t bmessage_open( |
|---|
| 132 | bmessage_format format |
|---|
| 133 | ); |
|---|
| 134 | |
|---|
| 135 | /* |
|---|
| 136 | Summary: |
|---|
| 137 | PID filtering structure passed to bmessage_open. |
|---|
| 138 | Description: |
|---|
| 139 | All filtering is done using bit by bit comparisons. |
|---|
| 140 | |
|---|
| 141 | There are two types of masks that are used in conjuntion with the coefs. |
|---|
| 142 | |
|---|
| 143 | inclusion mask (mask) - for all inclusion mask bits that are unmasked |
|---|
| 144 | (set to 0) ALL of the corresponding bits in the |
|---|
| 145 | message must match the bits specified by the coef in order to |
|---|
| 146 | be included. If one bit differs, it will be excluded. |
|---|
| 147 | |
|---|
| 148 | exclusion mask (excl) - for all exclusion mask bits that are unmasked |
|---|
| 149 | (set to 0) at least one of the corresponding bits |
|---|
| 150 | in the message must NOT match the bits specified |
|---|
| 151 | by the coef in order to be included. If all of the bits |
|---|
| 152 | match, it will be excluded. |
|---|
| 153 | |
|---|
| 154 | Results from both comparisons are AND'd together to form the final pass/fail decision. |
|---|
| 155 | |
|---|
| 156 | Exception: Currently for MPEG2 streams, byte 2 (i.e. the message length field) |
|---|
| 157 | of the filter and the MPEG2 message data is ignored. |
|---|
| 158 | */ |
|---|
| 159 | typedef struct bmessage_filter { |
|---|
| 160 | uint8_t mask[16]; /* Bits to be ignored. See Description. */ |
|---|
| 161 | uint8_t coef[16]; /* Bits to be included. See Description. */ |
|---|
| 162 | uint8_t excl[16]; /* Bits to be excluded. Doesn't apply to Venom2 platforms. See Description. */ |
|---|
| 163 | } bmessage_filter; |
|---|
| 164 | |
|---|
| 165 | /** |
|---|
| 166 | Summary: |
|---|
| 167 | Parameters for bmessage_start |
|---|
| 168 | **/ |
|---|
| 169 | typedef struct bmessage_stream_params { |
|---|
| 170 | bband_t band; /* The input band used to filter. Filtering actually happens on the parser band, but |
|---|
| 171 | this is mapped internally. |
|---|
| 172 | This setting is mutually exclusive with bmessage_stream_params.stream. */ |
|---|
| 173 | bstream_t stream; /* This is the playback stream to filter. It is required that the playback already be routed |
|---|
| 174 | to a parser band, otherwise this function will fail. On RAVE systems, playback always has a |
|---|
| 175 | dedicated parser band. On non-RAVE systems, you must set |
|---|
| 176 | bplayback_params.route_through_parser_band = true. |
|---|
| 177 | This setting is mutually exclusive with bmessage_stream_params.bnd. */ |
|---|
| 178 | uint16_t pid; /* the pid to filter */ |
|---|
| 179 | bmessage_filter filter; /* the filter to apply */ |
|---|
| 180 | int buffer_size; /* In kilobytes. Default is 4K. Ranges between |
|---|
| 181 | 1K and 512K in powers of 2. */ |
|---|
| 182 | bool filter_group; /* Defaults to false. |
|---|
| 183 | You can expand the number of message filters you use by using filter groups. |
|---|
| 184 | A filter group is a set of filters that share the same band and pid. All filters in the group |
|---|
| 185 | share the same pid channel. The downside is that all messages for a pid channel arrive in the |
|---|
| 186 | same buffer, and an additional software filter compare must be used to sort out who is gets the message. |
|---|
| 187 | Also, messages that wrap around the end of the buffer must be copied into an intermediate buffer. |
|---|
| 188 | If a filter group is not enabled, you will get higher throughput from bmessage because there |
|---|
| 189 | will be no copies or software filter comparisons, but you will be limited by the number of pid channels available. */ |
|---|
| 190 | |
|---|
| 191 | /* NOTE: psi_crc_disabled and psf_crc_disabled and can be used in the following */ |
|---|
| 192 | /* combinations to give the following functionality : */ |
|---|
| 193 | /* */ |
|---|
| 194 | /* AUTO Mode : CRC check is determined by the short/long form private section */ |
|---|
| 195 | /* if short form (section_syntax_indicator=0) no crc is checked */ |
|---|
| 196 | /* if long form (section_syntax_indicator=1) crc is needed */ |
|---|
| 197 | /* enable CRC : CRC enabled for both short and long form private section. */ |
|---|
| 198 | /* disable CRC: CRC disabled for both short and long form private section. */ |
|---|
| 199 | /* */ |
|---|
| 200 | /* AUTO : psf_crc_disabled = true , psi_crc_disabled = false */ |
|---|
| 201 | /* enable CRC : psf_crc_disabled = false, psi_crc_disabled = false */ |
|---|
| 202 | /* disable CRC: psf_crc_disabled = true, psi_crc_disabled = true */ |
|---|
| 203 | |
|---|
| 204 | bool psi_crc_disabled; /* disable CRC check of PSI message data */ |
|---|
| 205 | bsettop_callback data_ready_callback; /* Optional callback to notify the application |
|---|
| 206 | when bmessage_stream_get_buffer will return more data to be read. |
|---|
| 207 | When you get a callback, additional callbacks will be disabled until you |
|---|
| 208 | call bmessage_get_buffer. |
|---|
| 209 | |
|---|
| 210 | If you are using multiple bmessage_streams on the same band & pid, |
|---|
| 211 | then the behavior will change slightly. You may receive callbacks |
|---|
| 212 | and yet get no data when calling bmessage_get_buffer. This still falls |
|---|
| 213 | within specified behavior, and is necessary to make the internal |
|---|
| 214 | algorithm work. |
|---|
| 215 | */ |
|---|
| 216 | bsettop_callback overflow; /* Optional callback to notify the user when |
|---|
| 217 | an overflow has occured. */ |
|---|
| 218 | void *callback_context; /* User defined context which will be passed to |
|---|
| 219 | the above callback functions. */ |
|---|
| 220 | bool psf_crc_disabled; /* disable Private Short Form CRC check of PSI data */ |
|---|
| 221 | } bmessage_stream_params; |
|---|
| 222 | |
|---|
| 223 | void bmessage_stream_params_init( |
|---|
| 224 | bmessage_stream_params *params, |
|---|
| 225 | bmessage_stream_t stream); |
|---|
| 226 | |
|---|
| 227 | /* |
|---|
| 228 | Summary: |
|---|
| 229 | Start filtering a message stream for a particular band and pid. |
|---|
| 230 | |
|---|
| 231 | Description: |
|---|
| 232 | You can have multiple message streams started at the same time for the same band. |
|---|
| 233 | This technique makes message processing faster. The limit of message streams |
|---|
| 234 | depends on hardware. |
|---|
| 235 | */ |
|---|
| 236 | bresult bmessage_start( |
|---|
| 237 | bmessage_stream_t message_stream, |
|---|
| 238 | const bmessage_stream_params *params |
|---|
| 239 | ); |
|---|
| 240 | |
|---|
| 241 | /* |
|---|
| 242 | Summary: |
|---|
| 243 | Get pointer to data available to be read from the transport message buffer. |
|---|
| 244 | |
|---|
| 245 | Description: |
|---|
| 246 | The data in the buffer is raw and unparsed. |
|---|
| 247 | Depending on your buffer sizes and the amount of data captured, subsequent reads may |
|---|
| 248 | return data that starts in the middle of a message. It's up to the application |
|---|
| 249 | to join multiple reads together and parse the data. |
|---|
| 250 | |
|---|
| 251 | The transport hardware will return messages with a trailing pad to ensure |
|---|
| 252 | 4 byte alignment. You'll need to skip over these bytes in your app, however you |
|---|
| 253 | must include these bytes in your count for the bmessage_read_complete. |
|---|
| 254 | |
|---|
| 255 | This function is always non-blocking. |
|---|
| 256 | */ |
|---|
| 257 | bresult bmessage_get_buffer( |
|---|
| 258 | bmessage_stream_t message_stream, /* message stream handle returned by bmessage_open */ |
|---|
| 259 | const void ** p_bfr, /* [out] memory to read into */ |
|---|
| 260 | size_t *length |
|---|
| 261 | ); |
|---|
| 262 | |
|---|
| 263 | /** |
|---|
| 264 | Summary: |
|---|
| 265 | After processing bmessage_get_buffer, use this function to report back how much |
|---|
| 266 | data was consumed. |
|---|
| 267 | |
|---|
| 268 | Description: |
|---|
| 269 | You should never call bmessage_read_complete twice in a row without calling |
|---|
| 270 | bmessage_get_buffer again. |
|---|
| 271 | |
|---|
| 272 | The amount_consumed can never be greater than the length last returned by |
|---|
| 273 | bmessage_get_buffer. |
|---|
| 274 | **/ |
|---|
| 275 | bresult bmessage_read_complete( |
|---|
| 276 | bmessage_stream_t message_stream, /* message stream handle returned by bmessage_open */ |
|---|
| 277 | size_t amount_consumed |
|---|
| 278 | ); |
|---|
| 279 | |
|---|
| 280 | /* |
|---|
| 281 | Summary: |
|---|
| 282 | Stop any more data from being filtered. |
|---|
| 283 | |
|---|
| 284 | Description: |
|---|
| 285 | You cannot call bmessage_get_buffer after this. |
|---|
| 286 | You can call bmessage_start to start again, or bmessage_close to clean up. |
|---|
| 287 | */ |
|---|
| 288 | void bmessage_stop( |
|---|
| 289 | bmessage_stream_t message_stream /* message stream handle returned by bmessage_open */ |
|---|
| 290 | ); |
|---|
| 291 | |
|---|
| 292 | /* |
|---|
| 293 | Summary: |
|---|
| 294 | Close a message stream. |
|---|
| 295 | |
|---|
| 296 | Description: |
|---|
| 297 | If the message stream was not already stopped, it will be. |
|---|
| 298 | The bmessage_stream_t handle is no longer valid. |
|---|
| 299 | */ |
|---|
| 300 | void bmessage_close( |
|---|
| 301 | bmessage_stream_t message_stream /* message stream handle returned by bmessage_open */ |
|---|
| 302 | ); |
|---|
| 303 | |
|---|
| 304 | #ifdef __cplusplus |
|---|
| 305 | } |
|---|
| 306 | #endif |
|---|
| 307 | |
|---|
| 308 | #endif /* BSETTOP_MESSAGE_H__ */ |
|---|