RDK Documentation (Open Sourced RDK Components)
simgr.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #ifndef _SIMGR_H_
21 #define _SIMGR_H_
22 
23 #include <list>
24 #include <string>
25 #include <stdint.h>
26 #include <libxml/xmlmemory.h>
27 #include <libxml/parser.h>
28 
29 using namespace std;
30 
31 #define TRUE 1
32 #define FALSE 0
33 
34 /**
35  * @addtogroup SI_CACHE_TYPES
36  * @{
37  */
38 
39 #define SI_CACHE_FILE_VERSION 0x101u
40 #define SI_CACHE_MAX_FREQUENCIES 255
41 #define SI_CACHE_CRC_QUOTIENT 0x04C11DB7
42 #define HERTZ 1000000
43 
44 #define DEFAULT_SI_CACHE_FILENAME "SICache"
45 
46 /**
47  * @addtogroup sifields
48  * The following macros represents the default values for SI fields (OCAP specified)
49  * sourceId and tsId are set by default to -1
50  * @{
51  */
52 /* Default values for SI fields (OCAP specified) */
53 /* sourceId and tsId are set by default to -1 */
54 #define SOURCEID_UNKNOWN (0xFFFFFFFF)
55 #define TSID_UNKNOWN (0xFFFFFFFF) // ECR 1072
56 #define SI_DEFAULT_PROGRAM_NUMBER (0xFFFFFFFF)
57 #define PROGRAM_NUMBER_UNKNOWN (0xFFFF)
58 #define VIRTUAL_CHANNEL_UNKNOWN (0xFFFF)
59 #define SI_DEFAULT_CHANNEL_NUMBER 0xFFFFFFFF
60 
61 typedef enum _SIFileType_t_ {
62  SI_FILETYPE_XML,
63  SI_FILETYPE_BINARY,
64 }SIFileType_t;
65 
66 /**
67  * @enum siEntryState_
68  * @brief This enumeration represents the state of a service entry based on of SVCT-DCM, SVCT-VCM signaling.
69  * @ingroup Outofbanddatastructures
70  */
71 typedef enum _siEntryState_
72 {
73  SIENTRY_UNSPECIFIED = 0,
74  SIENTRY_PRESENT_IN_DCM = 0x01, //!< Present in DCM
75  SIENTRY_DEFINED = 0x02, //!< Defined in DCM
76  SIENTRY_MAPPED = 0x04, //!< Mapped in VCM
78  | SIENTRY_MAPPED, //!< Marked defined in SVCT-DCM, mapped in SVCT-VCM
79  SIENTRY_DEFINED_UNMAPPED = SIENTRY_PRESENT_IN_DCM | SIENTRY_DEFINED, //!< Marked defined in SVCT-DCM, not mapped in SVCT-VCM
80  SIENTRY_UNDEFINED_MAPPED = SIENTRY_PRESENT_IN_DCM | SIENTRY_MAPPED, //!< Marked undefined in SVCT-DCM, mapped in SVCT-VCM
81  SIENTRY_UNDEFINED_UNMAPPED = SIENTRY_PRESENT_IN_DCM
82 // Marked undefined SVCT-DCM, not mapped in SVCT-VCM
83 } siEntryState;
84 
85 /**
86  * @enum siChannelType
87  * @brief This enumeration represents the service information channel types such as normal, hidden and so on.
88  * @ingroup Outofbanddatastructures
89  */
90 typedef enum _siChannelType
91 {
92  CHANNEL_TYPE_NORMAL = 0x00,
93  CHANNEL_TYPE_HIDDEN = 0x01,
94  CHANNEL_TYPE_RESERVED_2 = 0x02,
95  CHANNEL_TYPE_RESERVED_3 = 0x03,
96  CHANNEL_TYPE_RESERVED_4 = 0x04,
97  CHANNEL_TYPE_RESERVED_5 = 0x05,
98  CHANNEL_TYPE_RESERVED_6 = 0x06,
99  CHANNEL_TYPE_RESERVED_7 = 0x07,
100  CHANNEL_TYPE_RESERVED_8 = 0x08,
101  CHANNEL_TYPE_RESERVED_9 = 0x09,
102  CHANNEL_TYPE_RESERVED_10 = 0x0A,
103  CHANNEL_TYPE_RESERVED_11 = 0x0B,
104  CHANNEL_TYPE_RESERVED_12 = 0x0C,
105  CHANNEL_TYPE_RESERVED_13 = 0x0D,
106  CHANNEL_TYPE_RESERVED_14 = 0x0E,
107  CHANNEL_TYPE_RESERVED_15 = 0x0F,
108 } siChannelType;
109 
110 typedef enum _siVideoStandard
111 {
112  VIDEO_STANDARD_NTSC = 0x00,
113  VIDEO_STANDARD_PAL625 = 0x01,
114  VIDEO_STANDARD_PAL525 = 0x02,
115  VIDEO_STANDARD_SECAM = 0x03,
116  VIDEO_STANDARD_MAC = 0x04,
117  VIDEO_STANDARD_UNKNOWN = 0x05
118 } siVideoStandard;
119 
120 /**
121  * @enum siServiceType
122  * @brief Service type values represents "digital television",
123  * "digital radio", "NVOD reference service", "NVOD time-shifted service",
124  * "analog television", "analog radio", "data broadcast" and "application".
125  *
126  * (These values are mappable to the ATSC service type in the VCT table and
127  * the DVB service type in the Service Descriptor.)
128  * @ingroup Outofbanddatastructures
129  */
130 typedef enum _siServiceType
131 {
132  SI_SERVICE_TYPE_UNKNOWN = 0x00,
133  SI_SERVICE_ANALOG_TV = 0x01,
134  SI_SERVICE_DIGITAL_TV = 0x02,
135  SI_SERVICE_DIGITAL_RADIO = 0x03,
136  SI_SERVICE_DATA_BROADCAST = 0x04,
137  SI_SERVICE_NVOD_REFERENCE = 0x05,
138  SI_SERVICE_NVOD_TIME_SHIFTED = 0x06,
139  SI_SERVICE_ANALOG_RADIO = 0x07,
140  SI_SERVICE_DATA_APPLICATION = 0x08
141 } siServiceType;
142 
143 typedef struct ProgramDetails_s
144 {
145  uint32_t virtual_channel_number;
146  uint32_t source_id;
147  uint32_t modulation_mode;
148  uint32_t carrier_frequency;
149  uint32_t program_number;
151 
152 #if 0
153 typedef struct _LangSpecificStringList
154 {
155  char language[4]; /* 3-character ISO 639 language code + null terminator */
156  char *string;
157  struct LangSpecificStringList *next;
158 } LangSpecificStringList;
159 #endif
160 
161 typedef struct _SourceNameEntry
162 {
163  bool appType;
164  uint32_t id; //!< if appType=FALSE, sourceID otherwise appID
165  bool mapped; // !<True if mapped by a virtual channel false for DSG service name
166  void *source_names; // !< NTT_SNS, CVCT
167  void *source_long_names; //!< NTT_SNS
168  struct _SourceNameEntry* next; //!< Next source name entry
170 
172 {
173  uint32_t ref_count;
174  uint32_t activation_time; //!< SVCT
175  long long ptime_service;
176  uint32_t ts_handle;
177  uint32_t program; // !<Program info for this service. Can be shared with other rmf_SiTableEntry elements,
178  uint32_t tuner_id; // !< '0' for OOB, start from '1' for IB
179  int32_t valid;
180  uint16_t virtual_channel_number;
181  int32_t isAppType; //!< For DSG app
182  uint32_t source_id; //!< SVCT
183  uint32_t app_id; //
184  uint32_t dsgAttached;
185  uint32_t dsg_attach_count; //!< DSG attach count
186  uint32_t state;
187  uint32_t channel_type; //!< SVCT
188  uint32_t video_standard; //!< SVCT (NTSC, PAL etc.)
189  uint32_t service_type; //!< SVCT (desc)
190 
191  void * source_name_entry; //!< Reference to the corresponding NTT_SNS entry
192  void *descriptions; //!< LVCT/CVCT (desc)
193  uint8_t freq_index; //!< SVCT
194  uint8_t mode_index; //!< SVCT
195  uint32_t major_channel_number;
196  uint32_t minor_channel_number; //!< SVCT (desc)
197 
198  uint16_t program_number; //!< SVCT
199  uint8_t transport_type; //!< SVCT (0==MPEG2, 1==non-MPEG2)
200  int32_t scrambled; //!< SVCT
201  void* hn_stream_session; //!< HN stream session handle
202  uint32_t hn_attach_count; //!< HN stream session PSI attach / registration count
203  siTableEntry* next; //!< next service entry
204 } ;
205 
207 {
208  protected:
209  list<ProgramDetails> m_program_list;
210  int numOfServices;
211 
212  private:
213  bool load_xml_file(string xml_file);
214  int xml_parse_attributes(xmlNodePtr parent);
215  void init_mpeg2_crc(void);
216  uint32_t calc_mpeg2_crc(uint8_t * data, uint32_t len);
217  void init_si_entry(siTableEntry *si_entry);
218  bool parse_program_details(siTableEntry **si_entry_head, uint32_t frequency[], uint32_t modulation[], int &f_index, int &m_index);
219  bool cache_si_data ( string sidbFileName);
220  bool cache_sns_data ( string snsdbFileName);
221  bool write_crc_for_si_cache(string sidbFileName);
222  bool write_crc_for_si_and_sns_cache(string sidbFileName, string snsdbFileName);
223  unsigned int get_file_size(const char * location);
224  bool load_si_data(string sidbFileName);
225 
226  public:
227  SiManager();
228  bool Load(string file_name, int mode);
229  bool GenerateSICache ( string sidbFileName );
230  bool GenerateSICache ( string sidbFileName, string snsdbFileName );
231  bool GenerateXML (string sixmlFileName);
232  void DumpChannelMap();
233 };
234 
235 #endif // _SIMGR_H_
236 
237 /**
238  * @}
239  */
240 
SIENTRY_DEFINED
@ SIENTRY_DEFINED
Defined in DCM.
Definition: simgr.h:75
siTableEntry::hn_stream_session
void * hn_stream_session
HN stream session handle.
Definition: simgr.h:201
siTableEntry::video_standard
uint32_t video_standard
SVCT (NTSC, PAL etc.)
Definition: simgr.h:188
siTableEntry::descriptions
void * descriptions
LVCT/CVCT (desc)
Definition: simgr.h:192
siTableEntry::activation_time
uint32_t activation_time
SVCT.
Definition: simgr.h:174
siTableEntry::mode_index
uint8_t mode_index
SVCT.
Definition: simgr.h:194
siTableEntry::dsg_attach_count
uint32_t dsg_attach_count
DSG attach count.
Definition: simgr.h:185
_SourceNameEntry::id
uint32_t id
if appType=FALSE, sourceID otherwise appID
Definition: simgr.h:164
siTableEntry::program_number
uint16_t program_number
SVCT.
Definition: simgr.h:198
SIENTRY_DEFINED_MAPPED
@ SIENTRY_DEFINED_MAPPED
Marked defined in SVCT-DCM, mapped in SVCT-VCM.
Definition: simgr.h:77
SIENTRY_MAPPED
@ SIENTRY_MAPPED
Mapped in VCM.
Definition: simgr.h:76
siTableEntry::next
siTableEntry * next
next service entry
Definition: simgr.h:203
_SourceNameEntry::next
struct _SourceNameEntry * next
Next source name entry.
Definition: simgr.h:168
siTableEntry::transport_type
uint8_t transport_type
SVCT (0==MPEG2, 1==non-MPEG2)
Definition: simgr.h:199
SiManager
Definition: simgr.h:206
_SourceNameEntry
Definition: simgr.h:161
siTableEntry::hn_attach_count
uint32_t hn_attach_count
HN stream session PSI attach / registration count.
Definition: simgr.h:202
siTableEntry::isAppType
int32_t isAppType
For DSG app.
Definition: simgr.h:181
siTableEntry::minor_channel_number
uint32_t minor_channel_number
SVCT (desc)
Definition: simgr.h:196
SIENTRY_UNDEFINED_MAPPED
@ SIENTRY_UNDEFINED_MAPPED
Marked undefined in SVCT-DCM, mapped in SVCT-VCM.
Definition: simgr.h:80
ProgramDetails_s
Definition: simgr.h:143
siTableEntry
Definition: simgr.h:171
siTableEntry::source_name_entry
void * source_name_entry
Reference to the corresponding NTT_SNS entry.
Definition: simgr.h:191
siTableEntry::channel_type
uint32_t channel_type
SVCT.
Definition: simgr.h:187
siTableEntry::scrambled
int32_t scrambled
SVCT.
Definition: simgr.h:200
SIENTRY_PRESENT_IN_DCM
@ SIENTRY_PRESENT_IN_DCM
Present in DCM.
Definition: simgr.h:74
siTableEntry::freq_index
uint8_t freq_index
SVCT.
Definition: simgr.h:193
_siEntryState_
_siEntryState_
Definition: simgr.h:71
siTableEntry::service_type
uint32_t service_type
SVCT (desc)
Definition: simgr.h:189
siTableEntry::source_id
uint32_t source_id
SVCT.
Definition: simgr.h:182
SIENTRY_DEFINED_UNMAPPED
@ SIENTRY_DEFINED_UNMAPPED
Marked defined in SVCT-DCM, not mapped in SVCT-VCM.
Definition: simgr.h:79
_SourceNameEntry::source_long_names
void * source_long_names
NTT_SNS.
Definition: simgr.h:167