////////////////////////////////////////////////////////////////////////////////// // // // 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 DomainObjects; namespace DVBServices { /// /// The class that describes a MediaHighway2 Summary section. /// public class MediaHighway2SummarySection { /// /// Get the summary data for this section. /// public MediaHighway2SummaryData SummaryData { get { return (summaryData); } } private MediaHighway2SummaryData summaryData; private int lastIndex = -1; /// /// Initialize a new instance of the MediaHighway2SummarySection class. /// internal MediaHighway2SummarySection() { } /// /// Parse the section. /// /// The MPEG2 section containing the summary data. /// Index of the first byte of the summary data in the MPEG2 section. /// True if the block contains data; false otherwise. internal bool Process(byte[] byteData, int index) { lastIndex = index; summaryData = new MediaHighway2SummaryData(); return(summaryData.Process(byteData, lastIndex)); } /// /// Log the section fields. /// public void LogMessage() { if (Logger.ProtocolLogger == null) return; summaryData.LogMessage(); } /// /// Process an MPEG2 section from the MediaHighway1 summary table. /// /// The MPEG2 section. /// A MediaHighway2SummarySection instance. public static MediaHighway2SummarySection ProcessMediaHighwaySummaryTable(byte[] byteData) { Mpeg2BasicHeader mpeg2Header = new Mpeg2BasicHeader(); try { mpeg2Header.Process(byteData); MediaHighway2SummarySection summarySection = new MediaHighway2SummarySection(); bool process = summarySection.Process(byteData, mpeg2Header.Index); if (process) { summarySection.LogMessage(); return (summarySection); } else return (null); } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write(" Summary section parsing failed: " + e.Message); return (null); } } } }