////////////////////////////////////////////////////////////////////////////////// // // // Copyright © 2005-2020 nzsjb // // // // This Program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2, or (at your option) // // any later version. // // // // This Program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with GNU Make; see the file COPYING. If not, write to // // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // // http://www.gnu.org/copyleft/gpl.html // // // ////////////////////////////////////////////////////////////////////////////////// using System; using System.Collections.ObjectModel; using DomainObjects; namespace DVBServices { /// /// The class that describes an Open TV Summary section. /// public class OpenTVSummarySection { /// /// Get the collection of Open TV Title sections. /// public static Collection OpenTVSummarySections { get { if (openTVSummarySections == null) openTVSummarySections = new Collection(); return (openTVSummarySections); } } /// /// Get the section number. /// public int SectionNumber { get { return (sectionNumber); } } /// /// Get the section number. /// public int LastSectionNumber { get { return (lastSectionNumber); } } /// /// Get the title header. /// public OpenTVSummaryHeader SummaryHeader { get { return (summaryHeader); } } private int sectionNumber; private int lastSectionNumber; private OpenTVSummaryHeader summaryHeader; private static Collection openTVSummarySections; private int lastIndex = -1; /// /// Initialize a new instance of the OpenTVSummarySection class. /// internal OpenTVSummarySection() { } /// /// Parse the section. /// /// The MPEG2 section containing the section. /// The MPEG2 header that preceedes the section. internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; sectionNumber = mpeg2Header.SectionNumber; lastSectionNumber = mpeg2Header.LastSectionNumber; summaryHeader = new OpenTVSummaryHeader(); summaryHeader.Process(byteData, lastIndex, mpeg2Header); } /// /// Log the section fields. /// public void LogMessage() { if (Logger.ProtocolLogger == null) return; summaryHeader.LogMessage(); } /// /// Process an MPEG2 section from the Open TV Summary table. /// /// The MPEG2 section. /// An Open TV Summary Section instance. public static OpenTVSummarySection ProcessOpenTVSummaryTable(byte[] byteData) { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); if (mpeg2Header.Current) { OpenTVSummarySection openTVSummarySection = new OpenTVSummarySection(); openTVSummarySection.Process(byteData, mpeg2Header); openTVSummarySection.LogMessage(); return (openTVSummarySection); } else return (null); } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write(" Error processing Summary Section: " + e.Message); return (null); } } /// /// Add a section to the collection. /// /// The section to be added. public static void AddSection(OpenTVSummarySection newSection) { /*foreach (OpenTVSummarySection oldSection in OpenTVSummarySections) { if (oldSection.sectionNumber == newSection.sectionNumber) return; if (oldSection.SectionNumber > newSection.SectionNumber) { OpenTVSummarySections.Insert(OpenTVSummarySections.IndexOf(oldSection), newSection); return; } }*/ OpenTVSummarySections.Add(newSection); } } }