source: svn/trunk/newcon3bcm2_21bu/magnum/commonutils/udp/budp_scteparse.h @ 2

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

first commit

  • Property svn:executable set to *
File size: 9.6 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-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: budp_scteparse.h $
11 * $brcm_Revision: Hydra_Software_Devel/3 $
12 * $brcm_Date: 10/28/10 4:00p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/commonutils/udp/budp_scteparse.h $
19 *
20 * Hydra_Software_Devel/3   10/28/10 4:00p darnstein
21 * SW3548-2364: trivial implementation of _isr functions for parsing.
22 *
23 * Hydra_Software_Devel/2   7/27/10 7:14p darnstein
24 * SW3548-3022: Some data structures involving SCTE-20 and SCTE-21 are
25 * moved from BVBI portiing interface to BUDP commonutils module.
26 *
27 * Hydra_Software_Devel/1   7/27/10 5:08p darnstein
28 * SW3548-3022: userdata parsing software.
29 *
30 ***************************************************************************/
31
32/*= Module Overview *********************************************************
33<verbatim>
34
35
36Overview
37BUDPSCTEparse module provides parsing of SCTE digital data.
38This data occurs as userdata in MPEG bitstreams.  There are two
39standards supported:  SCTE20 and SCTE21.
40
41In general, this software accepts a buffer of data that contains
42the MPEG userdata.  It parses out the SCTE data, and returns it as
43an array of complex data structures.  Each data structure contains
44SCTE data for output to a single video field. The data structures
45can be sent directly to the VBI encoding software in the porting
46interface (BUDP module).
47
48</verbatim>
49***************************************************************************/
50
51#ifndef BUDPSCTEPARSE_H__
52#define BUDPSCTEPARSE_H__
53
54#include "bstd.h"
55#include "bavc.h"
56#include "berr.h"
57#include "bavc.h"
58#include "budp.h"
59
60#ifdef __cplusplus
61extern "C" {
62#endif
63
64
65/*****************************************************************************
66 * Structures
67 *****************************************************************************/
68
69/***************************************************************************
70Summary:
71        This enum specifies the format used to encode SCTE data into MPEG
72        userdata.
73***************************************************************************/
74typedef enum {
75        BUDP_SCTEparse_Format_Unknown = 0,
76        BUDP_SCTEparse_Format_SCTE20,
77        BUDP_SCTEparse_Format_SCTE21CC,
78        BUDP_SCTEparse_Format_SCTE21ACC,
79        BUDP_SCTEparse_Format_SCTE21PAM
80}
81BUDP_SCTEparse_Format;
82
83/***************************************************************************
84Summary:
85        This structure describes a "piece" of SCTE data extracted
86        from MPEG userdata.
87
88Description:
89        BUDP_SCTEparse_sctedata is a "holder" for the SCTE
90        data structure used by the porting interface module
91        BVBI. The BUDP data structure adds a few needed extra
92        bits of information.
93
94        The format field indicates the method of encoding the SCTE
95        datum into MPEG userdata. 
96
97        The polarity field indicates whether the data belongs in
98        a video top field or a bottom field.
99
100***************************************************************************/
101typedef struct {
102        BAVC_Polarity polarity;
103        BUDP_SCTEparse_Format format;
104        BUDP_SCTE_Data data;
105} BUDP_SCTEparse_sctedata;
106
107/*****************************************************************************
108 * Public API
109 *****************************************************************************/
110
111/*****************************************************************************
112  Summary:
113    Parses SCTE 20 data from a buffer of MPEG userdata.
114
115  Description:
116    This function accepts a "packet" of MPEG userdata and searches it for
117        SCTE 20 data. 
118
119        In order to avoid having an output array of indefinite length, this
120        function will only parse at most one "packet" of MPEG userdata from its
121        input.  A "packet" is defined as the userdata that lies between two
122        successive userdata start codes (0x000001B2).  Therefore, several calls to
123        this function may be necessary to parse out all the userdata.  Parsing will
124        be complete when the function returns a *pBytesParsed argument such that
125        (offset + *pBytesParsed == pUserdata_info->ui32UserDataBufSize).
126
127        The typical usage of this function is as follows:
128
129    size_t offset = 0;
130    while (offset < info->ui32UserDataBufSize)
131    {
132        eStatus =
133            BUDP_SCTE20parse_isr (
134                                info, offset, &bytesParsed, &scte_count, sctedata);
135        if (eStatus == BERR_SUCCESS)
136        {
137            int icount;
138            for (icount = 0 ; icount < scte_count ; ++icount)
139            {
140                BUDP_SCTEparse_sctedata* psctedata = &sctedata[icount];
141
142                                // Send psctedata->data to SCTE encoder. This
143                                // data  must be sent on video field with polarity
144                                // pscte->polarity.
145            }
146        }
147                else if (eStatus == BERR_BUDP_NO_DATA)
148                {
149                        // Just keep looping, there may be more data to process.
150                }
151                else
152                {
153            // A real error, get out quick.
154            return eStatus;
155                }
156                offset += bytesParsed;
157        }
158
159  Returns:
160        BERR_SUCCESS              - The handle was successfully created.
161        BERR_INVALID_PARAMETER    - One of the supplied parameters was invalid,
162                                                            possibly NULL.
163        BERR_BUDP_NO_DATA      - No SCTE data was found.  As the above
164                                                                programming example shows, this is not really
165                                                                an error.
166        BERR_BUDP_PARSE_ERROR  - SCTE data was detected, but could not
167                                    be successfully parsed.
168
169 *****************************************************************************/
170BERR_Code BUDP_SCTE20parse_isr ( 
171        const BAVC_USERDATA_info* 
172               pUserdata_info, /*  [in] The MPEG userdata to be parsed.          */
173        size_t         offset, /*  [in] Parsing will start at this offset in the
174                                        input buffer
175                                                                    userdata_info->pUserDataBuffer.          */
176        size_t*  pBytesParsed, /* [out] The number of bytes parsed from the
177                                        input buffer
178                                                                        userdata_info->pUserDataBuffer.          */
179        uint8_t*  pscte_count, /* [out] The length of the following output
180                                        array.  Will be between 0 and 31.        */
181        BUDP_SCTEparse_sctedata* 
182                    psctedata  /* [out] An array holding extracted SCTE data.
183                                                    The user must provide an array of length
184                                                                        32, to accomodate the maximum data that
185                                                                        the standards will allow.                */
186);
187#define BUDP_SCTE20parse BUDP_SCTE20parse_isr
188
189/*****************************************************************************
190  Summary:
191    Parses SCTE 21 data from a buffer of MPEG userdata.
192
193  Description:
194    This function accepts a "packet" of MPEG userdata and searches it for
195        SCTE 21 data. 
196
197        In order to avoid having an output array of indefinite length, this
198        function will only parse at most one "packet" of MPEG userdata from its
199        input.  A "packet" is defined as the userdata that lies between two
200        successive userdata start codes (0x000001B2).  Therefore, several calls to
201        this function may be necessary to parse out all the userdata.  Parsing will
202        be complete when the function returns a *pBytesParsed argument such that
203        (offset + *pBytesParsed == pUserdata_info->ui32UserDataBufSize).
204
205        The typical usage of this function is as follows:
206
207    size_t offset = 0;
208    while (offset < info->ui32UserDataBufSize)
209    {
210        eStatus =
211            BUDP_SCTE21parse_isr (
212                                info, offset, &bytesParsed, &scte_count, sctedata);
213        if (eStatus == BERR_SUCCESS)
214        {
215            int icount;
216            for (icount = 0 ; icount < scte_count ; ++icount)
217            {
218                BUDP_SCTEparse_sctedata* psctedata = &sctedata[icount];
219
220                                // Send psctedata->data to SCTE encoder. This
221                                // data  must be sent on video field with polarity
222                                // pscte->polarity.
223            }
224        }
225                else if (eStatus == BERR_BUDP_NO_DATA)
226                {
227                        // Just keep looping, there may be more data to process.
228                }
229                else
230                {
231            // A real error, get out quick.
232            return eStatus;
233                }
234                offset += bytesParsed;
235        }
236
237  Returns:
238        BERR_SUCCESS              - The handle was successfully created.
239        BERR_INVALID_PARAMETER    - One of the supplied parameters was invalid,
240                                                            possibly NULL.
241        BERR_BUDP_NO_DATA      - No SCTE data was found.  As the above
242                                                                programming example shows, this is not really
243                                                                an error.
244        BERR_BUDP_PARSE_ERROR  - SCTE data was detected, but could not
245                                    be successfully parsed.
246
247 *****************************************************************************/
248BERR_Code BUDP_SCTE21parse_isr ( 
249        const BAVC_USERDATA_info* 
250               pUserdata_info, /*  [in] The MPEG userdata to be parsed.          */
251        size_t         offset, /*  [in] Parsing will start at this offset in the
252                                        input buffer
253                                                                    userdata_info->pUserDataBuffer.          */
254        size_t*  pBytesParsed, /* [out] The number of bytes parsed from the
255                                        input buffer
256                                                                        userdata_info->pUserDataBuffer.          */
257        uint8_t*  pscte_count, /* [out] The length of the following output
258                                        array.  Will be between 0 and 31.        */
259        BUDP_SCTEparse_sctedata* 
260                    psctedata  /* [out] An array holding extracted SCTE data.
261                                                    The user must provide an array of length
262                                                                        32, to accomodate the maximum data that
263                                                                        the standards will allow.                */
264);
265#define BUDP_SCTE21parse BUDP_SCTE21parse_isr
266
267#ifdef __cplusplus
268}
269#endif
270
271#endif /* BUDPSCTEPARSE_H__ */
Note: See TracBrowser for help on using the repository browser.