| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2004-2007, 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_recpump.h $ |
|---|
| 11 | * $brcm_Revision: 8 $ |
|---|
| 12 | * $brcm_Date: 11/9/07 9:25a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /BSEAV/api/include/bsettop_recpump.h $ |
|---|
| 19 | * |
|---|
| 20 | * 8 11/9/07 9:25a vsilyaev |
|---|
| 21 | * PR 34612: Added packet_size configuration |
|---|
| 22 | * |
|---|
| 23 | * 7 12/4/06 5:21p jrubio |
|---|
| 24 | * PR25213: PR25927 Add new recpump_immediate_stop that completely stops |
|---|
| 25 | * |
|---|
| 26 | * |
|---|
| 27 | * |
|---|
| 28 | * |
|---|
| 29 | * PR25213: PR25927 Add new recpump_immediate_stop that completely stops |
|---|
| 30 | * * all recpump from calling client callbacks |
|---|
| 31 | * |
|---|
| 32 | * 6 12/1/06 4:22p jrubio |
|---|
| 33 | * PR25213: PR25927 Add new recpump_immediate_stop that completely stops |
|---|
| 34 | * all recpump from calling client callbacks |
|---|
| 35 | * |
|---|
| 36 | * 5 7/12/06 3:18p ahulse |
|---|
| 37 | * PR16324: get playback / record time via call to bplayback_get_status / |
|---|
| 38 | * brecord_get_status |
|---|
| 39 | * |
|---|
| 40 | * 4 6/6/06 7:19p ahulse |
|---|
| 41 | * PR20917: Add MCARD 3DES decryption, using XPT TS_DMA/PB Engines, to |
|---|
| 42 | * BCM7038 SW |
|---|
| 43 | * |
|---|
| 44 | * 3 6/9/05 3:24p erickson |
|---|
| 45 | * PR15513: all pass record is now audio pid 0 or 0x1fff. large warnings |
|---|
| 46 | * now printed. |
|---|
| 47 | * |
|---|
| 48 | * 2 5/4/05 4:59p erickson |
|---|
| 49 | * PR14576: added num_descriptors and extended comments |
|---|
| 50 | * |
|---|
| 51 | * 1 2/7/05 7:06p dlwin |
|---|
| 52 | * Merge down for release 2005_REFSW_MERGETOMAIN: |
|---|
| 53 | * |
|---|
| 54 | * Irvine_BSEAVSW_Devel/6 11/23/04 8:12p vsilyaev |
|---|
| 55 | * PR 13351: Refactoring playback API. |
|---|
| 56 | * |
|---|
| 57 | * Irvine_BSEAVSW_Devel/5 6/29/04 11:29a erickson |
|---|
| 58 | * PR11135: updated deprecation notices for settop api |
|---|
| 59 | * |
|---|
| 60 | * Irvine_BSEAVSW_Devel/4 6/24/04 10:27a erickson |
|---|
| 61 | * PR11135: converted to generic bsettop_callback for playpump and recpump |
|---|
| 62 | * |
|---|
| 63 | * Irvine_BSEAVSW_Devel/3 6/17/04 9:37a erickson |
|---|
| 64 | * PR11135: recpump callback enabled |
|---|
| 65 | * |
|---|
| 66 | * Irvine_BSEAVSW_Devel/2 6/10/04 8:08a erickson |
|---|
| 67 | * PR11135: brecpump implemented and brecord converted to use recpump |
|---|
| 68 | * |
|---|
| 69 | * Irvine_BSEAVSW_Devel/1 6/8/04 7:40a erickson |
|---|
| 70 | * PR11135: added iniital playpump impl for 97038 |
|---|
| 71 | * |
|---|
| 72 | *******************************************************************************/ |
|---|
| 73 | #ifndef BSETTOP_RECPUMP_H__ |
|---|
| 74 | #define BSETTOP_RECPUMP_H__ |
|---|
| 75 | |
|---|
| 76 | #ifdef __cplusplus |
|---|
| 77 | extern "C" { |
|---|
| 78 | #endif |
|---|
| 79 | |
|---|
| 80 | /*=**************************************** |
|---|
| 81 | brecpump is a low-level PVR api for recording. |
|---|
| 82 | It does not perform any file i/o and does not maintain any threads, |
|---|
| 83 | but uses asynchronous callbacks to send data out to the application. |
|---|
| 84 | |
|---|
| 85 | The brecord api is built on top of brecpump. It performs file i/o |
|---|
| 86 | and threading. |
|---|
| 87 | *******************************************/ |
|---|
| 88 | |
|---|
| 89 | /** |
|---|
| 90 | Summary: |
|---|
| 91 | Handle for brecpump api. |
|---|
| 92 | **/ |
|---|
| 93 | typedef struct brecpump *brecpump_t; |
|---|
| 94 | |
|---|
| 95 | /** |
|---|
| 96 | Summary: |
|---|
| 97 | Parameters that must be passed into brecpump_open. |
|---|
| 98 | **/ |
|---|
| 99 | typedef struct brecpump_open_params { |
|---|
| 100 | struct { |
|---|
| 101 | size_t buffer_size; /* size in bytes of the record buffer */ |
|---|
| 102 | unsigned alignment; /* alignment for the block. units of 2^alignment. Therefore a value of 2 will be |
|---|
| 103 | 4 byte aligned, 3 will be 8 byte aligned, etc. only used for data, not scode. */ |
|---|
| 104 | unsigned num_descriptors; /* buffer_size/num_descriptors determines the size of the blocks that |
|---|
| 105 | you will receive from recpump. */ |
|---|
| 106 | void * buf; /* pass in ptr to buffer to be used instead of using own */ |
|---|
| 107 | } data, scode; |
|---|
| 108 | } brecpump_open_params; |
|---|
| 109 | |
|---|
| 110 | /** |
|---|
| 111 | Summary: |
|---|
| 112 | Returns default configuration parameters for the record pump |
|---|
| 113 | **/ |
|---|
| 114 | void brecpump_get_open_params( |
|---|
| 115 | bobject_t id, |
|---|
| 116 | brecpump_open_params *open_params /* [out] */ |
|---|
| 117 | ); |
|---|
| 118 | |
|---|
| 119 | /** |
|---|
| 120 | Summary: |
|---|
| 121 | Open a recpump source. |
|---|
| 122 | **/ |
|---|
| 123 | brecpump_t brecpump_open( |
|---|
| 124 | bobject_t id, |
|---|
| 125 | const brecpump_open_params *open_params /* optional parameters for the record pump */ |
|---|
| 126 | ); |
|---|
| 127 | |
|---|
| 128 | /** |
|---|
| 129 | Summary: |
|---|
| 130 | Close the recpump. |
|---|
| 131 | Description: |
|---|
| 132 | It should already be stopped. |
|---|
| 133 | **/ |
|---|
| 134 | void brecpump_close(brecpump_t recpump); |
|---|
| 135 | |
|---|
| 136 | /** |
|---|
| 137 | Summary: |
|---|
| 138 | Parameters that must be passed into brecpump_start. |
|---|
| 139 | **/ |
|---|
| 140 | typedef struct brecpump_params { |
|---|
| 141 | bencryption_params encryption; /* PVR encryption parameters to be applied to |
|---|
| 142 | the recorded data. */ |
|---|
| 143 | bool timestamp_enabled; /* If true, then a 4 byte timestamp is prepended to every |
|---|
| 144 | transport packet. bplayback_params.timestamp_enabled |
|---|
| 145 | must match. */ |
|---|
| 146 | void *callback_context; /* Context pointer which is returned in the callback functions. */ |
|---|
| 147 | bsettop_callback data_write_callback; /* Callback function that will be called for |
|---|
| 148 | MPEG data. You should call brecpump_data_get_buffer |
|---|
| 149 | but the actual file write and brecpump_data_write_complete |
|---|
| 150 | call should not be made from this callback. */ |
|---|
| 151 | bsettop_callback index_write_callback; /* Optional callback function that will be called |
|---|
| 152 | for SCT (start code table) data. You can set this to be |
|---|
| 153 | NULL if you don't want index data produced. */ |
|---|
| 154 | bsettop_callback overflow; /* Called whenever a buffer overflow is detected. |
|---|
| 155 | Recorded data will be corrupt. This is used for system |
|---|
| 156 | debug only. In a production system this should never |
|---|
| 157 | happen, and if it does, you should just keep on recording. */ |
|---|
| 158 | |
|---|
| 159 | size_t packet_size; /* the size of the blocks that you will receive from recpump would be multiplier of packet_size, please also see |
|---|
| 160 | brecpump_open_params for buffer_size and num_descriptors */ |
|---|
| 161 | } brecpump_params; |
|---|
| 162 | |
|---|
| 163 | /** |
|---|
| 164 | Summary: |
|---|
| 165 | Initialize the recpump parameters to defaults. |
|---|
| 166 | |
|---|
| 167 | Description: |
|---|
| 168 | You will need to set at the very least the data_write_callback. |
|---|
| 169 | **/ |
|---|
| 170 | void brecpump_params_init( |
|---|
| 171 | brecpump_params *params, /* [out] */ |
|---|
| 172 | brecpump_t recpump |
|---|
| 173 | ); |
|---|
| 174 | |
|---|
| 175 | /** |
|---|
| 176 | Summary: |
|---|
| 177 | Start recording a stream. |
|---|
| 178 | |
|---|
| 179 | Description: |
|---|
| 180 | To perform an "all pass" record of an entire transport stream, create a stream with video[0].pid and |
|---|
| 181 | audio[0].pid of 0. This is only supported on magnum-based platforms and has possibly undesired |
|---|
| 182 | effects on all records, so only use this as a test mode. |
|---|
| 183 | **/ |
|---|
| 184 | bresult brecpump_start( |
|---|
| 185 | brecpump_t recpump, |
|---|
| 186 | bstream_t stream, |
|---|
| 187 | const brecpump_params *params |
|---|
| 188 | ); |
|---|
| 189 | |
|---|
| 190 | /** |
|---|
| 191 | Summary: |
|---|
| 192 | Stop the recording and wait for the recording process to finalize. |
|---|
| 193 | The recpump handle can be safely closed after brecpump_stop returns. |
|---|
| 194 | **/ |
|---|
| 195 | bresult brecpump_stop( |
|---|
| 196 | brecpump_t recpump |
|---|
| 197 | ); |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | /** |
|---|
| 201 | Summary: |
|---|
| 202 | Please call before you call brecpump_stop if you have |
|---|
| 203 | stopped abnormally. This will ensure that when you stop |
|---|
| 204 | you will not receive any more call backs and data |
|---|
| 205 | **/ |
|---|
| 206 | void brecpump_immediate_stop( |
|---|
| 207 | brecpump_t recpump |
|---|
| 208 | ); |
|---|
| 209 | |
|---|
| 210 | /** |
|---|
| 211 | Summary: |
|---|
| 212 | Get next portion of MPEG data from the record buffer that needs to be consumed from transport. |
|---|
| 213 | |
|---|
| 214 | Description: |
|---|
| 215 | This returns the same type of information as the write_callback. |
|---|
| 216 | Note that after receiving the callback, if you call brecpump_data_get_buffer again, |
|---|
| 217 | there may be more data that becomes available. |
|---|
| 218 | **/ |
|---|
| 219 | bresult brecpump_data_get_buffer( |
|---|
| 220 | brecpump_t recpump, |
|---|
| 221 | const void **buffer, /* [out] memory which contains data to be written */ |
|---|
| 222 | size_t *buffer_size /* [out] total amount of data to be written */ |
|---|
| 223 | ); |
|---|
| 224 | |
|---|
| 225 | /** |
|---|
| 226 | Summary: |
|---|
| 227 | Get next portion of SCT index data from the record buffer that needs to be consumed. |
|---|
| 228 | Description: |
|---|
| 229 | This returns the same type of information as the write_callback. |
|---|
| 230 | Note that after receiving the callback, if you call brecpump_index_get_buffer again, |
|---|
| 231 | there may be more data that becomes available. |
|---|
| 232 | **/ |
|---|
| 233 | bresult brecpump_index_get_buffer( |
|---|
| 234 | brecpump_t recpump, |
|---|
| 235 | const void **buffer, /* [out] memory which contains data to be written */ |
|---|
| 236 | size_t *buffer_size /* [out] total amount of data to be written */ |
|---|
| 237 | ); |
|---|
| 238 | |
|---|
| 239 | /** |
|---|
| 240 | Summary: |
|---|
| 241 | Report back how much MPEG data was consumed (usually by writing to disk). |
|---|
| 242 | |
|---|
| 243 | Description: |
|---|
| 244 | If the write fails, the user has the option of calling brecpump_write_complete |
|---|
| 245 | or stopping pvr altogether. There is no way and no point in information brecpump |
|---|
| 246 | that a write has failed. |
|---|
| 247 | **/ |
|---|
| 248 | bresult brecpump_data_write_complete( |
|---|
| 249 | brecpump_t recpump, |
|---|
| 250 | size_t amount_written |
|---|
| 251 | ); |
|---|
| 252 | |
|---|
| 253 | /** |
|---|
| 254 | Summary: |
|---|
| 255 | Report back how much index data was consumed (usually by writing to disk). |
|---|
| 256 | |
|---|
| 257 | Description: |
|---|
| 258 | If the write fails, the user has the option of calling brecpump_write_complete |
|---|
| 259 | or stopping pvr altogether. There is no way and no point in information brecpump |
|---|
| 260 | that a write has failed. |
|---|
| 261 | **/ |
|---|
| 262 | bresult brecpump_index_write_complete( |
|---|
| 263 | brecpump_t recpump, |
|---|
| 264 | size_t amount_written |
|---|
| 265 | ); |
|---|
| 266 | |
|---|
| 267 | /** |
|---|
| 268 | Summary: |
|---|
| 269 | Status returned by brecord_get_status. |
|---|
| 270 | **/ |
|---|
| 271 | typedef struct brecpump_status { |
|---|
| 272 | unsigned long mpeg_bytes_recorded; /* Number of bytes of mpeg stream data recorded */ |
|---|
| 273 | unsigned long mpeg_fifo_depth; /* Current depth in bytes of the mpeg record buffer */ |
|---|
| 274 | unsigned long mpeg_fifo_size; /* Current size in bytes of the mpeg record buffer */ |
|---|
| 275 | bool has_index; /* If true, then you are recording an index and the following fields |
|---|
| 276 | are valid. */ |
|---|
| 277 | unsigned long index_bytes_recorded; /* Number of bytes of index data recorded */ |
|---|
| 278 | unsigned long index_fifo_depth; /* Current depth in bytes of the index record buffer */ |
|---|
| 279 | unsigned long index_fifo_size; /* Current size in bytes of the index record buffer */ |
|---|
| 280 | unsigned long last_timestamp; /* timestamp of last frame recorded. Not used by recpump, */ |
|---|
| 281 | /* but included for use in brecord_status -time in mSec */ |
|---|
| 282 | } brecpump_status; |
|---|
| 283 | |
|---|
| 284 | /** |
|---|
| 285 | Summary: |
|---|
| 286 | Get current status of the recording. |
|---|
| 287 | **/ |
|---|
| 288 | void brecpump_get_status( |
|---|
| 289 | brecpump_t recpump, |
|---|
| 290 | brecpump_status *status /* [out] current status information */ |
|---|
| 291 | ); |
|---|
| 292 | |
|---|
| 293 | #ifdef __cplusplus |
|---|
| 294 | } |
|---|
| 295 | #endif |
|---|
| 296 | |
|---|
| 297 | #endif /* BSETTOP_RECPUMP_H__ */ |
|---|