From 512cd24e5396bf2d027ff6dd698ad77f9b266ff5 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Wed, 30 Oct 2013 10:18:26 +0100 Subject: [PATCH] Added code for parsing LCN and AVC descriptors to libsi --- CONTRIBUTORS | 1 + HISTORY | 1 + libsi/descriptor.c | 99 +++++++++++++++++++++++++++++++++++++++++++++- libsi/descriptor.h | 59 ++++++++++++++++++++++++++- libsi/headers.h | 71 ++++++++++++++++++++++++++++++++- libsi/si.c | 11 +++++- libsi/si.h | 18 ++++++++- 7 files changed, 255 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 897500ba..46a8eb42 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1176,6 +1176,7 @@ Rolf Ahrenberg for fixing some compiler warnings with gcc-4.6.3 for suggesting to prompt the user for confirmation before overwriting an already existing edited version of a recording + for adding code for parsing LCN and AVC descriptors to libsi Ralf Klueber for reporting a bug in cutting a recording if there is only a single editing mark diff --git a/HISTORY b/HISTORY index 66d7c5f7..3fbd2bd8 100644 --- a/HISTORY +++ b/HISTORY @@ -8047,3 +8047,4 @@ Video Disk Recorder Revision History - The LIRC remote control now connects to the socket even if it doesn't yet exist when VDR is started (thanks to Lars Hanisch). - Changed the absolute latitude limit for visible satellites to 81.2 degrees. +- Added code for parsing LCN and AVC descriptors to libsi (thanks to Rolf Ahrenberg). diff --git a/libsi/descriptor.c b/libsi/descriptor.c index 07429b54..f763d62b 100644 --- a/libsi/descriptor.c +++ b/libsi/descriptor.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: descriptor.c 2.4 2012/01/11 11:35:17 kls Exp $ + * $Id: descriptor.c 3.1 2013/10/30 10:16:18 kls Exp $ * * ***************************************************************************/ @@ -922,6 +922,48 @@ int T2DeliverySystemDescriptor::getTfsFlag() const { return extended_data_flag ? s->tfs_flag : -1; } +void LogicalChannelDescriptor::Parse() { + //this descriptor is only a header and a loop + logicalChannelLoop.setData(data+sizeof(descr_logical_channel), getLength()-sizeof(descr_logical_channel)); +} + +int LogicalChannelDescriptor::LogicalChannel::getServiceId() const { + return HILO(s->service_id); +} + +int LogicalChannelDescriptor::LogicalChannel::getVisibleServiceFlag() const { + return s->visible_service_flag; +} + +int LogicalChannelDescriptor::LogicalChannel::getLogicalChannelNumber() const { + return HILO(s->logical_channel_number); +} + +void LogicalChannelDescriptor::LogicalChannel::Parse() { + s=data.getData(); +} + +void HdSimulcastLogicalChannelDescriptor::Parse() { + //this descriptor is only a header and a loop + hdSimulcastLogicalChannelLoop.setData(data+sizeof(descr_hd_simulcast_logical_channel), getLength()-sizeof(descr_hd_simulcast_logical_channel)); +} + +int HdSimulcastLogicalChannelDescriptor::HdSimulcastLogicalChannel::getServiceId() const { + return HILO(s->service_id); +} + +int HdSimulcastLogicalChannelDescriptor::HdSimulcastLogicalChannel::getVisibleServiceFlag() const { + return s->visible_service_flag; +} + +int HdSimulcastLogicalChannelDescriptor::HdSimulcastLogicalChannel::getLogicalChannelNumber() const { + return HILO(s->logical_channel_number); +} + +void HdSimulcastLogicalChannelDescriptor::HdSimulcastLogicalChannel::Parse() { + s=data.getData(); +} + int PremiereContentTransmissionDescriptor::getOriginalNetworkId() const { return HILO(s->original_network_id); } @@ -1145,4 +1187,59 @@ void RegistrationDescriptor::Parse() { privateData.assign(data.getData(offset), getLength()-offset); } +int AVCDescriptor::getProfileIdc() const { + return s->profile_idc; +} + +int AVCDescriptor::getConstraintSet0Flag() const { + return s->constraint_set0_flag; +} + +int AVCDescriptor::getConstraintSet1Flag() const { + return s->constraint_set1_flag; +} + +int AVCDescriptor::getConstraintSet2Flag() const { + return s->constraint_set2_flag; +} + +int AVCDescriptor::getConstraintSet3Flag() const { + return s->constraint_set3_flag; +} + +int AVCDescriptor::getConstraintSet4Flag() const { + return s->constraint_set4_flag; +} + +int AVCDescriptor::getConstraintSet5Flag() const { + return s->constraint_set5_flag; +} + +int AVCDescriptor::getAVCCompatibleFlags() const { + return s->avc_compatible_flags; +} + +int AVCDescriptor::getLevelIdc() const { + return s->level_idc; +} + +int AVCDescriptor::getAVCStillPresent() const { + return s->avc_still_present; +} + +int AVCDescriptor::getAVC24HourPictureFlag() const { + return s->avc_24_hour_picture_flag; +} + +int AVCDescriptor::getFramePackingSEINotPresentFlag() const { + return s->frame_packing_sei_not_present_flag; +} + +void AVCDescriptor::Parse() { + int offset=0; + data.setPointerAndOffset(s, offset); + if (checkSize(getLength()-offset)) + privateData.assign(data.getData(offset), getLength()-offset); +} + } //end of namespace diff --git a/libsi/descriptor.h b/libsi/descriptor.h index 3025876e..f931871a 100644 --- a/libsi/descriptor.h +++ b/libsi/descriptor.h @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: descriptor.h 2.4 2012/01/11 11:35:17 kls Exp $ + * $Id: descriptor.h 3.1 2013/10/30 10:16:18 kls Exp $ * * ***************************************************************************/ @@ -557,6 +557,42 @@ private: int extended_data_flag; }; +class LogicalChannelDescriptor : public Descriptor { +public: + class LogicalChannel : public LoopElement { + public: + int getServiceId() const; + int getVisibleServiceFlag() const; + int getLogicalChannelNumber() const; + virtual int getLength() { return sizeof(item_logical_channel); } + protected: + virtual void Parse(); + private: + const item_logical_channel *s; + }; + StructureLoop logicalChannelLoop; +protected: + virtual void Parse(); +}; + +class HdSimulcastLogicalChannelDescriptor : public Descriptor { +public: + class HdSimulcastLogicalChannel : public LoopElement { + public: + int getServiceId() const; + int getVisibleServiceFlag() const; + int getLogicalChannelNumber() const; + virtual int getLength() { return sizeof(item_hd_simulcast_logical_channel); } + protected: + virtual void Parse(); + private: + const item_hd_simulcast_logical_channel *s; + }; + StructureLoop hdSimulcastLogicalChannelLoop; +protected: + virtual void Parse(); +}; + // Private DVB Descriptor Premiere.de // 0xF2 Content Transmission Descriptor // http://dvbsnoop.sourceforge.net/examples/example-private-section.html @@ -735,6 +771,27 @@ private: const descr_registration *s; }; +class AVCDescriptor : public Descriptor { +public: + int getProfileIdc() const; + int getConstraintSet0Flag() const; + int getConstraintSet1Flag() const; + int getConstraintSet2Flag() const; + int getConstraintSet3Flag() const; + int getConstraintSet4Flag() const; + int getConstraintSet5Flag() const; + int getAVCCompatibleFlags() const; + int getLevelIdc() const; + int getAVCStillPresent() const; + int getAVC24HourPictureFlag() const; + int getFramePackingSEINotPresentFlag() const; + CharArray privateData; +protected: + virtual void Parse(); +private: + const descr_avc *s; +}; + } //end of namespace #endif //LIBSI_TABLE_H diff --git a/libsi/headers.h b/libsi/headers.h index 85c83b27..ff5bb5da 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 2.5 2012/06/09 14:37:24 kls Exp $ + * $Id: headers.h 3.1 2013/10/30 10:16:18 kls Exp $ * * ***************************************************************************/ @@ -1870,6 +1870,54 @@ struct descr_t2_delivery_system { fields looping to the end */ }; +/* 0x83 logical_channel_descriptor */ + +#define DESCR_LOGICAL_CHANNEL_LEN 2 +struct descr_logical_channel { + u_char descriptor_tag :8; + u_char descriptor_length :8; +}; + +#define ITEM_LOGICAL_CHANNEL_LEN 4 +struct item_logical_channel { + u_char service_id_hi :8; + u_char service_id_lo :8; +#if BYTE_ORDER == BIG_ENDIAN + u_char visible_service_flag :1; + u_char reserved :5; + u_char logical_channel_number_hi :2; +#else + u_char logical_channel_number_hi :2; + u_char reserved :5; + u_char visible_service_flag :1; +#endif + u_char logical_channel_number_lo :8; +}; + +/* 0x88 hd_simulcast_logical_channel_descriptor */ + +#define DESCR_HD_SIMULCAST_LOGICAL_CHANNEL_LEN 2 +struct descr_hd_simulcast_logical_channel { + u_char descriptor_tag :8; + u_char descriptor_length :8; +}; + +#define ITEM_HD_SIMULCAST_LOGICAL_CHANNEL_LEN 4 +struct item_hd_simulcast_logical_channel { + u_char service_id_hi :8; + u_char service_id_lo :8; +#if BYTE_ORDER == BIG_ENDIAN + u_char visible_service_flag :1; + u_char reserved :5; + u_char logical_channel_number_hi :2; +#else + u_char logical_channel_number_hi :2; + u_char reserved :5; + u_char visible_service_flag :1; +#endif + u_char logical_channel_number_lo :8; +}; + /* MHP 0x00 application_descriptor */ #define DESCR_APPLICATION_LEN 3 @@ -2088,6 +2136,27 @@ struct descr_registration { u_char format_identifier_lo_lo :8; }; +/* 0x28 avc_descriptor */ + +#define DESCR_AVC_LEN 6 +struct descr_avc { + u_char descriptor_tag :8; + u_char descriptor_length :8; + u_char profile_idc :8; + u_char constraint_set0_flag :1; + u_char constraint_set1_flag :1; + u_char constraint_set2_flag :1; + u_char constraint_set3_flag :1; + u_char constraint_set4_flag :1; + u_char constraint_set5_flag :1; + u_char avc_compatible_flags :2; + u_char level_idc :8; + u_char avc_still_present :1; + u_char avc_24_hour_picture_flag :1; + u_char frame_packing_sei_not_present_flag :1; + u_char reserved :5; +}; + } //end of namespace #endif //LIBSI_HEADERS_H diff --git a/libsi/si.c b/libsi/si.c index 80d34d14..0ef39397 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 2.8 2012/09/29 14:44:20 kls Exp $ + * $Id: si.c 3.1 2013/10/30 10:16:18 kls Exp $ * * ***************************************************************************/ @@ -508,6 +508,9 @@ Descriptor *Descriptor::getDescriptor(CharArray da, DescriptorTagDomain domain, case CarouselIdentifierDescriptorTag: d=new CarouselIdentifierDescriptor(); break; + case AVCDescriptorTag: + d=new AVCDescriptor(); + break; case NetworkNameDescriptorTag: d=new NetworkNameDescriptor(); break; @@ -614,6 +617,12 @@ Descriptor *Descriptor::getDescriptor(CharArray da, DescriptorTagDomain domain, case ExtensionDescriptorTag: d=new ExtensionDescriptor(); break; + case LogicalChannelDescriptorTag: + d=new LogicalChannelDescriptor(); + break; + case HdSimulcastLogicalChannelDescriptorTag: + d=new HdSimulcastLogicalChannelDescriptor(); + break; case RegistrationDescriptorTag: d=new RegistrationDescriptor(); break; diff --git a/libsi/si.h b/libsi/si.h index 8e4255e3..80750648 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 2.6 2012/10/15 11:56:06 kls Exp $ + * $Id: si.h 3.1 2013/10/30 10:16:18 kls Exp $ * * ***************************************************************************/ @@ -70,6 +70,10 @@ enum DescriptorTag { // defined by ISO-13818-6 (DSM-CC) CarouselIdentifierDescriptorTag = 0x13, // 0x14 - 0x3F Reserved + // defined by ISO/IEC 13818-1 Amendment + AVCDescriptorTag = 0x28, + SVCExtensionDescriptorTag = 0x30, + MVCExtensionDescriptorTag = 0x31, // defined by ETSI (EN 300 468) NetworkNameDescriptorTag = 0x40, ServiceListDescriptorTag = 0x41, @@ -134,6 +138,12 @@ enum DescriptorTag { DTSDescriptorTag = 0x7B, AACDescriptorTag = 0x7C, ExtensionDescriptorTag = 0x7F, + // defined by EICTA/EACEM/DIGITALEUROPE + LogicalChannelDescriptorTag = 0x83, + PreferredNameListDescriptorTag = 0x84, + PreferredNameIdentifierDescriptorTag = 0x85, + EacemStreamIdentifierDescriptorTag = 0x86, + HdSimulcastLogicalChannelDescriptorTag = 0x88, // Extension descriptors ImageIconDescriptorTag = 0x00, CpcmDeliverySignallingDescriptor = 0x01, @@ -147,6 +157,12 @@ enum DescriptorTag { TargetRegionDescriptorTag = 0x09, TargetRegionNameDescriptorTag = 0x0A, ServiceRelocatedDescriptorTag = 0x0B, + // defined by ETSI (EN 300 468) v 1.12.1 + XAITPidDescriptorTag = 0x0C, + C2DeliverySystemDescriptorTag = 0x0D, + // 0x0E - 0x0F Reserved + VideoDepthRangeDescriptorTag = 0x10, + T2MIDescriptorTag = 0x11, // Defined by ETSI TS 102 812 (MHP) // They once again start with 0x00 (see page 234, MHP specification)