| 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_dccparse_dss.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/2 $ |
|---|
| 12 | * $brcm_Date: 10/28/10 3:59p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/commonutils/udp/budp_dccparse_dss.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/2 10/28/10 3:59p darnstein |
|---|
| 21 | * SW3548-2364: trivial implementation of _isr functions for parsing. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/1 10/21/10 4:10p darnstein |
|---|
| 24 | * SW7401-2571: DSS parser, converted from BVBIlib to BUDP. |
|---|
| 25 | * |
|---|
| 26 | ***************************************************************************/ |
|---|
| 27 | |
|---|
| 28 | /*= Module Overview ********************************************************* |
|---|
| 29 | |
|---|
| 30 | * Handle DirecTV close caption data |
|---|
| 31 | ***************************************************************************/ |
|---|
| 32 | #ifndef BUDPDCCPARSEDSS_H__ |
|---|
| 33 | #define BUDPDCCPARSEDSS_H__ |
|---|
| 34 | |
|---|
| 35 | #include "bstd.h" |
|---|
| 36 | #include "bavc.h" |
|---|
| 37 | #include "berr.h" |
|---|
| 38 | #include "bavc.h" |
|---|
| 39 | #include "budp.h" |
|---|
| 40 | |
|---|
| 41 | typedef enum { |
|---|
| 42 | BUDP_DCCparse_CC_Dss_Type_Undefined, |
|---|
| 43 | BUDP_DCCparse_CC_Dss_Type_ClosedCaption, |
|---|
| 44 | BUDP_DCCparse_CC_Dss_Type_Subtitle |
|---|
| 45 | } BUDP_DCCparse_Dss_CC_Type; |
|---|
| 46 | |
|---|
| 47 | typedef struct { |
|---|
| 48 | bool bIsAnalog; |
|---|
| 49 | BAVC_Polarity polarity; |
|---|
| 50 | BUDP_DCCparse_Dss_CC_Type eCCType; |
|---|
| 51 | uint8_t cc_priority; |
|---|
| 52 | uint8_t language_type; /* not exist in dss-sd CC, sub_title_language_type in GLA subtitle */ |
|---|
| 53 | uint8_t cc_data_1; |
|---|
| 54 | uint8_t cc_data_2; |
|---|
| 55 | } BUDP_DCCparse_dss_cc_subtitle; |
|---|
| 56 | |
|---|
| 57 | /***************************************************************************** |
|---|
| 58 | Summary: |
|---|
| 59 | Parses digital closed caption data from a buffer of DSS userdata. |
|---|
| 60 | |
|---|
| 61 | Description: |
|---|
| 62 | This function accepts a "packet" of DSS userdata and searches |
|---|
| 63 | it for digital closed caption data. |
|---|
| 64 | |
|---|
| 65 | In order to avoid having an output array of indefinite |
|---|
| 66 | length, this function will only parse at most one "packet" |
|---|
| 67 | of userdata from its input. A "packet" is defined as the |
|---|
| 68 | userdata that lies between two successive userdata start |
|---|
| 69 | codes (0x000001B2). Therefore, several calls to this |
|---|
| 70 | function may be necessary to parse out all the userdata. |
|---|
| 71 | Parsing will be complete when the function returns a |
|---|
| 72 | *pBytesParsed argument such that (offset + *pBytesParsed == |
|---|
| 73 | pUserdata_info->ui32UserDataBufSize). |
|---|
| 74 | |
|---|
| 75 | Consider that the closed caption data can only be |
|---|
| 76 | encoded analog if the associated bIsAnalog field is set. |
|---|
| 77 | This consideration, together with the need to call the |
|---|
| 78 | function multiple times (previous paragraph) implies that |
|---|
| 79 | the typical usage of this function is as follows: |
|---|
| 80 | |
|---|
| 81 | size_t offset = 0; |
|---|
| 82 | while (offset < info->ui32UserDataBufSize) |
|---|
| 83 | { |
|---|
| 84 | eStatus = |
|---|
| 85 | BUDP_DCCparse_DSS_isr ( |
|---|
| 86 | info, offset, &bytesParsed, &cc_count, ccdata); |
|---|
| 87 | if (eStatus == BERR_SUCCESS) |
|---|
| 88 | { |
|---|
| 89 | int icount; |
|---|
| 90 | for (icount = 0 ; icount < cc_count ; ++icount) |
|---|
| 91 | { |
|---|
| 92 | BUDP_DCCparse_ccdata* pccdata = &ccdata[icount]; |
|---|
| 93 | if (pccdata->bIsAnalog == true) |
|---|
| 94 | { |
|---|
| 95 | // Send pccdata->cc_data_1 and pccdata->cc_data_2 |
|---|
| 96 | // to analog closed caption encoder, if any. These |
|---|
| 97 | // bytes must be sent on video field with polarity |
|---|
| 98 | // pcc->polarity. |
|---|
| 99 | } |
|---|
| 100 | // Possibly, send pccdata->cc_data_1 and pccdata->cc_data_2 |
|---|
| 101 | // to digital closed caption encoder. The customer must |
|---|
| 102 | // know if EIA-708-B processing is appropriate. |
|---|
| 103 | } |
|---|
| 104 | } |
|---|
| 105 | else if (eStatus == BERR_BUDP_NO_DATA) |
|---|
| 106 | { |
|---|
| 107 | // Just keep looping, there may be more data to process. |
|---|
| 108 | } |
|---|
| 109 | else |
|---|
| 110 | { |
|---|
| 111 | // A real error, get out quick. |
|---|
| 112 | return eStatus; |
|---|
| 113 | } |
|---|
| 114 | offset += bytesParsed; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | Returns: |
|---|
| 118 | BERR_SUCCESS - The handle was successfully created. |
|---|
| 119 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 120 | possibly NULL. |
|---|
| 121 | BERR_BUDP_NO_DATA - No closed caption data was found. As the above |
|---|
| 122 | programming example shows, this is not really |
|---|
| 123 | an error. |
|---|
| 124 | BERR_BUDP_PARSE_ERROR - Closed caption data was detected, but could not |
|---|
| 125 | be successfully parsed. |
|---|
| 126 | |
|---|
| 127 | See Also: |
|---|
| 128 | *****************************************************************************/ |
|---|
| 129 | BERR_Code BUDP_DCCparse_DSS_isr ( |
|---|
| 130 | const BAVC_USERDATA_info* |
|---|
| 131 | pUserdata_info, /* [in] The MPEG userdata to be parsed. */ |
|---|
| 132 | size_t offset, /* [in] Parsing will start at this offset in the |
|---|
| 133 | input buffer |
|---|
| 134 | userdata_info->pUserDataBuffer. */ |
|---|
| 135 | size_t* pBytesParsed, /* [out] The number of bytes parsed from the |
|---|
| 136 | input buffer |
|---|
| 137 | userdata_info->pUserDataBuffer. */ |
|---|
| 138 | uint8_t* pcc_count, /* [out] The length of the following output |
|---|
| 139 | array. Will be between 0 and 31. */ |
|---|
| 140 | BUDP_DCCparse_dss_cc_subtitle* |
|---|
| 141 | pCCdata, /* [out] An array holding extracted closed |
|---|
| 142 | caption data. The user must provide an |
|---|
| 143 | array of length 32, to accomodate the |
|---|
| 144 | maximum data that the standards will |
|---|
| 145 | allow. */ |
|---|
| 146 | uint8_t* psubtitle_count, /*count for subtitle data */ |
|---|
| 147 | BUDP_DCCparse_dss_cc_subtitle* pSubtitledata /*array holding extracted subtitle data */ |
|---|
| 148 | ); |
|---|
| 149 | #define BUDP_DCCparse_DSS BUDP_DCCparse_DSS_isr |
|---|
| 150 | |
|---|
| 151 | #endif /* BUDPDCCPARSEDSS_H__ */ |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | |
|---|