/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Service(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (length < 1) { return; } // Attach to data Section section = container.Section; // Load static ServiceType = (ServiceTypes)section[offset++]; // Adjust length -= 1; // Validate size if (length < 1) { return; } // Load length int providerLen = section[offset++]; // Adjust length -= 1 + providerLen; // Validate if (length < 1) { return; } // Read ProviderName = Section.ReadEncodedString(offset, providerLen, true); // Adjust offset += providerLen; // Load length int serviceLen = section[offset++]; // Adjust length -= 1 + serviceLen; // Validate if (0 != length) { return; } // Read ServiceName = Section.ReadEncodedString(offset, serviceLen, true); // We are valid m_Valid = true; }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveDescriptor"/> class. /// </summary> /// <param name="container">The <see cref="IDescriptorContainer"/> for the new instance.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="container"/> is <see langword="null"/>. /// </exception> public ReceiveDescriptor(IDescriptorContainer container) : base(container) { this.SocketArgs.Completed += this.EndReceiveAsynchronous; this.ClearBuffer(); }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Content(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Attach to data Section section = container.Section; // Collector List <int> all = new List <int>(); // Process content for (; length > 1; length -= 2) { // Read all int content = section[offset++]; int user = section[offset++]; // Remember all.Add(content); } // Remember Categories = all.ToArray(); // Test m_Valid = (0 == length); }
/// <summary> /// Erzeugt eine neue Ladeinstanz. /// </summary> /// <param name="table">Die zugehörige SI Struktur.</param> /// <param name="offset">Erstes Byte für Descriptoren.</param> /// <param name="length">Anzahl der Bytes für Descriptoren.</param> public DescriptorLoader(IDescriptorContainer table, int offset, int length) { // Remember all m_Container = table; m_Offset = offset; m_Length = length; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Content( IDescriptorContainer container, int offset, int length ) : base( container, offset, length ) { // Attach to data Section section = container.Section; // Collector List<int> all = new List<int>(); // Process content for (; length > 1; length -= 2) { // Read all int content = section[offset++]; int user = section[offset++]; // Remember all.Add( content ); } // Remember Categories = all.ToArray(); // Test m_Valid = (0 == length); }
public ServiceList(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Attach to section Section section = container.Section; // Process all while (length > 0) { // Not possible if (length < 3) return; // Load key ushort serviceIdentifier = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); // Remember Services[serviceIdentifier] = (ServiceTypes)section[offset + 2]; // Advance offset += 3; length -= 3; } // We are valid m_Valid = true; }
/// <summary> /// Erzeugt eine neue Liste. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param> /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param> /// <param name="length">Die Anzahl der Bytes für diese Liste.</param> public FrequencyList(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check for minimum length if (length < 1) { return; } // Attach to section Section section = container.Section; // Read the coding type CodingType = (CodingTypes)(section[offset + 0] & 0x3); // Load all for (length -= 1, offset += 1; length > 0; length -= 4, offset += 4) { // Not possible if (length < 4) { return; } // Load the item Frequencies.Add(Tools.MergeBytesToDoubleWord(section[offset + 3], section[offset + 2], section[offset + 1], section[offset + 0])); } // Test m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public PDCDescriptor(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if ( 3 != length ) return; // Attach to data Section section = container.Section; // Read parts byte pil0 = section[offset + 0]; byte pil1 = section[offset + 1]; byte pil2 = section[offset + 2]; // Split int dayHigh = pil0&0xf; int dayLow = pil1>>7; int hourHigh = pil1&0x7; int hourLow = pil2>>6; // Create label ProgramIdentificationLabel = string.Format("{0:00}-{1:00} {2:00}:{3:00}", (pil1>>3)&0xf, dayLow + 2 * dayHigh, hourLow + 4 * hourHigh, pil2&0x3f); // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public ExtendedEvent(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if ( length < 6 ) return; // Attach to data Section section = container.Section; // Read statics byte number = section[offset + 0]; // Decode DescriptorNumber = (number>>4)&0xf; LastDescriptorNumber = number&0xf; // Load length of items int itemLength = section[offset + 4]; // Verify if ( length < (6 + itemLength) ) return; // Load length of text int textLength = section[offset + 5 + itemLength]; // Verify if ( length != (6 + itemLength + textLength) ) return; // Read strings Language = section.ReadString(offset + 1, 3); Text = section.ReadEncodedString(offset + 6 + itemLength , textLength); // Items are currently not processed so we are done m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public ShortEvent(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if ( length < 5 ) return; // Attach to data Section section = container.Section; // Load length of event name int nameLength = section[offset + 3]; // Verify if ( length < (5 + nameLength) ) return; // Load length of text int textLength = section[offset + 4 + nameLength]; // Verify if ( length != (5 + nameLength + textLength) ) return; // Read strings Language = section.ReadString(offset + 0, 3); Name = section.ReadEncodedString(offset + 4, nameLength); Text = section.ReadEncodedString(offset + 5 + nameLength , textLength); // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public ISOLanguage(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if ( length < 0 ) return; // Attach to data Section section = container.Section; // Helper List<LanguageItem> items = new List<LanguageItem>(); // Load while (length > 0) { // Create LanguageItem item = LanguageItem.Create(section, offset, length); // Done if (null == item) break; // Remember items.Add(item); // Correct offset += item.Length; length -= item.Length; } // Test m_Valid = (0 == length); // Load if (m_Valid) Languages = items; }
/// <summary> /// Erstellt eine neue Beschreibung. /// </summary> /// <param name="container">Die Sammlung aller Beschreibungen.</param> /// <param name="offset">Das erste Rohdatenbyte zu dieser Beschreibung.</param> /// <param name="length">Die Größe der Beschreibung im Rohformat.</param> public CableDelivery(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Not possible if (11 != length) { return; } // Attach to section Section section = container.Section; // Load parts uint freq0 = (uint)Tools.FromBCD(section[offset + 0]); uint freq1 = (uint)Tools.FromBCD(section[offset + 1]); uint freq2 = (uint)Tools.FromBCD(section[offset + 2]); uint freq3 = (uint)Tools.FromBCD(section[offset + 3]); uint rate0 = (uint)Tools.FromBCD(section[offset + 7]); uint rate1 = (uint)Tools.FromBCD(section[offset + 8]); uint rate2 = (uint)Tools.FromBCD(section[offset + 9]); uint rate3 = (uint)Tools.FromBCD((byte)((section[offset + 10] >> 4) & 0xf)); // Load all SymbolRate = (rate3 + 10 * (rate2 + 100 * (rate1 + 100 * rate0))) / 10; Frequency = (freq3 + 100 * (freq2 + 100 * (freq1 + 100 * freq0))) / 10; InnerFEC = (InnerFECs)(section[offset + 10] & 0x0f); Modulation = (CableModulations)section[offset + 6]; OuterFEC = (OuterFECs)(section[offset + 5] & 0x0f); // We are valid m_Valid = true; }
/// <summary> /// Erzeugt eine neue Beschreibung. /// </summary> /// <param name="container">Die zugehörige Liste von Beschreibungen.</param> /// <param name="offset">Erstes Byte dieser Beschreibung.</param> /// <param name="length">Anzahl der Bytes für diese Beschreibung.</param> public ContentTransmissionPremiere(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (length < 6) return; // Attach to data Section section = container.Section; // Load station data TransportStreamIdentifier = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); OriginalNetworkIdentifier = Tools.MergeBytesToWord(section[offset + 3], section[offset + 2]); ServiceIdentifier = Tools.MergeBytesToWord(section[offset + 5], section[offset + 4]); // Adjust all offset += 6; length -= 6; // Times to use List<DateTime> dates = new List<DateTime>(); // Process all while (length >= 2) { // Read the data DateTime day = Tools.DecodeDate(section, offset + 0); // Read the number of times int bytes = section[offset + 2]; // Correct length and offset length -= 3 + bytes; offset += 3; // In error if (length < 0) return; // Read all for (; bytes > 0; bytes -= 3, offset += 3) { // Add the schedule dates.Add(day + Tools.DecodeDuration(section, offset)); } // Validate if (0 != bytes) return; } // In error if (0 != length) return; // Nothing found if (dates.Count < 1) return; // Remember StartTimes = dates.ToArray(); // Check if there is at least one time m_Valid = true; }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveDescriptor"/> class. /// </summary> /// <param name="container">The <see cref="IDescriptorContainer"/> for the new instance.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="container"/> is <see langword="null"/>. /// </exception> public ReceiveDescriptor(IDescriptorContainer container) : base(container) { SocketArgs.Completed += EndReceiveAsynchronous; ClearBuffer(); }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public PDCDescriptor(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (3 != length) { return; } // Attach to data Section section = container.Section; // Read parts byte pil0 = section[offset + 0]; byte pil1 = section[offset + 1]; byte pil2 = section[offset + 2]; // Split int dayHigh = pil0 & 0xf; int dayLow = pil1 >> 7; int hourHigh = pil1 & 0x7; int hourLow = pil2 >> 6; // Create label ProgramIdentificationLabel = string.Format("{0:00}-{1:00} {2:00}:{3:00}", (pil1 >> 3) & 0xf, dayLow + 2 * dayHigh, hourLow + 4 * hourHigh, pil2 & 0x3f); // We are valid m_Valid = true; }
/// <summary> /// Erzeugt eine neue Liste. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param> /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param> /// <param name="length">Die Anzahl der Bytes für diese Liste.</param> public FrequencyList( IDescriptorContainer container, int offset, int length ) : base( container, offset, length ) { // Check for minimum length if (length < 1) return; // Attach to section Section section = container.Section; // Read the coding type CodingType = (CodingTypes) (section[offset + 0] & 0x3); // Load all for (length -= 1, offset += 1; length > 0; length -= 4, offset += 4) { // Not possible if (length < 4) return; // Load the item Frequencies.Add( Tools.MergeBytesToDoubleWord( section[offset + 3], section[offset + 2], section[offset + 1], section[offset + 0] ) ); } // Test m_Valid = true; }
public CableDelivery(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Not possible if (11 != length) return; // Attach to section Section section = container.Section; // Load parts uint freq0 = (uint)Tools.FromBCD(section[offset + 0]); uint freq1 = (uint)Tools.FromBCD(section[offset + 1]); uint freq2 = (uint)Tools.FromBCD(section[offset + 2]); uint freq3 = (uint)Tools.FromBCD(section[offset + 3]); uint rate0 = (uint)Tools.FromBCD(section[offset + 7]); uint rate1 = (uint)Tools.FromBCD(section[offset + 8]); uint rate2 = (uint)Tools.FromBCD(section[offset + 9]); uint rate3 = (uint)Tools.FromBCD((byte)(section[offset + 10] & 0xf0)); // Load all SymbolRate = (rate3 + 100 * (rate2 + 100 * (rate1 + 100 * rate0))) / 10; Frequency = freq3 + 100 * (freq2 + 100 * (freq1 + 100 * freq0)); InnerFEC = (InnerFECs)(section[offset + 10] & 0x0f); Modulation = (CableModulations)section[offset + 6]; OuterFEC = (OuterFECs)(section[offset + 5] & 0x0f); // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Teletext(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if ( length < 0 ) return; // Attach to the section Section section = container.Section; // Helper List<TeletextItem> items = new List<TeletextItem>(); // Load while (length > 0) { // Try load TeletextItem item = TeletextItem.Create(section, offset, length); // Done if (null == item) break; // Add items.Add(item); // Count offset += item.Length; length -= item.Length; } // Store m_Valid = (0 == length); // Use if (m_Valid) Items = items; }
/// <summary> /// Erzeugt eine neue Liste. /// </summary> /// <param name="container">Alle Beschreibungen.</param> /// <param name="offset">Das erste Byte in den Rohdaten, dass zu dieser Beschreibung gehört.</param> /// <param name="length">Die Größe der Rohdaten zu dieser Beschreibung.</param> public ServiceList(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Attach to section Section section = container.Section; // Process all while (length > 0) { // Not possible if (length < 3) { return; } // Load key ushort serviceIdentifier = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); // Remember Services[serviceIdentifier] = (ServiceTypes)section[offset + 2]; // Advance offset += 3; length -= 3; } // We are valid m_Valid = true; }
/// <summary> /// Initializes a new instance of the <see cref="SendDescriptor"/> class. /// </summary> /// <param name="container">The <see cref="IDescriptorContainer"/> containing this instance.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="container" /> is <see langword="null"/>. /// </exception> public SendDescriptor(IDescriptorContainer container) : base(container) { this.SocketArgs.Completed += this.EndSendAsynchronous; this.isSending = new AtomicBoolean(false); this.queue = new ConcurrentQueue<byte[]>(); }
/// <summary> /// Initializes a new instance of the <see cref="SendDescriptor"/> class. /// </summary> /// <param name="container">The <see cref="IDescriptorContainer"/> containing this instance.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="container" /> is <see langword="null"/>. /// </exception> public SendDescriptor(IDescriptorContainer container) : base(container) { SocketArgs.Completed += EndSendAsynchronous; _isSending = new AtomicBoolean(false); _queue = new ConcurrentQueue <byte[]>(); }
/// <summary> /// Locate the related descriptor tag and create a new instance. /// </summary> /// <remarks> /// The tag can be found at the offset <i>- 2</i>. /// </remarks> /// <param name="container">The corresponding event instance. /// <seealso cref="EntryBase"/> /// </param> /// <param name="offset">The first byte of the descriptor raw data in /// the related <see cref="Section"/>.</param> /// <param name="length">The number of bytes for this instance. Since this /// does not include the tag and the length <see cref="byte"/> <see cref="Length"/> /// will be two greater than the value of this parameter.</param> /// <returns>A newly created <see cref="Descriptor"/> instance.</returns> static public Descriptor Create(IDescriptorContainer container, int offset, int length) { // Attach to the type Type pHandler = (Type)m_HandlerForTag[container.Section[offset - 2]]; // Create return((Descriptor)Activator.CreateInstance(pHandler, new object[] { container, offset, length })); }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public AC3(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if ( length-- < 1 ) return; // Attach to the section Section section = container.Section; // Read flags byte flags = section[offset++]; // Load flags m_HasComponentType = (0x80 == (0x80 & flags)); m_HasBSID = (0x40 == (0x40 & flags)); m_HasMainID = (0x20 == (0x20 & flags)); m_HasAssociatedService = (0x10 == (0x10 & flags)); // Read all if (m_HasComponentType) { // Test if (length-- < 1) return; // Load m_ComponentType = section[offset++]; } if (m_HasBSID) { // Test if (length-- < 1) return; // Load m_BSID = section[offset++]; } if (m_HasMainID) { // Test if (length-- < 1) return; // Load m_MainID = section[offset++]; } if (m_HasAssociatedService) { // Test if (length-- < 1) return; // Load m_AssociatedService = section[offset++]; } // Load the additional information m_AdditionalInformation = section.ReadBytes(offset, length); // Done m_Valid = true; }
/// <summary> /// Initializes a new instance of the <see cref="DescriptorBase"/> class. /// </summary> /// <remarks> /// This constructor initializes the /// <see cref="Container"/> and <see cref="SocketArgs"/> properties. /// </remarks> /// <param name="container">The container of this descriptor.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="container" /> is <see langword="null"/>. /// </exception> protected DescriptorBase(IDescriptorContainer container) { Guard.NotNull(() => container, container); this.isDisposed = false; this.socketArgs = new SocketAsyncEventArgs(); this.Container = container; }
/// <summary> /// Erstellt eine Beschreibung. /// </summary> /// <param name="container">Alle zusammenghörigen Beschreibungen.</param> /// <param name="offset">Das erste Byte dieser Beschreibung in den Rohdaten.</param> /// <param name="length">Die Größe dieser Beschreibung im Rohformat.</param> public NetworkName( IDescriptorContainer container, int offset, int length ) : base( container, offset, length ) { // Load the string Name = container.Section.ReadEncodedString( offset, length ); // We are valid m_Valid = true; }
/// <summary> /// Initialize a new instance. /// </summary> /// <param name="container">The corresponding event instance. /// <seealso cref="EntryBase"/> /// </param> /// <param name="offset">The first byte of the descriptor raw data in /// the related <see cref="Section"/>.</param> /// <param name="length">The number of bytes for this instance. Since this /// does not include the tag and the length <see cref="byte"/> <see cref="Length"/> /// will be two greater than the value of this parameter.</param> protected Descriptor(IDescriptorContainer container, int offset, int length) { // Set Tag = (DescriptorTags)container.Section[offset - 2]; // Remember Container = container; Length = 2 + length; }
/// <summary> /// Initializes a new instance of the <see cref="DescriptorBase"/> class. /// </summary> /// <remarks> /// This constructor initializes the <see cref="Container"/> and <see cref="SocketArgs"/> properties. /// </remarks> /// <param name="container">The container of this descriptor.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="container" /> is <see langword="null"/>. /// </exception> protected DescriptorBase(IDescriptorContainer container) { Guard.NotNull(() => container, container); _isDisposed = false; _socketArgs = new SocketAsyncEventArgs(); Container = container; }
/// <summary> /// Erstellt eine Beschreibung. /// </summary> /// <param name="container">Alle zusammenghörigen Beschreibungen.</param> /// <param name="offset">Das erste Byte dieser Beschreibung in den Rohdaten.</param> /// <param name="length">Die Größe dieser Beschreibung im Rohformat.</param> public NetworkName(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Load the string Name = container.Section.ReadEncodedString(offset, length); // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public DataBroadcast(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if (length < 8) { return; } // Attach to the section Section section = container.Section; // Load statics DataBroadcastID = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); ComponentTag = section[offset + 2]; // Read the length of the selector int selector = section[offset + 3]; // Correct length -= 4 + selector; // Test if (length < 1) { return; } // Load Selector = section.ReadBytes(offset + 4, selector); // Correct offset += 4 + selector; // Read the ISO language ISOLanguage = section.ReadString(offset, 3); // Read the length int text = section[offset + 3]; // Correct length -= 4 + text; // Test if (0 != length) { return; } // Load Text = section.ReadEncodedString(offset + 4, text); // Test m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public StreamIdentifier(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if ( 1 != length ) return; // Attach to data Section section = container.Section; // Load ComponentTag = section[offset]; // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Service(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if ( length < 1 ) return; // Attach to data Section section = container.Section; // Load static ServiceType = (ServiceTypes)section[offset++]; // Adjust length -= 1; // Validate size if (length < 1) return; // Load length int providerLen = section[offset++]; // Adjust length -= 1 + providerLen; // Validate if (length < 1) return; // Read ProviderName = Section.ReadEncodedString(offset, providerLen, true); // Adjust offset += providerLen; // Load length int serviceLen = section[offset++]; // Adjust length -= 1 + serviceLen; // Validate if (0 != length) return; // Read ServiceName = Section.ReadEncodedString(offset, serviceLen, true); // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public DataBroadcast(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if ( length < 8 ) return; // Attach to the section Section section = container.Section; // Load statics DataBroadcastID = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); ComponentTag = section[offset + 2]; // Read the length of the selector int selector = section[offset + 3]; // Correct length -= 4 + selector; // Test if (length < 1) return; // Load Selector = section.ReadBytes(offset + 4, selector); // Correct offset += 4 + selector; // Read the ISO language ISOLanguage = section.ReadString(offset, 3); // Read the length int text = section[offset + 3]; // Correct length -= 4 + text; // Test if (0 != length) return; // Load Text = section.ReadEncodedString(offset + 4, text); // Test m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public StreamIdentifier(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (1 != length) { return; } // Attach to data Section section = container.Section; // Load ComponentTag = section[offset]; // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public ISOLanguage(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if (length < 0) { return; } // Attach to data Section section = container.Section; // Helper List <LanguageItem> items = new List <LanguageItem>(); // Load while (length > 0) { // Create LanguageItem item = LanguageItem.Create(section, offset, length); // Done if (null == item) { break; } // Remember items.Add(item); // Correct offset += item.Length; length -= item.Length; } // Test m_Valid = (0 == length); // Load if (m_Valid) { Languages = items; } }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Teletext(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if (length < 0) { return; } // Attach to the section Section section = container.Section; // Helper List <TeletextItem> items = new List <TeletextItem>(); // Load while (length > 0) { // Try load TeletextItem item = TeletextItem.Create(section, offset, length); // Done if (null == item) { break; } // Add items.Add(item); // Count offset += item.Length; length -= item.Length; } // Store m_Valid = (0 == length); // Use if (m_Valid) { Items = items; } }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public ExtendedEvent(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (length < 6) { return; } // Attach to data Section section = container.Section; // Read statics byte number = section[offset + 0]; // Decode DescriptorNumber = (number >> 4) & 0xf; LastDescriptorNumber = number & 0xf; // Load length of items int itemLength = section[offset + 4]; // Verify if (length < (6 + itemLength)) { return; } // Load length of text int textLength = section[offset + 5 + itemLength]; // Verify if (length != (6 + itemLength + textLength)) { return; } // Read strings Language = section.ReadString(offset + 1, 3); Text = section.ReadEncodedString(offset + 6 + itemLength, textLength); // Items are currently not processed so we are done m_Valid = true; }
/// <summary> /// Erzeugt eine neue Liste. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param> /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param> /// <param name="length">Die Anzahl der Bytes für diese Liste.</param> public CellList(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if (length < 0) { return; } // Attach to data Section section = container.Section; // Helper List <CellInformation> cells = new List <CellInformation>(); // Load while (length > 0) { // Create CellInformation cell = CellInformation.Create(section, offset, length); // Done if (null == cell) { break; } // Remember cells.Add(cell); // Correct offset += cell.Length; length -= cell.Length; } // Test m_Valid = (0 == length); // Load if (m_Valid) { Cells = cells; } }
/// <summary> /// Erzeugt eine neue Referenzliste. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param> /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param> /// <param name="length">Die Anzahl der Bytes für diese Liste.</param> public CellFrequencyLink(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if (length < 0) { return; } // Attach to data Section section = container.Section; // Helper List <FrequencyLink> links = new List <FrequencyLink>(); // Load while (length > 0) { // Create FrequencyLink link = FrequencyLink.Create(section, offset, length); // Done if (null == link) { break; } // Remember links.Add(link); // Correct offset += link.Length; length -= link.Length; } // Test m_Valid = (0 == length); // Load if (m_Valid) { Links = links; } }
/// <summary> /// Erzeugt eine neue Beschreibung. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Beschreibung gefunden wurde.</param> /// <param name="offset">Das erste Byte zu den Rohdaten dieser Beschreibung in dem zugehörigen Bereich.</param> /// <param name="length">Die Anzahl der Bytes für die Rohdaten dieser Beschreibung.</param> public TerrestrialDelivery( IDescriptorContainer container, int offset, int length ) : base( container, offset, length ) { // Not possible if (11 != length) return; // Attach to section Section section = container.Section; // Load direct data Frequency = Tools.MergeBytesToDoubleWord( section[offset + 3], section[offset + 2], section[offset + 1], section[offset + 0] ) / 100; // Load bandwith Bandwidth = (TerrestrialBandwidths) (section[offset + 4] >> 5); // We are valid m_Valid = true; }
/// <summary> /// Erzeugt eine neue Beschreibung. /// </summary> /// <param name="container">Die zugehörige Liste zusammengehöriger Beschreibungen.</param> /// <param name="offset">Erstes Byte für diese einzelne Beschreibung.</param> /// <param name="length">Die Länge dieser Beschreibung in Bytes.</param> public Subtitle(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Process all while (length > 0) { // Create sub title data SubtitleInfo info = SubtitleInfo.Create(container.Section, offset, length); if (null == info) break; // Adjust offset += info.Length; length -= info.Length; // Remember Subtitles.Add(info); } // Check m_Valid = (0 == length); }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Component(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if ( length < 6 ) return; // Attach to data Section section = container.Section; // Read parts Content = section[offset + 0]&0xf; ComponentType = section[offset + 1]; ComponentTag = section[offset + 2]; // Load strings Language = section.ReadString(offset + 3, 3); Text = section.ReadEncodedString(offset + 6, length - 6); // Test m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public PrivateData(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if ( 4 != length ) return; // Attach to data Section section = container.Section; // Load UInt32 b3 = section[offset + 0]; UInt32 b2 = section[offset + 1]; UInt32 b1 = section[offset + 2]; UInt32 b0 = section[offset + 3]; // Merge Data = b0 + 256 * (b1 + 256 * (b2 + 256 * b3)); // We are valid m_Valid = true; }
/// <summary> /// Erzeugt eine neue Beschreibung. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Beschreibung gefunden wurde.</param> /// <param name="offset">Das erste Byte zu den Rohdaten dieser Beschreibung in dem zugehörigen Bereich.</param> /// <param name="length">Die Anzahl der Bytes für die Rohdaten dieser Beschreibung.</param> public TerrestrialDelivery(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Not possible if (11 != length) { return; } // Attach to section Section section = container.Section; // Load direct data Frequency = Tools.MergeBytesToDoubleWord(section[offset + 3], section[offset + 2], section[offset + 1], section[offset + 0]) / 100; // Load bandwith Bandwidth = (TerrestrialBandwidths)(section[offset + 4] >> 5); // We are valid m_Valid = true; }
/// <summary> /// Load all descriptors for an event instance. /// </summary> /// <remarks> /// No error will be reported if there is space left after the last decoded /// <see cref="Descriptor"/>. The returned <see cref="Array"/> may include instance /// with <see cref="IsValid"/> unset. /// </remarks> /// <param name="container">The corresponding event instance. /// <seealso cref="EntryBase"/> /// </param> /// <param name="offset">The first byte of the first descriptors raw data in /// the related <see cref="Section"/>.</param> /// <param name="length">The total number of bytes available in the /// event. New <see cref="Descriptor"/> instances are created until /// there is no space left.</param> /// <returns>All <see cref="Descriptor"/> instances for an event.</returns> static public Descriptor[] Load(IDescriptorContainer container, int offset, int length) { // Attach to data Section section = container.Section; // Helper ArrayList all = new ArrayList(); // Process as long as possible for (; ;) { // No space for header if (length < 2) { break; } // Read tag and length int bytes = section[offset + 1]; // Check space if ((2 + bytes) > length) { break; } // Create instance Descriptor pNew = Create(container, offset + 2, bytes); // Remember all.Add(pNew); // Adjust offset += pNew.Length; length -= pNew.Length; } // Create return((Descriptor[])all.ToArray(typeof(Descriptor))); }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public ParentalRating(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Attach to data Section section = container.Section; // Collector ArrayList all = new ArrayList(); // Process content for ( ; length > 3; length -= 4, offset += 4) { // Read all string country = section.ReadString(offset + 0, 3); byte rating = section[offset + 3]; // Check mode if (0 == rating) { // Remember all.Add(country); } else if (rating < 0x10) { // Remember all.Add(string.Format("{0}-{1}", country, rating + 3)); } else { // Remember all.Add(string.Format("{0} [{1}]", country, rating)); } } // Remember Ratings = (string[])all.ToArray(typeof(string)); // We are valid m_Valid = (0 == length); }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public ParentalRating(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Attach to data Section section = container.Section; // Collector ArrayList all = new ArrayList(); // Process content for ( ; length > 3 ; length -= 4, offset += 4 ) { // Read all string country = section.ReadString(offset + 0, 3); byte rating = section[offset + 3]; // Check mode if ( 0 == rating ) { // Remember all.Add(country); } else if ( rating < 0x10 ) { // Remember all.Add(string.Format("{0}-{1}", country, rating + 3)); } else { // Remember all.Add(string.Format("{0} [{1}]", country, rating)); } } // Remember Ratings = (string[])all.ToArray(typeof(string)); // We are valid m_Valid = (0 == length); }
/// <summary> /// Erstellt eine neue Beschreibung. /// </summary> /// <param name="container">Die Sammlung aller Beschreibungen.</param> /// <param name="offset">Das erste Byte in den Rohdaten zu dieser Beschreibung.</param> /// <param name="length">Die Größe der Beschreibung in den Rohdaten.</param> public SatelliteDelivery(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Not possible if (11 != length) { return; } // Attach to section Section section = container.Section; // Load parts uint freq0 = (uint)Tools.FromBCD(section[offset + 0]); uint freq1 = (uint)Tools.FromBCD(section[offset + 1]); uint freq2 = (uint)Tools.FromBCD(section[offset + 2]); uint freq3 = (uint)Tools.FromBCD(section[offset + 3]); ushort orb0 = (ushort)Tools.FromBCD(section[offset + 4]); ushort orb1 = (ushort)Tools.FromBCD(section[offset + 5]); uint rate0 = (uint)Tools.FromBCD(section[offset + 7]); uint rate1 = (uint)Tools.FromBCD(section[offset + 8]); uint rate2 = (uint)Tools.FromBCD(section[offset + 9]); uint rate3 = (uint)Tools.FromBCD((byte)((section[offset + 10] >> 4) & 0xf)); // Flags byte flags = section[offset + 6]; // Load all Frequency = (freq3 + 100 * (freq2 + 100 * (freq1 + 100 * freq0))) * 10; SymbolRate = (rate3 + 10 * (rate2 + 100 * (rate1 + 100 * rate0))) / 10; Polarization = (Polarizations)((flags >> 5) & 0x03); InnerFEC = (InnerFECs)(section[offset + 10] & 0x0f); OrbitalPosition = (ushort)(orb1 + 100 * orb0); West = (0x00 == (0x80 & flags)); Modulation = (byte)(flags & 0x1f); // We are valid m_Valid = true; }
/// <summary> /// Erzeugt eine neue Liste. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param> /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param> /// <param name="length">Die Anzahl der Bytes für diese Liste.</param> public CellList( IDescriptorContainer container, int offset, int length ) : base( container, offset, length ) { // Check minimum length if (length < 0) return; // Attach to data Section section = container.Section; // Helper List<CellInformation> cells = new List<CellInformation>(); // Load while (length > 0) { // Create CellInformation cell = CellInformation.Create( section, offset, length ); // Done if (null == cell) break; // Remember cells.Add( cell ); // Correct offset += cell.Length; length -= cell.Length; } // Test m_Valid = (0 == length); // Load if (m_Valid) Cells = cells; }
/// <summary> /// Erzeugt eine neue Referenzliste. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param> /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param> /// <param name="length">Die Anzahl der Bytes für diese Liste.</param> public CellFrequencyLink( IDescriptorContainer container, int offset, int length ) : base( container, offset, length ) { // Check minimum length if (length < 0) return; // Attach to data Section section = container.Section; // Helper List<FrequencyLink> links = new List<FrequencyLink>(); // Load while (length > 0) { // Create FrequencyLink link = FrequencyLink.Create( section, offset, length ); // Done if (null == link) break; // Remember links.Add( link ); // Correct offset += link.Length; length -= link.Length; } // Test m_Valid = (0 == length); // Load if (m_Valid) Links = links; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public ShortEvent(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (length < 5) { return; } // Attach to data Section section = container.Section; // Load length of event name int nameLength = section[offset + 3]; // Verify if (length < (5 + nameLength)) { return; } // Load length of text int textLength = section[offset + 4 + nameLength]; // Verify if (length != (5 + nameLength + textLength)) { return; } // Read strings Language = section.ReadString(offset + 0, 3); Name = section.ReadEncodedString(offset + 4, nameLength); Text = section.ReadEncodedString(offset + 5 + nameLength, textLength); // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Component(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if (length < 6) { return; } // Attach to data Section section = container.Section; // Read parts Content = section[offset + 0] & 0xf; ComponentType = section[offset + 1]; ComponentTag = section[offset + 2]; // Load strings Language = section.ReadString(offset + 3, 3); Text = section.ReadEncodedString(offset + 6, length - 6); // Test m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public PrivateData(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (4 != length) { return; } // Attach to data Section section = container.Section; // Load UInt32 b3 = section[offset + 0]; UInt32 b2 = section[offset + 1]; UInt32 b1 = section[offset + 2]; UInt32 b0 = section[offset + 3]; // Merge Data = b0 + 256 * (b1 + 256 * (b2 + 256 * b3)); // We are valid m_Valid = true; }
/// <summary> /// Erzeugt eine neue Beschreibung. /// </summary> /// <param name="container">Die zugehörige Liste zusammengehöriger Beschreibungen.</param> /// <param name="offset">Erstes Byte für diese einzelne Beschreibung.</param> /// <param name="length">Die Länge dieser Beschreibung in Bytes.</param> public Subtitle(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Process all while (length > 0) { // Create sub title data SubtitleInfo info = SubtitleInfo.Create(container.Section, offset, length); if (null == info) { break; } // Adjust offset += info.Length; length -= info.Length; // Remember Subtitles.Add(info); } // Check m_Valid = (0 == length); }
public SatelliteDelivery(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Not possible if (11 != length) return; // Attach to section Section section = container.Section; // Load parts uint freq0 = (uint)Tools.FromBCD(section[offset + 0]); uint freq1 = (uint)Tools.FromBCD(section[offset + 1]); uint freq2 = (uint)Tools.FromBCD(section[offset + 2]); uint freq3 = (uint)Tools.FromBCD(section[offset + 3]); ushort orb0 = (ushort)Tools.FromBCD(section[offset + 4]); ushort orb1 = (ushort)Tools.FromBCD(section[offset + 5]); uint rate0 = (uint)Tools.FromBCD(section[offset + 7]); uint rate1 = (uint)Tools.FromBCD(section[offset + 8]); uint rate2 = (uint)Tools.FromBCD(section[offset + 9]); uint rate3 = (uint)Tools.FromBCD((byte)(section[offset + 10] & 0xf0)); // Flags byte flags = section[offset + 6]; // Load all Frequency = freq3 + 100 * (freq2 + 100 * (freq1 + 100 * freq0)); SymbolRate = (rate3 + 100 * (rate2 + 100 * (rate1 + 100 * rate0))) / 10; Polarization = (Polarizations)((flags >> 5) & 0x03); InnerFEC = (InnerFECs)(section[offset + 10] & 0x0f); OrbitalPosition = (ushort)(orb1 + 100 * orb0); West = (0x00 == (0x80 & flags)); Modulation = (byte)(flags & 0x1f); // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Linkage(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (length < 7) { return; } // Attach to data Section section = container.Section; // Read head TransportStreamIdentifier = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); OriginalNetworkIdentifier = Tools.MergeBytesToWord(section[offset + 3], section[offset + 2]); ServiceIdentifier = Tools.MergeBytesToWord(section[offset + 5], section[offset + 4]); // Read type LinkType = section[offset + 6]; // Correct offset += 7; length -= 7; // Depends if (8 == LinkType) { // Check mode if (length < 1) { return; } // Raw read byte temp = section[offset + 0]; // Decode HandOverType = (byte)(temp >> 4); OriginType = (0 != (temp & 1)); // Special if ((1 == HandOverType) || (2 == HandOverType) || (3 == HandOverType)) { // Check mode if (length < 3) { return; } // Read NetworkID = Tools.MergeBytesToWord(section[offset + 2], section[offset + 1]); // Move ahead offset += 2; length -= 2; } // Special if (!OriginType) { // Check mode if (length < 3) { return; } // Read InitialServiceIdentifier = Tools.MergeBytesToWord(section[offset + 2], section[offset + 1]); // Move ahead offset += 2; length -= 2; } // Adjust ++offset; --length; } // The rest is private data PrivateData = section.ReadBytes(offset, length); // We are valid m_Valid = true; }
/// <summary> /// Load all descriptors for an event instance. /// </summary> /// <remarks> /// No error will be reported if there is space left after the last decoded /// <see cref="Descriptor"/>. The returned <see cref="Array"/> may include instance /// with <see cref="IsValid"/> unset. /// </remarks> /// <param name="entry">The corresponding event instance. /// <seealso cref="Entry"/> /// </param> /// <param name="offset">The first byte of the first descriptors raw data in /// the related <see cref="Section"/>.</param> /// <param name="length">The total number of bytes available in the /// event. New <see cref="Descriptor"/> instances are created until /// there is no space left.</param> /// <returns>All <see cref="Descriptor"/> instances for an event.</returns> public static Descriptor[] Load(IDescriptorContainer container, int offset, int length) { // Attach to data Section section = container.Section; // Helper ArrayList all = new ArrayList(); // Process as long as possible for ( ; ; ) { // No space for header if ( length < 2 ) break; // Read tag and length int bytes = section[offset + 1]; // Check space if ( (2 + bytes) > length ) break; // Create instance Descriptor pNew = Create(container, offset + 2, bytes); // Remember all.Add(pNew); // Adjust offset += pNew.Length; length -= pNew.Length; } // Create return (Descriptor[])all.ToArray(typeof(Descriptor)); }
/// <summary> /// Erzeugt eine neue Beschreibung. /// </summary> /// <param name="container">Die zugehörige Liste von Beschreibungen.</param> /// <param name="offset">Erstes Byte dieser Beschreibung.</param> /// <param name="length">Anzahl der Bytes für diese Beschreibung.</param> public ContentTransmissionPremiere(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if (length < 6) { return; } // Attach to data Section section = container.Section; // Load station data TransportStreamIdentifier = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); OriginalNetworkIdentifier = Tools.MergeBytesToWord(section[offset + 3], section[offset + 2]); ServiceIdentifier = Tools.MergeBytesToWord(section[offset + 5], section[offset + 4]); // Adjust all offset += 6; length -= 6; // Times to use List <DateTime> dates = new List <DateTime>(); // Process all while (length >= 2) { // Read the data DateTime day = Tools.DecodeDate(section, offset + 0); // Read the number of times int bytes = section[offset + 2]; // Correct length and offset length -= 3 + bytes; offset += 3; // In error if (length < 0) { return; } // Read all for (; bytes > 0; bytes -= 3, offset += 3) { // Add the schedule dates.Add(day + Tools.DecodeDuration(section, offset)); } // Validate if (0 != bytes) { return; } } // In error if (0 != length) { return; } // Nothing found if (dates.Count < 1) { return; } // Remember StartTimes = dates.ToArray(); // Check if there is at least one time m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Linkage(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Validate size if ( length < 7 ) return; // Attach to data Section section = container.Section; // Read head TransportStreamIdentifier = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); OriginalNetworkIdentifier = Tools.MergeBytesToWord(section[offset + 3], section[offset + 2]); ServiceIdentifier = Tools.MergeBytesToWord(section[offset + 5], section[offset + 4]); // Read type LinkType = section[offset + 6]; // Correct offset += 7; length -= 7; // Depends if ( 8 == LinkType ) { // Check mode if ( length < 1 ) return; // Raw read byte temp = section[offset + 0]; // Decode HandOverType = (byte)(temp>>4); OriginType = (0 != (temp&1)); // Special if ( (1 == HandOverType) || (2 == HandOverType) || (3 == HandOverType) ) { // Check mode if ( length < 3 ) return; // Read NetworkID = Tools.MergeBytesToWord(section[offset + 2], section[offset + 1]); // Move ahead offset += 2; length -= 2; } // Special if ( !OriginType ) { // Check mode if ( length < 3 ) return; // Read InitialServiceIdentifier = Tools.MergeBytesToWord(section[offset + 2], section[offset + 1]); // Move ahead offset += 2; length -= 2; } // Adjust ++offset; --length; } // The rest is private data PrivateData = section.ReadBytes(offset, length); // We are valid m_Valid = true; }
/// <summary> /// Create a new descriptor instance. /// </summary> /// <remarks> /// <see cref="Descriptor.IsValid"/> will only be set if the payload is /// consistent. /// </remarks> /// <param name="container">The related container instance.</param> /// <param name="offset">First byte of the descriptor data - the first byte after the tag.</param> /// <param name="length">Number of payload bytes for this descriptor.</param> public Generic(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { }