/// <summary> /// Process an MPEG2 section from the network information table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>A Network Information section instance.</returns> public static NetworkInformationSection ProcessNetworkInformationTable(byte[] byteData) { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); if (mpeg2Header.Current) { NetworkInformationSection networkInformationSection = new NetworkInformationSection(); networkInformationSection.Process(byteData, mpeg2Header); if (RunParameters.Instance.DebugIDs.Contains("NITSECTIONS")) { networkInformationSection.LogMessage(); } return(networkInformationSection); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing Network Information Section message: " + e.Message); } return(null); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; int descriptorLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (descriptorLength != 0) { descriptors = new Collection <DescriptorBase>(); while (descriptorLength > 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex); if (!descriptor.IsEmpty) { descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; descriptorLength -= DescriptorBase.MinimumDescriptorLength; } } } }
private void processSections(Collection <Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("DUMPEITSECTIONS")) { Logger.Instance.Dump("EIT Section", section.Data, section.Data.Length); } if (section.Table >= 0x4e && section.Table <= 0x6f) { try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { EITSection eitSection = new EITSection(); eitSection.Process(section.Data, mpeg2Header); eitSection.LogMessage(); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> EIT error: " + e.Message); } } } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containg the DSMCC data.</param> /// <param name="mpeg2Header">The MPEG2 header for the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { DSMCCHeader dsmccHeader = new DSMCCHeader(); dsmccHeader.Process(byteData, mpeg2Header); dsmccMessage = DSMCCMessage.CreateInstance(dsmccHeader, byteData); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; sourceID = mpeg2Header.TableIDExtension; lastSectionNumber = mpeg2Header.LastSectionNumber; protocolVersion = (int)byteData[lastIndex]; lastIndex++; int entryCount = (int)byteData[lastIndex]; lastIndex++; if (entryCount != 0) { events = new Collection <EventInformationTableEntry>(); while (entryCount != 0) { EventInformationTableEntry eventEntry = new EventInformationTableEntry(); eventEntry.Process(byteData, lastIndex); events.Add(eventEntry); lastIndex += eventEntry.TotalLength; entryCount--; } } Validate(); }
private void processSections(Collection <Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.TraceIDs.Contains("DISHNETWORKSECTIONS")) { Logger.Instance.Dump("Dish Network Section", section.Data, section.Length); } try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { if (mpeg2Header.TableID > 0x80 && mpeg2Header.TableID < 0xa5) { DishNetworkSection dishNetworkSection = new DishNetworkSection(); dishNetworkSection.Process(section.Data, mpeg2Header); } } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Dish Network error: " + e.Message); } } }
/// <summary> /// Parse the summary header. /// </summary> /// <param name="byteData">The MPEG2 section containing the summary header.</param> /// <param name="index">Index of the first byte of the summary header in the MPEG2 section.</param> /// <param name="mpeg2Header">The MPEG2 header of the section.</param> internal void Process(byte[] byteData, int index, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = index; channelID = mpeg2Header.TableIDExtension; try { baseDate = getDate(Utils.Convert2BytesToInt(byteData, lastIndex)); lastIndex += 2; while (lastIndex < byteData.Length - 4) { OpenTVSummaryData data = new OpenTVSummaryData(); data.Process(byteData, lastIndex, baseDate); if (summaryData == null) { summaryData = new Collection <OpenTVSummaryData>(); } summaryData.Add(data); lastIndex = data.Index; } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The Open TV Summary Header message is short")); } }
/// <summary> /// Parse the title header. /// </summary> /// <param name="byteData">The MPEG2 section containing the title header.</param> /// <param name="index">Index of the first byte of the title header in the MPEG2 section.</param> /// <param name="mpeg2Header">The MPEG2 header of the section.</param> /// <param name="pid">The PID of the section.</param> /// <param name="tid">The table ID of the section.</param> internal void Process(byte[] byteData, int index, Mpeg2ExtendedHeader mpeg2Header, int pid, int tid) { lastIndex = index; channelID = mpeg2Header.TableIDExtension; try { baseDate = getDate(Utils.Convert2BytesToInt(byteData, lastIndex)); lastIndex += 2; while (lastIndex < byteData.Length - 4) { OpenTVTitleData data = new OpenTVTitleData(); data.Process(byteData, lastIndex, baseDate, channelID, pid, tid); if (!data.IsEmpty) { if (titleData == null) { titleData = new Collection <OpenTVTitleData>(); } titleData.Add(data); } lastIndex = data.Index; } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("lastIndex = " + lastIndex)); } }
private void processVirtualChannelTable(Collection <Mpeg2Section> sections, int frequency) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("VIRTUALCHANNELTABLE")) { Logger.Instance.Dump("PSIP Virtual Channel Table", section.Data, section.Data.Length); } try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { VirtualChannelTable virtualChannelTable = new VirtualChannelTable(); virtualChannelTable.Process(section.Data, mpeg2Header, (mpeg2Header.TableID == 0xc9), frequency); VirtualChannelTable.AddSectionNumber(mpeg2Header.SectionNumber); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("PSIP error: " + e.Message); } } }
/// <summary> /// Process an MPEG2 section from the Open TV Summary table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>An Open TV Summary Section instance.</returns> 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("<e> Error processing Summary Section: " + e.Message); return(null); } }
private void processEventInformationTable(Collection <Mpeg2Section> sections, int frequency) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("EVENTINFORMATIONTABLE")) { Logger.Instance.Dump("PSIP Event Information Table", section.Data, section.Data.Length); } try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { EventInformationTable eventInformationTable = new EventInformationTable(); eventInformationTable.Process(section.Data, mpeg2Header); eventInformationTable.LogMessage(); if (eventInformationTable.Events != null) { foreach (EventInformationTableEntry eventEntry in eventInformationTable.Events) { processEvent(frequency, eventInformationTable.SourceID, eventEntry); } } } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> PSIP error: " + e.Message); } } }
private void processExtendedTextTable(Collection <Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("EXTENDEDTEXTTABLE")) { Logger.Instance.Dump("PSIP Extended Text Table", section.Data, section.Data.Length); } try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { ExtendedTextTable extendedTextTable = new ExtendedTextTable(); extendedTextTable.Process(section.Data, mpeg2Header); extendedTextTable.LogMessage(); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> PSIP error: " + e.Message); } } }
/// <summary> /// Process an MPEG2 section from the Open TV Title table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <param name="pid">The PID containing the section.</param> /// <param name="table">The table ID containing the section.</param> /// <returns>An Open TV Title Section instance or null if a section is not created.</returns> public static OpenTVTitleSection ProcessOpenTVTitleTable(byte[] byteData, int pid, int table) { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); if (mpeg2Header.Current) { OpenTVTitleSection openTVTitleSection = new OpenTVTitleSection(); openTVTitleSection.Process(byteData, mpeg2Header, pid, table); openTVTitleSection.LogMessage(); return(openTVTitleSection); } else { return(null); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing Title Section: " + e.Message); if (RunParameters.Instance.DebugIDs.Contains("TITLESECTION")) { Logger.Instance.Write(e.Message); Logger.Instance.Write(e.StackTrace); Logger.Instance.Dump("Title Section", byteData, byteData.Length); } return(null); } }
private void processSections(Collection <Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.TraceIDs.Contains("FREESATSECTIONS")) { Logger.Instance.Dump("FreeSat Section", section.Data, section.Length); } try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { FreeSatSection freeSatSection = new FreeSatSection(); freeSatSection.Process(section.Data, mpeg2Header); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> FreeSat error: " + e.Message); } } }
private void processEPGSections(Collection <Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { if (mpeg2Header.TableIDExtension == 0x702) { SiehFernInfoEPGSection epgSection = new SiehFernInfoEPGSection(); epgSection.Process(section.Data, mpeg2Header); epgSection.LogMessage(); bool added = SiehFernInfoEPGSection.AddSection(epgSection); if (added) { if (RunParameters.Instance.DebugIDs.Contains("SIEHFERNEPGBLOCKS")) { Logger.Instance.Dump("Siehfern Info Block Type 0x" + mpeg2Header.TableIDExtension.ToString("X"), section.Data, section.Data.Length); } } } } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing SiehFern Info EPG section: " + e.Message); } } }
private void processRatingRegionTable(Collection <Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("RATINGREGIONTABLE")) { Logger.Instance.Dump("PSIP Rating Region Table", section.Data, section.Data.Length); } try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { RatingRegionTable ratingRegionTable = new RatingRegionTable(); ratingRegionTable.Process(section.Data, mpeg2Header); ratingRegionTable.LogMessage(); RatingRegionTable.AddRegion(ratingRegionTable.Region); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> PSIP error: " + e.Message); } } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; sectionNumber = mpeg2Header.SectionNumber; lastSectionNumber = mpeg2Header.LastSectionNumber; summaryHeader = new OpenTVSummaryHeader(); summaryHeader.Process(byteData, lastIndex, mpeg2Header); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> /// <param name="pid">The PID containing the section.</param> /// <param name="tid">The table ID containing the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header, int pid, int tid) { lastIndex = mpeg2Header.Index; sectionNumber = mpeg2Header.SectionNumber; lastSectionNumber = mpeg2Header.LastSectionNumber; titleHeader = new OpenTVTitleHeader(); titleHeader.Process(byteData, lastIndex, mpeg2Header, pid, tid); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; bouquetID = mpeg2Header.TableIDExtension; sectionNumber = mpeg2Header.SectionNumber; lastSectionNumber = mpeg2Header.LastSectionNumber; int bouquetDescriptorLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (bouquetDescriptorLength != 0) { bouquetDescriptors = new Collection <DescriptorBase>(); while (bouquetDescriptorLength > 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, Scope.Bouquet); if (!descriptor.IsEmpty) { bouquetDescriptors.Add(descriptor); lastIndex = descriptor.Index; bouquetDescriptorLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; bouquetDescriptorLength -= DescriptorBase.MinimumDescriptorLength; } } } int transportStreamLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (transportStreamLoopLength != 0) { transportStreams = new Collection <TransportStream>(); while (transportStreamLoopLength > 0) { TransportStream transportStream = new TransportStream(); transportStream.Process(byteData, lastIndex, Scope.Bouquet); transportStreams.Add(transportStream); lastIndex = transportStream.Index; transportStreamLoopLength -= transportStream.TotalLength; } } lastIndex += transportStreamLoopLength; }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> /// <param name="isCable">True is the section is a virtual cable section;false otherwise.</param> /// <param name="frequency">The frequency being processed.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header, bool isCable, int frequency) { lastIndex = mpeg2Header.Index; lastSectionNumber = mpeg2Header.LastSectionNumber; protocolVersion = (int)byteData[lastIndex]; lastIndex++; int channelCount = (int)byteData[lastIndex]; lastIndex++; if (channelCount != 0) { if (channels == null) { channels = new Collection <VirtualChannel>(); } while (channelCount != 0) { VirtualChannel channel = new VirtualChannel(frequency); channel.Process(byteData, lastIndex, isCable); addChannel(channel); lastIndex += channel.TotalLength; channelCount--; } } int descriptorLoopLength = ((byteData[lastIndex] & 0x03) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; if (descriptorLoopLength != 0) { descriptors = new Collection <DescriptorBase>(); while (descriptorLoopLength != 0) { while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.AtscInstance(byteData, lastIndex); descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } } } Validate(); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; protocolVersion = (int)byteData[lastIndex]; lastIndex++; region = new RatingRegion(); region.Process(byteData, lastIndex, mpeg2Header.TableIDExtension & 0xff); Validate(); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; serviceID = mpeg2Header.TableIDExtension; pcrPID = ((byteData[lastIndex] & 0x1f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; int programInfoLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (programInfoLength != 0) { while (programInfoLength > 0) { descriptors = new Collection <DescriptorBase>(); while (programInfoLength > 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex); if (!descriptor.IsEmpty) { descriptors.Add(descriptor); lastIndex += descriptor.TotalLength; programInfoLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; programInfoLength -= DescriptorBase.MinimumDescriptorLength; } } } } streamInfos = new Collection <StreamInfo>(); while (lastIndex < byteData.Length - 4) { StreamInfo streamInfo = new StreamInfo(); streamInfo.Process(byteData, lastIndex); streamInfos.Add(streamInfo); lastIndex = streamInfo.Index; } Validate(); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; protocolVersion = (int)byteData[lastIndex]; lastIndex++; int tableCount = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; if (tableCount != 0) { tableEntries = new Collection <MasterGuideTableEntry>(); while (tableCount != 0) { MasterGuideTableEntry tableEntry = new MasterGuideTableEntry(); tableEntry.Process(byteData, lastIndex); tableEntries.Add(tableEntry); lastIndex += tableEntry.TotalLength; tableCount--; } } int descriptorLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; if (descriptorLoopLength != 0) { descriptors = new Collection <DescriptorBase>(); while (descriptorLoopLength != 0) { while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.AtscInstance(byteData, lastIndex); descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } } } Validate(); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; protocolVersion = (int)byteData[lastIndex]; lastIndex++; extendedTextEntry = new ExtendedTextTableEntry(); extendedTextEntry.Process(byteData, lastIndex); addEntry(extendedTextEntry); lastIndex += extendedTextEntry.Index; Validate(); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; transportStreamID = mpeg2Header.TableIDExtension; sectionNumber = mpeg2Header.SectionNumber; lastSectionNumber = mpeg2Header.LastSectionNumber; while (lastIndex < byteData.Length - 4) { ProgramInfo programInfo = new ProgramInfo(); programInfo.Process(byteData, lastIndex); programInfos.Add(programInfo); lastIndex = programInfo.Index; } }
/// <summary> /// Process an MPEG2 section from the time offset table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>A TimeOffsetSection instance.</returns> public static TimeOffsetSection ProcessTimeOffsetTable(byte[] byteData) { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); TimeOffsetSection timeOffsetSection = new TimeOffsetSection(); timeOffsetSection.Process(byteData, mpeg2Header); return(timeOffsetSection); } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing Time Offset Section message: " + e.Message); } return(null); }
/// <summary> /// Process an MPEG2 section from the time offset table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>A TimeOffsetSection instance.</returns> public static TimeOffsetSection ProcessTimeOffsetTable(byte[] byteData) { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); TimeOffsetSection timeOffsetSection = new TimeOffsetSection(); timeOffsetSection.Process(byteData, mpeg2Header); return (timeOffsetSection); } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing Time Offset Section message: " + e.Message); } return (null); }
/// <summary> /// Parse the header. /// </summary> /// <param name="byteData">The MPEG2 section containing the header.</param> /// <param name="mpeg2Header">Header of the MPEG2 section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; this.mpeg2Header = mpeg2Header; try { protocolDiscriminator = (int)byteData[lastIndex]; lastIndex++; dsmccType = (int)byteData[lastIndex]; lastIndex++; messageID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; transactionID = new DSMCCTransactionID(Utils.Convert4BytesToInt(byteData, lastIndex)); lastIndex += 4; reserved1 = (int)byteData[lastIndex]; lastIndex++; adaptionLength = (int)byteData[lastIndex]; lastIndex++; messageLength = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; if (adaptionLength != 0) { adaptionData = Utils.GetBytes(byteData, lastIndex, adaptionLength); lastIndex += adaptionLength; } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The DSMCC header is short")); } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; try { lastIndex += 40; sequenceNumber = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; data = Utils.GetBytes(byteData, lastIndex, byteData.Length - lastIndex - 4); lastIndex += data.Length; } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The SiehFern Info Channel section is short")); } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; transportStreamID = mpeg2Header.TableIDExtension; sectionNumber = mpeg2Header.SectionNumber; originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; reserved1 = (int)byteData[lastIndex]; lastIndex++; while (lastIndex < byteData.Length - 4) { ServiceDescription serviceDescription = new ServiceDescription(); serviceDescription.Process(byteData, lastIndex); serviceDescriptions.Add(serviceDescription); lastIndex = serviceDescription.Index; } }
/// <summary> /// Process an MPEG2 section from the program map table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>A ProgramMapSection instance.</returns> public static ProgramMapSection ProcessProgramMapTable(byte[] byteData) { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); if (mpeg2Header.Current) { ProgramMapSection programMapSection = new ProgramMapSection(); programMapSection.Process(byteData, mpeg2Header); return(programMapSection); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing Program Map Section message: " + e.Message); } return(null); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; serviceID = mpeg2Header.TableIDExtension; pcrPID = ((byteData[lastIndex] & 0x1f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; int programInfoLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (programInfoLength != 0) { while (programInfoLength > 0) { descriptors = new Collection<DescriptorBase>(); while (programInfoLength > 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex); if (!descriptor.IsEmpty) { descriptors.Add(descriptor); lastIndex += descriptor.TotalLength; programInfoLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; programInfoLength -= DescriptorBase.MinimumDescriptorLength; } } } } streamInfos = new Collection<StreamInfo>(); while (lastIndex < byteData.Length - 4) { StreamInfo streamInfo = new StreamInfo(); streamInfo.Process(byteData, lastIndex); streamInfos.Add(streamInfo); lastIndex = streamInfo.Index; } Validate(); }
/// <summary> /// Process an MPEG2 section from the Open TV Summary table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>An Open TV Summary Section instance.</returns> 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("<e> Error processing Summary Section: " + e.Message); return (null); } }
private void processVirtualChannelTable(Collection<Mpeg2Section> sections, int frequency) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("VIRTUALCHANNELTABLE")) Logger.Instance.Dump("PSIP Virtual Channel Table", section.Data, section.Data.Length); try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { VirtualChannelTable virtualChannelTable = new VirtualChannelTable(); virtualChannelTable.Process(section.Data, mpeg2Header, (mpeg2Header.TableID == 0xc9), frequency); VirtualChannelTable.AddSectionNumber(mpeg2Header.SectionNumber); virtualChannelTable.LogMessage(); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> PSIP error: " + e.Message); } } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; protocolVersion = (int)byteData[lastIndex]; lastIndex++; int tableCount = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex+= 2; if (tableCount != 0) { tableEntries = new Collection<MasterGuideTableEntry>(); while (tableCount != 0) { MasterGuideTableEntry tableEntry = new MasterGuideTableEntry(); tableEntry.Process(byteData, lastIndex); tableEntries.Add(tableEntry); lastIndex += tableEntry.TotalLength; tableCount--; } } int descriptorLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; if (descriptorLoopLength != 0) { descriptors = new Collection<DescriptorBase>(); while (descriptorLoopLength != 0) { while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.AtscInstance(byteData, lastIndex); descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } } } Validate(); }
private void processEPGSections(Collection<Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { if (mpeg2Header.TableIDExtension == 0x702) { SiehFernInfoEPGSection epgSection = new SiehFernInfoEPGSection(); epgSection.Process(section.Data, mpeg2Header); epgSection.LogMessage(); bool added = SiehFernInfoEPGSection.AddSection(epgSection); if (added) { if (RunParameters.Instance.DebugIDs.Contains("SIEHFERNEPGBLOCKS")) Logger.Instance.Dump("Siehfern Info Block Type 0x" + mpeg2Header.TableIDExtension.ToString("X"), section.Data, section.Data.Length); } } } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing SiehFern Info EPG section: " + e.Message); } } }
private void processMasterGuideTable(Collection<Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("MASTERGUIDETABLE")) Logger.Instance.Dump("PSIP Master Guide Table", section.Data, section.Data.Length); try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { masterGuideTable = new MasterGuideTable(); masterGuideTable.Process(section.Data, mpeg2Header); masterGuideTable.LogMessage(); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> PSIP error: " + e.Message); } } }
private void processSections(Collection<Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("DUMPEITSECTIONS")) Logger.Instance.Dump("EIT Section", section.Data, section.Data.Length); if (section.Table >= 0x4e && section.Table <= 0x6f) { try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { EITSection eitSection = new EITSection(); eitSection.Process(section.Data, mpeg2Header); eitSection.LogMessage(); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> EIT error: " + e.Message); } } } }
/// <summary> /// Process an MPEG2 section from the service description table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>A ServiceDescriptionSection instance.</returns> public static ServiceDescriptionSection ProcessServiceDescriptionTable(byte[] byteData) { if (RunParameters.Instance.DebugIDs.Contains("DUMPSDTBLOCK")) Logger.Instance.Dump("Service Description Block", byteData, byteData.Length); Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); if (mpeg2Header.Current) { try { ServiceDescriptionSection serviceDescriptionSection = new ServiceDescriptionSection(); serviceDescriptionSection.Process(byteData, mpeg2Header); serviceDescriptionSection.LogMessage(); return (serviceDescriptionSection); } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write(e.Message); return (null); } } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing Service Description Section message: " + e.Message); } return (null); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; int descriptorLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (descriptorLength != 0) { descriptors = new Collection<DescriptorBase>(); while (descriptorLength > 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex); if (!descriptor.IsEmpty) { descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; descriptorLength -= DescriptorBase.MinimumDescriptorLength; } } } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; bouquetID = mpeg2Header.TableIDExtension; sectionNumber = mpeg2Header.SectionNumber; lastSectionNumber = mpeg2Header.LastSectionNumber; int bouquetDescriptorLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (bouquetDescriptorLength != 0) { bouquetDescriptors = new Collection<DescriptorBase>(); while (bouquetDescriptorLength > 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, Scope.Bouquet); if (!descriptor.IsEmpty) { bouquetDescriptors.Add(descriptor); lastIndex = descriptor.Index; bouquetDescriptorLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; bouquetDescriptorLength -= DescriptorBase.MinimumDescriptorLength; } } } int transportStreamLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (transportStreamLoopLength != 0) { transportStreams = new Collection<TransportStream>(); while (transportStreamLoopLength > 0) { TransportStream transportStream = new TransportStream(); transportStream.Process(byteData, lastIndex, Scope.Bouquet); transportStreams.Add(transportStream); lastIndex = transportStream.Index; transportStreamLoopLength -= transportStream.TotalLength; } } lastIndex += transportStreamLoopLength; }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; serviceID = mpeg2Header.TableIDExtension; try { transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; segmentLastSectionNumber = (int)byteData[lastIndex]; lastIndex++; lastTableID = (int)byteData[lastIndex]; lastIndex++; } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The FreeSat EIT section is short")); } TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID); if (tvStation == null) return; bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber); if (!newSection) return; while (lastIndex < byteData.Length - 4) { FreeSatEntry freeSatEntry = new FreeSatEntry(); freeSatEntry.Process(byteData, lastIndex); EPGEntry epgEntry = new EPGEntry(); epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID; epgEntry.TransportStreamID = tvStation.TransportStreamID; epgEntry.ServiceID = tvStation.ServiceID; epgEntry.EPGSource = EPGSource.FreeSat; switch (freeSatEntry.ComponentTypeAudio) { case 3: epgEntry.AudioQuality = "stereo"; break; case 5: epgEntry.AudioQuality = "dolby digital"; break; default: break; } if (freeSatEntry.ComponentTypeVideo > 9) epgEntry.VideoQuality = "HDTV"; epgEntry.Duration = Utils.RoundTime(freeSatEntry.Duration); epgEntry.EventID = freeSatEntry.EventID; epgEntry.EventName = freeSatEntry.EventName; if (freeSatEntry.ParentalRating > 11) epgEntry.ParentalRating = "AO"; else { if (freeSatEntry.ParentalRating > 8) epgEntry.ParentalRating = "PGR"; else epgEntry.ParentalRating = "G"; } setSeriesEpisode(epgEntry, freeSatEntry); epgEntry.RunningStatus = freeSatEntry.RunningStatus; epgEntry.Scrambled = freeSatEntry.Scrambled; epgEntry.ShortDescription = freeSatEntry.ShortDescription; epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(freeSatEntry.StartTime)); epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, freeSatEntry.ContentType, freeSatEntry.ContentSubType); tvStation.AddEPGEntry(epgEntry); if (titleLogger != null) logTitle(freeSatEntry.EventName, epgEntry, titleLogger); if (descriptionLogger != null) logDescription(freeSatEntry.ShortDescription, epgEntry, descriptionLogger); lastIndex = freeSatEntry.Index; } }
private void processSections(Collection<Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.TraceIDs.Contains("DISHNETWORKSECTIONS")) Logger.Instance.Dump("Dish Network Section", section.Data, section.Length); try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { if (mpeg2Header.TableID > 0x80 && mpeg2Header.TableID < 0xa5) { DishNetworkSection dishNetworkSection = new DishNetworkSection(); dishNetworkSection.Process(section.Data, mpeg2Header); } } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Dish Network error: " + e.Message); } } }
/// <summary> /// Process an MPEG2 section from the program map table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>A ProgramMapSection instance.</returns> public static ProgramMapSection ProcessProgramMapTable(byte[] byteData) { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); if (mpeg2Header.Current) { ProgramMapSection programMapSection = new ProgramMapSection(); programMapSection.Process(byteData, mpeg2Header); return (programMapSection); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing Program Map Section message: " + e.Message); } return (null); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; serviceID = mpeg2Header.TableIDExtension; try { transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; segmentLastSectionNumber = (int)byteData[lastIndex]; lastIndex++; lastTableID = (int)byteData[lastIndex]; lastIndex++; } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The Bell TV section is short")); } TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID); if (tvStation == null) { if (!RunParameters.Instance.DebugIDs.Contains("CREATESTATIONS")) return; else { tvStation = new TVStation("Auto Generated Station: " + originalNetworkID + ":" + transportStreamID + ":" + serviceID); tvStation.OriginalNetworkID = originalNetworkID; tvStation.TransportStreamID = transportStreamID; tvStation.ServiceID = serviceID; TVStation.StationCollection.Add(tvStation); } } bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber); if (!newSection) return; while (lastIndex < byteData.Length - 4) { BellTVEntry bellTVEntry = new BellTVEntry(); bellTVEntry.Process(byteData, lastIndex, mpeg2Header.TableID); EPGEntry epgEntry = new EPGEntry(); epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID; epgEntry.TransportStreamID = tvStation.TransportStreamID; epgEntry.ServiceID = tvStation.ServiceID; epgEntry.EPGSource = EPGSource.BellTV; if (bellTVEntry.HighDefinition) epgEntry.VideoQuality = "HDTV"; if (bellTVEntry.ClosedCaptions) epgEntry.SubTitles = "teletext"; if (bellTVEntry.Stereo) epgEntry.AudioQuality = "stereo"; epgEntry.Duration = Utils.RoundTime(bellTVEntry.Duration); epgEntry.EventID = bellTVEntry.EventID; epgEntry.EventName = bellTVEntry.EventName; getParentalRating(epgEntry, bellTVEntry); epgEntry.RunningStatus = bellTVEntry.RunningStatus; epgEntry.Scrambled = bellTVEntry.Scrambled; epgEntry.ShortDescription = bellTVEntry.ShortDescription; if (bellTVEntry.SubTitle != bellTVEntry.EventName) epgEntry.EventSubTitle = bellTVEntry.SubTitle; epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(bellTVEntry.StartTime)); epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, bellTVEntry.ContentType, bellTVEntry.ContentSubType); epgEntry.StarRating = getStarRating(bellTVEntry); epgEntry.Date = bellTVEntry.Date; epgEntry.Cast = bellTVEntry.Cast; getSeriesEpisode(epgEntry, bellTVEntry.Series, bellTVEntry.Episode); epgEntry.HasGraphicLanguage = bellTVEntry.HasStrongLanguage; epgEntry.HasStrongSexualContent = bellTVEntry.HasSexualContent; epgEntry.HasGraphicViolence = bellTVEntry.HasViolence; epgEntry.HasNudity = bellTVEntry.HasNudity; epgEntry.PreviousPlayDate = bellTVEntry.OriginalAirDate; tvStation.AddEPGEntry(epgEntry); if (titleLogger != null) logTitle(bellTVEntry.EventName, epgEntry, titleLogger); if (descriptionLogger != null) { if (!RunParameters.Instance.DebugIDs.Contains("LOGORIGINAL")) logDescription(bellTVEntry.ShortDescription, epgEntry, descriptionLogger); else logDescription(bellTVEntry.OriginalDescription, epgEntry, descriptionLogger); } lastIndex = bellTVEntry.Index; } }
/// <summary> /// Parse the summary header. /// </summary> /// <param name="byteData">The MPEG2 section containing the summary header.</param> /// <param name="index">Index of the first byte of the summary header in the MPEG2 section.</param> /// <param name="mpeg2Header">The MPEG2 header of the section.</param> internal void Process(byte[] byteData, int index, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = index; channelID = mpeg2Header.TableIDExtension; try { baseDate = getDate(Utils.Convert2BytesToInt(byteData, lastIndex)); lastIndex += 2; while (lastIndex < byteData.Length - 4) { OpenTVSummaryData data = new OpenTVSummaryData(); data.Process(byteData, lastIndex, baseDate); if (summaryData == null) summaryData = new Collection<OpenTVSummaryData>(); summaryData.Add(data); lastIndex = data.Index; } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The Open TV Summary Header message is short")); } }
private void processEventInformationTable(Collection<Mpeg2Section> sections, int frequency) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("EVENTINFORMATIONTABLE")) Logger.Instance.Dump("PSIP Event Information Table", section.Data, section.Data.Length); try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { EventInformationTable eventInformationTable = new EventInformationTable(); eventInformationTable.Process(section.Data, mpeg2Header); eventInformationTable.LogMessage(); if (eventInformationTable.Events != null) { foreach (EventInformationTableEntry eventEntry in eventInformationTable.Events) processEvent(frequency, eventInformationTable.SourceID, eventEntry); } } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> PSIP error: " + e.Message); } } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; sourceID = mpeg2Header.TableIDExtension; lastSectionNumber = mpeg2Header.LastSectionNumber; protocolVersion = (int)byteData[lastIndex]; lastIndex++; int entryCount = (int)byteData[lastIndex]; lastIndex++; if (entryCount != 0) { events = new Collection<EventInformationTableEntry>(); while (entryCount != 0) { EventInformationTableEntry eventEntry = new EventInformationTableEntry(); eventEntry.Process(byteData, lastIndex); events.Add(eventEntry); lastIndex += eventEntry.TotalLength; entryCount--; } } Validate(); }
private void processRatingRegionTable(Collection<Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.DebugIDs.Contains("RATINGREGIONTABLE")) Logger.Instance.Dump("PSIP Rating Region Table", section.Data, section.Data.Length); try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { RatingRegionTable ratingRegionTable = new RatingRegionTable(); ratingRegionTable.Process(section.Data, mpeg2Header); ratingRegionTable.LogMessage(); RatingRegionTable.AddRegion(ratingRegionTable.Region); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> PSIP error: " + e.Message); } } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; protocolVersion = (int)byteData[lastIndex]; lastIndex++; extendedTextEntry = new ExtendedTextTableEntry(); extendedTextEntry.Process(byteData, lastIndex); addEntry(extendedTextEntry); lastIndex+= extendedTextEntry.Index; Validate(); }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header) { lastIndex = mpeg2Header.Index; serviceID = mpeg2Header.TableIDExtension; transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; segmentLastSectionNumber = (int)byteData[lastIndex]; lastIndex++; lastTableID = (int)byteData[lastIndex]; lastIndex++; TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID); if (tvStation == null) { if (!RunParameters.Instance.DebugIDs.Contains("CREATESTATIONS")) return; else { tvStation = new TVStation("Auto Generated Station: " + originalNetworkID + ":" + transportStreamID + ":" + serviceID); tvStation.OriginalNetworkID = originalNetworkID; tvStation.TransportStreamID = transportStreamID; tvStation.ServiceID = serviceID; TVStation.StationCollection.Add(tvStation); } } bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber); if (!newSection) return; while (lastIndex < byteData.Length - 4) { EITEntry eitEntry = new EITEntry(); eitEntry.Process(byteData, lastIndex); if (eitEntry.StartTime != DateTime.MinValue) { EPGEntry epgEntry = new EPGEntry(); epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID; epgEntry.TransportStreamID = tvStation.TransportStreamID; epgEntry.ServiceID = tvStation.ServiceID; epgEntry.EPGSource = EPGSource.EIT; switch (eitEntry.ComponentTypeAudio) { case 3: epgEntry.AudioQuality = "stereo"; break; case 5: epgEntry.AudioQuality = "dolby digital"; break; default: break; } if (eitEntry.ComponentTypeVideo > 9) epgEntry.VideoQuality = "HDTV"; if (!RunParameters.Instance.Options.Contains("USEDESCASCATEGORY")) epgEntry.EventCategory = getEventCategory(eitEntry.EventName, eitEntry.Description, eitEntry.ContentType, eitEntry.ContentSubType); else epgEntry.EventCategory = eitEntry.ShortDescription; epgEntry.Duration = Utils.RoundTime(eitEntry.Duration); epgEntry.EventID = eitEntry.EventID; epgEntry.EventName = eitEntry.EventName; if (RunParameters.Instance.CountryCode != null) { epgEntry.ParentalRating = ParentalRating.FindRating(RunParameters.Instance.CountryCode, "EIT", (eitEntry.ParentalRating + 3).ToString()); epgEntry.MpaaParentalRating = ParentalRating.FindMpaaRating(RunParameters.Instance.CountryCode, "EIT", (eitEntry.ParentalRating + 3).ToString()); } else { if (eitEntry.ParentalRating > 11) { epgEntry.ParentalRating = "AO"; epgEntry.MpaaParentalRating = "AO"; } else { if (eitEntry.ParentalRating > 8) { epgEntry.ParentalRating = "PGR"; epgEntry.MpaaParentalRating = "PG"; } else { epgEntry.ParentalRating = "G"; epgEntry.MpaaParentalRating = "G"; } } } epgEntry.RunningStatus = eitEntry.RunningStatus; epgEntry.Scrambled = eitEntry.Scrambled; if (!RunParameters.Instance.Options.Contains("USEDESCASCATEGORY")) epgEntry.ShortDescription = eitEntry.Description; else epgEntry.ShortDescription = eitEntry.ExtendedDescription; epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(eitEntry.StartTime)); epgEntry.Cast = eitEntry.Cast; epgEntry.Directors = eitEntry.Directors; epgEntry.Date = eitEntry.Year; if (eitEntry.TVRating != null) epgEntry.ParentalRating = eitEntry.TVRating; epgEntry.StarRating = eitEntry.StarRating; if (eitEntry.TVRating != null) epgEntry.ParentalRating = eitEntry.TVRating; setSeriesEpisode(epgEntry, eitEntry); /*if (eitEntry.PreviousPlayDate != null) { try { TimeSpan offset = new TimeSpan(Int32.Parse(eitEntry.PreviousPlayDate) * TimeSpan.TicksPerSecond); epgEntry.PreviousPlayDate = epgEntry.StartTime - offset; } catch (FormatException) { } }*/ epgEntry.Country = eitEntry.Country; tvStation.AddEPGEntry(epgEntry); if (titleLogger != null) logTitle(eitEntry.EventName, eitEntry, epgEntry, titleLogger); if (descriptionLogger != null) logTitle(eitEntry.Description, eitEntry, epgEntry, descriptionLogger); if (RunParameters.Instance.DebugIDs.Contains("CATXREF")) updateCategoryEntries(tvStation, eitEntry); } lastIndex = eitEntry.Index; } }
private void processSections(Collection<Mpeg2Section> sections) { foreach (Mpeg2Section section in sections) { if (RunParameters.Instance.TraceIDs.Contains("FREESATSECTIONS")) Logger.Instance.Dump("FreeSat Section", section.Data, section.Length); try { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); mpeg2Header.Process(section.Data); if (mpeg2Header.Current) { FreeSatSection freeSatSection = new FreeSatSection(); freeSatSection.Process(section.Data, mpeg2Header); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> FreeSat error: " + e.Message); } } }
/// <summary> /// Parse the section. /// </summary> /// <param name="byteData">The MPEG2 section containing the section.</param> /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param> /// <param name="isCable">True is the section is a virtual cable section;false otherwise.</param> /// <param name="frequency">The frequency being processed.</param> public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header, bool isCable, int frequency) { lastIndex = mpeg2Header.Index; lastSectionNumber = mpeg2Header.LastSectionNumber; protocolVersion = (int)byteData[lastIndex]; lastIndex++; int channelCount = (int)byteData[lastIndex]; lastIndex++; if (channelCount != 0) { if (channels == null) channels = new Collection<VirtualChannel>(); while (channelCount != 0) { VirtualChannel channel = new VirtualChannel(frequency); channel.Process(byteData, lastIndex, isCable); addChannel(channel); lastIndex += channel.TotalLength; channelCount--; } } int descriptorLoopLength = ((byteData[lastIndex] & 0x03) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; if (descriptorLoopLength != 0) { descriptors = new Collection<DescriptorBase>(); while (descriptorLoopLength != 0) { while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.AtscInstance(byteData, lastIndex); descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } } } Validate(); }
/// <summary> /// Process an MPEG2 section from the bouquet association table. /// </summary> /// <param name="byteData">The MPEG2 section.</param> /// <returns>A Bouquet Association instance.</returns> public static BouquetAssociationSection ProcessBouquetAssociationTable(byte[] byteData) { Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader(); try { mpeg2Header.Process(byteData); if (mpeg2Header.Current) { BouquetAssociationSection bouquetAssociationSection = new BouquetAssociationSection(); bouquetAssociationSection.Process(byteData, mpeg2Header); bouquetAssociationSection.LogMessage(); return (bouquetAssociationSection); } } catch (ArgumentOutOfRangeException e) { Logger.Instance.Write("<e> Error processing Bouquet Association Section message: " + e.Message); } return (null); }
/// <summary> /// Parse the title header. /// </summary> /// <param name="byteData">The MPEG2 section containing the title header.</param> /// <param name="index">Index of the first byte of the title header in the MPEG2 section.</param> /// <param name="mpeg2Header">The MPEG2 header of the section.</param> /// <param name="pid">The PID of the section.</param> /// <param name="tid">The table ID of the section.</param> internal void Process(byte[] byteData, int index, Mpeg2ExtendedHeader mpeg2Header, int pid, int tid) { lastIndex = index; channelID = mpeg2Header.TableIDExtension; try { baseDate = getDate(Utils.Convert2BytesToInt(byteData, lastIndex)); lastIndex += 2; while (lastIndex < byteData.Length - 4) { OpenTVTitleData data = new OpenTVTitleData(); data.Process(byteData, lastIndex, baseDate, channelID, pid, tid); if (!data.IsEmpty) { if (titleData == null) titleData = new Collection<OpenTVTitleData>(); titleData.Add(data); } lastIndex = data.Index; } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("lastIndex = " + lastIndex)); } }