DVBCore  17.9.0
Open Source DVB Engine
 All Data Structures Files Functions Typedefs Macros Pages
Macros | Typedefs | Enumerations | Functions
ap_si.c File Reference

Application level SI task. More...

#include <stdio.h>
#include <string.h>
#include "techtype.h"
#include "dbgfuncs.h"
#include "stbhwos.h"
#include "stbhwtun.h"
#include "stbhwav.h"
#include "stbheap.h"
#include "stberc.h"
#include "stbgc.h"
#include "stbdpc.h"
#include "stbsiflt.h"
#include "stbsitab.h"
#include "stbllist.h"
#include "stbdsapi.h"
#include "stbuni.h"
#include "media_image.h"
#include "app.h"
#include "ap_cfg.h"
#include "ap_cfdat.h"
#include "ap_dbacc.h"
#include "ap_tmr.h"
#include "ap_dbdef.h"
#include "ap_cntrl.h"
#include "ap_si.h"
#include "ap_pvr.h"
#include "app_nvm.h"
#include "ca_glue.h"
#include "ap_ca.h"
#include "dba.h"

Macros

#define AP_SI_PRINT(x)
 
#define DONT_CARE_ID_MATCH   0x0000
 
#define DONT_CARE_ID_MASK   0x0000
 
#define EITPF_ACTUAL_TID   0x4E
 
#define EITPF_OTHER_TID   0x4F
 
#define EITSC_ACTUAL_TID   0x50
 
#define EITSC_OTHER_TID   0x60
 
#define EITPF_PLUS_TID   0xd1 /* Freesat EITpf++ table ID */
 
#define TDT_TID   0x70
 
#define TOT_TID   0x73
 
#define AC3_DESC_DTAG   0x6a
 
#define EAC3_DESC_DTAG   0x7a
 
#define BAT_TIMEOUT_MS   12000
 
#define CAT_TIMEOUT_MS   2000
 
#define PAT_TIMEOUT_MS   800
 
#define PMT_TIMEOUT_MS   3000
 
#define NIT_TIMEOUT_MS   15000
 
#define SDT_TIMEOUT_MS   5000
 
#define EIT_TIMEOUT_MS   3000
 
#define TOT_TIMEOUT_MS   32000
 
#define TDT_TIMEOUT_MS   32000
 
#define SCHED_TIMEOUT_MS   3600000 /* 1 hour */
 
#define PMT_UPDATE_MS   1000
 
#define SI_UPDATE_DELAY_MS   100
 
#define MAX_PMT_PRIORITY_LIST   4
 
#define DVB_SSU_LINKAGE_TYPE   0x09
 
#define DVB_DVBH1_LINKAGE_TYPE   0x0B
 
#define DVB_DVBH2_LINKAGE_TYPE   0x0C
 
#define IGNORE_VERSION   TRUE
 
#define CHECK_VERSION   FALSE
 
#define EIT_ACTUAL_ONLY   TRUE
 
#define EIT_ACTUAL_OR_OTHER   FALSE
 
#define REPORT_PMT   TRUE
 
#define DONT_REPORT_PMT   FALSE
 
#define EIT_LIST_REQD   TRUE
 
#define EIT_LIST_NOT_REQD   FALSE
 
#define REPORT_CAT   TRUE
 
#define DONT_REPORT_CAT   FALSE
 
#define INVALID_SERVICE_ID   0xffffffff
 
#define UK_DTT_PRIVATE_DATA_CODE   0x0000233a
 
#define FREESAT_PRIVATE_DATA_CODE   0x46534154
 

Typedefs

typedef struct pmt_list_entry PMT_LIST_ENTRY
 
typedef struct eit_list_entry EIT_LIST_ENTRY
 
typedef struct s_si_event_data S_SI_EVENT_DATA
 

Enumerations

enum  E_DB_ACCESS_MODE { DB_ACCESS_UPDATE, DB_ACCESS_SEARCH, DB_ACCESS_PLAYBACK }
 
enum  E_PMT_REQUEST_MODE { PMT_REQUEST_CURRENT, PMT_REQUEST_MONITOR, PMT_REQUEST_PRIORITY }
 

Functions

void ASI_InitialiseAppSi (void)
 Initialises application SI handling.
 
void ASI_SetAppSiMode (U8BIT path, E_APP_SI_MODE si_mode)
 Sets application SI mode - used before STB_DPStartSI() is called. More...
 
BOOLEAN ASI_CheckServiceListReadyDuringSearch (U8BIT path)
 Reports the state of the service_list_ready flag which is set when the sdt has been processed in a search. More...
 
U16BIT ASI_GetPmtPid (U16BIT serv_id, U16BIT ts_id, U16BIT on_id)
 Returns the PID for the pmt of a given service (on live path) More...
 
void ASI_StopPmtReporting (U8BIT path)
 Prevents the current pmt being reported (e.g. to MHEG).
 
BOOLEAN ASI_PmtReported (U8BIT path)
 Returns TRUE if pmt has been reported to third parties. More...
 
void ASI_SetStandbyState (BOOLEAN standby_state)
 Performs the neccessary actions for this module when entering/exiting standby according to the value passed in standby_state. More...
 
void * ASI_GetNextOTALocation (void *network, void *prev_location, U16BIT *onid_ptr, U16BIT *tid_ptr, U16BIT *sid_ptr)
 Returns the DVB triplet for the next location containing a possible OTA update. More...
 
BOOLEAN ASI_SSURefused (void)
 Returns the flag indicating whether the SSU was refused. More...
 
void ASI_RefuseSSU (BOOLEAN refuse)
 Sets the flag indicating whether the SSU has been refused or not. More...
 
void ASI_SSUSetMandatory (BOOLEAN mandatory)
 Sets the flag indicating whether the SSU can be refused by the user. More...
 
BOOLEAN ASI_SSUGetMandatory (void)
 Returns the flag indicating whether the SSU is mandatory and so can't be refused. More...
 
BOOLEAN ASI_CheckForServiceChange (void)
 Checks whether the NIT or SDT version numbers have changed, which may indicate a change to the service lineup requiring an update service scan. More...
 
void ASI_RestartCatFilter (U8BIT path)
 Forces the SI demux filter collecting the CAT tables to be reset, so a previously processed version of the table won't be ignored. More...
 
void ASI_RestartNitFilter (U8BIT path)
 Forces the SI demux filter collecting the NIT tables to be reset, so a previously processed version of the table won't be ignored. More...
 
void ASI_RestartSdtFilter (U8BIT path)
 Forces the SI demux filter collecting the SDT tables to be reset, so a previously processed versions of the tables won't be ignored. More...
 
void ASI_RestartBatFilter (U8BIT path)
 Forces the SI demux filter collecting the BAT tables to be reset, so a previously processed versions of the tables won't be ignored. More...
 
void ASI_RestartTotFilter (U8BIT path)
 Forces the SI demux filter collecting the TOT tables to be reset, so a previously processed versions of the tables won't be ignored. More...
 
void ASI_RestartTdtFilter (U8BIT path)
 Forces the SI demux filter collecting the TDT tables to be reset, so a previously processed versions of the tables won't be ignored. More...
 
void ASI_SetSearchServiceType (E_SEARCH_SERVICE_TYPE service_type)
 Set the type for services that should be added during a service search. More...
 
void ASI_SetServiceUpdateMode (E_SERVICE_UPDATE_MODE update_mode, E_SORT_ORDER sort_order)
 Set the update mode to specify behaviour when SDT or NIT version changes and services are added, deleted or modified. More...
 
void ASI_AddServiceToPmtList (U16BIT service_id)
 Add the given service id to the list of services whose PMT will be requested with a higher priority than others. More...
 
void ASI_RemoveServiceFromPmtList (U16BIT service_id)
 Removes the service id from the PMT priority list. More...
 
void ASI_ClearPmtList (void)
 Clears all service ids from the PMT priority list.
 
void ASI_ProcessPmt (U8BIT path, void *s_ptr, U8BIT *pmt_data)
 Takes data for a raw PMT for the given service and processes it as if it had been received from the demux, also passing it to anything monitoring PMTs and CI+. More...
 
void ASI_SetEITScheduleLimit (U16BIT limit_hours)
 Sets the number of hours of EIT data that's kept for each service that hasn't its had EIT schedule disabled. More...
 
U16BIT ASI_GetEITScheduleLimit (void)
 Returns the current setting for the number of hours of EIT data that's kept. More...
 
void ASI_EnableBatCollection (BOOLEAN use_bats, U16BIT *bouquet_ids, U16BIT num_ids)
 Enables or disables the collection of BATs as part of the SI processing and allows the bouquet IDs of the BATs to be collected to be specified. More...
 
void ASI_RestartSITables (U8BIT path, BOOLEAN use_standard_pids)
 Cancels any existing SI filters and starts a new one for the SDT, TDT, TOT, NIT, EIT (pf, pf++ and sched) and BAT SI tables. More...
 
void ASI_SetEITParserFunction (F_EitParser parser_func)
 Sets a function that will be called when parsing an EIT table and a descriptor is found that the standard code doesn't know how to parse. More...
 
void ASI_SetUpdateBatFunction (F_BatTableUpdate update_func)
 Sets a function that will be called when a BAT table is received. More...
 
void ASI_SetUpdateEitFunction (F_EitTableUpdate update_func)
 Sets a function that will be called when an EIT table is received. More...
 
void ASI_SetUpdateNitFunction (F_NitTableUpdate update_func)
 Sets a function that will be called when an NIT table is received. More...
 
void ASI_SetUpdatePmtFunction (F_PmtTableUpdate update_func)
 Sets a function that will be called when a PMT table is received. More...
 
void ASI_SetUpdateSdtFunction (F_SdtTableUpdate update_func)
 Sets a function that will be called when an SDT table is received. More...
 
void ASI_ProcessEitTable (SI_TABLE_RECORD *table_rec, BOOLEAN playback)
 Processes an EIT table, partial or full, and updates the events of the service it is for. More...
 
void ASI_ProcessTotTable (SI_TABLE_RECORD *table_rec)
 Processes the TOT table record to extract data for the database. More...
 
void ASI_ProcessTdtTable (SI_TABLE_RECORD *table_rec)
 Processes the TDT table record to extract data for the database. More...
 
void ASI_RegisterEitSchedUpdateCallback (F_EitSchedUpdateCB sched_update_callback)
 Registers a function that will be called whenever an EIT event is added, updated, deleted or expires from a service's EIT schedule. The registered function should return control as soon as possible, otherwise processing of other EIT events will be affected. More...
 
void ASI_NotifyEitSchedUpdate (void *serv_ptr, U16BIT event_id, E_APP_SI_EIT_JOURNAL_TYPE type)
 Calls the EIT schedule update callback function, if one has been registered, with details of the service and event. More...
 

Detailed Description

Application level SI task.

Date
October 2003

Function Documentation

void ASI_AddServiceToPmtList ( U16BIT  service_id)

Add the given service id to the list of services whose PMT will be requested with a higher priority than others.

Parameters
service_idservice id to be added to the list
BOOLEAN ASI_CheckForServiceChange ( void  )

Checks whether the NIT or SDT version numbers have changed, which may indicate a change to the service lineup requiring an update service scan.

Returns
TRUE if one of the version numbers has changed, FALSE otherwise
BOOLEAN ASI_CheckServiceListReadyDuringSearch ( U8BIT  path)

Reports the state of the service_list_ready flag which is set when the sdt has been processed in a search.

Parameters
U8BITpath
Returns
service_list_ready[path]
void ASI_EnableBatCollection ( BOOLEAN  use_bats,
U16BIT *  bouquet_ids,
U16BIT  num_ids 
)

Enables or disables the collection of BATs as part of the SI processing and allows the bouquet IDs of the BATs to be collected to be specified.

Parameters
use_batsTRUE to enable the collection and processing of BATs, FALSE to disable
bouquet_idsan array of the bouquet IDs that are to be used. If this is NULL then all BATs will be used.
num_idsnumber of bouquet IDs in the array
U16BIT ASI_GetEITScheduleLimit ( void  )

Returns the current setting for the number of hours of EIT data that's kept.

Returns
number of hours, 0 means all data is kept
void* ASI_GetNextOTALocation ( void *  network,
void *  prev_location,
U16BIT *  onid_ptr,
U16BIT *  tid_ptr,
U16BIT *  sid_ptr 
)

Returns the DVB triplet for the next location containing a possible OTA update.

Parameters
networknetwork on which the OTA search is being made
prev_locationif this is NULL then info from the first OTA location on the network will be returned, otherwise it should be the value returned when this function was last called so the next possible OTA location will be returned
onid_ptrpointer to return the value of the original network ID for the possible OTA
tdi_ptrpointer to return the value of the transport ID for the possible OTA
sid_ptrpointer to return the value of the service ID for the possible OTA
Returns
If NULL then no OTA locations are available, otherwise a possible OTA is available and the returned value should be passed in the next time this function is called
U16BIT ASI_GetPmtPid ( U16BIT  serv_id,
U16BIT  ts_id,
U16BIT  on_id 
)

Returns the PID for the pmt of a given service (on live path)

Parameters
service_idprovides the required service ID
ts_idprovides the required transport stream ID
on_idprovides the required original network ID
Returns
the PID of the pmt for that service
void ASI_NotifyEitSchedUpdate ( void *  serv_ptr,
U16BIT  event_id,
E_APP_SI_EIT_JOURNAL_TYPE  type 
)

Calls the EIT schedule update callback function, if one has been registered, with details of the service and event.

Parameters
serv_ptrservice whose EIT schedule has changed
event_idID of the event that's been added, updated, deleted or expired
typetype of the change. For APP_SI_EIT_JOURNAL_TYPE_CLEAR, the event_id is irrelevant
BOOLEAN ASI_PmtReported ( U8BIT  path)

Returns TRUE if pmt has been reported to third parties.

Parameters
pathdecode path
Returns
TRUE if reported, FALSE otherwise
void ASI_ProcessEitTable ( SI_TABLE_RECORD table_rec,
BOOLEAN  playback 
)

Processes an EIT table, partial or full, and updates the events of the service it is for.

Parameters
table_recSI table record containing the EIT data
playbackTRUE if the EIT is related to PVR playback
void ASI_ProcessPmt ( U8BIT  path,
void *  s_ptr,
U8BIT *  pmt_data 
)

Takes data for a raw PMT for the given service and processes it as if it had been received from the demux, also passing it to anything monitoring PMTs and CI+.

Parameters
pathdecode path
s_ptrservice to be updated with info extracted from the PMT
pmt_dataraw PMT data
void ASI_ProcessTdtTable ( SI_TABLE_RECORD table_rec)

Processes the TDT table record to extract data for the database.

Parameters
table_recpointer to the pat table record
void ASI_ProcessTotTable ( SI_TABLE_RECORD table_rec)

Processes the TOT table record to extract data for the database.

Parameters
table_recpointer to the pat table record
void ASI_RefuseSSU ( BOOLEAN  refuse)

Sets the flag indicating whether the SSU has been refused or not.

Parameters
refuseTRUE to refuse the SSU, FALSE to accept
void ASI_RegisterEitSchedUpdateCallback ( F_EitSchedUpdateCB  sched_update_callback)

Registers a function that will be called whenever an EIT event is added, updated, deleted or expires from a service's EIT schedule. The registered function should return control as soon as possible, otherwise processing of other EIT events will be affected.

Parameters
sched_update_callbackfunction to be called
void ASI_RemoveServiceFromPmtList ( U16BIT  service_id)

Removes the service id from the PMT priority list.

Parameters
service_idservice id to be removed
void ASI_RestartBatFilter ( U8BIT  path)

Forces the SI demux filter collecting the BAT tables to be reset, so a previously processed versions of the tables won't be ignored.

Parameters
path- decode path that will be affected
void ASI_RestartCatFilter ( U8BIT  path)

Forces the SI demux filter collecting the CAT tables to be reset, so a previously processed version of the table won't be ignored.

Parameters
path- decode path that will be affected
void ASI_RestartNitFilter ( U8BIT  path)

Forces the SI demux filter collecting the NIT tables to be reset, so a previously processed version of the table won't be ignored.

Parameters
path- decode path that will be affected
void ASI_RestartSdtFilter ( U8BIT  path)

Forces the SI demux filter collecting the SDT tables to be reset, so a previously processed versions of the tables won't be ignored.

Parameters
path- decode path that will be affected
void ASI_RestartSITables ( U8BIT  path,
BOOLEAN  use_standard_pids 
)

Cancels any existing SI filters and starts a new one for the SDT, TDT, TOT, NIT, EIT (pf, pf++ and sched) and BAT SI tables.

Parameters
pathdecode path the filters are using
use_standard_pidsTRUE if SI tables on the DVB standard PIDs are to be collected, FALSE will only start a filter if a PID is defined for that table on the current service.
void ASI_RestartTdtFilter ( U8BIT  path)

Forces the SI demux filter collecting the TDT tables to be reset, so a previously processed versions of the tables won't be ignored.

Parameters
path- decode path that will be affected
void ASI_RestartTotFilter ( U8BIT  path)

Forces the SI demux filter collecting the TOT tables to be reset, so a previously processed versions of the tables won't be ignored.

Parameters
path- decode path that will be affected
void ASI_SetAppSiMode ( U8BIT  path,
E_APP_SI_MODE  si_mode 
)

Sets application SI mode - used before STB_DPStartSI() is called.

Parameters
pathdecode path
si_moderequired mode
void ASI_SetEITParserFunction ( F_EitParser  parser_func)

Sets a function that will be called when parsing an EIT table and a descriptor is found that the standard code doesn't know how to parse.

Parameters
parser_funcfunction pointer
void ASI_SetEITScheduleLimit ( U16BIT  limit_hours)

Sets the number of hours of EIT data that's kept for each service that hasn't its had EIT schedule disabled.

Parameters
limit_hoursnumber of hours to EIT data to be kept. 0 turns this feature off and all data will be kept.
void ASI_SetSearchServiceType ( E_SEARCH_SERVICE_TYPE  service_type)

Set the type for services that should be added during a service search.

Parameters
service_typeall, free-to-air, or scrambled
void ASI_SetServiceUpdateMode ( E_SERVICE_UPDATE_MODE  update_mode,
E_SORT_ORDER  sort_order 
)

Set the update mode to specify behaviour when SDT or NIT version changes and services are added, deleted or modified.

Set the update mode to specify behaviour when SDT or NIT version changes and whether services are automatically added, deleted or modified.

Parameters
update_modeignore changes (default) or automatically add/remove services
sort_orderspecify where new services should be added to database
void ASI_SetStandbyState ( BOOLEAN  standby_state)

Performs the neccessary actions for this module when entering/exiting standby according to the value passed in standby_state.

Parameters
standby_stateif set TRUE indicates that the STB is entering standby mode and if set FALSE indicates shat the STB is exiting from standby mode.
void ASI_SetUpdateBatFunction ( F_BatTableUpdate  update_func)

Sets a function that will be called when a BAT table is received.

Parameters
update_funcfunction pointer
void ASI_SetUpdateEitFunction ( F_EitTableUpdate  update_func)

Sets a function that will be called when an EIT table is received.

Parameters
update_funcfunction pointer
void ASI_SetUpdateNitFunction ( F_NitTableUpdate  update_func)

Sets a function that will be called when an NIT table is received.

Parameters
update_funcfunction pointer
void ASI_SetUpdatePmtFunction ( F_PmtTableUpdate  update_func)

Sets a function that will be called when a PMT table is received.

Parameters
update_funcfunction pointer
void ASI_SetUpdateSdtFunction ( F_SdtTableUpdate  update_func)

Sets a function that will be called when an SDT table is received.

Parameters
update_funcfunction pointer
BOOLEAN ASI_SSUGetMandatory ( void  )

Returns the flag indicating whether the SSU is mandatory and so can't be refused.

Returns
TRUE if the SSU is mandatory, FALSE otherwise
BOOLEAN ASI_SSURefused ( void  )

Returns the flag indicating whether the SSU was refused.

Returns
TRUE if the SSU was refused, FALSE otherwise
void ASI_SSUSetMandatory ( BOOLEAN  mandatory)

Sets the flag indicating whether the SSU can be refused by the user.

Parameters
mandatoryTRUE if the SSU can't be refused by the user, FALSE otherwise