DVBCore  22.11.0
Open Source DVB Engine
dba.h
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 /* Pre-processor mechanism so multiple inclusions don't cause compilation error */
26 
27 #ifndef _DBA_H
28 #define _DBA_H
29 
30 #include "techtype.h"
31 
32 //---Constant and macro definitions for public use-----------------------------
33 
34 /* Field IDs MUST be unique but need not be contiguous within records range 0x0000 to 0xffff
35  * some fields are used in more than one record spare IDs are left for future expansion. */
36 
37 /* Fields common to more than one record type */
38 #define DBA_FIELD_PARENT 0x0100
39 #define DBA_FIELD_REC_NAME 0x0101
40 #define DBA_FIELD_ORIG_NET_ID 0x0102
41 #define DBA_FIELD_NET_ID 0x0103
42 #define DBA_FIELD_TRANSPORT_ID 0x0104
43 #define DBA_FIELD_SERVICE_ID 0x0105
44 #define DBA_FIELD_VERSION 0x0106
45 #define DBA_FIELD_URL 0x0107
46 
47 /* Fields in LNB records */
48 #define DBA_FIELD_LNB_TYPE 0x0202
49 #define DBA_FIELD_LNB_22K 0x0203
50 #define DBA_FIELD_LNB_12V 0x0204
51 #define DBA_FIELD_LNB_PULSEPOSN 0x0205
52 #define DBA_FIELD_LNB_DISPOSN 0x0206
53 #define DBA_FIELD_LNB_DISTONE 0x0207
54 #define DBA_FIELD_LNB_DISCSWITCH 0x0208
55 #define DBA_FIELD_LNB_DISUSWITCH 0x0209
56 #define DBA_FIELD_LNB_DISSMATV 0x020a
57 #define DBA_FIELD_LNB_DISREPEAT 0x020b
58 #define DBA_FIELD_LNB_UNICABLEFREQ 0x020c
59 #define DBA_FIELD_LNB_UNICABLECHAN 0x020d
60 #define DBA_FIELD_LNB_POWER 0x020e
61 #define DBA_FIELD_LNB_NAME 0x020f
62 
63 /* Fields in satellite records */
64 #define DBA_FIELD_SAT_DISH 0x0300
65 #define DBA_FIELD_SAT_LONGWE 0x0301
66 #define DBA_FIELD_SAT_LONGPOS 0x0302
67 
68 /* Fields in network records */
69 #define DBA_FIELD_PROFILE_TYPE 0x0401
70 #define DBA_FIELD_PROFILE_CAM_ID 0x0402
71 #define DBA_FIELD_PROFILE_NAME 0x0403
72 #define DBA_FIELD_OPERATOR_SEARCH 0x0404
73 #define DBA_FIELD_OP_SEARCH_DATE 0x0405
74 #define DBA_FIELD_OP_SEARCH_TIME 0x0406
75 
76 /* Fields common to transport records */
77 #define DBA_FIELD_TRAN_FREQ 0x0500
78 #define DBA_FIELD_TRAN_SRATE 0x0501
79 #define DBA_FIELD_TRAN_SIGNAL_STRENGTH 0x0502
80 #define DBA_FIELD_TRAN_SIGNAL_QUALITY 0x0503
81 
82 /* Fields in satellite transport records */
83 #define DBA_FIELD_STRAN_POL 0x0600
84 #define DBA_FIELD_STRAN_FEC 0x0601
85 #define DBA_FIELD_STRAN_DVBS2 0x0602
86 #define DBA_FIELD_STRAN_MODULATION 0x0603
87 
88 /* Fields in terrestrial transport records */
89 #define DBA_FIELD_TTRAN_MODE 0x0700
90 #define DBA_FIELD_TTRAN_TERR_TYPE 0x0701
91 #define DBA_FIELD_TTRAN_PLP_ID 0x0702
92 #define DBA_FIELD_TTRAN_BWIDTH 0x0703
93 
94 /* Fields in cable transport records */
95 #define DBA_FIELD_CTRAN_MODE 0x0800
96 
97 /* Fields common to service records */
98 #define DBA_FIELD_SERV_ID 0x0900
99 #define DBA_FIELD_SERV_TYPE 0x0901
100 #define DBA_FIELD_SERV_LCN 0x0902
101 #define DBA_FIELD_SERV_REQ_LCN 0x0903
102 #define DBA_FIELD_SERV_HIDDEN 0x0904
103 #define DBA_FIELD_SERV_SELECTABLE 0x0905
104 #define DBA_FIELD_SERV_LOCKED 0x0906
105 #define DBA_FIELD_SERV_SCHED_DISABLED 0x0907
106 #define DBA_FIELD_SERV_NOWNEXT_DISABLED 0x0908
107 #define DBA_FIELD_SERV_FAV_GROUPS 0x0909
108 #define DBA_FIELD_SERV_FREESAT_ID 0x090a
109 #define DBA_FIELD_SERV_REGION_ID 0x090b
110 #define DBA_FIELD_SERV_LCN_EDITABLE 0x090c
111 #define DBA_FIELD_SERV_DELETED 0x090d
112 #define DBA_FIELD_SERV_PORT 0x090e
113 #define DBA_FIELD_SERV_FEC_LAYER 0x090f
114 #define DBA_FIELD_SERV_FEC_PORT1 0x0910
115 #define DBA_FIELD_SERV_FEC_PORT2 0x0911
116 
117 /* Fields in timer records */
118 #define DBA_FIELD_TIMER_HANDLE 0x0a00
119 #define DBA_FIELD_TIMER_STARTTIME 0x0a01
120 #define DBA_FIELD_TIMER_DURATION 0x0a02
121 #define DBA_FIELD_TIMER_TYPE 0x0a03
122 #define DBA_FIELD_TIMER_FREQUENCY 0x0a04
123 #define DBA_FIELD_TIMER_RAMPVOLUME 0x0a05
124 #define DBA_FIELD_TIMER_EVENTID 0x0a06
125 #define DBA_FIELD_TIMER_NOTIFY_TIME 0x0a07
126 #define DBA_FIELD_TIMER_CRID 0x0a08
127 #define DBA_FIELD_TIMER_DISKID 0x0a09
128 #define DBA_FIELD_TIMER_OTHERCRID 0x0a0a
129 #define DBA_FIELD_TIMER_MISSED 0x0a0b
130 #define DBA_FIELD_TIMER_EVENT_TRIGGERED 0x0a0c
131 #define DBA_FIELD_TIMER_ADDITIONAL_INFO 0x0a0d
132 #define DBA_FIELD_TIMER_START_PADDING 0x0a0e
133 #define DBA_FIELD_TIMER_END_PADDING 0x0a0f
134 #define DBA_FIELD_TIMER_DO_NOT_DELETE 0x0a10
135 
136 /* Fields in CRID records */
137 #define DBA_FIELD_CRID_EIT_DATE 0x0b00
138 #define DBA_FIELD_CRID_SERIES 0x0b01
139 #define DBA_FIELD_CRID_RECOMMENDED 0x0b02
140 #define DBA_FIELD_CRID_DO_NOT_DELETE 0x0b03
141 
142 /* Fields in favourite lists and favourite services */
143 #define DBA_FIELD_FAVLIST_ID 0x0c00
144 #define DBA_FIELD_FAVLIST_INDEX 0x0c01
145 #define DBA_FIELD_FAVLIST_USER_DATA 0x0c02
146 
147 /* Fields used to store event information */
148 #define DBA_FIELD_EVENT_STARTTIME 0x0d00
149 #define DBA_FIELD_EVENT_DURATION 0x0d01
150 #define DBA_FIELD_EVENT_ID 0x0d02
151 #define DBA_FIELD_EVENT_CONTENT 0x0d03
152 #define DBA_FIELD_EVENT_AGE_RATING 0x0d04
153 #define DBA_FIELD_EVENT_SCRAMBLED 0x0d05
154 #define DBA_FIELD_EVENT_SUBTITLES 0x0d06
155 #define DBA_FIELD_EVENT_AUDIO_DESC 0x0d07
156 #define DBA_FIELD_EVENT_FREE_TO_AIR 0x0d08
157 #define DBA_FIELD_EVENT_DO_NOT_SCRAMBLE 0x0d09
158 #define DBA_FIELD_EVENT_NAME 0x0d0a
159 #define DBA_FIELD_EVENT_DESCRIPTION 0x0d0b
160 #define DBA_FIELD_EVENT_EXTENDED_DESC 0x0d0c
161 #define DBA_FIELD_EVENT_GUIDANCE 0x0d0d
162 #define DBA_FIELD_EVENT_CONTENT_DATA 0x0d0e
163 
164 /* Fields in LNB band records */
165 #define DBA_FIELD_BAND_POLARITY 0x0e00
166 #define DBA_FIELD_BAND_MIN_FREQUENCY 0x0e01
167 #define DBA_FIELD_BAND_MAX_FREQUENCY 0x0e02
168 #define DBA_FIELD_BAND_LOCAL_OSC_FREQUENCY 0x0e03
169 #define DBA_FIELD_BAND_LNB_VOLTAGE 0x0e04
170 #define DBA_FIELD_BAND_22_KHZ 0x0e05
171 
172 
173 //---Enumerations for public use-----------------------------------------------
174 
175 /* Set of record types supported by the database, though not all types may be supported
176  * by all database implementations */
177 typedef enum
178 {
179  DBA_RECORD_LNB = 0,
180  DBA_RECORD_SATELLITE,
181  DBA_RECORD_NETWORK,
182  DBA_RECORD_SAT_TRANSPORT,
183  DBA_RECORD_TERR_TRANSPORT,
184  DBA_RECORD_CAB_TRANSPORT,
185  DBA_RECORD_SERVICE,
186  DBA_RECORD_TIMER,
187  DBA_RECORD_CRID,
188  DBA_RECORD_FAV_LIST,
189  DBA_RECORD_FAV_SERV,
190  DBA_RECORD_LNB_BAND,
191  DBA_RECORD_CICAM_TIMER,
192  DBA_RECORD_IP_TRANSPORT,
193  /*DBA_RECORD_EVENT,*/
194  DBA_NUM_RECORDS /* This must be the last value in the enum */
195 } E_DBA_RECORDS;
196 
197 
198 //---Global type defs for public use-------------------------------------------
199 
200 //---Global Function prototypes for public use---------------------------------
201 
206 BOOLEAN DBA_Initialise(void);
207 
212 void DBA_Terminate(void);
213 
223 BOOLEAN DBA_LoadDatabase(U8BIT *pathname);
224 
230 BOOLEAN DBA_SaveDatabase(void);
231 
238 BOOLEAN DBA_ClearDatabase(void);
239 
248 BOOLEAN DBA_BackupDatabase(U8BIT *pathname);
249 
254 BOOLEAN DBA_CanRestoreDatabase(void);
255 
260 BOOLEAN DBA_RestoreDatabase(void);
261 
266 void DBA_EraseBackupDatabase(void);
267 
273 BOOLEAN DBA_ExportToXML(U8BIT *xml_pathname);
274 
282 BOOLEAN DBA_ImportFromXML(U8BIT *xml_pathname);
283 
287 void DBA_LockDatabase(void);
288 
292 void DBA_UnlockDatabase(void);
293 
298 U8BIT* DBA_DatabaseVersion(void);
299 
306 U32BIT DBA_DatabaseFileSize(U32BIT *max_size);
307 
315 void* DBA_CreateRecord(U32BIT record_id, void *parent);
316 
322 void DBA_DestroyRecord(void *record);
323 
334 void* DBA_FindRecord(U32BIT record_id, void *parent, void *last_rec);
335 
341 void DBA_SetRecordParent(void *record, void *parent);
342 
348 void* DBA_GetRecordParent(void *record);
349 
356 void DBA_SaveRecord(void *record);
357 
366 BOOLEAN DBA_SetFieldValue(void *record, U32BIT field_id, U32BIT value);
367 
379 BOOLEAN DBA_SetFieldString(void *record, U32BIT field_id, U8BIT *string, U16BIT num_bytes);
380 
393 BOOLEAN DBA_SetFieldLangString(void *record, U32BIT field_id, U32BIT lang_code, U8BIT *string,
394  U16BIT num_bytes);
395 
406 BOOLEAN DBA_SetFieldData(void *record, U32BIT field_id, U8BIT *data, U16BIT num_bytes);
407 
416 BOOLEAN DBA_GetFieldValue(void *record, U32BIT field_id, U32BIT *value);
417 
429 BOOLEAN DBA_GetFieldString(void *record, U32BIT field_id, U8BIT **string, U16BIT *num_bytes);
430 
443 BOOLEAN DBA_GetFieldLangString(void *record, U32BIT field_id, U32BIT lang_code, U8BIT **string,
444  U16BIT *num_bytes);
445 
457 BOOLEAN DBA_GetFieldData(void *record, U32BIT field_id, U8BIT **data, U16BIT *num_bytes);
458 
464 U32BIT DBA_DataBlockSize(U32BIT data_block_id);
465 
473 U32BIT DBA_DataBlockRead(U32BIT data_block_id, U8BIT *data, U32BIT max_num_bytes);
474 
482 BOOLEAN DBA_DataBlockWrite(U32BIT data_block_id, U8BIT *data, U32BIT num_bytes);
483 
484 #endif /* _DBA_H */
485 
BOOLEAN DBA_GetFieldData(void *record, U32BIT field_id, U8BIT **data, U16BIT *num_bytes)
Gets the data of a record's field. The function will fail if the record doesn't exist, the record doesn't include the given field, or the field isn't a data field. The pointer to the data returned will be to the data held by the database, so the data must not be changed.
Definition: dba_nvm.c:1488
void * DBA_FindRecord(U32BIT record_id, void *parent, void *last_rec)
Finds the next record, of the given type, that comes after last_rec. last_rec must be the same type o...
Definition: dba_nvm.c:1055
BOOLEAN DBA_RestoreDatabase(void)
Restores the working database from a previously made backup copy.
Definition: dba_nvm.c:789
U8BIT * DBA_DatabaseVersion(void)
Returns a version string representing the working database.
Definition: dba_nvm.c:887
void DBA_SaveRecord(void *record)
Forces a record to be saved to non-volatile storage. Depending on the implementation, this function may not do anything if the data is updated to non-volatile storage as any records and/or fields are created or updated.
Definition: dba_nvm.c:1157
void DBA_DestroyRecord(void *record)
Destroys the given record, removing it from the database and freeing any memory associated with it...
Definition: dba_nvm.c:1013
BOOLEAN DBA_GetFieldString(void *record, U32BIT field_id, U8BIT **string, U16BIT *num_bytes)
Gets the string value of a record's field. The function will fail if the record doesn't exist...
Definition: dba_nvm.c:1400
BOOLEAN DBA_SetFieldData(void *record, U32BIT field_id, U8BIT *data, U16BIT num_bytes)
Set a variable amount of data of a record's field. The function will fail if the record doesn't exist...
Definition: dba_nvm.c:1318
BOOLEAN DBA_SetFieldLangString(void *record, U32BIT field_id, U32BIT lang_code, U8BIT *string, U16BIT num_bytes)
Set the string value of a record's field. The function will fail if the record doesn't exist...
Definition: dba_nvm.c:1291
void DBA_SetRecordParent(void *record, void *parent)
Set of change the parent of the given record.
Definition: dba_nvm.c:1080
BOOLEAN DBA_SetFieldValue(void *record, U32BIT field_id, U32BIT value)
Set the value of a record's field. The function will fail if the record doesn't exist, the record doesn't include the given field, or the field isn't a value field.
Definition: dba_nvm.c:1175
void DBA_LockDatabase(void)
Locks the database to prevent access from other threads or processes.
Definition: dba_nvm.c:866
U32BIT DBA_DataBlockSize(U32BIT data_block_id)
Returns the number of bytes available for the given data block.
Definition: dba_nvm.c:1508
void * DBA_CreateRecord(U32BIT record_id, void *parent)
Creates a new record of the given type, adding it to the database as a child of the given parent reco...
Definition: dba_nvm.c:940
BOOLEAN DBA_BackupDatabase(U8BIT *pathname)
Creates a backup copy of the working database. Whether the backup database is saved to non-volatile s...
Definition: dba_nvm.c:723
BOOLEAN DBA_GetFieldValue(void *record, U32BIT field_id, U32BIT *value)
Gets the value of a record's field. The function will fail if the record doesn't exist, the record doesn't include the given field, or the field isn't a value field.
Definition: dba_nvm.c:1341
BOOLEAN DBA_GetFieldLangString(void *record, U32BIT field_id, U32BIT lang_code, U8BIT **string, U16BIT *num_bytes)
Gets the string value of a record's field. The function will fail if the record doesn't exist...
Definition: dba_nvm.c:1460
BOOLEAN DBA_DataBlockWrite(U32BIT data_block_id, U8BIT *data, U32BIT num_bytes)
Writes a block of data into the database from the given buffer.
Definition: dba_nvm.c:1560
BOOLEAN DBA_LoadDatabase(U8BIT *pathname)
Reads a database from non-volatile storage, creating any structures in memory that will be required t...
Definition: dba_nvm.c:541
BOOLEAN DBA_SetFieldString(void *record, U32BIT field_id, U8BIT *string, U16BIT num_bytes)
Set the string value of a record's field. The function will fail if the record doesn't exist...
Definition: dba_nvm.c:1227
U32BIT DBA_DataBlockRead(U32BIT data_block_id, U8BIT *data, U32BIT max_num_bytes)
Read a block of data from the database into the given buffer.
Definition: dba_nvm.c:1528
System Wide Global Technical Data Type Definitions.
void DBA_EraseBackupDatabase(void)
Erases the backup copy of the database. If data was stored in non-volatile storage then this should b...
Definition: dba_nvm.c:822
BOOLEAN DBA_ClearDatabase(void)
Clears the working database of all records. Following this call, it should still be possible to acces...
Definition: dba_nvm.c:694
void * DBA_GetRecordParent(void *record)
Returns the handle to the parent of the given record.
Definition: dba_nvm.c:1129
void DBA_Terminate(void)
Releases any resources acquired by initialisation and clears any currently loaded database...
Definition: dba_nvm.c:508
void DBA_UnlockDatabase(void)
Unlocks the database to allow other threads or processes to access it.
Definition: dba_nvm.c:876
U32BIT DBA_DatabaseFileSize(U32BIT *max_size)
Returns the size in bytes of the database as stored in non-volatile storage.
Definition: dba_nvm.c:915
BOOLEAN DBA_ImportFromXML(U8BIT *xml_pathname)
Imports records from the given XML file into the working database. If a record already exists in the ...
Definition: dba_nvm.c:855
BOOLEAN DBA_Initialise(void)
Performs any initialisation required prior to the database being loaded.
Definition: dba_nvm.c:482
BOOLEAN DBA_CanRestoreDatabase(void)
Checks whether the working database can be restored from a backup copy.
Definition: dba_nvm.c:766
BOOLEAN DBA_SaveDatabase(void)
Saves any changes made to the working database to non-volatile storage. If saving to a file...
Definition: dba_nvm.c:667
BOOLEAN DBA_ExportToXML(U8BIT *xml_pathname)
Export the working database to an XML file.
Definition: dba_nvm.c:840