source: svn/newcon3bcm2_21bu/nexus/lib/dtcp_ip/include/b_dtcp_applib.h

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 14.1 KB
Line 
1/******************************************************************************
2 *    (c)2009-2011 Broadcom Corporation
3 *
4 * This program is the proprietary software of Broadcom Corporation and/or its licensors,
5 * and may only be used, duplicated, modified or distributed pursuant to the terms and
6 * conditions of a separate, written license agreement executed between you and Broadcom
7 * (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8 * no license (express or implied), right to use, or waiver of any kind with respect to the
9 * Software, and Broadcom expressly reserves all rights in and to the Software and all
10 * intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11 * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12 * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. 
13 * 
14 * Except as expressly set forth in the Authorized License,
15 * 
16 * 1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 * and to use this information only in connection with your use of Broadcom integrated circuit products.
19 * 
20 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 * THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 * USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 * ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: b_dtcp_applib.h $
39 * $brcm_Revision: 9 $
40 * $brcm_Date: 5/5/11 3:03p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/lib/dtcp_ip/include/b_dtcp_applib.h $
47 *
48 * 9   5/5/11 3:03p leisun
49 * SWSECURITY-49: Update Nonce value change period, other device modes
50 *  support
51 *
52 * 8   2/11/11 5:37p leisun
53 * SWSECURITY-32: Updated lib to V1SE1.3 conformance.
54 *
55 * 7   3/1/10 1:39p leisun
56 * SW7420-561: Update from plugfest bugs
57 *
58 * 6   10/6/09 1:41p leisun
59 * SW7405-3138: Fixes for live HTTP streaming
60 *
61 * 5   7/16/09 7:03p lwhite
62 * PR55693: Fixed signedness
63 *
64 * 4   7/13/09 11:23a leisun
65 * PR 55693: Re-design interfaces, and other cleanups
66 *
67 * 3   7/1/09 4:31p leisun
68 * PR 55693: added GetNewExchKey function, fixed linked list deletion
69 *  problem, etc
70 *
71 * 2   6/30/09 10:37p leisun
72 * PR 55693: Added exchange key expiration timer
73 *
74 * 1   6/5/09 4:06p leisun
75 * PR 55693: checking in DTCP-IP lib
76 *
77 *****************************************************************************/
78#ifndef B_DTCP_APPLIB_H
79#define B_DTCP_APPLIB_H   
80
81#ifdef __cplusplus
82extern "C"
83{
84#endif
85
86#define DTCP_CONTENT_LENGTH_UNLIMITED   -1
87#define DTCP_DESCRIPTOR_LENGTH  6
88
89/* \enum B_DeviceMode
90 * \brief Device mode
91 */
92typedef enum B_DeviceMode
93{
94        B_DeviceMode_eSource = 0,                       /* Format-non-cognizant source function. */
95        B_DeviceMode_eSink = 1,                         /* Format-non-cognizant sink function. */
96        B_DeviceMode_eFCSource = 2,                     /* Format-cognizant source function */
97        B_DeviceMode_eFCSink = 3,                       /* Format-cognizant sink function. */
98        B_DeviceMode_eRecord = 5,                       /* Format-non-cognizant recording function. */
99        B_DeviceMode_eFCRecord = 7,                     /* Format-cognizant recording function. */
100        B_DeviceMode_eAudioFCSource = 4,        /* Audio-Format-cognizant source function. */
101        B_DeviceMode_eAudioFCSink = 9,          /* Audio-format-cognizant sink function.*/
102        B_DeviceMode_eAudioFCRecord = 11 ,      /* Audio-format-cognizant recording function.*/
103        /* Audio-format-non-cognizant sink/record function only available for bridge.*/
104        B_DeviceMode_eBridge
105}B_DeviceMode_T;
106
107#define IS_SINK(mode)   ( mode & B_DeviceMode_eSink)
108#define IS_SOURCE(mode) (!(mode & B_DeviceMode_eSink))
109
110/*! \enum B_StackId
111 *  \brief Stack ID, currently only DTCP-IP is implemented.
112 */
113typedef enum B_StackId
114{
115        B_StackId_eIP,
116        B_StackId_e1394,
117        B_StackId_eUSB
118}B_StackId_T;
119/*! \enum b_stream_transport
120 *  \brief stream transport type.
121 */
122typedef enum b_stream_transport
123{
124        B_StreamTransport_eRtp,
125        B_StreamTransport_eHttp,
126        B_StreamTransport_eUdp
127}B_StreamTransport_T;
128
129/* \enum b_stream_type
130 * \brief Stream type source/sink
131 */
132typedef enum b_stream_type
133{
134        B_Stream_eSource,
135        B_Stream_eSink
136}B_StreamType_T;
137/* \enum b_ur_mode
138 * \brief usage rule mode, if PCP-UR is used.
139 */
140typedef enum b_ur_mode
141{
142        B_UR_Mode_eNoInfo,
143        B_UR_Mode_eCCI,
144        B_UR_Mode_eNoCCI,
145        B_UR_Mode_eReserved
146}B_UR_Mode_T;
147/* \enum b_content_type
148 * \brief content type in PCP_UR header.
149 */
150typedef enum b_content_type
151{
152        B_Content_eAudioVisual,
153        B_Content_eType1Audio,
154        B_Content_eReserved1,
155        B_Content_eReserved2,
156        /* Additional type for PCP_UR handling*/
157        B_Content_eMPEG_TS,
158        B_Content_eType2Audio,
159        B_Content_eMultiplex
160}B_Content_Type_T;
161
162/* \enum b_aps_cci
163 * \brief analog copy protection info.
164 */
165typedef enum b_aps_cci
166{
167        B_APS_eCopyFree,
168        B_APS_eType1,
169        B_APS_eType2,
170        B_APS_eType3
171}B_APS_CCI_T;
172/* \enum b_ict
173 * \brief image constraint token.
174 */
175typedef enum b_ict
176{
177        B_ICT_e0,       /* HD Analog output in the form of constraint image.*/
178        B_ICT_e1        /* HD analog output in HD analog form. */
179}B_ICT_T;
180
181/* \enmu b_cci
182 * \brief copy generation management information.
183 */
184typedef enum b_cci
185{
186        B_CCI_eCopyFree,
187        B_CCI_eNoMoreCopy,
188        B_CCI_eCopyOneGeneration,
189        B_CCI_eCopyNever
190}B_CCI_T;
191/* \enum b_audio_cci
192 * \brief CCI for audio content.
193 */
194typedef enum b_audio_cci
195{
196        B_Audio_CCI_eCopyFree,
197        B_Audio_CCI_eNoMoreCopy,
198        B_Audio_CCI_eCPT,               /* copy permitted per type.*/
199        B_Audio_CCI_eNA
200}B_Audio_CCI_T;
201
202/* \enum b_retention_stte
203 * \brief retention_state values.
204 */
205typedef enum b_retention_state
206{
207        B_Retention_Forever,
208        B_Retention_1week,
209        B_Retention_2days,
210        B_Retention_1day,
211        B_Retention_12hours,
212        B_Retention_6hours,
213        B_Retention_3hours,
214        B_Retention_90minutes
215}B_Retention_State;
216
217/*!\brief exproted library startup function,must be called before any other AKE function call.
218 * \param[in] mode device mode source/sink
219 */
220void * DtcpAppLib_Startup(B_DeviceMode_T mode, bool use_pcp_ur);
221/*! \brief shut down dtcp-ip library, free any internal allocated resources.
222 *  \param[in] ctx DTCP-IP stack context pointer, obtained from DtcpAppLib_Startup() function.
223 *  \retval none.
224 */
225void DtcpAppLib_Shutdown(void * ctx);
226/*! \brief Perform AKE procedure, for sink device only.
227 *  \param[in] ctx DTCP-IP context pointer.
228 *  \param[in] aRemoteIp server's IP address.
229 *  \param[in] aRemotePort server's DTCP port number.
230 *  \param[out] aAkeHandle result AKE handle, dereferencing the handle to obtain AKE session.
231 *  \retval BERR_SUCCESS or other error code.
232 */
233int DtcpAppLib_DoAke(void * ctx, const char *aRemoteIp, unsigned short aRemotePort, void **aAkeHandle);
234/*! \brief  close AKE session, after the DoAke call, used by sink device only.
235 *  \param[in] ctx DTCP-IP context pointer.
236 *  \param[in] aAkeHandle active AKE handle to close.
237 *  \retval BERR_SUCCESS or other error code.
238 */
239int DtcpAppLib_CloseAke(void * ctx, void *aAkeHandle);
240/*! \brief start DTCP/IP source functionon listen to sink device's AKE request
241 *  \param[in] ctx DTCP-IP context pointer.
242 *  \param[in] aSourceIp the IP address to listen on, if it's NULL will listen on all interfaces.
243 *  \param[in] aSourcePort DTCP-IP port number
244 *  \retval BERR_SUCCESS or other error code.
245 */
246int DtcpAppLib_Listen(const void * ctx, const char *aSourceIp, unsigned short aSourcePort);
247/*! \brief stop DTCP/IP source function, cancel listening.
248 *  \param[in] ctx DTCP-IP context pointer.
249 *  \retval BERR_SUCCESS or other error code.
250 */
251int DtcpAppLib_CancelListen(void * ctx);
252/*! \brief function to verify sink's exchange key is still valid or not.
253 * \param[in] ctx DTCP-IP context pointer.
254 * \param[in] aAkeHandle Ake session handle.
255 * \retvalu true if the exchange key is valid or false otherwise.
256 */
257bool DtcpAppLib_VerifyExchKey(void * ctx, void *aAkeHandle);
258/*! \brief for an exsiting AKE session whose exchange key has expired, call
259 *  this function to re-authenticate with server to get new exchange key.
260 *  \param[in] ctx DTCP-IP context pointer.
261 *  \param[in] aAkeHandle AKE session handle.
262 *  \retval BERR_SUCCESS or other error code.
263 */
264int DtcpAppLib_GetNewExchKey(void * ctx, void *aAkeHandle);
265
266/*! \brief retrive active sink device's AKE session.
267 *  \param[in] ctx DTCP-IP context pointer.
268 *  \param[in] aRemoteIp sink device's IP address.
269 *  \param[out] aAkeHandle AkE handle pointer retrived.
270 *
271 *  This function is used by source device streaming function, once received streaming request from sink, it will
272 *  try to retrive AKE handle for this sink, if AKE handle is NULL< streaming request should be rejected.
273 */
274void DtcpAppLib_GetSinkAkeSession(void * ctx, const char *aRemoteIp, void **aAkeHandle);
275/*! \brief Initialize a DTCP-IP source stream
276 *  \param[in] aAkehandle AKE session handle.
277 *  \param[in] TransportType stream transport type.
278 *  \param[in] ContentLength length of the raw content.
279 *  \param[in] cci content's CCI (Copy Control Information) value.
280 *  \param[in] content_type type of the content, e.g AudioVisual, etc.
281 *  \param[in] max_packet_size size of the PCP packet.
282 *  \retval a stream handle if success or a NULL if failed.
283 */
284void * DtcpAppLib_OpenSourceStream(void *aAkeHandle, B_StreamTransport_T TransportType, 
285                int ContentLength, int cci, int content_type, int max_packet_size);
286
287/*! \brief set source stream atribute (copy control information)
288 *  \param[in[ stream stream handle.
289 *  \param[in] content_has_cci flag to indicate if the content has CCI or not.
290 *  \param[in] content_type type of the content.
291 *  \param[in] aps analog copy right information.
292 *  \param[in] ict image constraint token.
293 *  \param[in] ast analog sunset token.
294 */
295void DtcpAppLib_SetSourceStreamAttribute(void *hStreamHandle, bool content_has_cci,
296                int content_type, int aps, int ict, int ast);
297/*! \brief get the sink stream's attribute, to determine
298 * if processing (decryption) is allowed.
299 * \param[in] akeHandle AKE session handle.
300 * \param[in] stream stream handle.
301 * \param[in/out] content_type stream content type.
302 * \param[in/out] aps analog copy right information.
303 * \param[in/out] ict image constraint token.
304 * \param[in/out] ast analog sunset token.
305 */
306BERR_Code DtcpAppLib_GetSinkStreamAttribute(void *akeHandle, void *hStreamHandle, 
307                int *content_type, int *aps, int *ict, int *ast);
308
309/*! \brief set the stream's emi value, if caller wish to override the emi value
310 *  obtained internally by DTCP lib.
311 *  \param[in] hStreamHandle handle to the sink stream.
312 *  \param[in] emi emi value to set.
313 */
314void DtcpAppLib_SetSourceStreamEmi(void *hStreamHandle, int emi);
315/*! \brief Get the stream's emi value.
316 *  \param[in] hStreamHandle handle to the sink stream.
317 */
318int DtcpAppLib_GetSinkStreamEmi(void *hStreamHandle);
319
320/*! \brief Get the DTCP descriptor based on stream info, to insert into PMT of MPEG_TS stream.
321 * \param[in] hStreamHandle handle to the source stream.
322 * \param[in] buf buffer to store the dtcp descriptor.
323 * \param[in] length length of the buffer.
324 */
325BERR_Code DtcpAppLib_GetDescriptor(void *hStreamHandle, unsigned char *buf, int length);
326
327/*! \brief Initialize a DTCP-IP sink stream.
328 *  \param[in] aAkeHandle AKE session handle.
329 *  \param[in] TransportType stream transport type.
330 *  \retval a stream handle if success of NULL if failed.
331 */
332void * DtcpAppLib_OpenSinkStream(void *aAkeHandle, B_StreamTransport_T TransportType);
333
334/*! \brief close a opened stream.
335 * \param[in] hStreamHandle the stream handle.
336 */
337void DtcpAppLib_CloseStream(void * hStreamHandle);
338
339/*! \brief Packetize data, used by source device only.
340 *  \param[in] hStreamHandle the source stream handle.
341 *  \param[in] hAkeHandle handle to AKE session.
342 *  \param[in] clear_buf buffer hold the input data.
343 *  \param[in] clear_buf_size size of the input buffer.
344 *  \param[in,out] encrypted_buf buffer for output data.
345 *  \param[in] encrypted_buf_size size of output buffer.
346 *  \param[out] total total bytes processed.
347 *  \retval BERR_SUCCESS or other error code.
348 */
349BERR_Code DtcpAppLib_StreamPacketizeData(void * hStreamHandle, void * hAkeHandle, 
350                unsigned char * clear_buf, unsigned int clear_buf_size, unsigned char ** encrypted_buf, unsigned int * encrypted_buf_size, unsigned int * total);
351
352/*! \brief Depacketize data, used by sink device only.
353 *  \param[in] hStreamHandle the sink stream handle.
354 *  \param[in] hAkeHandle handle to AKE session.
355 *  \param[in] clear_buf buffer hold the input data.
356 *  \param[in] clear_buf_size size of the input buffer.
357 *  \param[in,out] encrypted_buf buffer for output data.
358 *  \param[in] encrypted_buf_size size of output buffer.
359 *  \param[out] total total bytes processed.
360 *  \retval BERR_SUCCESS or other error code.
361 */
362BERR_Code DtcpAppLib_StreamDepacketizeData(void * hStreamHandle, void * hAkeHandle,
363                unsigned char * encrypted_buf, unsigned int encrypted_buf_size, unsigned char * clear_buf, unsigned int * clear_buf_size, unsigned int * total, bool * pcp_header_found);
364
365#if defined(B_DTCP_IP_HW_ENCRYPTION) || defined(B_DTCP_IP_HW_DECRYPTION)
366/*! \brief Initialize hardware security context.
367 * 
368 *  Only when DTCP_IP_HARDWARE_DECRYPTION or DTCP_IP_HARDWARE_ENCRYPTION is defined.
369 */
370BERR_Code DtcpInitHWSecurityParams(void * nexusDmaHandle);
371/*! \brief cleanup hardware security context.
372 * 
373 *  Only when DTCP_IP_HARDWARE_DECRYPTION or DTCP_IP_HARDWARE_ENCRYPTION is defined.
374 */
375void DtcpCleanupHwSecurityParams(void);
376#endif
377
378#ifdef __cplusplus
379}
380#endif
381#endif /* B_DTCP_APPLIB_H */
Note: See TracBrowser for help on using the repository browser.