source: svn/trunk/newcon3bcm2_21bu/BSEAV/lib/bcmplayer/include/bcmindexer.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 15.5 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2002-2010, 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: bcmindexer.h $
11 * $brcm_Revision: 6 $
12 * $brcm_Date: 6/22/10 11:13a $
13 *
14 * Module Description: Broadcom Index Player
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/lib/bcmplayer/include/bcmindexer.h $
19 *
20 * 6   6/22/10 11:13a erickson
21 * SW7405-4465: add BNAV_Indexer_Settings.ptsBasedFrameRate for PTS-based
22 * offline indexing
23 *
24 * 5   6/2/10 12:51p erickson
25 * SW7400-2789: add BNAV_Indexer_Settings.allowLargeTimeGaps
26 *
27 * 4   1/7/09 9:51p erickson
28 * PR49501: added append settings
29 *
30 * 3   2/26/08 12:28p katrep
31 * PR38429: Added AVS record and playback support
32 *
33 * 2   12/27/07 3:27p erickson
34 * PR37035: changed simulatedFrameRate to unsigned
35 *
36 * Irvine_BSEAVSW_Devel/35   3/6/06 1:20p erickson
37 * PR19853: added VC1 PES support
38 *
39 * Irvine_BSEAVSW_Devel/34   1/6/06 10:17a erickson
40 * PR17108: fix for 64 bit architectures
41 *
42 * Irvine_BSEAVSW_Devel/33   7/13/05 2:11p erickson
43 * PR16138: added AVC NAV version
44 *
45 * Irvine_BSEAVSW_Devel/32   3/18/05 9:37a erickson
46 * PR14451: moved BSCT_Entry to common file, added AVC support and 6 word
47 * SCT support
48 *
49 * Irvine_BSEAVSW_Devel/31   12/14/04 4:54p marcusk
50 * PR13560: Updated to default to frameratesimulation to 0.  Command line
51 * indexer updated to accept frame rate setting.
52 *
53 * Irvine_BSEAVSW_Devel/30   4/13/04 4:54p erickson
54 * PR10292: added BNAV_Indexer_FeedReverse
55 *
56 * Irvine_BSEAVSW_Devel/29   12/2/03 12:05a erickson
57 * PR8807: updated docs
58 *
59 * Irvine_BSEAVSW_Devel/28   11/10/03 2:29p erickson
60 * PR8563: added transport timestamp support to bcmplayer
61 *
62 * Irvine_BSEAVSW_Devel/27   6/24/03 11:03a erickson
63 * PR7218 - handled partially encrypted streams. Added maxFrameSize and
64 * mpegSizeCallback. Had to change the
65 * NAV table format (version 2) in order to handle I frames with reference
66 * offset of 0. Bcmplayer
67 * is backward compatible.
68 *
69 * Irvine_BSEAVSW_Devel/26   6/19/03 9:04a erickson
70 * added BNAV_Indexer_GetPosition (PR7211)
71 *
72 * Irvine_BSEAVSW_Devel/25   3/31/03 2:42p erickson
73 * updated documentation (further updates will come when DocJet is more
74 * available)
75 *
76 * Irvine_BSEAVSW_Devel/24   2/14/03 1:57p erickson
77 * New naming convention
78 * Fixed looping from previous rework
79 * Removed bcmindexer _getParam/_setParam
80 * Did not change code shared between tsplayer and bcmplayer
81 * Refactored settings, playmode and other structures
82 *
83 * Irvine_HDDemo_Devel/23   9/26/02 3:4p erickson
84 * Changed bcmindexer vchip from 3 bits to 16 bits packed into 12 bits.
85 * The index is NOT backward compatible, but the 3 bit version had only
86 * been released for 1 day.
87 *
88 * Irvine_HDDemo_Devel/22   9/10/02 2:2p erickson
89 * changed vchip from 16 to 3 bits
90 *
91 * Irvine_HDDemo_Devel/21   9/10/02 9:5a erickson
92 * updated comments
93 *
94 * Irvine_HDDemo_Devel/20   9/9/02 11:51a erickson
95 * added vchip support
96 *
97 * Irvine_HDDemo_Devel/19   8/12/02 10:21a erickson
98 * a couple small changes requested by customer
99 *
100 * Irvine_HDDemo_Devel\18   4/17/02 4:20p erickson
101 * Removed simulateFramerate from allocate()
102 * Added setParam and simulateFramerate enum
103 *
104 * Irvine_HDDemo_Devel\17   4/17/02 3:27p erickson
105 * Removed simulatedFramerate from allocate
106 *
107 * Irvine_HDDemo_Devel\16   4/17/02 1:14p erickson
108 * Made sBcmIndexEntry public
109 * Added simulatedFramerate because of timestamping
110 *
111 * Irvine_HDDemo_Devel\15   4/16/02 12:51p erickson
112 * Changed initial comments.
113 * Added reset function
114 * Added version to allocate/reset
115 *
116 *
117 ***************************************************************************/
118#ifndef BCMINDEXER_H__
119#define BCMINDEXER_H__
120
121#include "bcmplayer_version.h"
122#include "bcmsct_index.h"
123
124#ifdef __cplusplus
125extern "C" {
126#endif
127
128/**
129* Summary:
130* Structure of a Broadcom index entry.
131*
132* Description:
133* It is used internally but is made public to support BNAV_Player_ReadIndex().
134**/
135typedef struct
136{
137    uint32_t words[8];    /* Index entry data */
138} BNAV_Entry;
139
140/**
141* Summary:
142* An extension of BNAV_Entry to support AVC indexing.
143*
144* Description:
145* The first 8 words are identical to BNAV_Entry.
146**/
147typedef struct
148{
149    uint32_t words[16];    /* Index entry data */
150} BNAV_AVC_Entry;
151
152/**
153* Summary:
154* The size of one BNAV_Entry.
155**/
156#define BNAV_ENTRY_SIZE     sizeof(BNAV_Entry)  /* in bytes, but should be an even word */
157
158/**
159* Summary:
160* Opaque handle used to identify one instance of Bcmindexer.
161**/
162typedef struct BNAV_Indexer_HandleImpl *BNAV_Indexer_Handle;
163
164/**
165* Summary:
166* Callback function which is used by BNAV_Indexer_Settings.
167**/
168typedef unsigned long (*BNAV_WRITE_CB)( const void *p_bfr, unsigned long numEntries, unsigned long entrySize, void *fp );
169
170/**
171* Summary:
172* Optionally used callback for determining the current MPEG file size in order
173* to resolve wrapping issues.
174*
175* Description:
176* See BNAV_Indexer_Settings.mpegSizeCallback for details on how and why this is used.
177* Should returns 0 on success.
178**/
179typedef int (*BNAV_MPEG_SIZE_CB) (
180    BNAV_Indexer_Handle handle,
181    unsigned long *sizeHi,  /* [out] Hi 32 bits of the current MPEG file size */
182    unsigned long *sizeLo   /* [out] Lo 32 bits of the current MPEG file size */
183    );
184
185/**
186Summary:
187The type of video being processed.
188
189Description:
190These enum values should match bvideo_codec in the Settop API for consistency.
191**/
192typedef enum BNAV_Indexer_VideoFormat {
193    BNAV_Indexer_VideoFormat_MPEG2 = 2,
194    BNAV_Indexer_VideoFormat_AVC = 0x1b,
195    BNAV_Indexer_VideoFormat_VC1 = 0xea,
196    BNAV_Indexer_VideoFormat_AVS =  0x42
197
198} BNAV_Indexer_VideoFormat;
199
200/**
201* Summary:
202* Settings structure which is passed to BNAV_Indexer_Open.
203**/
204typedef struct {
205    BNAV_WRITE_CB writeCallback;/* Write callback used to output the new index.
206                                    You can use fwrite. */
207    void *filePointer;          /* File pointer passed to the write callback.
208                                    If you use fwrite, this should be FILE*. */
209    BSCT_Version sctVersion;    /* Sets the version of the incoming SCT entries. These cannot
210                                    be autodetected. */
211    BNAV_Version navVersion;        /* Set compatibility version. bcmplayer will auto-detect
212                                    the eBcmNavTableVersion when allocated or reset. */
213    BNAV_Indexer_VideoFormat videoFormat; /* Defaults to MPEG2 */
214
215    bool ptsBasedFrameRate;         /* If you're using bcmindexer off-line (not during live
216                                    recording), this will set the timestamp based on the PTS
217                                    in the stream. */
218    unsigned simulatedFrameRate;    /* If you're using bcmindexer off-line (not during live
219                                    recording), the timestamp needs to set according
220                                    to a simulated frame rate. A non-zero simulatedFrameRate enables
221                                    this simulation and the value of simulatedFrameRate is used as the rate,
222                                    in units of frames per second. Default is 0 (disabled). */
223    unsigned long maxFrameSize; /* Any frame larger than this will be assumed to be bad and
224                                    discarded. Value is specified in units of bytes.
225                                    Default is 5 MB. This addresses the problem of
226                                    partially encrypted streams. When a stream becomes
227                                    encrypted midway through the record, SCT entries
228                                    stop being generated and a huge frame results when the
229                                    next SCT entry is fed. When this happens, the huge
230                                    frame, all frames up to the next I frame, and
231                                    any open GOP B's after the next I frame must be
232                                    discarded. */
233    BNAV_MPEG_SIZE_CB mpegSizeCallback;
234                                /* Optional callback retrieves the size of the MPEG file.
235                                    MPEG data is usually recorded in a different thread
236                                    than index data, therefore the size is not available.
237                                    This makes it available.
238                                    The size of MPEG data is needed to determine how many
239                                    times the 32 bit SCT frame offset has wrapped when
240                                    the MPEG becomes unencrypted after a section of
241                                    encryption. During the encrypted section, the 32 bit SCT frame
242                                    offset may have wrapped any number of times.
243                                    Otherwise there is no way for bcmindexer to know.
244                                    Defaults to NULL (no callback). This callback is ignored
245                                    for 40 bit SCT frame offset systems because it is assumed
246                                    that they will never wrap. */
247    int transportTimestampEnabled; /* If true, then transport has prepended a 4 byte
248                                    timestamp to every transport packet and this must be
249                                    taken into account. */
250
251    /* If these are set, the index is being appended on to another index.
252    The offset will be added to every index entry. timestamps will resume from the last timestamp.
253    The start of the appended index will be the next random access point. */
254    struct {
255        unsigned long offsetHi;         /* Hi 32 bits of the MPEG file offset */
256        unsigned long offsetLo;         /* Lo 32 bits of the MPEG file offset */
257        unsigned long timestamp;        /* Bcmindexer calculated timestamp */
258    } append;
259
260    bool allowLargeTimeGaps;       /* By default, any large gap in the recording (e.g. from a disconnected frontend) will cause
261                                      the NAV index timestamp to be paused. This means that the gap will not appear in the timestamps on playback.
262                                      Set allowLargeTimeGaps to true if you want to disable this feature. Any gap in the recording will
263                                      appear in the index timestamps. */
264} BNAV_Indexer_Settings;
265
266/**
267* Summary:
268* Must initialize the BNAV_Indexer_Settings before using it and
269* passing it to BNAV_Indexer_Open.
270**/
271void BNAV_Indexer_GetDefaultSettings(
272    BNAV_Indexer_Settings *settings     /* [out] */
273    );
274
275/**
276* Summary:
277* Open an instance of Bcmindexer as identified by the handle.
278*
279* Return values:
280* 0 on success
281* -1 if the sctVersion or navVersion is not supported.
282**/
283int BNAV_Indexer_Open(
284    BNAV_Indexer_Handle *handle,        /* [out] */
285    const BNAV_Indexer_Settings *settings
286    );
287
288/**
289* Summary:
290* Reset Bcmindexer instance to its initial state.
291*
292* Return values:
293* 0 on success
294* -1 if the sctVersion or navVersion is not supported.
295**/
296int BNAV_Indexer_Reset(
297    BNAV_Indexer_Handle handle,
298    const BNAV_Indexer_Settings *settings
299    );
300
301/**
302* Summary:
303* Free a Bcmindexer instance.
304* Description:
305* The handle becomes invalid and any further use leads to undefined behavior.
306**/
307void BNAV_Indexer_Close(
308    BNAV_Indexer_Handle handle
309    );
310
311/**
312* Summary:
313* Feed start code table (SCT) data into Bcmindexer.
314*
315* Description:
316* You must send even blocks of size BSCT_Entry or BSCT_SixWord_Entry. All write callbacks
317* will happen while BNAV_Indexer_Feed() is executing. This means that there is no
318* buffer which gets flushed to the write callback when you call BNAV_Indexer_Close().
319*
320* Return values:
321* -1 on error
322* Number of entries processed
323**/
324long BNAV_Indexer_Feed(
325    BNAV_Indexer_Handle handle,
326    void *p_bfr,                /* Pointer to start code index data. This could be
327                                    either BSCT_Entry's or BSCT_SixWord_Entry's,
328                                    depending on the BSCT_Version. */
329    long numEntries             /* Number of SCT entries (either 4 or 6 word) pointed
330                                    to by p_bfr. */
331    );
332
333/**
334* Summary:
335* Feed PES data into Bcmindexer.
336*
337* Description:
338* No intermediate SCT entries are produced.
339* This is only supported for VC1 currently.
340*
341* Return values:
342* -1 on error
343* 0 on success
344**/
345int BNAV_Indexer_FeedPES(
346    BNAV_Indexer_Handle handle,
347    uint8_t *p_bfr,             /* Pointer to PES data. */
348    unsigned size                   /* Number of bytes pointed to by p_bfr. */
349    );
350
351/**
352* Summary:
353* Feed start code table (SCT) data in reverse order into Bcmindexer.
354*
355* Description:
356* Works like BNAV_Indexer_Feed, except that you feed SCT data in reverse order.
357* If p_bfr points to more than one SCT, those SCT's should be in forward order
358* and bcmindexer will traverse them in reverse. Subsequent calls to BNAV_Indexer_FeedReverse
359* should send data in reverse order.
360*
361* Return values:
362* -1 on error
363* Number of entries processed
364**/
365long BNAV_Indexer_FeedReverse(
366    BNAV_Indexer_Handle handle,
367    const BSCT_Entry *p_bfr,                /* Pointer to start code index data */
368    long numEntries                 /* Number of BSCT_Entry's pointed to by p_bfr. */
369    );
370
371/**
372* Summary:
373* Read whether Bcmindexer believes the MPEG it's indexing is HITS
374* or not.
375*
376* Description:
377* HITS means Head-end-in-the-sky and uses progressive refresh instead of
378* I frames.
379*
380* You must feed a "good amount" of index through before you can tell, otherwise it
381* defaults to true. Right now, the algorthim looks for one I frame. When it finds
382* just one, it switches it to be not HITS. Therefore you need to feed in at least
383* one whole GOP to get an I frame.
384*
385* Return values:
386* 0 = not HITS
387* 1 = it is HITS
388**/
389int BNAV_Indexer_IsHits(
390    BNAV_Indexer_Handle handle
391    );
392
393/**
394* Summary:
395* Set the current VChip state.
396*
397* Description:
398* Every entry written to disk after this call will contain this vchip state.
399*
400* Return values:
401* 0 = success
402* -1 = failure, invalid vchip state
403**/
404int BNAV_Indexer_SetVChipState(
405    BNAV_Indexer_Handle handle,
406    unsigned short vchipState
407    );
408
409/**
410* Summary:
411* Get the current VChip state.
412*
413* Return values:
414* vchip state
415**/
416unsigned short BNAV_Indexer_GetVChipState(
417    BNAV_Indexer_Handle handle
418    );
419
420/**
421* Summary:
422* Current position data returned by BNAV_Indexer_GetPosition.
423* Description:
424* Even though BNAV_Indexer_Position is identical with BNAV_Player_Position,
425* they are separate structures because they belong to different API's and
426* could diverge in the future.
427**/
428typedef struct {
429    long index;                     /* Index offset in the Broadcom index */
430    unsigned long pts;              /* PTS (Presentation Time Stamp) */
431    unsigned long offsetHi;         /* Hi 32 bits of the MPEG file offset */
432    unsigned long offsetLo;         /* Lo 32 bits of the MPEG file offset */
433    unsigned long timestamp;        /* Bcmindexer calculated timestamp */
434    unsigned short vchipState;      /* Current vchip state set by BNAV_Indexer_SetVChipState */
435} BNAV_Indexer_Position;
436
437/**
438* Summary:
439* Get current position information for Bcmindexer.
440*
441* Return values:
442* 0 if successful
443* -1 if unsuccessful (because no entries have been written yet)
444**/
445int BNAV_Indexer_GetPosition(
446    BNAV_Indexer_Handle handle,
447    BNAV_Indexer_Position *position     /* [out] */
448    );
449
450#ifdef __cplusplus
451}
452#endif
453
454#endif /* BCMINDEXER_H__ */
455
Note: See TracBrowser for help on using the repository browser.