summaryrefslogtreecommitdiff
path: root/libdtv/libsi/include
diff options
context:
space:
mode:
Diffstat (limited to 'libdtv/libsi/include')
-rw-r--r--libdtv/libsi/include/libsi.h248
-rw-r--r--libdtv/libsi/include/si_tables.h156
2 files changed, 356 insertions, 48 deletions
diff --git a/libdtv/libsi/include/libsi.h b/libdtv/libsi/include/libsi.h
index 8e9e260..715d18b 100644
--- a/libdtv/libsi/include/libsi.h
+++ b/libdtv/libsi/include/libsi.h
@@ -4,11 +4,13 @@
/// ///
//////////////////////////////////////////////////////////////
-// $Revision: 1.6 $
-// $Date: 2002/01/30 17:04:13 $
+// $Revision: 1.7 $
+// $Date: 2003/02/04 18:45:36 $
// $Author: hakenes $
//
-// (C) 2001 Rolf Hakenes <hakenes@hippomi.de>, under the GNU GPL.
+// (C) 2001-03 Rolf Hakenes <hakenes@hippomi.de>, under the
+// GNU GPL with contribution of Oleg Assovski,
+// www.satmania.com
//
// libsi is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -38,9 +40,9 @@
/* Program Identifier */
#define PID_PAT 0x00 /* Program Association Table */
-#define PID_BAT 0x01 /* Bouquet Association Table */
#define PID_CAT 0x01 /* Conditional Access Table */
#define PID_NIT 0x10 /* Network Information Table */
+#define PID_BAT 0x11 /* Bouquet Association Table */
#define PID_SDT 0x11 /* Service Description Table */
#define PID_EIT 0x12 /* Event Information Table */
#define PID_RST 0x13 /* Running Status Table */
@@ -75,12 +77,13 @@
#define TID_TOT 0x73 /* Time Offset Section */
#define TID_CA_ECM_0 0x80
#define TID_CA_ECM_1 0x81
+#define TID_CA_EMM 0x82
-#define TID_BAT 0x01 /* Bouquet Association Section */
+#define TID_BAT 0x4A /* Bouquet Association Section */
#define TID_EIT 0x12 /* Event Information Section */
-#define TID_RST 0x13 /* Running Status Section */
-#define TID_ST 0x14 /* Stuffung Section */
+#define TID_RST 0x71 /* Running Status Section */
+#define TID_ST 0x72 /* Stuffing Section */
/* 0xFF */ /* Reserved for future use */
/* Descriptor Identifier */
@@ -160,6 +163,40 @@
#define MAX_SECTION_BUFFER 4096
+/* NetworkInfo structure (used to store NIT/BAT information) */
+
+struct NetworkInfo {
+ struct NODE Node;
+ unsigned short ID; // NetworkID / BouquetID
+ struct LIST *Descriptors;
+ struct LIST *TransportStreams;
+};
+
+#define CreateNetworkInfo(ni, id) \
+ do { \
+ xCreateNode (ni, NULL); \
+ (ni)->ID = id; \
+ (ni)->Descriptors = xNewList(NULL); \
+ (ni)->TransportStreams = NULL; \
+ } while(0)
+
+/* TransportStream structure (NIT/BAT TS loop member) */
+
+struct TransportStream {
+ struct NODE Node;
+ int TransportStreamID;
+ unsigned short OriginalNetworkID;
+ struct LIST *Descriptors;
+};
+
+#define CreateTransportStream(ts, tsid, onid) \
+ do { \
+ xCreateNode (ts, NULL); \
+ (ts)->TransportStreamID = tsid; \
+ (ts)->OriginalNetworkID = onid; \
+ (ts)->Descriptors = xNewList(NULL); \
+ } while(0)
+
/* Strukturen zur Aufnahme der SDT und EIT Informationen */
struct Service {
@@ -305,38 +342,32 @@ struct PidInfo {
#define STREAMTYPE_13818_D 13
#define STREAMTYPE_13818_AUX 14
-/* Descriptors */
-
-#define DescriptorTag(x) ((struct Descriptor *)(x))->Tag
-struct Descriptor {
- struct NODE Node;
- unsigned short Tag;
+struct Tot {
+ time_t UTC;
+ time_t Bias;
+ struct LIST *Descriptors;
};
+#define CreateTot(tot, utc) \
+ do \
+ { \
+ xMemAlloc(sizeof(struct Tot), &tot); \
+ tot->UTC = utc; \
+ tot->Bias = ((utc - time(NULL) + 1800)/3600)*3600; \
+ tot->Descriptors = xNewList(NULL); \
+ } while (0)
-/* ConditionalAccessDescriptor */
-struct ConditionalAccessDescriptor {
+/* Descriptors */
+
+#define DescriptorTag(x) ((struct Descriptor *)(x))->Tag
+
+struct Descriptor {
struct NODE Node;
unsigned short Tag;
- unsigned short Amount; /* Data */
- unsigned char *Data;
};
-#define CreateConditionalAccessDescriptor(descr, amount, data) \
- do \
- { \
- unsigned char *tmpptr; \
- \
- xMemAlloc (amount, &tmpptr); \
- memcpy (tmpptr, data, amount); \
- xCreateNode (((struct ConditionalAccessDescriptor *)descr), NULL); \
- ((struct ConditionalAccessDescriptor *)descr)->Tag = DESCR_CA; \
- ((struct ConditionalAccessDescriptor *)descr)->Amount = amount; \
- ((struct ConditionalAccessDescriptor *)descr)->Data = tmpptr; \
- } while (0)
-
/* Iso639LanguageDescriptor */
@@ -434,19 +465,23 @@ struct AncillaryDataDescriptor {
/* BouquetNameDescriptor */
+/*
+ the same used instead of NetworkNameDescriptor because their structures
+ are identical. We pass 'tag' parameter to distinguish between them later
+*/
struct BouquetNameDescriptor {
struct NODE Node; /* Node enthält Namen */
unsigned short Tag;
};
-#define CreateBouquetNameDescriptor(descr, text) \
+#define CreateBouquetNameDescriptor(descr, text, tag) \
do \
{ \
xCreateNode (((struct BouquetNameDescriptor *)descr), NULL); \
((struct NODE *)descr)->Name = text; \
((struct NODE *)descr)->HashKey = xHashKey (text); \
- ((struct BouquetNameDescriptor *)descr)->Tag = DESCR_BOUQUET_NAME; \
+ ((struct BouquetNameDescriptor *)descr)->Tag = tag; \
} while (0)
@@ -514,6 +549,33 @@ struct CaIdentifierDescriptor {
((struct CaIdentifierDescriptor *)descr)->SystemID[num] = id
#define GetCaIdentifierID(descr, num) (((struct CaIdentifierDescriptor *)descr)->SystemID[num])
+/* CaDescriptor */
+
+struct CaDescriptor {
+ struct NODE Node;
+ unsigned short Tag;
+ unsigned short CA_type;
+ unsigned short CA_PID;
+ unsigned int ProviderID;
+ unsigned short DataLength;
+ unsigned char *Data;
+};
+
+#define CreateCaDescriptor(descr, typ, capid, len) \
+ do \
+ { \
+ xCreateNode (((struct CaDescriptor *)descr), NULL); \
+ ((struct CaDescriptor *)descr)->Tag = DESCR_CA; \
+ ((struct CaDescriptor *)descr)->CA_type = typ; \
+ ((struct CaDescriptor *)descr)->CA_PID = capid; \
+ ((struct CaDescriptor *)descr)->ProviderID = 0; \
+ ((struct CaDescriptor *)descr)->DataLength = len; \
+ xMemAlloc (len+1, &((struct CaDescriptor *)descr)->Data); \
+ } while (0)
+
+#define SetCaData(descr, num, id) \
+ ((struct CaDescriptor *)descr)->Data[num] = id
+#define GetCaData(descr, num) (((struct CaDescriptor *)descr)->Data[num])
/* StreamIdentifierDescriptor */
@@ -968,6 +1030,122 @@ struct SubtitlingItem {
xAddTail (((struct SubtitlingDescriptor *)desc)->Items, item); \
} while (0)
+/* SatelliteDeliverySystemDescriptor */
+
+struct SatelliteDeliverySystemDescriptor {
+ struct NODE Node;
+ unsigned short Tag;
+ long Frequency;
+ short OrbitalPosition;
+ char Polarization;
+ long SymbolRate;
+ char FEC;
+};
+
+#define CreateSatelliteDeliverySystemDescriptor(descr, freq, orb, polar, sr, fec) \
+ do \
+ { \
+ xCreateNode (((struct SatelliteDeliverySystemDescriptor *)descr), NULL); \
+ ((struct SatelliteDeliverySystemDescriptor *)descr)->Tag = DESCR_SAT_DEL_SYS; \
+ ((struct SatelliteDeliverySystemDescriptor *)descr)->Frequency = freq; \
+ ((struct SatelliteDeliverySystemDescriptor *)descr)->OrbitalPosition = orb; \
+ ((struct SatelliteDeliverySystemDescriptor *)descr)->Polarization = polar; \
+ ((struct SatelliteDeliverySystemDescriptor *)descr)->SymbolRate = sr; \
+ ((struct SatelliteDeliverySystemDescriptor *)descr)->FEC = fec; \
+ } while (0)
+
+/* ServiceListDescriptor */
+
+struct ServiceListDescriptor {
+ struct NODE Node;
+ unsigned short Tag;
+ struct LIST *ServiceList;
+};
+
+#define CreateServiceListDescriptor(descr) \
+ do \
+ { \
+ xCreateNode (((struct ServiceListDescriptor *)descr), NULL); \
+ ((struct ServiceListDescriptor *)descr)->Tag = DESCR_SERVICE_LIST; \
+ ((struct ServiceListDescriptor *)descr)->ServiceList = xNewList(NULL); \
+ } while (0)
+
+struct ServiceListEntry {
+ struct NODE Node;
+ int ServiceID;
+ unsigned short ServiceType;
+};
+
+#define AddServiceListEntry(descr, id, typ) \
+ do \
+ { \
+ struct ServiceListEntry *newent; \
+ \
+ xCreateNode (newent, NULL); \
+ newent->ServiceID = id; \
+ newent->ServiceType = typ; \
+ xAddTail (((struct ServiceListDescriptor *)descr)->ServiceList, newent); \
+ } while (0)
+
+/* LocalTimeOffsetDescriptor */
+
+struct LocalTimeOffsetDescriptor {
+ struct NODE Node;
+ unsigned short Tag;
+ struct LIST *LocalTimeOffsets;
+};
+
+#define CreateLocalTimeOffsetDescriptor(descr) \
+ do \
+ { \
+ xCreateNode (((struct LocalTimeOffsetDescriptor *)descr), NULL); \
+ ((struct LocalTimeOffsetDescriptor *)descr)->Tag = DESCR_LOCAL_TIME_OFF; \
+ ((struct LocalTimeOffsetDescriptor *)descr)->LocalTimeOffsets = xNewList(NULL); \
+ } while (0)
+
+struct LocalTimeOffsetEntry {
+ struct NODE Node;
+ char CountryCode[4];
+ char RegionID;
+ time_t CurrentOffset;
+ time_t ChangeTime;
+ time_t NextOffset;
+};
+
+#define CreateLocalTimeOffsetEntry(newent, code1, code2, code3, reg, co, ct, no) \
+ do \
+ { \
+ xCreateNode (newent, NULL); \
+ newent->CountryCode[0] = code1; \
+ newent->CountryCode[1] = code2; \
+ newent->CountryCode[2] = code3; \
+ newent->CountryCode[3] = '\0'; \
+ newent->RegionID = reg; \
+ newent->CurrentOffset = co; \
+ newent->ChangeTime = ct; \
+ newent->NextOffset = no; \
+ } while (0)
+
+#define AddLocalTimeOffsetEntry(descr, code1, code2, code3, reg, co, ct, no) \
+ do \
+ { \
+ struct LocalTimeOffsetEntry *newent; \
+ \
+ xCreateNode (newent, NULL); \
+ newent->CountryCode[0] = code1; \
+ newent->CountryCode[1] = code2; \
+ newent->CountryCode[2] = code3; \
+ newent->CountryCode[3] = '\0'; \
+ newent->RegionID = reg; \
+ newent->CurrentOffset = co; \
+ newent->ChangeTime = ct; \
+ newent->NextOffset = no; \
+ xAddTail (((struct LocalTimeOffsetDescriptor *)descr)->LocalTimeOffsets, newent); \
+ } while (0)
+
+#define timezonecmp(ptoe,cod,reg) \
+ (strncmp(ptoe->CountryCode, cod, 3) || (ptoe->RegionID != reg))
+
/* Prototypes */
@@ -979,13 +1157,17 @@ extern "C" {
/* si_parser.c */
struct LIST *siParsePAT (u_char *);
+struct LIST *siParseCAT (u_char *);
struct Pid *siParsePMT (u_char *);
struct LIST *siParseSDT (u_char *);
+struct LIST *siParseNIT (u_char *);
struct LIST *siParseEIT (u_char *);
time_t siParseTDT (u_char *);
+struct Tot *siParseTOT (u_char *);
void siParseDescriptors (struct LIST *, u_char *, int, u_char);
void siParseDescriptor (struct LIST *, u_char *);
char *siGetDescriptorText (u_char *, int);
+char *siGetDescriptorName (u_char *, int);
u_long crc32 (char *data, int len);
/* si_debug_services.c */
@@ -999,6 +1181,8 @@ void siDebugPids (char *, struct LIST *);
void siDebugDescriptors (char *, struct LIST *);
void siDebugEitServices (struct LIST *);
void siDebugEitEvents (char *, struct LIST *);
+void siDumpDescriptor (void *);
+void siDumpSection (void *);
#ifdef __cplusplus
}
diff --git a/libdtv/libsi/include/si_tables.h b/libdtv/libsi/include/si_tables.h
index dfda3bf..b7cfea2 100644
--- a/libdtv/libsi/include/si_tables.h
+++ b/libdtv/libsi/include/si_tables.h
@@ -5,11 +5,13 @@
/// ///
//////////////////////////////////////////////////////////////
-// $Revision: 1.3 $
-// $Date: 2001/10/07 10:24:46 $
+// $Revision: 1.4 $
+// $Date: 2003/02/04 18:45:36 $
// $Author: hakenes $
//
-// (C) 2001 Rolf Hakenes <hakenes@hippomi.de>, under the GNU GPL.
+// (C) 2001-03 Rolf Hakenes <hakenes@hippomi.de>, under the
+// GNU GPL with contribution of Oleg Assovski,
+// www.satmania.com
//
// libsi is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -32,12 +34,22 @@
#define BcdTimeToSeconds(x) ((3600 * ((10*((x##_h & 0xF0)>>4)) + (x##_h & 0xF))) + \
(60 * ((10*((x##_m & 0xF0)>>4)) + (x##_m & 0xF))) + \
((10*((x##_s & 0xF0)>>4)) + (x##_s & 0xF)))
+#define BcdTimeToMinutes(x) ((60 * ((10*((x##_h & 0xF0)>>4)) + (x##_h & 0xF))) + \
+ (((10*((x##_m & 0xF0)>>4)) + (x##_m & 0xF))))
+#define BcdCharToInt(x) (10*((x & 0xF0)>>4) + (x & 0xF))
+#define CheckBcdChar(x) ((((x & 0xF0)>>4) <= 9) && \
+ ((x & 0x0F) <= 9))
+#define CheckBcdSignedChar(x) ((((x & 0xF0)>>4) >= 0) && (((x & 0xF0)>>4) <= 9) && \
+ ((x & 0x0F) >= 0) && ((x & 0x0F) <= 9))
#define TableHasMoreSections(x) (((pat_t *)(x))->last_section_number > ((pat_t *)(x))->section_number)
#define GetTableId(x) ((pat_t *)(x))->table_id
#define GetSectionNumber(x) ((pat_t *)(x))->section_number
#define GetLastSectionNumber(x) ((pat_t *)(x))->last_section_number
#define GetServiceId(x) (((eit_t *)(x))->service_id_hi << 8) | ((eit_t *)(x))->service_id_lo
+#define GetSegmentLastSectionNumber(x) ((eit_t *)(x))->segment_last_section_number
+#define GetLastTableId(x) ((eit_t *)(x))->segment_last_table_id
+#define GetSectionLength(x) HILO(((pat_t *)(x))->section_length)
/*
*
@@ -113,7 +125,37 @@ typedef struct {
* applicable.
*
*/
- /* TO BE DONE */
+#define CAT_LEN 8
+
+typedef struct {
+ u_char table_id :8;
+#if BYTE_ORDER == BIG_ENDIAN
+ u_char section_syntax_indicator :1;
+ u_char dummy :1; // has to be 0
+ u_char :2;
+ u_char section_length_hi :4;
+#else
+ u_char section_length_hi :4;
+ u_char :2;
+ u_char dummy :1; // has to be 0
+ u_char section_syntax_indicator :1;
+#endif
+ u_char section_length_lo :8;
+ u_char reserved_1 :8;
+ u_char reserved_2 :8;
+#if BYTE_ORDER == BIG_ENDIAN
+ u_char :2;
+ u_char version_number :5;
+ u_char current_next_indicator :1;
+#else
+ u_char current_next_indicator :1;
+ u_char version_number :5;
+ u_char :2;
+#endif
+ u_char section_number :8;
+ u_char last_section_number :8;
+} cat_t;
+
/*
*
* 3) Program Map Table (PMT):
@@ -297,7 +339,7 @@ typedef struct {
* bouquet.
*
*/
- /* TO BE DONE */
+/* SEE NIT (It has the same structure but has different allowed descriptors) */
/*
*
* 2) Service Description Table (SDT):
@@ -339,6 +381,9 @@ typedef struct {
u_char :8;
} sdt_t;
+#define GetSDTTransportStreamId(x) (HILO(((sdt_t *) x)->transport_stream_id))
+#define GetSDTOriginalNetworkId(x) (HILO(((sdt_t *) x)->original_network_id))
+
#define SDT_DESCR_LEN 5
typedef struct {
@@ -483,7 +528,36 @@ typedef struct {
* to the frequent updating of the time information.
*
*/
- /* TO BE DONE */
+#define TOT_LEN 10
+
+typedef struct {
+ u_char table_id :8;
+#if BYTE_ORDER == BIG_ENDIAN
+ u_char section_syntax_indicator :1;
+ u_char :3;
+ u_char section_length_hi :4;
+#else
+ u_char section_length_hi :4;
+ u_char :3;
+ u_char section_syntax_indicator :1;
+#endif
+ u_char section_length_lo :8;
+ u_char utc_mjd_hi :8;
+ u_char utc_mjd_lo :8;
+ u_char utc_time_h :8;
+ u_char utc_time_m :8;
+ u_char utc_time_s :8;
+#if BYTE_ORDER == BIG_ENDIAN
+ u_char :4;
+ u_char descriptors_loop_length_hi :4;
+#else
+ u_char descriptors_loop_length_hi :4;
+ u_char :4;
+#endif
+ u_char descriptors_loop_length_lo :8;
+} tot_t;
+
+
/*
*
* 7) Stuffing Table (ST):
@@ -545,6 +619,25 @@ typedef struct descr_gen_struct {
#define GetDescriptorLength(x) (((descr_gen_t *) x)->descriptor_length+DESCR_GEN_LEN)
+/* 0x09 ca_descriptor */
+
+#define DESCR_CA_LEN 6
+typedef struct descr_ca_struct {
+ u_char descriptor_tag :8;
+ u_char descriptor_length :8;
+ u_char CA_type_hi :8;
+ u_char CA_type_lo :8;
+#if BYTE_ORDER == BIG_ENDIAN
+ u_char reserved :3;
+ u_char CA_PID_hi :5;
+#else
+ u_char CA_PID_hi :5;
+ u_char reserved :3;
+#endif
+ u_char CA_PID_lo :8;
+} descr_ca_t;
+#define CastCaDescriptor(x) ((descr_ca_t *)(x))
+
/* 0x0A iso_639_language_descriptor */
#define DESCR_ISO_639_LANGUAGE_LEN 5
@@ -560,25 +653,31 @@ typedef struct descr_iso_639_language_struct {
/* 0x40 network_name_descriptor */
-#define DESCR_NETWORK_NAME_LEN XX
+#define DESCR_NETWORK_NAME_LEN 2
typedef struct descr_network_name_struct {
u_char descriptor_tag :8;
u_char descriptor_length :8;
- /* TBD */
} descr_network_name_t;
#define CastNetworkNameDescriptor(x) ((descr_network_name_t *)(x))
/* 0x41 service_list_descriptor */
-#define DESCR_SERVICE_LIST_LEN XX
+#define DESCR_SERVICE_LIST_LEN 2
typedef struct descr_service_list_struct {
u_char descriptor_tag :8;
u_char descriptor_length :8;
- /* TBD */
} descr_service_list_t;
#define CastServiceListDescriptor(x) ((descr_service_list_t *)(x))
+#define DESCR_SERVICE_LIST_LOOP_LEN 3
+typedef struct descr_service_list_loop_struct {
+ u_char service_id_hi :8;
+ u_char service_id_lo :8;
+ u_char service_type :8;
+} descr_service_list_loop_t;
+#define CastServiceListDescriptorLoop(x) ((descr_service_list_loop_t *)(x))
+
/* 0x42 stuffing_descriptor */
@@ -604,13 +703,13 @@ typedef struct descr_satellite_delivery_system_struct {
u_char orbital_position1 :8;
u_char orbital_position2 :8;
#if BYTE_ORDER == BIG_ENDIAN
- u_char modulation :5;
- u_char polarization :2;
- u_char west_east_flag :1;
-#else
u_char west_east_flag :1;
u_char polarization :2;
u_char modulation :5;
+#else
+ u_char modulation :5;
+ u_char polarization :2;
+ u_char west_east_flag :1;
#endif
u_char symbol_rate1 :8;
u_char symbol_rate2 :8;
@@ -964,14 +1063,39 @@ typedef struct descr_telephone_struct {
/* 0x58 local_time_offset_descriptor */
-#define DESCR_LOCAL_TIME_OFFSET_LEN XX
+#define DESCR_LOCAL_TIME_OFFSET_LEN 2
typedef struct descr_local_time_offset_struct {
u_char descriptor_tag :8;
u_char descriptor_length :8;
- /* TBD */
} descr_local_time_offset_t;
#define CastLocalTimeOffsetDescriptor(x) ((descr_local_time_offset_t *)(x))
+#define LOCAL_TIME_OFFSET_ENTRY_LEN 15
+typedef struct local_time_offset_entry_struct {
+ u_char country_code1 :8;
+ u_char country_code2 :8;
+ u_char country_code3 :8;
+#if BYTE_ORDER == BIG_ENDIAN
+ u_char country_region_id :6;
+ u_char :1;
+ u_char local_time_offset_polarity :1;
+#else
+ u_char local_time_offset_polarity :1;
+ u_char :1;
+ u_char country_region_id :6;
+#endif
+ u_char local_time_offset_h :8;
+ u_char local_time_offset_m :8;
+ u_char time_of_change_mjd_hi :8;
+ u_char time_of_change_mjd_lo :8;
+ u_char time_of_change_time_h :8;
+ u_char time_of_change_time_m :8;
+ u_char time_of_change_time_s :8;
+ u_char next_time_offset_h :8;
+ u_char next_time_offset_m :8;
+} local_time_offset_entry_t ;
+#define CastLocalTimeOffsetEntry(x) ((local_time_offset_entry_t *)(x))
+
/* 0x59 subtitling_descriptor */