| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2005, 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_stream.h $ |
|---|
| 11 | * $brcm_Revision: 4 $ |
|---|
| 12 | * $brcm_Date: 8/10/05 3:17p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /BSEAV/api/include/bsettop_stream.h $ |
|---|
| 19 | ***************************************************************************/ |
|---|
| 20 | #ifndef BSETTOP_STREAM_H__ |
|---|
| 21 | #define BSETTOP_STREAM_H__ |
|---|
| 22 | |
|---|
| 23 | #include "bapp_types.h" |
|---|
| 24 | |
|---|
| 25 | #ifdef __cplusplus |
|---|
| 26 | extern "C" { |
|---|
| 27 | #endif |
|---|
| 28 | |
|---|
| 29 | /* |
|---|
| 30 | Summary: |
|---|
| 31 | Maximum number of video or audio programs which the bstream_mpeg data structure stores. |
|---|
| 32 | stores. |
|---|
| 33 | Description: |
|---|
| 34 | If your application needs more, you'll need to override this value. |
|---|
| 35 | */ |
|---|
| 36 | #define BSETTOP_MAX_PROGRAMS 1 |
|---|
| 37 | /* |
|---|
| 38 | Summary: |
|---|
| 39 | Maximum number of streams. |
|---|
| 40 | */ |
|---|
| 41 | |
|---|
| 42 | #define BSETTOP_MAX_STREAMS 3 |
|---|
| 43 | |
|---|
| 44 | /* |
|---|
| 45 | Summary: |
|---|
| 46 | Beginning PID channel for video. |
|---|
| 47 | */ |
|---|
| 48 | #define B_VIDEO_PIDCH 0 |
|---|
| 49 | /* |
|---|
| 50 | Summary: |
|---|
| 51 | PCR PID channel. |
|---|
| 52 | */ |
|---|
| 53 | #define B_PCR_PIDCH 6 |
|---|
| 54 | /* |
|---|
| 55 | Summary: |
|---|
| 56 | DMA PID channel for video. |
|---|
| 57 | */ |
|---|
| 58 | #define B_DMA_PIDCH 7 |
|---|
| 59 | /* |
|---|
| 60 | Summary: |
|---|
| 61 | PCR PID channel for audio. |
|---|
| 62 | */ |
|---|
| 63 | #define B_AUDIO_PIDCH 7 |
|---|
| 64 | |
|---|
| 65 | /* |
|---|
| 66 | Summary: |
|---|
| 67 | Default transport parser band from internal tuner/demodulator. |
|---|
| 68 | */ |
|---|
| 69 | |
|---|
| 70 | #define DEF_PARSER_BAND 0 |
|---|
| 71 | |
|---|
| 72 | /* |
|---|
| 73 | Summary: |
|---|
| 74 | Macro to set playback parser band flag. i.e BSETTOP_PB_PARSER(DEF_PARSER_BAND). |
|---|
| 75 | */ |
|---|
| 76 | |
|---|
| 77 | #define BSETTOP_PB_PARSER( x ) ( ( x ) | 0x8000 ) |
|---|
| 78 | |
|---|
| 79 | /* |
|---|
| 80 | Summary: |
|---|
| 81 | Invalid PID channel definition. |
|---|
| 82 | */ |
|---|
| 83 | |
|---|
| 84 | #define B_INVALID_PIDCH ((unsigned int)-1) |
|---|
| 85 | |
|---|
| 86 | /* |
|---|
| 87 | Summary: |
|---|
| 88 | A stream is either a digital or analog program which can be decoded or recorded. |
|---|
| 89 | Description: |
|---|
| 90 | Streams are produced by one of the following: |
|---|
| 91 | - tuning linein or rf (btuner_tune_rf or btuner_tune_linein) |
|---|
| 92 | - tuning digital and selecting mpeg params (btuner_tune_qpsk/qam and bstream_set_mpeg) |
|---|
| 93 | - starting playback (bplay_start) |
|---|
| 94 | - direct transport input (bstream_set) |
|---|
| 95 | */ |
|---|
| 96 | typedef struct bstream *bstream_t; |
|---|
| 97 | |
|---|
| 98 | /* |
|---|
| 99 | Summary: |
|---|
| 100 | MPEG parameters for a single program with the same pcr pid which are passed to bstream_open and bplayback_start. |
|---|
| 101 | |
|---|
| 102 | Description: |
|---|
| 103 | The reason for multiple video and audio pids is to support multiple elementary |
|---|
| 104 | streams within the same program. All video and audio pids should use the same |
|---|
| 105 | pcr pid. |
|---|
| 106 | |
|---|
| 107 | Multiple audio elementary streams are needed for multiple language support (i.e. English |
|---|
| 108 | and Spansih). Multiple video elementary streams might be needed for multiple |
|---|
| 109 | viewing angles of the same program. |
|---|
| 110 | |
|---|
| 111 | You should not use this structure to store mutliple programs for channel change. |
|---|
| 112 | Each "channel" should have its own bstream_mpeg structure because each channel |
|---|
| 113 | has its own pcr pid. |
|---|
| 114 | |
|---|
| 115 | For PES decode the pid value is used to represent the PES packet id. Typically this |
|---|
| 116 | will be 0xE0 for video, 0xC0 for mpeg audio, and 0xBD for ac3 audio. |
|---|
| 117 | |
|---|
| 118 | For VOB decode, video and mpeg audio type streams are handled identically to a PES |
|---|
| 119 | based decode. AC3 and DTS tracks ares slightly different as the upper 8 bits |
|---|
| 120 | of the pid value represent the substream id that is to be decoded. For example: |
|---|
| 121 | pid==0x00BD would correspond to AC3/DTS track 0, while 0x01BD would correspond to |
|---|
| 122 | AC3/DTS track 1. |
|---|
| 123 | */ |
|---|
| 124 | typedef struct bstream_mpeg { |
|---|
| 125 | struct { |
|---|
| 126 | uint16_t pid; |
|---|
| 127 | uint8_t format; |
|---|
| 128 | } video[BSETTOP_MAX_PROGRAMS]; /* video stream pids */ |
|---|
| 129 | struct { |
|---|
| 130 | uint16_t pid; |
|---|
| 131 | uint8_t format; |
|---|
| 132 | } audio[BSETTOP_MAX_PROGRAMS]; /* audio stream pids */ |
|---|
| 133 | uint16_t pcr_pid; |
|---|
| 134 | } bstream_mpeg; |
|---|
| 135 | |
|---|
| 136 | /* |
|---|
| 137 | Summary: |
|---|
| 138 | Stream structure provides access to band, program PIDs and currently assigned PID channels. |
|---|
| 139 | |
|---|
| 140 | Description: |
|---|
| 141 | |
|---|
| 142 | */ |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | /* |
|---|
| 146 | Summary: |
|---|
| 147 | Required to initialize int bstream_mpeg data structure. |
|---|
| 148 | */ |
|---|
| 149 | void bstream_mpeg_init( |
|---|
| 150 | bstream_mpeg *mpeg /* [out] */ |
|---|
| 151 | ); |
|---|
| 152 | |
|---|
| 153 | /** |
|---|
| 154 | Summary: |
|---|
| 155 | Dynamically create a digital stream using a band and mpeg parameters. |
|---|
| 156 | |
|---|
| 157 | Description: |
|---|
| 158 | This is used for digital streams which are created from a tuned band or streamer band. |
|---|
| 159 | The application supplies MPEG parameters which are obtained from scanning PSI information |
|---|
| 160 | or stored separately. |
|---|
| 161 | |
|---|
| 162 | On some platforms, you can call bstream_open on the same band more than once. In this case, |
|---|
| 163 | the transport block routes the data from one input band to multiple parser bands. |
|---|
| 164 | |
|---|
| 165 | You must call bstream_close to release resources. |
|---|
| 166 | **/ |
|---|
| 167 | bstream_t bstream_open( |
|---|
| 168 | bband_t band, /* input band */ |
|---|
| 169 | const bstream_mpeg *mpegparams /* MPEG pids to filter */ |
|---|
| 170 | ); |
|---|
| 171 | |
|---|
| 172 | /* |
|---|
| 173 | * Summary: |
|---|
| 174 | * Digital stream status returned by bstream_get_mpeg_parameters. |
|---|
| 175 | * **/ |
|---|
| 176 | typedef struct bstream_status { |
|---|
| 177 | bband_t band; |
|---|
| 178 | uint32_t stc; |
|---|
| 179 | uint32_t pcr; |
|---|
| 180 | bstream_mpeg mpeg; |
|---|
| 181 | unsigned long tsrate; /* in bits per second */ |
|---|
| 182 | } bstream_status; |
|---|
| 183 | |
|---|
| 184 | /** |
|---|
| 185 | * Summary: |
|---|
| 186 | * Get status information from a digital stream. |
|---|
| 187 | * Description: |
|---|
| 188 | * This is useful for getting MPEG parameters from an encoded stream |
|---|
| 189 | * where the bsettop_mpeg structure |
|---|
| 190 | * is created internally. |
|---|
| 191 | **/ |
|---|
| 192 | |
|---|
| 193 | bresult |
|---|
| 194 | bstream_get_status( |
|---|
| 195 | bstream_t stream, |
|---|
| 196 | bstream_status *status /* [out]*/ |
|---|
| 197 | ); |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | /* |
|---|
| 201 | * Summary: |
|---|
| 202 | * Global transport configuration settings. |
|---|
| 203 | * **/ |
|---|
| 204 | typedef struct bstream_config { |
|---|
| 205 | unsigned int cdb_size; /* CDB Size in bytes */ |
|---|
| 206 | unsigned int itb_size; /* ITB Size in bytes */ |
|---|
| 207 | } bstream_config; |
|---|
| 208 | |
|---|
| 209 | /** |
|---|
| 210 | * Summary: |
|---|
| 211 | * Get global transport configuraiton settings. |
|---|
| 212 | **/ |
|---|
| 213 | |
|---|
| 214 | bresult |
|---|
| 215 | bstream_get_config( |
|---|
| 216 | bstream_config *config /* [out]*/ |
|---|
| 217 | ); |
|---|
| 218 | |
|---|
| 219 | /** |
|---|
| 220 | * Summary: |
|---|
| 221 | * Set global transport configuraiton settings. |
|---|
| 222 | **/ |
|---|
| 223 | |
|---|
| 224 | bresult |
|---|
| 225 | bstream_set_config( |
|---|
| 226 | bstream_config *config /* [in]*/ |
|---|
| 227 | ); |
|---|
| 228 | |
|---|
| 229 | /** |
|---|
| 230 | Summary: |
|---|
| 231 | Close a stream. |
|---|
| 232 | |
|---|
| 233 | Description: |
|---|
| 234 | This is required if you use bstream_open to obtain a stream. |
|---|
| 235 | This is allowed but not required if you get an analog stream from btuner or |
|---|
| 236 | any stream from bplayback or bplaypump. |
|---|
| 237 | **/ |
|---|
| 238 | void bstream_close( |
|---|
| 239 | bstream_t stream /* Handle returned by bstream_open, btuner_tune_rf, |
|---|
| 240 | btuner_tune_linein or bplayback_start. */ |
|---|
| 241 | ); |
|---|
| 242 | |
|---|
| 243 | |
|---|
| 244 | /** |
|---|
| 245 | Summary: |
|---|
| 246 | Callback function after XPT interrupt fires |
|---|
| 247 | |
|---|
| 248 | Description: |
|---|
| 249 | This allows a function to be called after an interrupt fires. |
|---|
| 250 | **/ |
|---|
| 251 | void bstream_callback( |
|---|
| 252 | void *data |
|---|
| 253 | ); |
|---|
| 254 | |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | #ifdef __cplusplus |
|---|
| 258 | } |
|---|
| 259 | #endif |
|---|
| 260 | |
|---|
| 261 | #endif /* BSETTOP_STREAM_H__ */ |
|---|
| 262 | |
|---|
| 263 | |
|---|