DVBCore  20.3.0
DVBCore Documentation
ca_glue.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2013 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
25 /*#define CA_DEBUG*/
26 
27 /*---Includes for this file---------------------------------------------------*/
28 /* compiler library header files */
29 
30 /* Third party header files */
31 
32 /* Ocean Blue Software header files */
33 #include <techtype.h>
34 #include <dbgfuncs.h>
35 #include <stbhwc.h>
36 #include "ca_glue.h"
37 
38 /*---constant definitions for this file----------------------------------------*/
39 
40 #ifdef CA_DEBUG
41 #define CA_DBG(X) STB_SPDebugWrite X
42 #else
43 #define CA_DBG(X)
44 #endif
45 
46 /*---local typedef structs for this file---------------------------------------*/
47 
48 /*---local (static) variable declarations for this file------------------------*/
49 /* (internal variables declared static to make them local) */
50 
51 /*---local function prototypes for this file-----------------------------------*/
52 /* (internal functions declared static to make them local) */
53 
54 
55 /*---global function definitions-----------------------------------------------*/
56 
57 /*!**************************************************************************
58  * @brief Called once on system startup to allow initialisation of the CA systems
59  * @return TRUE if initialisation is successful, FALSE otherwise
60  ****************************************************************************/
61 BOOLEAN STB_CAInitialise(void)
62 {
63  FUNCTION_START(STB_CAInitialise);
64 
65  CA_DBG(("%s", __FUNCTION__));
66 
67  FUNCTION_FINISH(STB_CAInitialise);
68 
69  return(TRUE);
70 }
71 
72 /*!**************************************************************************
73  * @brief This function is used by the resource manager to acquire a CA descrambler
74  * that's able to descramble a service that uses one of the CA systems
75  * defined by the array of CA system IDs (ca_ids). If a descrambler is
76  * available then a handle should be returned in 'handle' which will be
77  * used in all future calls related to this descrambler.
78  * If the CA software needs to set the demux descrambling keys, or create
79  * any filters to monitor SI data, the given demux handle should be used.
80  * @param demux - demux to be used if a descrambler is acquired
81  * @param serv_id - ID of the service the descrambler is being acquired for
82  * @param ca_ids - array of CA system IDs for the service
83  * @param num_ca_ids - number of CA system IDs in the array
84  * @param handle - pointer to return a handle to identify the acquired CA descrambler
85  * @return TRUE if a descrambler is acquired, FALSE otherwise
86  ****************************************************************************/
87 BOOLEAN STB_CAAcquireDescrambler(U8BIT demux, U16BIT serv_id, U16BIT *ca_ids, U16BIT num_ca_ids,
88  U32BIT *handle)
89 {
90  FUNCTION_START(STB_CAAcquireDescrambler);
91 
92  CA_DBG(("%s(demux=%u, serv_id=%u, ca_ids=%p, num_ca_ids=%u)", __FUNCTION__, demux, serv_id,
93  ca_ids, num_ca_ids));
94 
95  USE_UNWANTED_PARAM(demux);
96  USE_UNWANTED_PARAM(serv_id);
97  USE_UNWANTED_PARAM(ca_ids);
98  USE_UNWANTED_PARAM(num_ca_ids);
99  USE_UNWANTED_PARAM(handle);
100 
101  FUNCTION_FINISH(STB_CAAcquireDescrambler);
102 
103  return(FALSE);
104 }
105 
106 /*!**************************************************************************
107  * @brief Will be called when a CA descrambler is no longer required.
108  * @param handle - CA descrambler handle being released
109  * @return TRUE if the descrambler is released, FALSE otherwise
110  ****************************************************************************/
111 BOOLEAN STB_CAReleaseDescrambler(U32BIT handle)
112 {
113  FUNCTION_START(STB_CAReleaseDescrambler);
114 
115  CA_DBG(("%s(0x%lx)", __FUNCTION__, handle));
116 
117  USE_UNWANTED_PARAM(handle);
118 
119  FUNCTION_FINISH(STB_CAReleaseDescrambler);
120 
121  return(FALSE);
122 }
123 
124 /*!**************************************************************************
125  * @brief This function will be called when decoding of a service is about to start
126  * and there's an associated descrambler.
127  * @param handle - CA descrambler handle
128  ****************************************************************************/
129 void STB_CADescrambleServiceStart(U32BIT handle)
130 {
131  FUNCTION_START(STB_CADescrambleServiceStart);
132 
133  CA_DBG(("%s(0x%lx)", __FUNCTION__, handle));
134 
135  USE_UNWANTED_PARAM(handle);
136 
137  FUNCTION_FINISH(STB_CADescrambleServiceStart);
138 }
139 
140 /*!**************************************************************************
141  * @brief This function will be called when decoding of a service is stopped
142  * @param handle - CA descrambler handle
143  ****************************************************************************/
144 void STB_CADescrambleServiceStop(U32BIT handle)
145 {
146  FUNCTION_START(STB_CADescrambleServiceStop);
147 
148  CA_DBG(("%s(0x%lx)", __FUNCTION__, handle));
149 
150  USE_UNWANTED_PARAM(handle);
151 
152  FUNCTION_FINISH(STB_CADescrambleServiceStop);
153 }
154 
155 /*!**************************************************************************
156  * @brief When there's an update to the PMT for a service, the updated PMT
157  * will be reported to the CA system using this function.
158  * @param handle - CA descrambler handle
159  * @param pmt_data - raw PMT section data
160  * @param data_len - number of bytes in the PMT
161  ****************************************************************************/
162 void STB_CAReportPMT(U32BIT handle, U8BIT *pmt_data, U16BIT data_len)
163 {
164  FUNCTION_START(STB_CAReportPMT);
165 
166  CA_DBG(("%s(handle=0x%lx, pmt_data=%p, data_len=%u)", __FUNCTION__, handle, pmt_data, data_len));
167 
168  USE_UNWANTED_PARAM(handle);
169  USE_UNWANTED_PARAM(pmt_data);
170  USE_UNWANTED_PARAM(data_len);
171 
172  FUNCTION_FINISH(STB_CAReportPMT);
173 }
174 
175 /*!**************************************************************************
176  * @brief When there's an update to the CAT for a service, the updated CAT
177  * will be reported to the CA system using this function. The data is
178  * provided a section at a time, rather than as a complete table.
179  * @param handle - CA descrambler handle
180  * @param cat_data - raw CAT section data
181  * @param data_len - number of bytes in the CAT section
182  ****************************************************************************/
183 void STB_CAReportCAT(U32BIT handle, U8BIT *cat_data, U16BIT data_len)
184 {
185  FUNCTION_START(STB_CAReportCAT);
186 
187  CA_DBG(("%s(handle=0x%lx, cat_data=%p, data_len=%u)", __FUNCTION__, handle, cat_data, data_len));
188 
189  USE_UNWANTED_PARAM(handle);
190  USE_UNWANTED_PARAM(cat_data);
191  USE_UNWANTED_PARAM(data_len);
192 
193  FUNCTION_FINISH(STB_CAReportCAT);
194 }
195 
196 /*!**************************************************************************
197  * @brief When there's an update to the BAT, the updated BAT will be reported
198  * to the CA system using this function. The data is provided a section
199  * at a time, rather than as a complete table.
200  * @param handle - CA descrambler handle
201  * @param bat_data - raw BAT section data
202  * @param data_len - number of bytes in the BAT section
203  ****************************************************************************/
204 void STB_CAReportBAT(U32BIT handle, U8BIT *bat_data, U16BIT data_len)
205 {
206  FUNCTION_START(STB_CAReportBAT);
207 
208  CA_DBG(("%s(handle=0x%lx, bat_data=%p, data_len=%u)", __FUNCTION__, handle, bat_data, data_len));
209 
210  USE_UNWANTED_PARAM(handle);
211  USE_UNWANTED_PARAM(bat_data);
212  USE_UNWANTED_PARAM(data_len);
213 
214  FUNCTION_FINISH(STB_CAReportBAT);
215 }
216 
217 /*!**************************************************************************
218  * @brief When there's an update to the NIT, the updated NIT will be reported
219  * to the CA system using this function. The data is provided a section
220  * at a time, rather than as a complete table.
221  * @param handle - CA descrambler handle
222  * @param nit_data - raw NIT section data
223  * @param data_len - number of bytes in the NIT section
224  ****************************************************************************/
225 void STB_CAReportNIT(U32BIT handle, U8BIT *nit_data, U16BIT data_len)
226 {
227  FUNCTION_START(STB_CAReportNIT);
228 
229  CA_DBG(("%s(handle=0x%lx, nit_data=%p, data_len=%u)", __FUNCTION__, handle, nit_data, data_len));
230 
231  USE_UNWANTED_PARAM(handle);
232  USE_UNWANTED_PARAM(nit_data);
233  USE_UNWANTED_PARAM(data_len);
234 
235  FUNCTION_FINISH(STB_CAReportNIT);
236 }
237 
238 /*!**************************************************************************
239  * @brief Notifies the CA system of a change in the video decoding state
240  * @param handle - CA descrambler handle
241  * @param decode_status - decoding status
242  ****************************************************************************/
243 void STB_CADecodeVideoStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
244 {
245  FUNCTION_START(STB_CADecodeVideoStatus);
246 
247  CA_DBG(("%s(handle=0x%lx, status=%u)", __FUNCTION__, handle, decode_status));
248 
249  USE_UNWANTED_PARAM(handle);
250  USE_UNWANTED_PARAM(decode_status);
251 
252  FUNCTION_FINISH(STB_CADecodeVideoStatus);
253 }
254 
255 /*!**************************************************************************
256  * @brief Notifies the CA system of a change in the audio decoding state
257  * @param handle - CA descrambler handle
258  * @param decode_status - decoding status
259  ****************************************************************************/
260 void STB_CADecodeAudioStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
261 {
262  FUNCTION_START(STB_CADecodeAudioStatus);
263 
264  CA_DBG(("%s(handle=0x%lx, status=%u)", __FUNCTION__, handle, decode_status));
265 
266  USE_UNWANTED_PARAM(handle);
267  USE_UNWANTED_PARAM(decode_status);
268 
269  FUNCTION_FINISH(STB_CADecodeAudioStatus);
270 }
271 
272 /*!**************************************************************************
273  * @brief Notifies the CA system of a change in the AD decoding state
274  * @param handle - CA descrambler handle
275  * @param decode_status - decoding status
276  ****************************************************************************/
277 void STB_CADecodeADStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
278 {
279  FUNCTION_START(STB_CADecodeADStatus);
280 
281  CA_DBG(("%s(handle=0x%lx, status=%u)", __FUNCTION__, handle, decode_status));
282 
283  USE_UNWANTED_PARAM(handle);
284  USE_UNWANTED_PARAM(decode_status);
285 
286  FUNCTION_FINISH(STB_CADecodeADStatus);
287 }
288 
289 /*!**************************************************************************
290  * @brief This function will be called when there's a change to the running status
291  * of a service being descrambled as indicated by the running_status field
292  * in the SDT.
293  * @param handle - CA descrambler handle
294  * @param status - running status as defined in the SDT
295  ****************************************************************************/
296 void STB_CANotifyRunningStatus(U32BIT handle, U8BIT status)
297 {
298  FUNCTION_START(STB_CANotifyRunningStatus);
299 
300  CA_DBG(("%s(handle=0x%lx, status=%u)", __FUNCTION__, handle, status));
301 
302  USE_UNWANTED_PARAM(handle);
303  USE_UNWANTED_PARAM(status);
304 
305  FUNCTION_FINISH(STB_CANotifyRunningStatus);
306 }
307 
308 /*!**************************************************************************
309  * @brief This function specifies whether a CA descrambler is required to playback
310  * a recording with one of the given CA system IDs.
311  * @param ca_ids - array of CA system IDs
312  * @param num_ca_ids - number of CA system IDs in the array
313  * @return TRUE if a CA descrambler is required, FALSE otherwise
314  ****************************************************************************/
315 BOOLEAN STB_CADescramblerRequiredForPlayback(U16BIT *ca_ids, U16BIT num_ca_ids)
316 {
317  FUNCTION_START(STB_CADescramblerRequiredForPlayback);
318 
319  CA_DBG(("%s(ca_ids=%p, num_ca_ids=%u)", __FUNCTION__, ca_ids, num_ca_ids));
320 
321  USE_UNWANTED_PARAM(ca_ids);
322  USE_UNWANTED_PARAM(num_ca_ids);
323 
324  FUNCTION_FINISH(STB_CADescramblerRequiredForPlayback);
325 
326  return(FALSE);
327 }
328 
329 /*!**************************************************************************
330  * @brief This function specifies whether a CA descrambler is required to record
331  * a service with one of the given CA system IDs.
332  * @param ca_ids - array of CA system IDs
333  * @param num_ca_ids - number of CA system IDs in the array
334  * @return TRUE if a CA descrambler is required, FALSE otherwise
335  ****************************************************************************/
336 BOOLEAN STB_CADescramblerRequiredForRecording(U16BIT *ca_ids, U16BIT num_ca_ids)
337 {
339 
340  CA_DBG(("%s(ca_ids=%p, num_ca_ids=%u)", __FUNCTION__, ca_ids, num_ca_ids));
341 
342  USE_UNWANTED_PARAM(ca_ids);
343  USE_UNWANTED_PARAM(num_ca_ids);
344 
345  FUNCTION_FINISH(STB_CADescramblerRequiredForRecording);
346 
347  return(FALSE);
348 }
349 
350 /*!**************************************************************************
351  * @brief This function is called to get an array of PIDs that need to be recorded
352  * for the CA system required for the given PMT. The array must be allocated
353  * by this function, which also returns the number of items in the array.
354  * @param pmt_data - raw PMT section data
355  * @param pid_array - pointer to an array allocated by this function on return,
356  * containing the PIDs to be recorded
357  * @return the number of PIDs in the returned array
358  ****************************************************************************/
359 U16BIT STB_CAGetRecordingPids(U8BIT *pmt_data, U16BIT **pid_array)
360 {
361  U16BIT num_pids;
362 
363  FUNCTION_START(STB_CAGetRecordingPids);
364 
365  num_pids = 0;
366 
367  USE_UNWANTED_PARAM(pmt_data);
368  USE_UNWANTED_PARAM(pid_array);
369 
370  CA_DBG(("%s(pmt_data=%p, pid_array=%u): %u", __FUNCTION__, pmt_data, pid_array, num_pids));
371 
372  FUNCTION_FINISH(STB_CAGetRecordingPids);
373 
374  return(num_pids);
375 }
376 
377 /*!**************************************************************************
378  * @brief Called to free the array of PIDs allocated by STB_CAGetRecordingPids.
379  * @param pid_array - array of PIDs to be freed
380  * @param num_pids - number of PIDs in the array
381  ****************************************************************************/
382 void STB_CAReleaseRecordingPids(U16BIT *pid_array, U16BIT num_pids)
383 {
384  FUNCTION_START(STB_CAReleaseRecordingPids);
385 
386  CA_DBG(("%s(pid_array=%p, num_pids=%u)", __FUNCTION__, pid_array, num_pids));
387 
388  USE_UNWANTED_PARAM(pid_array);
389  USE_UNWANTED_PARAM(num_pids);
390 
391  FUNCTION_FINISH(STB_CAReleaseRecordingPids);
392 }
393 
394 /*!**************************************************************************
395  * @brief This function is called when a recording starts and when it stops
396  * @param handle - CA descrambler handle
397  * @param status - TRUE when a recording starts, FALSE when it stops
398  ****************************************************************************/
399 void STB_CANotifyRecordingStatus(U32BIT handle, BOOLEAN status)
400 {
401  FUNCTION_START(STB_CANotifyRecordingStatus);
402 
403  CA_DBG(("%s(handle=0x%lx, status=%u)", __FUNCTION__, handle, status));
404 
405  USE_UNWANTED_PARAM(handle);
406  USE_UNWANTED_PARAM(status);
407 
408  FUNCTION_FINISH(STB_CANotifyRecordingStatus);
409 }
410 
411 /******************************************************************************
412 ** End of file
413 ******************************************************************************/
void STB_CAReportCAT(U32BIT handle, U8BIT *cat_data, U16BIT data_len)
When there&#39;s an update to the CAT for a service, the updated CAT will be reported to the CA system us...
Definition: ca_glue.c:183
void STB_CAReportNIT(U32BIT handle, U8BIT *nit_data, U16BIT data_len)
When there&#39;s an update to the NIT, the updated NIT will be reported to the CA system using this funct...
Definition: ca_glue.c:225
BOOLEAN STB_CAInitialise(void)
Called once on system startup to allow initialisation of the CA systems.
Definition: ca_glue.c:61
Function prototypes for HW control.
void STB_CADecodeAudioStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
Notifies the CA system of a change in the audio decoding state.
Definition: ca_glue.c:260
void STB_CADescrambleServiceStop(U32BIT handle)
This function will be called when decoding of a service is stopped.
Definition: ca_glue.c:144
BOOLEAN STB_CAAcquireDescrambler(U8BIT demux, U16BIT serv_id, U16BIT *ca_ids, U16BIT num_ca_ids, U32BIT *handle)
This function is used by the resource manager to acquire a CA descrambler that&#39;s able to descramble a...
Definition: ca_glue.c:87
U16BIT STB_CAGetRecordingPids(U8BIT *pmt_data, U16BIT **pid_array)
This function is called to get an array of PIDs that need to be recorded for the CA system required f...
Definition: ca_glue.c:359
void STB_CANotifyRunningStatus(U32BIT handle, U8BIT status)
This function will be called when there&#39;s a change to the running status of a service being descrambl...
Definition: ca_glue.c:296
BOOLEAN STB_CADescramblerRequiredForPlayback(U16BIT *ca_ids, U16BIT num_ca_ids)
This function specifies whether a CA descrambler is required to playback a recording with one of the ...
Definition: ca_glue.c:315
void STB_CAReportBAT(U32BIT handle, U8BIT *bat_data, U16BIT data_len)
When there&#39;s an update to the BAT, the updated BAT will be reported to the CA system using this funct...
Definition: ca_glue.c:204
void STB_CADecodeADStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
Notifies the CA system of a change in the AD decoding state.
Definition: ca_glue.c:277
Debug functions header file.
void STB_CAReportPMT(U32BIT handle, U8BIT *pmt_data, U16BIT data_len)
When there&#39;s an update to the PMT for a service, the updated PMT will be reported to the CA system us...
Definition: ca_glue.c:162
Glue layer between DVB and conditional access systems.
BOOLEAN STB_CADescramblerRequiredForRecording(U16BIT *ca_ids, U16BIT num_ca_ids)
This function specifies whether a CA descrambler is required to record a service with one of the give...
Definition: ca_glue.c:336
System Wide Global Technical Data Type Definitions.
void STB_CADecodeVideoStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
Notifies the CA system of a change in the video decoding state.
Definition: ca_glue.c:243
void STB_CANotifyRecordingStatus(U32BIT handle, BOOLEAN status)
This function is called when a recording starts and when it stops.
Definition: ca_glue.c:399
BOOLEAN STB_CAReleaseDescrambler(U32BIT handle)
Will be called when a CA descrambler is no longer required.
Definition: ca_glue.c:111
void STB_CAReleaseRecordingPids(U16BIT *pid_array, U16BIT num_pids)
Called to free the array of PIDs allocated by STB_CAGetRecordingPids.
Definition: ca_glue.c:382
void STB_CADescrambleServiceStart(U32BIT handle)
This function will be called when decoding of a service is about to start and there&#39;s an associated d...
Definition: ca_glue.c:129