From 402184b9da571d8bed4e6c118074d451c6b355f1 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 20 Feb 2004 13:54:14 +0100 Subject: Added subtable ID and TSDT handling to 'libsi' --- libsi/headers.h | 47 ++++++++++++++++++++++++++++++++++++++++++++--- libsi/section.c | 18 +++++++++++++++++- libsi/section.h | 15 ++++++++++++++- libsi/si.c | 10 +++++++++- libsi/si.h | 5 ++++- 5 files changed, 88 insertions(+), 7 deletions(-) (limited to 'libsi') diff --git a/libsi/headers.h b/libsi/headers.h index d5c11999..26fdb27c 100644 --- a/libsi/headers.h +++ b/libsi/headers.h @@ -10,7 +10,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: headers.h 1.2 2003/12/13 10:43:26 kls Exp $ + * $Id: headers.h 1.3 2004/02/20 13:49:16 kls Exp $ * * ***************************************************************************/ @@ -257,7 +257,48 @@ struct pmt_info { /* * - * 4) Network Information Table (NIT): + * 4) Transport Stream Description Table (TSDT): + * + * - The TSDT carries a loop of descriptors that apply to + * the whole transport stream. The syntax and semantics + * of the TSDT are defined in newer versions of ISO/IEC 13818-1. + * + */ + +#define TSDT_LEN 8 + +struct tsdt { + 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 :8; + u_char :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; +}; + +/* + * + * 5) Network Information Table (NIT): * * - the NIT is intended to provide information about the physical * network. The syntax and semantics of the NIT are defined in @@ -468,7 +509,7 @@ struct eit { u_char original_network_id_hi :8; u_char original_network_id_lo :8; u_char segment_last_section_number :8; - u_char segment_last_table_id :8; + u_char last_table_id :8; }; #define EIT_EVENT_LEN 12 diff --git a/libsi/section.c b/libsi/section.c index 0de2a573..2cac809d 100644 --- a/libsi/section.c +++ b/libsi/section.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: section.c 1.2 2003/12/13 10:42:14 kls Exp $ + * $Id: section.c 1.3 2004/02/20 13:44:59 kls Exp $ * * ***************************************************************************/ @@ -76,6 +76,14 @@ void PMT::Stream::Parse() { streamDescriptors.setData(data+offset, HILO(s->ES_info_length)); } +/*********************** TSDT ***********************/ + +void TSDT::Parse() { + unsigned int offset=0; + data.setPointerAndOffset(s, offset); + transportStreamDescriptors.setDataAndOffset(data+offset, getLength()-offset-4, offset); +} + /*********************** NIT ***********************/ int NIT::getNetworkId() const { @@ -161,6 +169,14 @@ int EIT::getOriginalNetworkId() const { return HILO(s->original_network_id); } +int EIT::getSegmentLastSectionNumber() const { + return s->segment_last_section_number; +} + +int EIT::getLastTableId() const { + return s->last_table_id; +} + bool EIT::isPresentFollowing() const { return getTableId() == TableIdEIT_presentFollowing || getTableId() == TableIdEIT_presentFollowing_other; } diff --git a/libsi/section.h b/libsi/section.h index efca9bb6..5b43f05f 100644 --- a/libsi/section.h +++ b/libsi/section.h @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: section.h 1.2 2003/12/13 10:42:15 kls Exp $ + * $Id: section.h 1.3 2004/02/20 13:45:45 kls Exp $ * * ***************************************************************************/ @@ -77,6 +77,17 @@ private: const pmt *s; }; +class TSDT : public NumberedSection { +public: + TSDT(const unsigned char *data, bool doCopy=true) : NumberedSection(data, doCopy) {} + TSDT() {} + DescriptorLoop transportStreamDescriptors; +protected: + virtual void Parse(); +private: + const tsdt *s; +}; + class NIT : public NumberedSection { public: NIT(const unsigned char *data, bool doCopy=true) : NumberedSection(data, doCopy) {} @@ -166,6 +177,8 @@ public: int getServiceId() const; int getTransportStreamId() const; int getOriginalNetworkId() const; + int getSegmentLastSectionNumber() const; + int getLastTableId() const; StructureLoop eventLoop; //true if table conveys present/following information, false if it conveys schedule information diff --git a/libsi/si.c b/libsi/si.c index 0aa9c524..b952fb51 100644 --- a/libsi/si.c +++ b/libsi/si.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: si.c 1.6 2004/01/24 14:49:00 kls Exp $ + * $Id: si.c 1.7 2004/02/20 13:46:12 kls Exp $ * * ***************************************************************************/ @@ -61,6 +61,14 @@ bool CRCSection::CheckCRCAndParse() { return true; } +int NumberedSection::getTableIdExtension() const { + return getTableIdExtension(data.getData()); +} + +int NumberedSection::getTableIdExtension(const unsigned char *d) { + return HILO(((const ExtendedSectionHeader *)d)->table_id_extension); +} + bool NumberedSection::getCurrentNextIndicator() const { return data.getData()->current_next_indicator; } diff --git a/libsi/si.h b/libsi/si.h index 4666c2d4..7e90c415 100644 --- a/libsi/si.h +++ b/libsi/si.h @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: si.h 1.6 2004/01/12 16:19:11 kls Exp $ + * $Id: si.h 1.7 2004/02/20 13:47:09 kls Exp $ * * ***************************************************************************/ @@ -216,11 +216,14 @@ class NumberedSection : public CRCSection { public: NumberedSection(const unsigned char *data, bool doCopy=true) : CRCSection(data, doCopy) {} NumberedSection() {} + int getTableIdExtension() const; bool getCurrentNextIndicator() const; int getVersionNumber() const; int getSectionNumber() const; int getLastSectionNumber() const; bool moreThanOneSection() const { return getLastSectionNumber()>0; } + + static int getTableIdExtension(const unsigned char *d); }; class VariableLengthPart : public Object { -- cgit v1.2.3