| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2002-2009, 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: bcmplayer.h $ |
|---|
| 11 | * $brcm_Revision: 3 $ |
|---|
| 12 | * $brcm_Date: 7/13/09 10:47a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: Transport Stream Index Player Header File |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * Created: 02/09/2001 by Marcus Kellerman |
|---|
| 19 | * |
|---|
| 20 | * $brcm_Log: /BSEAV/lib/bcmplayer/include/bcmplayer.h $ |
|---|
| 21 | * |
|---|
| 22 | * 3 7/13/09 10:47a ahulse |
|---|
| 23 | * PR56762: Report if B frame or not |
|---|
| 24 | * |
|---|
| 25 | * 2 12/6/07 10:24a ahulse |
|---|
| 26 | * PR36547: On file trim, ensure we jump to next I frame |
|---|
| 27 | * |
|---|
| 28 | * Irvine_BSEAVSW_Devel/44 9/12/06 5:58p ahulse |
|---|
| 29 | * PR22600, PR22661: Increased PTS_CACHE_SIZE, reworked search algorithm |
|---|
| 30 | * to avoid lengthy searches, interpolate PTS's if needed |
|---|
| 31 | * |
|---|
| 32 | * Irvine_BSEAVSW_Devel/43 7/15/05 8:07p erickson |
|---|
| 33 | * PR16138: updated comments |
|---|
| 34 | * |
|---|
| 35 | * Irvine_BSEAVSW_Devel/42 6/8/05 1:37p erickson |
|---|
| 36 | * PR15126: converted BNAV_Player_FindIndexFromPts to use a cache of |
|---|
| 37 | * recently sent pictures and their PTS values. No longer perform an |
|---|
| 38 | * index search. |
|---|
| 39 | * |
|---|
| 40 | * Irvine_BSEAVSW_Devel/41 11/30/04 4:05p erickson |
|---|
| 41 | * PR13303: added useReferenceFrame setting, defaulting to true, which |
|---|
| 42 | * allows reduced memory/reduced performance mode |
|---|
| 43 | * |
|---|
| 44 | * Irvine_BSEAVSW_Devel/40 4/13/04 4:54p erickson |
|---|
| 45 | * PR10292: added skipSanityCheck to support virtual indexes |
|---|
| 46 | * |
|---|
| 47 | * Irvine_BSEAVSW_Devel/39 3/18/04 3:37p erickson |
|---|
| 48 | * PR10111: documented new behavior for BNAV_Player_SetBounds |
|---|
| 49 | * |
|---|
| 50 | * Irvine_BSEAVSW_Devel/38 12/8/03 11:32a erickson |
|---|
| 51 | * PR8879: added BNAV_Player_GetPositionInformation. doesn't impact |
|---|
| 52 | * existing api. |
|---|
| 53 | * |
|---|
| 54 | * Irvine_BSEAVSW_Devel/37 12/2/03 12:05a erickson |
|---|
| 55 | * PR8807: updated docs |
|---|
| 56 | * |
|---|
| 57 | * Irvine_BSEAVSW_Devel/36 11/10/03 2:29p erickson |
|---|
| 58 | * PR8563: added transport timestamp support to bcmplayer |
|---|
| 59 | * |
|---|
| 60 | * Irvine_BSEAVSW_Devel/35 5/19/03 1:16p marcusk |
|---|
| 61 | * Specify how many bytes must be zeroed when performing trick modes and |
|---|
| 62 | * frames are not aligned to transport packet boundaries. |
|---|
| 63 | * |
|---|
| 64 | * Irvine_BSEAVSW_Devel/34 4/17/03 8:58a erickson |
|---|
| 65 | * changed vchipState from int to unsigned short |
|---|
| 66 | * |
|---|
| 67 | * Irvine_BSEAVSW_Devel/33 3/31/03 2:42p erickson |
|---|
| 68 | * updated documentation (further updates will come when DocJet is more |
|---|
| 69 | * available) |
|---|
| 70 | * |
|---|
| 71 | * Irvine_BSEAVSW_Devel/32 2/28/03 5:20p erickson |
|---|
| 72 | * BNAV_Player_SetCurrentIndex now verifies the index and can fail |
|---|
| 73 | * |
|---|
| 74 | * Irvine_BSEAVSW_Devel/31 2/14/03 3:16p erickson |
|---|
| 75 | * Added const to GetPlayMode() |
|---|
| 76 | * |
|---|
| 77 | * Irvine_BSEAVSW_Devel/30 2/14/03 1:57p erickson |
|---|
| 78 | * New naming convention |
|---|
| 79 | * Fixed looping from previous rework |
|---|
| 80 | * Removed bcmindexer _getParam/_setParam |
|---|
| 81 | * Did not change code shared between tsplayer and bcmplayer |
|---|
| 82 | * Refactored settings, playmode and other structures |
|---|
| 83 | * |
|---|
| 84 | * Irvine_BSEAVSW_Devel/29 2/10/03 5:15p erickson |
|---|
| 85 | * bcmplayer rework: |
|---|
| 86 | * 1) version 2.02 |
|---|
| 87 | * 2) removed getParam/setParam API |
|---|
| 88 | * 3) added various get/set functions and specific algorithmic functions. |
|---|
| 89 | * No more typecasting |
|---|
| 90 | * or strange parameter passing needed. Each function has a specified |
|---|
| 91 | * execution time. |
|---|
| 92 | * 4) added run-time debug modes |
|---|
| 93 | * 5) normal play is no longer frame based. this enables 60 frames/sec |
|---|
| 94 | * content. |
|---|
| 95 | * |
|---|
| 96 | * Irvine_HDDemo_Devel/28 9/10/02 9:5a erickson |
|---|
| 97 | * updated comments |
|---|
| 98 | * |
|---|
| 99 | * Irvine_HDDemo_Devel/27 8/12/02 10:21a erickson |
|---|
| 100 | * a couple small changes requested by customer |
|---|
| 101 | * |
|---|
| 102 | * Irvine_HDDemo_Devel\26 4/17/02 1:15p erickson |
|---|
| 103 | * Added readIndex(). Customer requirement. |
|---|
| 104 | * |
|---|
| 105 | * Irvine_HDDemo_Devel\25 4/16/02 2:52p erickson |
|---|
| 106 | * Added printCachePerformance |
|---|
| 107 | * |
|---|
| 108 | * \main\Irvine_HDDemo_Devel\23 3/15/02 6:32p erickson |
|---|
| 109 | * Added documentation |
|---|
| 110 | * |
|---|
| 111 | * \main\Irvine_HDDemo_Devel\22 3/4/02 8:34p erickson |
|---|
| 112 | * Added more documentation to the enums |
|---|
| 113 | * |
|---|
| 114 | * \main\Irvine_HDDemo_Devel\21 2/27/02 12:29p erickson |
|---|
| 115 | * Added eBpFifoSize and eBpIsHits parameters, and eBpPlaySkipP mode (not |
|---|
| 116 | * implemented). Cleaned up comments about which parameters are get, set |
|---|
| 117 | * or get/set. |
|---|
| 118 | * |
|---|
| 119 | ***************************************************************************/ |
|---|
| 120 | #ifndef BCMPLAYER_H__ |
|---|
| 121 | #define BCMPLAYER_H__ |
|---|
| 122 | |
|---|
| 123 | #include "playertypes.h" |
|---|
| 124 | #include "bcmindexer.h" |
|---|
| 125 | #include "bcmplayer_version.h" |
|---|
| 126 | |
|---|
| 127 | #ifdef __cplusplus |
|---|
| 128 | extern "C" { |
|---|
| 129 | #endif |
|---|
| 130 | |
|---|
| 131 | /** |
|---|
| 132 | * Summary: |
|---|
| 133 | * Opaque handle used to identify one instance of Bcmplayer. |
|---|
| 134 | */ |
|---|
| 135 | typedef struct BNAV_Player_HandleImpl *BNAV_Player_Handle; |
|---|
| 136 | |
|---|
| 137 | /** |
|---|
| 138 | * Summary: |
|---|
| 139 | * Optional callback to determine the first and last index offsets of the index file. |
|---|
| 140 | * |
|---|
| 141 | * Description: |
|---|
| 142 | * This callback is set using the BNAV_Player_Settings structure. |
|---|
| 143 | * It is called anytime Bcmplayer needs to bound itself using the firstIndex or lastIndex. |
|---|
| 144 | * Note that lastIndex == totalIndexes - 1. |
|---|
| 145 | * This is necessary for files which are growing (lastIndex is increasing) or are being |
|---|
| 146 | * trimmed (firstIndex is increasing). For static files, it's most efficient to not |
|---|
| 147 | * specify a callback and call BNAV_Player_SetBounds instead. |
|---|
| 148 | * |
|---|
| 149 | * Return values: |
|---|
| 150 | * 0 = success |
|---|
| 151 | * nonzero = failure |
|---|
| 152 | **/ |
|---|
| 153 | typedef int (*BP_BOUNDS_CB)( |
|---|
| 154 | BNAV_Player_Handle handle, |
|---|
| 155 | void *filePointer, |
|---|
| 156 | long *firstIndex, /* [out] */ |
|---|
| 157 | long *lastIndex /* [out] */ |
|---|
| 158 | ); |
|---|
| 159 | |
|---|
| 160 | /** |
|---|
| 161 | * Summary: |
|---|
| 162 | * Default implementation of BP_BOUNDS_CB which uses the seekCb and tellCb callbacks to |
|---|
| 163 | * determine the lastIndex. |
|---|
| 164 | * |
|---|
| 165 | * Return values: |
|---|
| 166 | * 0 = success |
|---|
| 167 | * nonzero = failure |
|---|
| 168 | **/ |
|---|
| 169 | int BNAV_Player_DefaultGetBounds( |
|---|
| 170 | BNAV_Player_Handle handle, |
|---|
| 171 | void *filePointer, |
|---|
| 172 | long *firstIndex, /* [out] */ |
|---|
| 173 | long *lastIndex /* [out] */ |
|---|
| 174 | ); |
|---|
| 175 | |
|---|
| 176 | /** |
|---|
| 177 | * Summary: |
|---|
| 178 | * Debug modes for BNAV_Player_SetDebugMode. |
|---|
| 179 | **/ |
|---|
| 180 | typedef enum { |
|---|
| 181 | BNAV_Player_DebugNone, /* Don't print anything */ |
|---|
| 182 | BNAV_Player_DebugDisplayFramesSent, /* Only print displayable frames */ |
|---|
| 183 | BNAV_Player_DebugFramesSent, /* Print all decode-only and decode-and-display |
|---|
| 184 | frames */ |
|---|
| 185 | BNAV_Player_DebugFramesAndAllPacketsSent /* Print everything sent, including all |
|---|
| 186 | BTP packets. */ |
|---|
| 187 | } BNAV_Player_DebugMode; |
|---|
| 188 | |
|---|
| 189 | /** |
|---|
| 190 | * Summary: |
|---|
| 191 | * Settings used to initalize Bcmplayer. |
|---|
| 192 | * |
|---|
| 193 | * Description: |
|---|
| 194 | * You must call BNAV_Player_GetDefaultSettings before setting any member of this structure. |
|---|
| 195 | * See Also: |
|---|
| 196 | * BNAV_Player_GetDefaultSettings, BNAV_Player_Open, BNAV_Player_Reset and BNAV_Player_SetSettings. |
|---|
| 197 | **/ |
|---|
| 198 | typedef struct { |
|---|
| 199 | unsigned short videoPid;/* Video pid for the stream. This is used to generate |
|---|
| 200 | valid BTP packets. |
|---|
| 201 | REQUIRED to be set. */ |
|---|
| 202 | BP_READ_CB readCb; /* Callback bcmplayer uses to read the index. |
|---|
| 203 | fread() works fine, but you can use your own callback. |
|---|
| 204 | REQUIRED to be set. */ |
|---|
| 205 | BP_TELL_CB tellCb; /* Callback bcmplayer uses to tell the location of the index. |
|---|
| 206 | ftell() works fine, but you can use your own callback. |
|---|
| 207 | ftello() with 64 bit off_t does not work (therefore you can't have |
|---|
| 208 | >2GB indexes.) |
|---|
| 209 | REQUIRED to be set. */ |
|---|
| 210 | BP_SEEK_CB seekCb; /* Callback bcmplayer uses to seek to a location in the index. |
|---|
| 211 | fseek() works fine, but you can use your own callback. |
|---|
| 212 | fseeko() with 64 bit off_t does not work (therefore you can't have |
|---|
| 213 | >2GB indexes.) |
|---|
| 214 | REQUIRED to be set. */ |
|---|
| 215 | BP_BOUNDS_CB boundsCb; /* Callback bcmplayer uses to set firstIndex and lastIndex. |
|---|
| 216 | The callback is invoked every time before bcmplayer uses |
|---|
| 217 | the firstIndex and lastIndex values. |
|---|
| 218 | |
|---|
| 219 | BNAV_Player_GetDefaultSettings() sets this to |
|---|
| 220 | BNAV_Player_DefaultGetBounds, which uses the seek and tell |
|---|
| 221 | callbacks. |
|---|
| 222 | |
|---|
| 223 | If you set it to NULL, this disables the polling feature. |
|---|
| 224 | You can then change firstIndex and |
|---|
| 225 | lastIndex by calling bcmplayer_setSettings(). This gives |
|---|
| 226 | a performance increase if the file size is static, and it |
|---|
| 227 | gives applications an option to control when the player is |
|---|
| 228 | updated. Also, if you updating the bounds from a separate thread |
|---|
| 229 | (i.e. the record thread), you must be careful to not call |
|---|
| 230 | bcmplayer functions re-entrantly. */ |
|---|
| 231 | void *filePointer; /* Pointer to be passed to the callback functions. If you |
|---|
| 232 | are using fread()/fseek()/ftell(), then this should be the |
|---|
| 233 | corresponding pointer to FILE. |
|---|
| 234 | REQUIRED to be set. */ |
|---|
| 235 | BNAV_DecoderFeatures decoderFeatures; |
|---|
| 236 | /* Lists which features the decoder supports. */ |
|---|
| 237 | int normalPlayBufferSize; /* Normal playback isn't frame based. This is because |
|---|
| 238 | disk seek times will overwhelm 60 frames/sec content. |
|---|
| 239 | However, using bcmplayer for normal play does allow |
|---|
| 240 | the currentIndex to be kept up-to-date. The normalPlayBufferSize |
|---|
| 241 | determines how big the blocks will be. Generally HD content |
|---|
| 242 | needs larger sized blocks than SD content. */ |
|---|
| 243 | int cacheSize; /* Size of NAV Table cache. */ |
|---|
| 244 | BNAV_Player_DebugMode debugMode; |
|---|
| 245 | /* Runtime control for debug information. This feature is subject to change. |
|---|
| 246 | See implementation for details. */ |
|---|
| 247 | long firstIndex; /* Determines the first index accessible by bcmplayer. |
|---|
| 248 | If boundsCb is not NULL, this is ignored. If boundsCb is NULL, |
|---|
| 249 | you can update these values with bcmplayer_setBounds(). */ |
|---|
| 250 | long lastIndex; /* Determines the last index accessiable by bcmplayer. Note that |
|---|
| 251 | lastIndex = totalIndexes - 1. |
|---|
| 252 | If boundsCb is not NULL, this is ignored. If boundsCb is NULL, |
|---|
| 253 | you can update these values with bcmplayer_setBounds(). */ |
|---|
| 254 | BNAV_Version navVersion;/* You can specify the version of the NAV table. |
|---|
| 255 | BNAV_Player_GetDefaultSettings() sets this to BNAV_VersionUnknown |
|---|
| 256 | add the actual version is auto-detected. */ |
|---|
| 257 | int isPes; /* If non-zero, the NAV table is for PES format. |
|---|
| 258 | bcmplayer may not be able to autodetect the difference between |
|---|
| 259 | TS and PES NAV Tables because the entries are of different |
|---|
| 260 | size. |
|---|
| 261 | NOTE: This is not supported yet. */ |
|---|
| 262 | int transportTimestampEnabled; /* If true, then transport has prepended a 4 byte |
|---|
| 263 | timestamp to every transport packet and this must be |
|---|
| 264 | taken into account. */ |
|---|
| 265 | int skipSanityCheck; /* When bcmplayer opens a new index, it performs a few checks |
|---|
| 266 | to make sure the index is valid. By default the check is |
|---|
| 267 | performed. You may want to turn this off (for instance, |
|---|
| 268 | if you're accessing a "virtualized" index which doesn't |
|---|
| 269 | exist yet.) */ |
|---|
| 270 | int useReferenceFrame; /* Allows bcmplayer algorithm to use a "reference frame" |
|---|
| 271 | which leads to better performance but more memory usage. |
|---|
| 272 | This is a boolean which defaults true. */ |
|---|
| 273 | } BNAV_Player_Settings; |
|---|
| 274 | |
|---|
| 275 | /** |
|---|
| 276 | * Summary: |
|---|
| 277 | * Get default values for BNAV_Player_Settings. |
|---|
| 278 | * Description: |
|---|
| 279 | * This must be called before using the BNAV_Player_Settings structure. |
|---|
| 280 | **/ |
|---|
| 281 | void BNAV_Player_GetDefaultSettings( |
|---|
| 282 | BNAV_Player_Settings *settings /* [out] */ |
|---|
| 283 | ); |
|---|
| 284 | |
|---|
| 285 | /** |
|---|
| 286 | * Summary: |
|---|
| 287 | * Open a new Bcmplayer handle. |
|---|
| 288 | * |
|---|
| 289 | * Description: |
|---|
| 290 | * You can open multiple players. Each player can process a single index. All calls |
|---|
| 291 | * to the BNAV_Player API must be synchronized if using the same handle. |
|---|
| 292 | * |
|---|
| 293 | * Return values: |
|---|
| 294 | * 0 on success |
|---|
| 295 | * -1 on error |
|---|
| 296 | **/ |
|---|
| 297 | int BNAV_Player_Open( |
|---|
| 298 | BNAV_Player_Handle *handle, /* [out] New handle. Only valid if function returns 0. */ |
|---|
| 299 | const BNAV_Player_Settings *settings /* Some members of BNAV_Player_Settings must be |
|---|
| 300 | set to non-default values. See the structure's |
|---|
| 301 | documentation for details. */ |
|---|
| 302 | ); |
|---|
| 303 | |
|---|
| 304 | /** |
|---|
| 305 | * Summary: |
|---|
| 306 | * Reset Bcmplayer to an initial state. |
|---|
| 307 | * Description: |
|---|
| 308 | * If cacheSize is unchanged, the cache will not be reallocated. |
|---|
| 309 | * |
|---|
| 310 | * Return values: |
|---|
| 311 | * -1 on error |
|---|
| 312 | * 0 on success |
|---|
| 313 | **/ |
|---|
| 314 | int BNAV_Player_Reset( |
|---|
| 315 | BNAV_Player_Handle handle, |
|---|
| 316 | const BNAV_Player_Settings *settings |
|---|
| 317 | ); |
|---|
| 318 | |
|---|
| 319 | /** |
|---|
| 320 | * Summary: |
|---|
| 321 | * Free a Bcmplayer instance. |
|---|
| 322 | * Description: |
|---|
| 323 | * The handle becomes invalid and any further use leads to undefined behavior. |
|---|
| 324 | **/ |
|---|
| 325 | void BNAV_Player_Close( |
|---|
| 326 | BNAV_Player_Handle handle |
|---|
| 327 | ); |
|---|
| 328 | |
|---|
| 329 | /** |
|---|
| 330 | * Summary: |
|---|
| 331 | * Populate a BNAV_Player_Settings structure with current values. |
|---|
| 332 | * Description: |
|---|
| 333 | * This performs no disk access or searches, and so it is guaranteed to be fast. |
|---|
| 334 | **/ |
|---|
| 335 | void BNAV_Player_GetSettings( |
|---|
| 336 | BNAV_Player_Handle handle, |
|---|
| 337 | BNAV_Player_Settings *settings /* [out] */ |
|---|
| 338 | ); |
|---|
| 339 | |
|---|
| 340 | /** |
|---|
| 341 | * Summary: |
|---|
| 342 | * Set the search bounds of the player. |
|---|
| 343 | * Description: |
|---|
| 344 | * This is an alternative to using the boundsCb member of BNAV_Player_Settings. |
|---|
| 345 | * This can be used if you know the file is fixed size and the bounds will never change. |
|---|
| 346 | * |
|---|
| 347 | * By calling this function, you will NULL out any bounds callback you may have |
|---|
| 348 | * specified. This includes the default bounds callback. Instead, the values you pass |
|---|
| 349 | * in will be used. |
|---|
| 350 | * |
|---|
| 351 | * Return values: |
|---|
| 352 | * 0 if successful. |
|---|
| 353 | * -1 if bounds are inconsistent or negative. |
|---|
| 354 | **/ |
|---|
| 355 | int BNAV_Player_SetBounds( |
|---|
| 356 | BNAV_Player_Handle handle, |
|---|
| 357 | long firstIndex, |
|---|
| 358 | long lastIndex |
|---|
| 359 | ); |
|---|
| 360 | |
|---|
| 361 | /** |
|---|
| 362 | * Summary: |
|---|
| 363 | * Set the debug mode of BNAV_Player. |
|---|
| 364 | * Description: |
|---|
| 365 | * Debug modes will print information to the console about what frames are being |
|---|
| 366 | * sent out of BNAV_Player_GetNextEntry. |
|---|
| 367 | **/ |
|---|
| 368 | void BNAV_Player_SetDebugMode( |
|---|
| 369 | BNAV_Player_Handle handle, |
|---|
| 370 | BNAV_Player_DebugMode debugMode |
|---|
| 371 | ); |
|---|
| 372 | |
|---|
| 373 | /****************************************** |
|---|
| 374 | * |
|---|
| 375 | * Getting play entries |
|---|
| 376 | * |
|---|
| 377 | **/ |
|---|
| 378 | |
|---|
| 379 | /** |
|---|
| 380 | * Summary: |
|---|
| 381 | * Data structure used to return data from BNAV_Player_GetNextEntry(). |
|---|
| 382 | **/ |
|---|
| 383 | typedef struct |
|---|
| 384 | { |
|---|
| 385 | unsigned long startOffsetHi; /* High-order 32 bits of mpeg offset. */ |
|---|
| 386 | unsigned long startOffset; /* Low-order 32 bits of mpeg offset. */ |
|---|
| 387 | unsigned long byteCount; /* Number of bytes of mpeg to transfer. */ |
|---|
| 388 | char isInsertedPacket; /* Inserted packet flag. If true, then |
|---|
| 389 | ignore startOffset/startOffsetHi/byteCount and |
|---|
| 390 | write the 188 (or 192) bytes pointed to be pkt |
|---|
| 391 | parameter to the decoder. |
|---|
| 392 | The size is 192 if transportTimestampEnabled |
|---|
| 393 | is true. */ |
|---|
| 394 | char isLastEntry; /* True if this is the last piece of data in |
|---|
| 395 | bcmplayer's fifo. */ |
|---|
| 396 | unsigned long zeroByteCountBegin; /* Number of bytes at the beginnigg of the play entry that |
|---|
| 397 | the application should overwrite with zeros. |
|---|
| 398 | This prevents garbage data from being fed to the |
|---|
| 399 | video decoder while allowing complete transport packets |
|---|
| 400 | (or PES packets) to be transfered. The application |
|---|
| 401 | must be smart when zeroing out these bytes and only |
|---|
| 402 | over-write bytes that are part of the transport payload. This |
|---|
| 403 | would mean skipping over (not zeroing) the sync byte, pid, and |
|---|
| 404 | adaptation field, and PES header. For example, if this value |
|---|
| 405 | was set to 50, and the start of the transport payload started at the |
|---|
| 406 | 40th byte of the transport packet, the first 10 bytes of |
|---|
| 407 | the payload should be zero'ed. */ |
|---|
| 408 | unsigned long zeroByteCountEnd; /* Number of bytes at the end of the play entry that |
|---|
| 409 | the application should overwrite with zeros. |
|---|
| 410 | This prevents garbage data from being fed to the |
|---|
| 411 | video decoder while allow complete transport packets |
|---|
| 412 | (or PES packets) to be transfered */ |
|---|
| 413 | } BNAV_Player_PlayEntry; |
|---|
| 414 | |
|---|
| 415 | /** |
|---|
| 416 | * Summary: |
|---|
| 417 | * Signal to calling app different index retrieval failures. |
|---|
| 418 | * |
|---|
| 419 | * Description: |
|---|
| 420 | * In most case it is sufficient to signal to calling app that index retrieval failed ( BNAV_GENERIC_IDX_FAIL ), |
|---|
| 421 | * but during continuous record we need to know when Advance Index retrieval fails, as this usually happens |
|---|
| 422 | * before begin/end of index entries are reached. |
|---|
| 423 | * |
|---|
| 424 | **/ |
|---|
| 425 | #define BNAV_GENERIC_IDX_FAIL -1 |
|---|
| 426 | #define BNAV_ADVANCE_IDX_FAIL -2 |
|---|
| 427 | |
|---|
| 428 | /** |
|---|
| 429 | * Summary: |
|---|
| 430 | * Retrieve the offset and size of the next chunk of mpeg data to be |
|---|
| 431 | * sent to the decoder. |
|---|
| 432 | * |
|---|
| 433 | * Description: |
|---|
| 434 | * This function is repeatedly called by the user application in the playback thread. |
|---|
| 435 | * See the Sample Usage Code for an example of how to call this. |
|---|
| 436 | * |
|---|
| 437 | * Return values: |
|---|
| 438 | * 0 = success |
|---|
| 439 | * -1 = failure |
|---|
| 440 | **/ |
|---|
| 441 | int BNAV_Player_GetNextPlayEntry( |
|---|
| 442 | BNAV_Player_Handle handle, |
|---|
| 443 | BNAV_Player_PlayEntry *entry, /* [out] Contains the result of the call. */ |
|---|
| 444 | unsigned char *pkt /* [out] Pointer to 188 (or 192) byte array. If |
|---|
| 445 | p_tpEntry->isInsertedPacket is true, then |
|---|
| 446 | this contains data which must be sent |
|---|
| 447 | to the decoder. Ignore the offset/byteCount |
|---|
| 448 | in p_tpEntry. |
|---|
| 449 | The packet size must be 192 if transportTimestampEnabled |
|---|
| 450 | is true, otherwise 188. |
|---|
| 451 | */ |
|---|
| 452 | ); |
|---|
| 453 | |
|---|
| 454 | |
|---|
| 455 | /****************************************** |
|---|
| 456 | * |
|---|
| 457 | * Play Mode |
|---|
| 458 | * |
|---|
| 459 | **/ |
|---|
| 460 | |
|---|
| 461 | /** |
|---|
| 462 | * Summary: |
|---|
| 463 | * The play mode stucture tells BNAV_Player how it should feed frames to the application. |
|---|
| 464 | */ |
|---|
| 465 | typedef struct { |
|---|
| 466 | eBpPlayModeParam playMode; /* Determines what kind of playback to use. */ |
|---|
| 467 | int playModeModifier; /* Sets direction and speed for the playMode. Some |
|---|
| 468 | modifiers are not allowed for certain play modes: |
|---|
| 469 | |
|---|
| 470 | eBpPlayNormal and eBpPlayIP assert this value |
|---|
| 471 | to 1 and so the value you pass in is ignored. |
|---|
| 472 | |
|---|
| 473 | eBpPlayI and eBpPlayBrcm are the only modes which |
|---|
| 474 | can have a negative value. |
|---|
| 475 | |
|---|
| 476 | 0 is never allowed. |
|---|
| 477 | */ |
|---|
| 478 | eBpLoopModeParam loopMode; /* Sets whether bcmplayer will automatically loop |
|---|
| 479 | at the end of the file. If you choose eBpLoopForever, |
|---|
| 480 | be aware that the firmware must be able to detect |
|---|
| 481 | a discontinuity and not decode open gop |
|---|
| 482 | B's at the beginning of the stream, otherwise you |
|---|
| 483 | will macroblock. This is currently not done. */ |
|---|
| 484 | int disableExtraBOptimization; /* If false, adjacent B's will be combined into |
|---|
| 485 | the same DISPLAY_REWIND sequence when doing |
|---|
| 486 | Brcm 1x rewind. This results in a significant |
|---|
| 487 | bandwidth savings. You may want to see this |
|---|
| 488 | to true when doing host-based frame reverse. */ |
|---|
| 489 | } BNAV_Player_PlayMode; |
|---|
| 490 | |
|---|
| 491 | /** |
|---|
| 492 | * Summary: |
|---|
| 493 | * Change the play mode. |
|---|
| 494 | * |
|---|
| 495 | * Description: |
|---|
| 496 | * This causes bcmplayer's play state to be reset and fifo to be |
|---|
| 497 | * flushed. |
|---|
| 498 | **/ |
|---|
| 499 | int BNAV_Player_SetPlayMode( |
|---|
| 500 | BNAV_Player_Handle handle, |
|---|
| 501 | const BNAV_Player_PlayMode *playMode |
|---|
| 502 | ); |
|---|
| 503 | |
|---|
| 504 | /** |
|---|
| 505 | * Summary: |
|---|
| 506 | * Populates a BNAV_Player_PlayMode structure with the current play mode parameters. |
|---|
| 507 | **/ |
|---|
| 508 | void BNAV_Player_GetPlayMode( |
|---|
| 509 | const BNAV_Player_Handle handle, |
|---|
| 510 | BNAV_Player_PlayMode *playMode /* [out] */ |
|---|
| 511 | ); |
|---|
| 512 | |
|---|
| 513 | |
|---|
| 514 | |
|---|
| 515 | /****************************************** |
|---|
| 516 | * |
|---|
| 517 | * Position and Status |
|---|
| 518 | * |
|---|
| 519 | **/ |
|---|
| 520 | |
|---|
| 521 | /** |
|---|
| 522 | * Summary: |
|---|
| 523 | * Information about the current position of the player. |
|---|
| 524 | **/ |
|---|
| 525 | typedef struct { |
|---|
| 526 | long index; /* Index offset in the Broadcom index */ |
|---|
| 527 | unsigned long pts; /* PTS (Presentation Time Stamp) */ |
|---|
| 528 | unsigned long offsetHi; /* Hi 32 bits of the MPEG file offset */ |
|---|
| 529 | unsigned long offsetLo; /* Lo 32 bits of the MPEG file offset */ |
|---|
| 530 | unsigned long timestamp; /* Bcmindexer calculated timestamp */ |
|---|
| 531 | unsigned short vchipState; /* Current vchip state set by BNAV_Indexer_SetVChipState */ |
|---|
| 532 | } BNAV_Player_Position; |
|---|
| 533 | |
|---|
| 534 | /** |
|---|
| 535 | * Summary: |
|---|
| 536 | * Get information about the current position of the player. |
|---|
| 537 | * |
|---|
| 538 | * Description: |
|---|
| 539 | * Getting the position of bcmplayer reads the current index. If that index is not already |
|---|
| 540 | * in the index cache, it will involve one disk seek and read. There are no searches involved. |
|---|
| 541 | * |
|---|
| 542 | * Notice that the currentIndex is returned by both getStatus and getPosition. |
|---|
| 543 | * It is the only position paramter that doesn't require disk access. |
|---|
| 544 | * |
|---|
| 545 | * Return values: |
|---|
| 546 | * 0 = index was found and the BNAV_Player_Position structue has been successfully populated. |
|---|
| 547 | * -1 = index was not found and the BNAV_Player_Position structure is unchanged. |
|---|
| 548 | **/ |
|---|
| 549 | int BNAV_Player_GetPosition( |
|---|
| 550 | BNAV_Player_Handle handle, |
|---|
| 551 | BNAV_Player_Position *position /* [out] */ |
|---|
| 552 | ); |
|---|
| 553 | |
|---|
| 554 | /** |
|---|
| 555 | * Summary: |
|---|
| 556 | * Get information about a specified index entry without resetting the current location. |
|---|
| 557 | * |
|---|
| 558 | * Description: |
|---|
| 559 | * Reading any index entry will first check the cache. If it is not present in the cache, |
|---|
| 560 | * it will involve one disk seek and read. There are no searches involved. |
|---|
| 561 | * |
|---|
| 562 | * BNAV_Player_GetPosition works by calling this function with the current index. |
|---|
| 563 | * |
|---|
| 564 | * Return values: |
|---|
| 565 | * 0 = index was found and the BNAV_Player_Position structue has been successfully populated. |
|---|
| 566 | * -1 = index was not found and the BNAV_Player_Position structure is unchanged. |
|---|
| 567 | **/ |
|---|
| 568 | int BNAV_Player_GetPositionInformation( |
|---|
| 569 | BNAV_Player_Handle handle, |
|---|
| 570 | long index, /* Index to query */ |
|---|
| 571 | BNAV_Player_Position *position /* [out] */ |
|---|
| 572 | ); |
|---|
| 573 | |
|---|
| 574 | |
|---|
| 575 | /** |
|---|
| 576 | * Summary: |
|---|
| 577 | * Status returned by BNAV_Player_GetStatus. |
|---|
| 578 | **/ |
|---|
| 579 | typedef struct { |
|---|
| 580 | long currentIndex; /* Current index offset. */ |
|---|
| 581 | int fifoSize; /* How many frames are queued up in the internal Bcmplayer FIFO. |
|---|
| 582 | Each call to BNAV_Player_GetNextEntry will consume one entry |
|---|
| 583 | in the FIFO. When the FIFO is empty, the player will advance |
|---|
| 584 | and the FIFO is filled again. |
|---|
| 585 | You can clear this FIFO using BNAV_Player_FlushFifo(). */ |
|---|
| 586 | } BNAV_Player_Status; |
|---|
| 587 | |
|---|
| 588 | /** |
|---|
| 589 | * Summary: |
|---|
| 590 | * Populate a BNAV_Player_Status structure with current status. |
|---|
| 591 | * |
|---|
| 592 | * Description: |
|---|
| 593 | * Getting the status of Bcmplayer performs no disk access or searches, and so it |
|---|
| 594 | * is guaranteed to be fast. |
|---|
| 595 | * |
|---|
| 596 | * Notice that the currentIndex is returned by both getStatus and getPosition. |
|---|
| 597 | * It is the only position paramter that doesn't require disk access. |
|---|
| 598 | **/ |
|---|
| 599 | void BNAV_Player_GetStatus( |
|---|
| 600 | const BNAV_Player_Handle handle, |
|---|
| 601 | BNAV_Player_Status *status /* [out] */ |
|---|
| 602 | ); |
|---|
| 603 | |
|---|
| 604 | /** |
|---|
| 605 | * Summary: |
|---|
| 606 | * Reposition the current index. |
|---|
| 607 | * Description: |
|---|
| 608 | * This resets the play state variables in bcmplayer including |
|---|
| 609 | * flushing the fifo (bcmplayer_flush). It is automatically called by |
|---|
| 610 | * bcmplayer_setPlayMode. |
|---|
| 611 | * |
|---|
| 612 | * The current index must fall within the bounds. |
|---|
| 613 | * |
|---|
| 614 | * Because the new position is not validated, there is no return code. |
|---|
| 615 | * |
|---|
| 616 | * Return values: |
|---|
| 617 | * 0 = success, current index was changed |
|---|
| 618 | * -1 = index was invalid and current index is unchanged |
|---|
| 619 | **/ |
|---|
| 620 | int BNAV_Player_SetCurrentIndex( |
|---|
| 621 | BNAV_Player_Handle handle, |
|---|
| 622 | long index /* new current index */ |
|---|
| 623 | ); |
|---|
| 624 | |
|---|
| 625 | /** |
|---|
| 626 | * Summary: |
|---|
| 627 | * Flush all frames from the bcmplayer internal fifo. |
|---|
| 628 | * Description: |
|---|
| 629 | * Bcmplayer maintains an internal FIFO. The state of the FIFO is usually of no concern to the |
|---|
| 630 | * application, unless the application wants to flush the system (including decode and playback |
|---|
| 631 | * buffers) without changing the bcmplayer mode. Then you will need an explicit call to |
|---|
| 632 | * BNAV_Player_FlushFifo. |
|---|
| 633 | **/ |
|---|
| 634 | void BNAV_Player_FlushFifo( |
|---|
| 635 | BNAV_Player_Handle handle |
|---|
| 636 | ); |
|---|
| 637 | |
|---|
| 638 | |
|---|
| 639 | |
|---|
| 640 | /****************************************** |
|---|
| 641 | * |
|---|
| 642 | * Various search and information algorithms. None of these algorithms changes the current |
|---|
| 643 | * index of bcmplayer. |
|---|
| 644 | * |
|---|
| 645 | **/ |
|---|
| 646 | |
|---|
| 647 | /** |
|---|
| 648 | * Summary: |
|---|
| 649 | * Determine if the stream is a HITS (progressive I slice) stream. |
|---|
| 650 | * |
|---|
| 651 | * Description: |
|---|
| 652 | * Performs search from beginning of the index, looking for an I-frame. It is bounded |
|---|
| 653 | * the number of frames specified by searchRange |
|---|
| 654 | * |
|---|
| 655 | * Return values: |
|---|
| 656 | * 0 = successful search, no I-frame, therefore HITS. |
|---|
| 657 | * 1 = successful search, I-frame found, therefore not HITS. |
|---|
| 658 | * -1 = unsuccessful search |
|---|
| 659 | **/ |
|---|
| 660 | int BNAV_Player_IsHits( |
|---|
| 661 | BNAV_Player_Handle handle, |
|---|
| 662 | int searchRange /* Maximum number of frames to search. The correct value |
|---|
| 663 | depends on the GOP size. */ |
|---|
| 664 | ); |
|---|
| 665 | |
|---|
| 666 | /** |
|---|
| 667 | * Summary: |
|---|
| 668 | * Set ptscache search direction to backwards |
|---|
| 669 | * |
|---|
| 670 | * Description: |
|---|
| 671 | * In steady state, Ptscache is normally searched from oldest to newest entry ( forward search ) |
|---|
| 672 | * For transitions ( eg trickmode change ) it is more efficient to search from newest entry |
|---|
| 673 | * to oldest ( backwards search ). |
|---|
| 674 | * |
|---|
| 675 | **/ |
|---|
| 676 | void BNAV_Player_SetBackwardPtsCacheSearch( |
|---|
| 677 | BNAV_Player_Handle handle |
|---|
| 678 | ); |
|---|
| 679 | |
|---|
| 680 | /** |
|---|
| 681 | * Summary: |
|---|
| 682 | * Search for the index which most closely matches the pts. |
|---|
| 683 | * |
|---|
| 684 | * Description: |
|---|
| 685 | * It does not change the current index. |
|---|
| 686 | * |
|---|
| 687 | * This function was written with two usage modes in mind: |
|---|
| 688 | * o Using the decoder's current PTS, converted to an index, to position the PVR cursor in a GUI |
|---|
| 689 | * o Using the decoder's current PTS, converted to an index, to relocate the player for trick mode transitions. |
|---|
| 690 | * |
|---|
| 691 | * Both modes assume you are using the decoder's current PTS. Because of this, we maintain a cache of picture's PTS |
|---|
| 692 | * and index values that have recently been sent to the decoder. This is efficient and will work regardless of the |
|---|
| 693 | * trick mode speed used (even very fast speeds). Because of PTS discontinuities, an index-wide binary search |
|---|
| 694 | * for a PTS is impossible anyway; therefore this narrow definition of PTS search is acceptible. |
|---|
| 695 | * |
|---|
| 696 | * Initially this function only ever searched from newest to oldest when trying to find a match. This is the simplest |
|---|
| 697 | * and most reliable scheme, but the tradeoff is that the more compressed pictures that fit in a decoder's compressed |
|---|
| 698 | * picture buffer, the more entries we need to maintain in our cache, and the longer the search becomes. |
|---|
| 699 | * In order to mitigate this, the function now does a backward search on trick mode transitions / decoder cache flushes, |
|---|
| 700 | * and thereafter maintains a read ptr to the last found cache hit ( minus back off ), and searches forward from this |
|---|
| 701 | * point. |
|---|
| 702 | * |
|---|
| 703 | * This function also now interpolates the index value for streams which have all the pictures in a GOP encoded with |
|---|
| 704 | * the same PTS. |
|---|
| 705 | * |
|---|
| 706 | * If you get bad index values back, you should also see BDBG_ERR messages stating that the PTS diff exceeded a minimum |
|---|
| 707 | * threshold. In this case, you are either using this function in an unsupported way (i.e. searching for PTS |
|---|
| 708 | * values that have not been recently decoded), or you need to expand the internal cache size (see |
|---|
| 709 | * PTS_CACHE_SIZE in the implementation). |
|---|
| 710 | * |
|---|
| 711 | * If you want to do index-wide searches, you should use other values like index number, MPEG offset or |
|---|
| 712 | * timestamp. |
|---|
| 713 | * |
|---|
| 714 | * Return values: |
|---|
| 715 | * -1 = failure |
|---|
| 716 | * Otherwise returns the index number. |
|---|
| 717 | **/ |
|---|
| 718 | long BNAV_Player_FindIndexFromPts( |
|---|
| 719 | BNAV_Player_Handle handle, |
|---|
| 720 | unsigned long pts, /* the pts to search for */ |
|---|
| 721 | int searchWindow /* this parameter is no longer used */ |
|---|
| 722 | ); |
|---|
| 723 | |
|---|
| 724 | /** |
|---|
| 725 | * Summary: |
|---|
| 726 | * Search for the index which contains the specified byte offset. |
|---|
| 727 | * |
|---|
| 728 | * Description: |
|---|
| 729 | * It does not change the current index. |
|---|
| 730 | * The position is interpolated using the size of the file, followed |
|---|
| 731 | * by a very brief linear search. It should be very fast. |
|---|
| 732 | * |
|---|
| 733 | * Return values: |
|---|
| 734 | * -1 = failure |
|---|
| 735 | * Otherwise returns the index number. |
|---|
| 736 | **/ |
|---|
| 737 | long BNAV_Player_FindIndexFromOffset( |
|---|
| 738 | BNAV_Player_Handle handle, |
|---|
| 739 | unsigned long offsetHi, /* high 32 bits of the mpeg file offset. */ |
|---|
| 740 | unsigned long offsetLo /* low 32 bits of the mpeg file offset. */ |
|---|
| 741 | ); |
|---|
| 742 | |
|---|
| 743 | /** |
|---|
| 744 | * Summary: |
|---|
| 745 | * Search for the index which most closely matches the timestamp. |
|---|
| 746 | * |
|---|
| 747 | * Description: |
|---|
| 748 | * It does not change the current index. |
|---|
| 749 | * Because timestamp is guaranteed to be continuous, the position is interpolated, followed |
|---|
| 750 | * by a very brief linear search. It should be very fast. |
|---|
| 751 | * |
|---|
| 752 | * Return values: |
|---|
| 753 | * -1 = failure |
|---|
| 754 | * Otherwise returns the index number. |
|---|
| 755 | **/ |
|---|
| 756 | long BNAV_Player_FindIndexFromTimestamp( |
|---|
| 757 | BNAV_Player_Handle handle, |
|---|
| 758 | unsigned long timestamp |
|---|
| 759 | ); |
|---|
| 760 | |
|---|
| 761 | /** |
|---|
| 762 | * Summary: |
|---|
| 763 | * Searches for the first I frame from the specified starting index in the specified |
|---|
| 764 | * direction. |
|---|
| 765 | * |
|---|
| 766 | * Description: |
|---|
| 767 | * It does not change the current index. |
|---|
| 768 | * |
|---|
| 769 | * WARNING: For HITS streams, this will search to the beginning or end of the index |
|---|
| 770 | * and then fail. |
|---|
| 771 | * |
|---|
| 772 | * Return values: |
|---|
| 773 | * -1 = failure |
|---|
| 774 | * Otherwise returns the index number. |
|---|
| 775 | **/ |
|---|
| 776 | long BNAV_Player_FindIFrameFromIndex( |
|---|
| 777 | BNAV_Player_Handle handle, |
|---|
| 778 | long index, /* starting location */ |
|---|
| 779 | eBpDirectionParam dir /* search direction */ |
|---|
| 780 | ); |
|---|
| 781 | |
|---|
| 782 | /** |
|---|
| 783 | * Summary: |
|---|
| 784 | * Checks if frame at passed in index value is a B frame or not. |
|---|
| 785 | * |
|---|
| 786 | * Description: |
|---|
| 787 | * Checks if frame at passed in index value is a B frame or not. |
|---|
| 788 | * |
|---|
| 789 | * Return values: |
|---|
| 790 | * true if B frame |
|---|
| 791 | * false if other Frame. |
|---|
| 792 | **/ |
|---|
| 793 | bool BNAV_Player_IndexIsBFrame( |
|---|
| 794 | BNAV_Player_Handle handle, |
|---|
| 795 | long index /* index to check */ |
|---|
| 796 | ); |
|---|
| 797 | |
|---|
| 798 | /** |
|---|
| 799 | * Summary: |
|---|
| 800 | * Prints the hit/miss ratios for the two internal index caches to stdout. |
|---|
| 801 | * |
|---|
| 802 | * Description: |
|---|
| 803 | * This is used to test the cache performance of bcmplayer. The cache size may need |
|---|
| 804 | * to be adjusted depending on the normal types of trick modes, frames rates (e.g. 60 fps), |
|---|
| 805 | * and memory requirements of the system. |
|---|
| 806 | **/ |
|---|
| 807 | void BNAV_Player_PrintCachePerformance( |
|---|
| 808 | const BNAV_Player_Handle handle |
|---|
| 809 | ); |
|---|
| 810 | |
|---|
| 811 | /** |
|---|
| 812 | * Summary: |
|---|
| 813 | * Reads the BNAV_Entry specified by the index number. |
|---|
| 814 | * |
|---|
| 815 | * Description: |
|---|
| 816 | * This uses bcmplayer's seek/tell/read |
|---|
| 817 | * callbacks as well as the index cache. It does not change the state of the player, except |
|---|
| 818 | * for possibly the cache. |
|---|
| 819 | * |
|---|
| 820 | * Return values: |
|---|
| 821 | * -1 on failure |
|---|
| 822 | * 0 on success |
|---|
| 823 | **/ |
|---|
| 824 | int BNAV_Player_ReadIndex( |
|---|
| 825 | BNAV_Player_Handle handle, |
|---|
| 826 | int index, /* Index offset to read. */ |
|---|
| 827 | BNAV_Entry *entry /* [out] Memory location to read index into. */ |
|---|
| 828 | ); |
|---|
| 829 | |
|---|
| 830 | #ifdef __cplusplus |
|---|
| 831 | } |
|---|
| 832 | #endif |
|---|
| 833 | |
|---|
| 834 | #endif /* BCMPLAYER_H__ */ |
|---|