| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2004-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_playpump.h $ |
|---|
| 11 | * $brcm_Revision: 28 $ |
|---|
| 12 | * $brcm_Date: 10/31/08 9:40a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /BSEAV/api/include/bsettop_playpump.h $ |
|---|
| 19 | * |
|---|
| 20 | * 28 10/31/08 9:40a jgarrett |
|---|
| 21 | * PR 47230: Adding TTS Pacing |
|---|
| 22 | * |
|---|
| 23 | * PR47230/1 10/28/08 10:37a jjordan |
|---|
| 24 | * PR47230: Port TTS Pacing to Nexus |
|---|
| 25 | * |
|---|
| 26 | * 27 3/5/08 3:23p vsilyaev |
|---|
| 27 | * PR38347: PR 38347 : Set seperate timestamp offset for audio and video |
|---|
| 28 | * |
|---|
| 29 | * PR38347/1 12/19/07 11:04a gmohile |
|---|
| 30 | * PR 38347 : Set seperate timestamp offset for audio and video |
|---|
| 31 | * |
|---|
| 32 | * 26 6/12/07 4:36p jgarrett |
|---|
| 33 | * PR 30310: Adding bplaypump_state_display_queue_trick_mode |
|---|
| 34 | * |
|---|
| 35 | * 25 4/25/07 10:45a vsilyaev |
|---|
| 36 | * PR 29921: Added code to manage timestamps for navigation and trickmodes |
|---|
| 37 | * |
|---|
| 38 | * 24 4/19/07 7:28p jgarrett |
|---|
| 39 | * PR 30010: Add TCP support |
|---|
| 40 | * |
|---|
| 41 | * 23 12/21/06 12:34p jgarrett |
|---|
| 42 | * PR 26768: Merging to main branch. |
|---|
| 43 | * |
|---|
| 44 | * PROD_IPSTB_REFSW_Devel/6 12/21/06 10:09a jjordan |
|---|
| 45 | * PR26768: Improve RTP Header extension processing |
|---|
| 46 | * |
|---|
| 47 | * PROD_IPSTB_REFSW_Devel/5 12/21/06 9:10a jjordan |
|---|
| 48 | * PR26768: merge from main branch |
|---|
| 49 | * |
|---|
| 50 | * PROD_IPSTB_REFSW_Devel/4 10/3/06 4:50p jjordan |
|---|
| 51 | * PR24714: Add support for RTSP protocol |
|---|
| 52 | * |
|---|
| 53 | * 20 8/4/06 12:46p vsilyaev |
|---|
| 54 | * PR 22876: Added support for paced trickmodes to allow rate accurate |
|---|
| 55 | * trick modes |
|---|
| 56 | * |
|---|
| 57 | * 19 7/26/06 9:35a dlwin |
|---|
| 58 | * PR22906: Merged into main-line, for: Integrate liveMedia open-source |
|---|
| 59 | * for RTP and RTCP support |
|---|
| 60 | * |
|---|
| 61 | * 18 7/20/06 8:43p dlwin |
|---|
| 62 | * PR20685: asf drm integration |
|---|
| 63 | * |
|---|
| 64 | * PR20685_MSDRM/1 6/30/06 12:59p ptimariu |
|---|
| 65 | * PR20685: asf drm integration |
|---|
| 66 | * |
|---|
| 67 | * 17 4/25/06 3:11p vsilyaev |
|---|
| 68 | * PR 20683: Added code for the ASF trickmodes |
|---|
| 69 | * |
|---|
| 70 | * 15 3/30/06 5:58p dlwin |
|---|
| 71 | * PR 20221: Merge from IPSTB development. |
|---|
| 72 | * |
|---|
| 73 | * PROD_IPSTB_REFSW_Devel/1 3/30/06 5:31p jjordan |
|---|
| 74 | * PR20221: export overflow as status for use by playback_ip |
|---|
| 75 | * |
|---|
| 76 | * 14 3/15/06 4:51p vsilyaev |
|---|
| 77 | * PR20221: NetIF DMA interface |
|---|
| 78 | * |
|---|
| 79 | * 13 3/14/06 6:54p dlwin |
|---|
| 80 | * PR 20206: Removed B_HAS_IP use. Now it always incude |
|---|
| 81 | * |
|---|
| 82 | * 12 3/1/06 6:24p dlwin |
|---|
| 83 | * PR 18981: Corrected for Merge Manager problem |
|---|
| 84 | * |
|---|
| 85 | * 11 3/1/06 4:11p dlwin |
|---|
| 86 | * PR18981: PR18981: fix "live playback" and add config option |
|---|
| 87 | * IP_USE_LIVE_PLAYBACK |
|---|
| 88 | * PR18981: prototype "live playback" |
|---|
| 89 | * |
|---|
| 90 | * 10 2/3/06 3:53p vsilyaev |
|---|
| 91 | * PR 18642: Update PCRlibrary to support playback of constant bitrate |
|---|
| 92 | * streams |
|---|
| 93 | * |
|---|
| 94 | * PR18642/1 1/27/06 4:18p vsilyaev |
|---|
| 95 | * PR18642: Use special configuration mode to change offsets for the |
|---|
| 96 | * constant rate streams |
|---|
| 97 | * |
|---|
| 98 | * 9 11/2/05 6:19p vsilyaev |
|---|
| 99 | * PR 16982: split bsettop_impl.h to bsettop_impl.h and bsettop_impl_cfg.h |
|---|
| 100 | * |
|---|
| 101 | * 8 8/4/05 9:08a erickson |
|---|
| 102 | * PR16504: converted playpump_params.band to |
|---|
| 103 | * playpump_params.route_through_parser_band |
|---|
| 104 | * |
|---|
| 105 | * 7 8/1/05 12:20p erickson |
|---|
| 106 | * PR16300: added bplaypump_set and bplaypump_get |
|---|
| 107 | * |
|---|
| 108 | * 6 5/5/05 11:45a jjordan |
|---|
| 109 | * PR15200: Add support for IP STB STC clock steering |
|---|
| 110 | * |
|---|
| 111 | * 6 5/5/05 11:44a jjordan |
|---|
| 112 | * PR15200: Add support for IP STB STC clock steering |
|---|
| 113 | * |
|---|
| 114 | * 6 5/5/05 11:30a jjordan |
|---|
| 115 | * PR15200: Add support for IP STB STC clock steering |
|---|
| 116 | * |
|---|
| 117 | * 5 5/4/05 5:23p erickson |
|---|
| 118 | * PR15173: comments added to bplaypump_read_complete |
|---|
| 119 | * |
|---|
| 120 | * 4 5/4/05 4:59p erickson |
|---|
| 121 | * PR14576: added num_descriptors and extended comments |
|---|
| 122 | * |
|---|
| 123 | * 3 4/20/05 4:55p vsilyaev |
|---|
| 124 | * PR 14724: Added option to activate use of timestamps. |
|---|
| 125 | * |
|---|
| 126 | * 2 3/18/05 11:25a vsilyaev |
|---|
| 127 | * PR 14509: Route playback thru pidparser. |
|---|
| 128 | * |
|---|
| 129 | * Irvine_BSEAVSW_Devel/BESOTFPVR/4 11/15/04 8:44p vsilyaev |
|---|
| 130 | * Added band parameter. |
|---|
| 131 | * |
|---|
| 132 | * Irvine_BSEAVSW_Devel/BESOTFPVR/3 11/13/04 1:56p vsilyaev |
|---|
| 133 | * Separated otfpvr to backend and frontend parts. |
|---|
| 134 | * Removed play interface. |
|---|
| 135 | * |
|---|
| 136 | * Irvine_BSEAVSW_Devel/BESOTFPVR/2 10/21/04 8:08p vsilyaev |
|---|
| 137 | * Merged 7038 branch |
|---|
| 138 | * |
|---|
| 139 | * Irvine_BSEAVSW_Devel/BESOTFPVR/BESOTFPVR_7038/1 10/18/04 6:25p vsilyaev |
|---|
| 140 | * Changed bsettop_play_start to return a stream. |
|---|
| 141 | * |
|---|
| 142 | * Irvine_BSEAVSW_Devel/BESOTFPVR/1 10/8/04 7:59p vsilyaev |
|---|
| 143 | * Added BESPVR suport |
|---|
| 144 | * |
|---|
| 145 | * Irvine_BSEAVSW_Devel/5 6/29/04 11:29a erickson |
|---|
| 146 | * PR11135: updated deprecation notices for settop api |
|---|
| 147 | * |
|---|
| 148 | * Irvine_BSEAVSW_Devel/4 6/24/04 10:27a erickson |
|---|
| 149 | * PR11135: converted to generic bsettop_callback for playpump and recpump |
|---|
| 150 | * |
|---|
| 151 | * Irvine_BSEAVSW_Devel/3 6/16/04 5:16p erickson |
|---|
| 152 | * PR11135: added bsettop_stream.h include |
|---|
| 153 | * |
|---|
| 154 | * Irvine_BSEAVSW_Devel/2 6/10/04 2:11p erickson |
|---|
| 155 | * PR11135: continued playpump devel |
|---|
| 156 | * |
|---|
| 157 | * Irvine_BSEAVSW_Devel/1 6/8/04 7:40a erickson |
|---|
| 158 | * PR11135: added iniital playpump impl for 97038 |
|---|
| 159 | * |
|---|
| 160 | *******************************************************************************/ |
|---|
| 161 | #ifndef BSETTOP_PLAYPUMP_H__ |
|---|
| 162 | #define BSETTOP_PLAYPUMP_H__ |
|---|
| 163 | |
|---|
| 164 | #include "bsettop_stream.h" |
|---|
| 165 | #include "bsettop_ip.h" |
|---|
| 166 | |
|---|
| 167 | #ifdef __cplusplus |
|---|
| 168 | extern "C" { |
|---|
| 169 | #endif |
|---|
| 170 | |
|---|
| 171 | /*=************************************************ |
|---|
| 172 | The bplaypump API is a push-based PVR api. This means that the calling app is responsible |
|---|
| 173 | for reading PVR data from disk, memory or network in whatever chunks it wants. |
|---|
| 174 | |
|---|
| 175 | This differs from the bplayback API which is designed to pull data from disk. The |
|---|
| 176 | bplayback API is built on top of the bplaypump API. |
|---|
| 177 | |
|---|
| 178 | There are several ways to interact with playpump in order to feed data: |
|---|
| 179 | 1) don't create your own read-loop but use the read callback exclusively |
|---|
| 180 | 2) create your own blocking read-loop and ignore the callback |
|---|
| 181 | 3) create your own non-blocking read-loop and use the read callback to wake up the loop |
|---|
| 182 | when space becomes available. |
|---|
| 183 | |
|---|
| 184 | Example code exists for each above methods in the api/examples directory as |
|---|
| 185 | playpumpX.c. You can also refer to bsettop_playback.c for another example of |
|---|
| 186 | how to use the playpump API. |
|---|
| 187 | ***************************************************/ |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | /** |
|---|
| 191 | Summary: |
|---|
| 192 | Parameters that must be passed into bplaypump_open. |
|---|
| 193 | **/ |
|---|
| 194 | typedef struct bplaypump_open_params { |
|---|
| 195 | size_t buffer_size; /* size in bytes of the playback buffer */ |
|---|
| 196 | unsigned alignment; /* alignment for the block. units of 2^alignment. Therefore a value of 2 will be |
|---|
| 197 | 4 byte aligned, 3 will be 8 byte aligned, etc. */ |
|---|
| 198 | unsigned num_descriptors; /* Number of descriptors. In general, the number of descriptors should be the |
|---|
| 199 | buffer_size / average read size. If you have too few, you won't be able to fill your playback buffer. |
|---|
| 200 | If you have too many, you'll waste memory. Be aware that the number needed for normal playback might |
|---|
| 201 | be far less than the number needed for a Broadcom Trick Mode or IP playback which requires small reads. */ |
|---|
| 202 | void* dcrypt_context; /* crypto context used to call the decrypt func */ |
|---|
| 203 | } bplaypump_open_params; |
|---|
| 204 | |
|---|
| 205 | /** |
|---|
| 206 | Summary: |
|---|
| 207 | Returns default configuration parameters for bplaypump_open. |
|---|
| 208 | **/ |
|---|
| 209 | void bplaypump_get_open_params( |
|---|
| 210 | bobject_t id, |
|---|
| 211 | bplaypump_open_params *open_params /* [out] */ |
|---|
| 212 | ); |
|---|
| 213 | |
|---|
| 214 | /** |
|---|
| 215 | Summary: |
|---|
| 216 | Open a new playpump resource where the id refers to the physical playback channel. |
|---|
| 217 | **/ |
|---|
| 218 | bplaypump_t bplaypump_open( |
|---|
| 219 | bobject_t id, |
|---|
| 220 | const bplaypump_open_params *open_params /* optional parameters for the playback pump */ |
|---|
| 221 | ); |
|---|
| 222 | |
|---|
| 223 | /** |
|---|
| 224 | Summary: |
|---|
| 225 | Close a playpump resource. |
|---|
| 226 | **/ |
|---|
| 227 | void bplaypump_close(bplaypump_t playpump); |
|---|
| 228 | |
|---|
| 229 | /** |
|---|
| 230 | Summary: |
|---|
| 231 | Params to be passed into bplaypump_start. |
|---|
| 232 | **/ |
|---|
| 233 | typedef struct bplaypump_params { |
|---|
| 234 | bsettop_callback read_callback; /* This callback is called whenever space becomes |
|---|
| 235 | available for writing. Please see the documentation of bsettop_callback |
|---|
| 236 | to learn about general rules for Settop API callbacks. |
|---|
| 237 | In this callback, you may call bplaypump_get_buffer in order to schedule |
|---|
| 238 | I/O. If no I/O is needed (for instance, if you're generated a BTP packet in |
|---|
| 239 | memory), you can call bplaypump_read_complete and will not have any recursion. |
|---|
| 240 | See bplaypump_read_complete for more rules on using this callback. */ |
|---|
| 241 | void *callback_context; /* context passed into the read_callback */ |
|---|
| 242 | bool timestamp_enabled; /* If true, then a 4 byte timestamp has been prepended to every |
|---|
| 243 | transport packet. brecord_params.timestamp_enabled |
|---|
| 244 | must match. */ |
|---|
| 245 | bsettop_callback error; /* Called out of the internal playback thread whenever |
|---|
| 246 | the a fatal error happens. This means that the playback is about to be stopped. |
|---|
| 247 | You cannot call a settop api function from this callback. */ |
|---|
| 248 | bool route_through_parser_band; /* if true, playback shall be routed through a parser band */ |
|---|
| 249 | bool timestamp_active; /* use timestamps to dynamicaly control playback rate (pacing) */ |
|---|
| 250 | bool constant_rate; /* streams comes from a media which has a constant rate, i.e. video over IP */ |
|---|
| 251 | bool is_playback_ip; /* true if playpump is IP playback, false otherwise */ |
|---|
| 252 | bool use_live_playback_mode; |
|---|
| 253 | unsigned long pacing_max_error; /* set the timestamp error bound, as used by the playback pacing logic */ |
|---|
| 254 | } bplaypump_params; |
|---|
| 255 | |
|---|
| 256 | /** |
|---|
| 257 | Summary: |
|---|
| 258 | Required to set bplaypump_params to an initial state. |
|---|
| 259 | **/ |
|---|
| 260 | void bplaypump_params_init( |
|---|
| 261 | bplaypump_params *params, /* [out] */ |
|---|
| 262 | bplaypump_t playpump |
|---|
| 263 | ); |
|---|
| 264 | |
|---|
| 265 | /** |
|---|
| 266 | Summary: |
|---|
| 267 | Starts playback and returns a stream which can be decoded or recorded. |
|---|
| 268 | **/ |
|---|
| 269 | bstream_t bplaypump_start( |
|---|
| 270 | bplaypump_t playpump, |
|---|
| 271 | const bstream_mpeg *mpeg, /* MPEG settings for the source. |
|---|
| 272 | These are required by playpump for for decryption. |
|---|
| 273 | They are also embedded in the returned bstream_t |
|---|
| 274 | for use by bdecode. */ |
|---|
| 275 | const bplaypump_params *params |
|---|
| 276 | ); |
|---|
| 277 | |
|---|
| 278 | /** |
|---|
| 279 | Summary: |
|---|
| 280 | Stop playback of the stream. |
|---|
| 281 | Description: |
|---|
| 282 | The bstream_t handle returned by bplaypump_start is no longer valid after |
|---|
| 283 | calling this. |
|---|
| 284 | **/ |
|---|
| 285 | bresult bplaypump_stop( |
|---|
| 286 | bplaypump_t playpump |
|---|
| 287 | ); |
|---|
| 288 | |
|---|
| 289 | /** |
|---|
| 290 | Summary: |
|---|
| 291 | Get buffer space for the next read. |
|---|
| 292 | |
|---|
| 293 | Description: |
|---|
| 294 | If block is false and no space is available, size will be 0 and |
|---|
| 295 | buffer will be NULL. |
|---|
| 296 | If block is true and no space is available, the function will block until space |
|---|
| 297 | becomes available or there is an error. |
|---|
| 298 | |
|---|
| 299 | If you make a non-blocking call and no space is available, the read_callback will |
|---|
| 300 | be called when space becomes available. |
|---|
| 301 | |
|---|
| 302 | This is a non-destructive call. This means you can call this function as many times |
|---|
| 303 | as you want and it won't consume any data or change any state. |
|---|
| 304 | **/ |
|---|
| 305 | bresult bplaypump_get_buffer( |
|---|
| 306 | bplaypump_t playpump, |
|---|
| 307 | void **buffer, /* [out] Get buffer space for the next read. */ |
|---|
| 308 | size_t *size /* [out] The size of buffer space available for the next read. */ |
|---|
| 309 | ); |
|---|
| 310 | |
|---|
| 311 | /** |
|---|
| 312 | Summary: |
|---|
| 313 | Report back how much of the buffer returned by bplaypump_get_buffer has been |
|---|
| 314 | used and should be sent to playback. |
|---|
| 315 | |
|---|
| 316 | Description: |
|---|
| 317 | You can call bplaypump_get_buffer as much as you like, but you should only |
|---|
| 318 | call bplaypump_read_complete once for every buffer pointer that you actually |
|---|
| 319 | read data into. |
|---|
| 320 | |
|---|
| 321 | This function name was chosen from the persepective of the application. Therefore it |
|---|
| 322 | is called "read" complete because your application will most likely read data |
|---|
| 323 | into this buffer. |
|---|
| 324 | |
|---|
| 325 | After calling read_complete, it is advised that the application take the initiative |
|---|
| 326 | to call bplaypump_get_buffer and see if there's more data that can be sent. |
|---|
| 327 | playpump may not generated another read callback after read_complete has been called |
|---|
| 328 | (the exact behavior is implementation and platform dependent, based on whether |
|---|
| 329 | the callback is edge or level triggered internally.) If you do not do this, you |
|---|
| 330 | may have to wait until the playback buffer is empty before sending the extra |
|---|
| 331 | chunk of data, and this will lead to playback underflow. |
|---|
| 332 | |
|---|
| 333 | There are three scenarios for using the skip value: |
|---|
| 334 | 1. When playpump comes to the end of its circular buffer, bplaypump_get_buffer may return a |
|---|
| 335 | very small size. If that size is too small for your i/o requirements, you should call |
|---|
| 336 | bplaypump_read_complete with a skip equal to the entire size of the buffer and amount |
|---|
| 337 | equal to 0. The small buffer will be skipped over and your next call to bplaypump_get_buffer |
|---|
| 338 | should return a large buffer at the beginning of playback. |
|---|
| 339 | 2. If your i/o method requires a certain byte alignment (e.g. 4K page aligned), you'll need to use |
|---|
| 340 | skip to offset into the buffer and start reading at the address you need. |
|---|
| 341 | 3. If you don't have any of these requirements, then always set skip to 0 and set amount to the |
|---|
| 342 | amount you are reading. |
|---|
| 343 | **/ |
|---|
| 344 | bresult bplaypump_read_complete( |
|---|
| 345 | bplaypump_t playpump, |
|---|
| 346 | size_t skip, /* The number of bytes at the beginning of the buffer returned by bplaypump_get_buffer |
|---|
| 347 | which should be ignored. |
|---|
| 348 | skip can be any value between 0 and the buffer_size. |
|---|
| 349 | skip + amount must be <= buffer_size. */ |
|---|
| 350 | size_t amount /* The amount of data written into the buffer returned by bplaypump_get_buffer, |
|---|
| 351 | following the skip amount. It does not include the skipped amount. |
|---|
| 352 | amount can be any value between 0 and the buffer_size. |
|---|
| 353 | skip + amount must be <= buffer_size. */ |
|---|
| 354 | ); |
|---|
| 355 | |
|---|
| 356 | /** |
|---|
| 357 | Summary: |
|---|
| 358 | Decoder states for playback. See bplaypump_settings for usage. |
|---|
| 359 | **/ |
|---|
| 360 | typedef enum bplaypump_state { |
|---|
| 361 | bplaypump_state_normal, /* Host sends unmodified stream to decoder */ |
|---|
| 362 | bplaypump_state_host_trick_mode, /* Host manipulates the stream before sending to decoder for vsync decode */ |
|---|
| 363 | bplaypump_state_brcm_trick_mode, /* Host manipulates the stream, including embedded BTP's, before sending to decoder for vsync decode */ |
|---|
| 364 | bplaypump_state_host_paced, /* Host manipulates the stream and the PTS's before sending to decoder for TSM decode */ |
|---|
| 365 | bplaypump_state_display_queue_trick_mode /* Host sends beginning of GOP for decode and post-decode reordering */ |
|---|
| 366 | } bplaypump_state; |
|---|
| 367 | |
|---|
| 368 | /** |
|---|
| 369 | Summary: |
|---|
| 370 | Special modes for the decoder. See bplaypump_settings for usage. |
|---|
| 371 | **/ |
|---|
| 372 | typedef enum bplaypump_decode_mode { |
|---|
| 373 | bplaypump_decode_mode_all, |
|---|
| 374 | bplaypump_decode_mode_i, |
|---|
| 375 | bplaypump_decode_mode_ip |
|---|
| 376 | } bplaypump_decode_mode; |
|---|
| 377 | |
|---|
| 378 | /** |
|---|
| 379 | Summary: |
|---|
| 380 | This macro is used in bplaypump_settings.rate to specify decoder or STC based |
|---|
| 381 | slowmotion, pause and fastforward. |
|---|
| 382 | **/ |
|---|
| 383 | #define BPLAYPUMP_NORMALPLAY_SPEED 100 |
|---|
| 384 | |
|---|
| 385 | /** |
|---|
| 386 | Summary: |
|---|
| 387 | Combination of decoder and host based trick mode settings. |
|---|
| 388 | **/ |
|---|
| 389 | typedef struct bplaypump_settings { |
|---|
| 390 | bplaypump_state state; /* Used to enable host-based trick modes. */ |
|---|
| 391 | bool forward; /* Used for host-based trick modes. |
|---|
| 392 | If true, decode top and bottom fields in the forward direction. If false, |
|---|
| 393 | reverse the decode of fields. No effect on progressive content. */ |
|---|
| 394 | unsigned decode_rate; /* Used for decoder-based trick modes. |
|---|
| 395 | This is the rate at which the decode should decode and display the content. |
|---|
| 396 | Use BPLAYPUMP_NORMALPLAY_SPEED to compute the rate. |
|---|
| 397 | For instance, BPLAYPUMP_NORMALPLAY_SPEED/2 is 2x slow motion. |
|---|
| 398 | BPLAYPUMP_NORMALPLAY_SPEED*2 is 2x fast forward. |
|---|
| 399 | Do not assume the value of BPLAYPUMP_NORMALPLAY_SPEED because it may change in the future. |
|---|
| 400 | The rate 0 is a decoder pause. */ |
|---|
| 401 | bplaypump_decode_mode decode_mode; /* Special mode the decoder. Often used to skip content. */ |
|---|
| 402 | } bplaypump_settings; |
|---|
| 403 | |
|---|
| 404 | /** |
|---|
| 405 | Summary: |
|---|
| 406 | Change the state of playpump to accomplish trick modes. |
|---|
| 407 | |
|---|
| 408 | Description: |
|---|
| 409 | bplaypump_settings enables both decoder and host based trick modes. |
|---|
| 410 | For host based trick modes, higher-level software must work in conjunction with playpump to accomplish the trick mode. |
|---|
| 411 | See bsettop_pvr.h and bsettop_playback.c for examples of higher-level trick mode |
|---|
| 412 | implementation. |
|---|
| 413 | |
|---|
| 414 | When you change the bplaypump_state or direction (the forward variable), it will reset the pump such that the next |
|---|
| 415 | bplaypump_read function is guaranteed to be intended for the new state. The higher-level |
|---|
| 416 | software is resposible for also flushing its state and any queues it has. |
|---|
| 417 | |
|---|
| 418 | Changing decode_rate and decode_mode will not cause any flush or reset. If only decode_rate and decode_mode are changed, |
|---|
| 419 | no higher-level flush or reset is required. |
|---|
| 420 | |
|---|
| 421 | Use of host and decoder based trick mode settings are orthogonal. They can be combined in a variety of ways |
|---|
| 422 | to accomplish various trick modes. |
|---|
| 423 | |
|---|
| 424 | If the decode_rate is changed, playpump will internally decide if either video decoder or STC trick modes will be used, |
|---|
| 425 | depending on the context. In general STC trick modes are preferred because the audio FIFO is not cleared |
|---|
| 426 | and you can resume normal play with immediate audio decode. |
|---|
| 427 | **/ |
|---|
| 428 | bresult bplaypump_set( |
|---|
| 429 | bplaypump_t playpump, |
|---|
| 430 | const bplaypump_settings *settings |
|---|
| 431 | ); |
|---|
| 432 | |
|---|
| 433 | /** |
|---|
| 434 | Summary: |
|---|
| 435 | Return the current settings of playpump as set by bplaypump_set. |
|---|
| 436 | **/ |
|---|
| 437 | void bplaypump_get( |
|---|
| 438 | bplaypump_t playpump, |
|---|
| 439 | bplaypump_settings *settings |
|---|
| 440 | ); |
|---|
| 441 | |
|---|
| 442 | /** |
|---|
| 443 | Summary: |
|---|
| 444 | This function is deprecated and may be removed. See bplaypump_set. |
|---|
| 445 | **/ |
|---|
| 446 | bresult bplaypump_set_state( |
|---|
| 447 | bplaypump_t playpump, |
|---|
| 448 | bplaypump_state state, |
|---|
| 449 | bool forward |
|---|
| 450 | ); |
|---|
| 451 | |
|---|
| 452 | /** |
|---|
| 453 | Summary: |
|---|
| 454 | This function is deprecated and may be removed. See bplaypump_set. |
|---|
| 455 | **/ |
|---|
| 456 | bresult bplaypump_set_decoder_rate( |
|---|
| 457 | bplaypump_t playpump, |
|---|
| 458 | unsigned rate |
|---|
| 459 | ); |
|---|
| 460 | |
|---|
| 461 | /** |
|---|
| 462 | Summary: |
|---|
| 463 | Tell the decoder to advance one frame from a paused state. |
|---|
| 464 | |
|---|
| 465 | Description: |
|---|
| 466 | You must be already in a paused state. This is done by setting bplaypump_settings.rate = 0. |
|---|
| 467 | |
|---|
| 468 | Based on the context of the pause, you will be in a video decoder pause, |
|---|
| 469 | or an STC (system time clock) pause. Based on this state, this function will perform |
|---|
| 470 | an video decoder or STC frame advance. |
|---|
| 471 | |
|---|
| 472 | This function cannot perform a frame reverse. |
|---|
| 473 | **/ |
|---|
| 474 | bresult bplaypump_frame_advance( |
|---|
| 475 | bplaypump_t playpump |
|---|
| 476 | ); |
|---|
| 477 | |
|---|
| 478 | /** |
|---|
| 479 | Summary: |
|---|
| 480 | A simple flush, apart from a change of state, is needed for jumps. |
|---|
| 481 | **/ |
|---|
| 482 | bresult bplaypump_flush( |
|---|
| 483 | bplaypump_t playpump |
|---|
| 484 | ); |
|---|
| 485 | |
|---|
| 486 | /** |
|---|
| 487 | Summary: |
|---|
| 488 | Status information which can be obtained from bplaypump_get_status. |
|---|
| 489 | **/ |
|---|
| 490 | typedef struct bplaypump_status { |
|---|
| 491 | unsigned long fifo_depth; /* Depth in bytes of the playback buffer */ |
|---|
| 492 | unsigned long fifo_size; /* Size in bytes of the playback buffer */ |
|---|
| 493 | void *buffer_base; /* Pointer to the base of the playback buffer. |
|---|
| 494 | This can be used for calculating your exact position |
|---|
| 495 | in the buffer for alignment considerations. */ |
|---|
| 496 | uint64_t bytes_played; /* Total number of bytes played since starting */ |
|---|
| 497 | bool running; |
|---|
| 498 | unsigned noverflows; /* for use by playback_ip to detect overflows in playpump_ip */ |
|---|
| 499 | } bplaypump_status; |
|---|
| 500 | |
|---|
| 501 | /** |
|---|
| 502 | Summary: |
|---|
| 503 | Get status of playpump and current transport playback buffer levels. |
|---|
| 504 | **/ |
|---|
| 505 | bresult bplaypump_get_status( |
|---|
| 506 | bplaypump_t p, |
|---|
| 507 | bplaypump_status *status /* [out] current status information returned here */ |
|---|
| 508 | ); |
|---|
| 509 | |
|---|
| 510 | /** |
|---|
| 511 | Summary: |
|---|
| 512 | Sets the PWM value for the decoder clock associated with this playpump |
|---|
| 513 | **/ |
|---|
| 514 | bresult bplaypump_p_set_pwm_value( |
|---|
| 515 | bplaypump_t p, |
|---|
| 516 | int pwm_value); |
|---|
| 517 | |
|---|
| 518 | typedef int bsettop_socket; |
|---|
| 519 | |
|---|
| 520 | typedef enum bplaypump_source_type { |
|---|
| 521 | bplaypump_source_none=0, /* normal mode, data shalll be written into the buffer in a sequential order */ |
|---|
| 522 | bplaypump_source_normal=0, /* normal mode, data shalll be written into the buffer in a sequential order */ |
|---|
| 523 | bplaypump_source_segmented, /* segemented mode, data shall be fed in the format <desc> <data>, |
|---|
| 524 | where desc is structure of bplaypump_chunk_desc type and |
|---|
| 525 | data is payload of variable size (size specified in the desc), |
|---|
| 526 | application shall ensure that desc doesn't occupyes continious region of memory |
|---|
| 527 | */ |
|---|
| 528 | bplaypump_source_socket /* playpump reads data from the IP/UDP socket */ |
|---|
| 529 | }bplaypump_source_type; |
|---|
| 530 | |
|---|
| 531 | #define BPLAYPUMP_SEGMENT_SIGNATURE ((((uint32_t)'B')<<24) | (((uint32_t)'P')<<16 ) | (((uint32_t)'L')<<8) | 0) |
|---|
| 532 | #define BPLAYPUMP_SEGMENT_STREAMS 2 |
|---|
| 533 | typedef struct bplaypump_segment_desc { |
|---|
| 534 | uint32_t length; /* size of the segment, including length field */ |
|---|
| 535 | uint64_t offset; /* 64 bit offset in the source file */ |
|---|
| 536 | uint32_t timestamp; /* timestamp for this segment */ |
|---|
| 537 | struct { |
|---|
| 538 | uint16_t stream_id; |
|---|
| 539 | int16_t timestamp_delta; |
|---|
| 540 | } timestamp_delta[9]; |
|---|
| 541 | uint32_t signature; /* this field shall be set to BPLAYPUMP_SEGMENT_SIGNATURE */ |
|---|
| 542 | }bplaypump_segment_desc; |
|---|
| 543 | |
|---|
| 544 | typedef struct bplaypump_source { |
|---|
| 545 | bplaypump_source_type source_type; /* source type */ |
|---|
| 546 | bsettop_socket socket; /* is source_type == bplaypump_source_socket this shall be valid IP/UDP socket */ |
|---|
| 547 | bsettop_ip_protocol ip_protocol; |
|---|
| 548 | uint32_t remote_addr; |
|---|
| 549 | uint32_t remote_port; |
|---|
| 550 | unsigned local_addr; |
|---|
| 551 | } bplaypump_source; |
|---|
| 552 | |
|---|
| 553 | void bplaypump_get_source(bplaypump_t playpump, bplaypump_source *source); |
|---|
| 554 | bresult bplaypump_set_source(bplaypump_t playpump, const bplaypump_source *source); |
|---|
| 555 | |
|---|
| 556 | |
|---|
| 557 | /** |
|---|
| 558 | Summary: |
|---|
| 559 | This macro specifies a default RTP header size for skipping when passing a |
|---|
| 560 | RTP packet payload the playback hardware |
|---|
| 561 | **/ |
|---|
| 562 | #define RTP_FIXED_HEADER_SIZE 12 |
|---|
| 563 | |
|---|
| 564 | /** |
|---|
| 565 | Summary: |
|---|
| 566 | This macro specifies the maximum number of RTP headers that can be returned |
|---|
| 567 | by a call to bplaypump_get_rtp_hdr_data() |
|---|
| 568 | **/ |
|---|
| 569 | #define B_MAX_RTP_HDRS 4000 |
|---|
| 570 | |
|---|
| 571 | /** |
|---|
| 572 | Summary: |
|---|
| 573 | This struct defines the fields of the RTP header |
|---|
| 574 | **/ |
|---|
| 575 | typedef struct bplaypump_rtp_header { |
|---|
| 576 | uint8_t version; |
|---|
| 577 | uint8_t padding; |
|---|
| 578 | bool extension; |
|---|
| 579 | uint8_t csrc_count; |
|---|
| 580 | uint8_t marker; |
|---|
| 581 | uint8_t payload_type; |
|---|
| 582 | uint16_t sequence_num; |
|---|
| 583 | uint32_t timestamp; |
|---|
| 584 | uint32_t ssrc; |
|---|
| 585 | |
|---|
| 586 | struct { |
|---|
| 587 | uint16_t defined_by_profile; |
|---|
| 588 | uint16_t length; |
|---|
| 589 | } extension_header; |
|---|
| 590 | } bplaypump_rtp_header; |
|---|
| 591 | |
|---|
| 592 | /** |
|---|
| 593 | Summary: |
|---|
| 594 | This struct defines the fields of the fixed RTP header |
|---|
| 595 | **/ |
|---|
| 596 | typedef struct bplaypump_rtp_hdr_data_t { |
|---|
| 597 | void *data; /* pointer to RTP header reception data (used by RTCP/RTSP) */ |
|---|
| 598 | unsigned entry_cnt; /* number of headers received */ |
|---|
| 599 | } bplaypump_rtp_hdr_data_t; |
|---|
| 600 | |
|---|
| 601 | /** |
|---|
| 602 | Summary: |
|---|
| 603 | Get RTP header data. |
|---|
| 604 | The entry_cnt output parameter specifies how many headers are returned by the |
|---|
| 605 | rtp_header_data pointer |
|---|
| 606 | **/ |
|---|
| 607 | bresult bplaypump_get_rtp_hdr_data(bplaypump_t p, const bplaypump_rtp_hdr_data_t *rtp_header_data, unsigned *entry_cnt); |
|---|
| 608 | |
|---|
| 609 | #ifdef __cplusplus |
|---|
| 610 | } |
|---|
| 611 | #endif |
|---|
| 612 | |
|---|
| 613 | #endif /* BSETTOP_PLAYPUMP_H__ */ |
|---|