DSMCC  15.3.1
source/dsfm/inc/dsfm.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
00003  * Copyright © 2004 Ocean Blue Software Ltd
00004  *
00005  * This file is part of a DTVKit Software Component
00006  * You are permitted to copy, modify or distribute this file subject to the terms
00007  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
00008  *
00009  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00010  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00011  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00012  *
00013  * If you or your organisation is not a member of DTVKit then you have access
00014  * to this source code outside of the terms of the licence agreement
00015  * and you are expected to delete this and any associated files immediately.
00016  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
00017  *******************************************************************************/
00024 #ifndef _DSFM_H_
00025 #define _DSFM_H_
00026 
00027 #include "cldsmtypes.h"
00028 #include "dmxtypes.h"
00029 #include "stdfuncs.h"
00030 #include "stb_filter.h"
00031  #include "dsm_debug.h"
00032 
00033 #define SECTION_HEADER_LENGTH 8
00034 
00035 typedef enum {
00036    SFM_ERROR,
00037    SFM_IGNORE,
00038    SFM_UPDATE_CACHE,
00039    SFM_UPDATE_LOW,
00040    SFM_UPDATE_HIGH
00041 } E_SFM_STATUS;
00042 
00043 typedef struct s_DmxPidFilter*   H_DmxPidFilter;
00044 
00045 /*------------------- Functions supplied to SFM at setup ---------------------*/
00046 
00055 typedef void (*F_UpdateFilter)( H_SfmInstance sfm, H_DmxPidFilter hPF );
00056 
00069 typedef void (*F_CacheMatch)( H_SfmInstance sfm, U8BIT* pSection,
00070                               void* hBuffer, E_SFM_STATUS status );
00071 
00072 /*---------------- Setup structure for SFM initialisation -------------------*/
00073 
00074 typedef struct
00075 {
00076    /* ---------- Manditory functions ----------- */
00077 
00078    F_MemAlloc           memAlloc;
00079    F_MemFree            memFree;
00080 
00081    F_Locking            mutexLock;
00082    F_Locking            mutexUnlock;
00083 
00084    /* Hardware filter callback function that will handle section and lead to
00085     * calling SFM_RequireSection() followed by SFM_ProcessSection()
00086     */
00087    F_FILTER_CALLBACK    hwFilterCallback;
00088 
00089    /* Callback function to inform client that filters require updating
00090     */
00091    F_UpdateFilter       updateFilter;
00092 
00093    /* ---------- Optional functions ----------- */
00094 
00095    /* cacheMatch function provided so that processing of section data matched
00096     * in cache can happen after DSM-CC has finished processing request for
00097     * relevant section filter.
00098     * If 'cacheMatch' is NULL, then SFM_DsmccFilterAdd will directly call
00099     * SFM_ProcessSection.
00100     */
00101    F_CacheMatch         cacheMatch;
00102 
00103    /* -------- Optional debug functions --------- */
00104 
00105    /* errPrintf and dbgPrintf functions are only used in a debug build
00106     * When not supplied, these must be set to NULL
00107     */
00108    F_Printf             errPrintf;
00109    F_Printf             dbgPrintf;
00110 
00111    /* ------------- Mutex parameters ------------ */
00112 
00113    /* sfmMutex is manditory, used in mutexLock / mutexUnlock functions
00114     * and must be created and valid before supplying to SFM_CreateInstance
00115     */
00116    void*                sfmMutex;
00117 
00118    /* cacheMutex and bufferMutex are only required.if caching
00119     * - see sectionBuffCacheSize
00120     * It if used in mutexLock / mutexUnlock functions and must be created
00121     * before supplying to SFM_CreateInstance
00122     */
00123    void*                cacheMutex;
00124    void*                bufferMutex;
00125 
00126    /* -------- Configuration parameters --------- */
00127 
00128    /* Set maximum number of PID filters available to be used symultaneously
00129     * Minimum value: 4
00130     */
00131    U8BIT                maxPidFilters;
00132 
00133    /* Set maximum number of section filters per PID filter used symultaneously.
00134     * Low values will increase requirement for SFM to do it's own
00135     * software section filtering.
00136     * Minimum value: 1
00137     */
00138    U8BIT                maxSecFiltersPerPid;
00139 
00140    /* Size of section buffer manager cache in 64K byte blocks. This memory is
00141     * used to store section data not immediately required by DSM-CC instance.
00142     * This facilitates faster DSM-CC file loading - particularly when the number
00143     * of section filters is limited. See maxSecFiltersPerPid (and maxPidFilters)
00144     * Minimum value: 0
00145     * Suggested value: 16
00146     */
00147    U8BIT                sectionBuffCacheSize;
00148 
00149    /*
00150     * Specifies the maximum number of section filters that are available
00151     * to the DSM-CC instance for simultaneously acquiring DSM-CC private sections.
00152     * This should be set with the same value as that given to the DSM-CC instance
00153     * creation - see 'maxAvailableSectionFilters' in DSM-CC setup.
00154     */
00155    U16BIT               maxAvailableSectionFilters;
00156 
00157    /* dbgState controls type of debug output for dbgPrintf
00158     * For valid debug filter states see above
00159     */
00160    U32BIT               dbgState;
00161 
00162 } S_SfmSetup;
00163 
00164 
00165 /*---------------------- Functions that configure SFM ------------------------*/
00166 
00172 H_SfmInstance SFM_CreateInstance( S_SfmSetup *pSetup );
00173 
00183 void SFM_DestroyInstance( H_SfmInstance sfm, void **pSfmMtx,
00184                           void **pCchMtx, void **pBufMtx );
00185 
00194 void SFM_SetDebugConfig( H_SfmInstance sfm,  F_Printf errPrintf,
00195                          F_Printf dbgPrintf, U32BIT dbgState );
00196 
00203 void SFM_SetDebugState( H_SfmInstance sfm, U32BIT dbgState );
00204 
00211 void SFM_SetDsmInstance( H_SfmInstance sfm, clDsmInstHandle_t dsmcc );
00212 
00219 void SFM_SetDemuxHandle( H_SfmInstance sfm, DMXREF demux );
00220 
00221 
00222 
00223 /*----------------- Functions that process section data  ---------------------*/
00224 
00240 E_SFM_STATUS SFM_RequireSection( H_SfmInstance sfm, PIDFILT pfid,
00241                                  U8BIT *pHeader, void** phBuffer );
00242 
00254 U8BIT* SFM_CacheBuffer( H_SfmInstance sfm, void* hBuffer );
00255 
00268 void SFM_ProcessSection( H_SfmInstance sfm, U8BIT *pSection, void* hBuffer );
00269 
00276 void SFM_FilterUpdate( H_SfmInstance sfm, H_DmxPidFilter hPF );
00277 
00278 /*-------------------- Functions to manage SFM caching -----------------------*/
00279 
00286 BOOLEAN SFM_CacheEnableSSF( H_SfmInstance sfm );
00287 
00293 void SFM_CacheDisableSSF( H_SfmInstance sfm );
00294 
00303 void SFM_CacheClear( H_SfmInstance sfm );
00304 
00305 
00306 
00307 /*----------------- Functions provided to DSM-CC component -------------------*/
00308 
00319 void* SFM_DsmccFilterAdd( H_SfmInstance sfm, pclDsmSFilter_t pFilter,
00320                           clDsmSFRef_t dsmSfRef );
00321 
00332 void SFM_DsmccFilterDelete( H_SfmInstance sfm, void* filterHandle,
00333                             clDsmSFRef_t dsmSfRef );
00334 
00335 
00347 void SFM_DsmccFilterPriorityChange( H_SfmInstance sfm, void* filterHandle,
00348                                     clDsmSFRef_t dsmSfRef,
00349                                     clDsmSFPriority_t priority );
00350 
00351 #endif /*_DSFM_H_*/
 All Data Structures Files Functions Typedefs