/// <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 entry. /// </summary> /// <param name="byteData">The MPEG2 section containing the transport stream.</param> /// <param name="index">Index of the first byte of the transport stream in the MPEG2 section.</param> internal void Process(byte[] byteData, int index) { lastIndex = index; try { eventID = ((byteData[lastIndex] & 0x3f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; startTime = new DateTime(1980, 1, 6, 0, 0, 0, DateTimeKind.Utc) + new TimeSpan(Utils.Convert4BytesToInt(byteData, lastIndex) * TimeSpan.TicksPerSecond); lastIndex += 4; etmLocation = (byteData[lastIndex] & 0x30) >> 4; duration = new TimeSpan( ((byteData[lastIndex] & 0x0f) * 16384) + ((byteData[lastIndex + 1] * 256) + byteData[lastIndex + 2]) * TimeSpan.TicksPerSecond); lastIndex += 3; int titleLength = (int)byteData[lastIndex]; lastIndex++; if (titleLength != 0) { eventName = new MultipleString(); eventName.Process(byteData, lastIndex); lastIndex += titleLength; } int descriptorLoopLength = ((byteData[lastIndex] & 0x03) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; totalLength = (lastIndex - index) + descriptorLoopLength; if (descriptorLoopLength != 0) { descriptors = new Collection <DescriptorBase>(); while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.AtscInstance(byteData, lastIndex); descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The Event Information Table entry message is short")); } }
private void processDescriptor(DescriptorBase descriptor) { switch (descriptor.Tag) { case DescriptorBase.DishNetworkShortEventDescriptorTag: DishNetworkShortEventDescriptor shortEventDescriptor = descriptor as DishNetworkShortEventDescriptor; eventName = shortEventDescriptor.EventName; break; case DescriptorBase.DishNetworkExtendedEventDescriptorTag: DishNetworkExtendedEventDescriptor extendedEventDescriptor = descriptor as DishNetworkExtendedEventDescriptor; originalDescription = extendedEventDescriptor.OriginalDescription; shortDescription = extendedEventDescriptor.EventDescription; subTitle = extendedEventDescriptor.SubTitle; closedCaptions = extendedEventDescriptor.ClosedCaptions; highDefinition = extendedEventDescriptor.HighDefinition; stereo = extendedEventDescriptor.Stereo; date = extendedEventDescriptor.Date; cast = extendedEventDescriptor.Cast; break; case DescriptorBase.DishNetworkRatingDescriptorTag: DishNetworkRatingDescriptor ratingDescriptor = descriptor as DishNetworkRatingDescriptor; parentalRating = ratingDescriptor.ParentalRating; starRating = ratingDescriptor.StarRating; hasSexualContent = ratingDescriptor.HasSexualContent; hasStrongLanguage = ratingDescriptor.HasStrongLanguage; hasViolence = ratingDescriptor.HasViolence; hasNudity = ratingDescriptor.HasNudity; break; case DescriptorBase.DishNetworkSeriesDescriptorTag: DishNetworkSeriesDescriptor seriesDescriptor = descriptor as DishNetworkSeriesDescriptor; series = seriesDescriptor.Series; episode = seriesDescriptor.Episode; originalAirDate = seriesDescriptor.OriginalAirDate; break; case DescriptorBase.ContentDescriptorTag: contentType = (descriptor as DVBContentDescriptor).ContentSubType[0]; contentSubType = (descriptor as DVBContentDescriptor).UserType[0]; break; default: if (RunParameters.Instance.DebugIDs.Contains("UNKNOWNDESCRIPTORS")) { Logger.Instance.Write("Unprocessed Dish Network descriptor: 0x" + descriptor.Tag.ToString("X")); if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTORDATA")) { Logger.Instance.Dump("Descriptor Data", descriptor.Data, descriptor.Data.Length); } } break; } }
/// <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 service description. /// </summary> /// <param name="byteData">The MPEG2 section containing the service description.</param> /// <param name="index">Index of the first byte of the service description in the MPEG2 section.</param> internal void Process(byte[] byteData, int index) { lastIndex = index; try { serviceID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; eitSchedule = ((int)byteData[lastIndex] & 0x02) != 0; eitPresentFollowing = ((int)byteData[lastIndex] & 0x01) != 0; lastIndex++; runningStatus = (int)(byteData[lastIndex] >> 5); scrambled = ((int)byteData[lastIndex] & 0x10) >> 4 == 1; int descriptorLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, Scope.ServiceDescripton); if (!descriptor.IsEmpty) { if (descriptor as DVBServiceDescriptor != null) { serviceDescriptor = descriptor as DVBServiceDescriptor; } else { if (descriptor as ServiceChannelDescriptor != null) { serviceChannelDescriptor = descriptor as ServiceChannelDescriptor; } } lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; descriptorLoopLength -= DescriptorBase.MinimumDescriptorLength; } } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The DVB Service Description message 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> /// <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> 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> /// Create an instance of the descriptor class for Dish Network descriptors. /// </summary> /// <param name="byteData">The MPEG2 section containing the descriptor.</param> /// <param name="index">The index of the tag byte of the descriptor.</param> /// <param name="table">The table ID containing this descriptor.</param> /// <returns>A descriptor instance.</returns> internal static DescriptorBase DishNetworkInstance(byte[] byteData, int index, int table) { DescriptorBase descriptor; switch ((int)byteData[index]) { case DishNetworkRatingDescriptorTag: descriptor = new DishNetworkRatingDescriptor(); break; case DishNetworkShortEventDescriptorTag: descriptor = new DishNetworkShortEventDescriptor(); break; case DishNetworkExtendedEventDescriptorTag: descriptor = new DishNetworkExtendedEventDescriptor(); break; case DishNetworkSupplementaryDescriptorTag: descriptor = new DishNetworkSupplementaryDescriptor(); break; case DishNetworkVCHIPDescriptorTag: descriptor = new DishNetworkVCHIPDescriptor(); break; case DishNetworkSeriesDescriptorTag: descriptor = new DishNetworkSeriesDescriptor(); break; case ContentDescriptorTag: descriptor = new DVBContentDescriptor(); break; default: descriptor = new DescriptorBase(); break; } descriptor.table = table; descriptor.tag = (int)byteData[index]; index++; descriptor.length = (int)byteData[index]; index++; descriptor.Process(byteData, index); return(descriptor); }
/// <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 entry. /// </summary> /// <param name="byteData">The MPEG2 section containing the transport stream.</param> /// <param name="index">Index of the first byte of the transport stream in the MPEG2 section.</param> /// <param name="scope">The scope of the processing..</param> internal void Process(byte[] byteData, int index, Scope scope) { lastIndex = index; try { transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; int descriptorLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; totalLength = descriptorLoopLength + 6; if (descriptorLoopLength != 0) { descriptors = new Collection <DescriptorBase>(); while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, scope); if (!descriptor.IsEmpty) { descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; descriptorLoopLength -= DescriptorBase.MinimumDescriptorLength; } } } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The DVB Transport Stream message is short")); } }
/// <summary> /// Parse the entry. /// </summary> /// <param name="byteData">The MPEG2 section containing the entry.</param> /// <param name="index">Index of the event identification byte in the MPEG2 section.</param> /// <param name="table">The table ID containing this section.</param> public void Process(byte[] byteData, int index, int table) { lastIndex = index; try { eventID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; getStartTime(byteData, lastIndex); lastIndex += 5; getDuration(byteData, lastIndex); lastIndex += 3; runningStatus = (int)(byteData[lastIndex] >> 5); scrambled = ((int)byteData[lastIndex] & 0x10) >> 4 == 1; int descriptorLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.DishNetworkInstance(byteData, lastIndex, table); if (!descriptor.IsEmpty) { processDescriptor(descriptor); descriptor.LogMessage(); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; descriptorLoopLength -= DescriptorBase.MinimumDescriptorLength; } } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The Dish Network message is short")); } }
/// <summary> /// Parse the stream information. /// </summary> /// <param name="byteData">The MPEG2 section containing the stream information.</param> /// <param name="index">Index of the first byte of the stream information in the MPEG2 section.</param> internal void Process(byte[] byteData, int index) { lastIndex = index; try { streamType = (int)byteData[lastIndex]; lastIndex++; programID = ((byteData[lastIndex] & 0x1f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; int esInfoLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; if (esInfoLength != 0) { descriptors = new Collection <DescriptorBase>(); while (esInfoLength > 0) { DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex); if (!descriptor.IsEmpty) { descriptors.Add(descriptor); lastIndex += descriptor.TotalLength; esInfoLength -= descriptor.TotalLength; } else { lastIndex += DescriptorBase.MinimumDescriptorLength; esInfoLength -= DescriptorBase.MinimumDescriptorLength; } } } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The DVB Stream Info message is short")); } }
/// <summary> /// Create an instance of the descriptor class for ATSC descriptors. /// </summary> /// <param name="byteData">The MPEG2 section containing the descriptor.</param> /// <param name="index">The index of the tag byte of the descriptor.</param> /// <returns>A descriptor instance.</returns> internal static DescriptorBase AtscInstance(byte[] byteData, int index) { DescriptorBase descriptor; switch ((int)byteData[index]) { case AtscAC3AudioDescriptorTag: descriptor = new AC3AudioDescriptor(); break; case AtscCaptionServiceDescriptorTag: descriptor = new CaptionServiceDescriptor(); break; case AtscContentAdvisoryDescriptorTag: descriptor = new ContentAdvisoryDescriptor(); break; case AtscExtendedChannelNameDescriptorTag: descriptor = new ExtendedChannelNameDescriptor(); break; case AtscServiceLocationDescriptorTag: descriptor = new ServiceLocationDescriptor(); break; case AtscGenreDescriptorTag: descriptor = new GenreDescriptor(); break; default: descriptor = new DescriptorBase(); break; } descriptor.tag = (int)byteData[index]; index++; descriptor.length = (int)byteData[index]; index++; descriptor.Process(byteData, index); return(descriptor); }
/// <summary> /// Parse the entry. /// </summary> /// <param name="byteData">The MPEG2 section containing the transport stream.</param> /// <param name="index">Index of the first byte of the transport stream in the MPEG2 section.</param> internal void Process(byte[] byteData, int index) { lastIndex = index; try { tableType = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; pid = ((byteData[lastIndex] & 0x1f) * 256) + byteData[lastIndex + 1]; lastIndex += 2; version = byteData[lastIndex] & 0x01f; lastIndex++; byteCount = Utils.Convert4BytesToInt(byteData, lastIndex); lastIndex += 4; int descriptorLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; totalLength = descriptorLoopLength + 11; if (descriptorLoopLength != 0) { descriptors = new Collection <DescriptorBase>(); while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.AtscInstance(byteData, lastIndex); descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The Master Guide Table entry message is short")); } }
/// <summary> /// Create an instance of the descriptor class for Bell TV descriptors. /// </summary> /// <param name="byteData">The MPEG2 section containing the descriptor.</param> /// <param name="index">The index of the tag byte of the descriptor.</param> /// <param name="table">The table ID containing this descriptor.</param> /// <returns>A descriptor instance.</returns> internal static DescriptorBase BellTVInstance(byte[] byteData, int index, int table) { DescriptorBase descriptor; switch ((int)byteData[index]) { case ShortEventDescriptorTag: descriptor = new BellShortEventDescriptor(); break; case BellTVExtendedEventDescriptorTag: descriptor = new BellTVExtendedEventDescriptor(); break; case BellTVRatingDescriptorTag: descriptor = new BellTVRatingDescriptor(); break; case BellTVSeriesDescriptorTag: descriptor = new BellTVSeriesDescriptor(); break; case ContentDescriptorTag: descriptor = new DVBContentDescriptor(); break; default: descriptor = new DescriptorBase(); break; } descriptor.table = table; descriptor.tag = (int)byteData[index]; index++; descriptor.length = (int)byteData[index]; index++; descriptor.Process(byteData, index); return(descriptor); }
/// <summary> /// Create an instance of the descriptor class for ATSC descriptors. /// </summary> /// <param name="byteData">The MPEG2 section containing the descriptor.</param> /// <param name="index">The index of the tag byte of the descriptor.</param> /// <returns>A descriptor instance.</returns> internal static DescriptorBase AtscInstance(byte[] byteData, int index) { DescriptorBase descriptor; switch ((int)byteData[index]) { case AtscAC3AudioDescriptorTag: descriptor = new AC3AudioDescriptor(); break; case AtscCaptionServiceDescriptorTag: descriptor = new CaptionServiceDescriptor(); break; case AtscContentAdvisoryDescriptorTag: descriptor = new ContentAdvisoryDescriptor(); break; case AtscExtendedChannelNameDescriptorTag: descriptor = new ExtendedChannelNameDescriptor(); break; case AtscServiceLocationDescriptorTag: descriptor = new ServiceLocationDescriptor(); break; case AtscGenreDescriptorTag: descriptor = new GenreDescriptor(); break; default: descriptor = new DescriptorBase(); break; } descriptor.tag = (int)byteData[index]; index++; descriptor.length = (int)byteData[index]; index++; descriptor.Process(byteData, index); return (descriptor); }
/// <summary> /// Parse the descriptor. /// </summary> /// <param name="byteData">The mpeg2 section containing the descriptor.</param> /// <param name="index">Index of the byte in the mpeg2 section following the descriptor length.</param> /// <param name="region">The region being processed.</param> internal void Process(byte[] byteData, int index, int region) { lastIndex = index; this.region = region; int nameLength = (int)byteData[lastIndex]; lastIndex++; if (nameLength != 0) { name = new MultipleString(); name.Process(byteData, lastIndex); name.LogMessage(); lastIndex = name.Index; } int dimensionCount = (int)byteData[lastIndex]; lastIndex++; if (dimensionCount != 0) { dimensions = new Collection <RatingRegionDimension>(); while (dimensionCount != 0) { RatingRegionDimension dimension = new RatingRegionDimension(); dimension.Process(byteData, lastIndex); dimensions.Add(dimension); lastIndex = dimension.Index; dimensionCount--; } } 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> /// Create an instance of the descriptor class for Dish Network descriptors. /// </summary> /// <param name="byteData">The MPEG2 section containing the descriptor.</param> /// <param name="index">The index of the tag byte of the descriptor.</param> /// <param name="table">The table ID containing this descriptor.</param> /// <returns>A descriptor instance.</returns> internal static DescriptorBase DishNetworkInstance(byte[] byteData, int index, int table) { DescriptorBase descriptor; switch ((int)byteData[index]) { case DishNetworkRatingDescriptorTag: descriptor = new DishNetworkRatingDescriptor(); break; case DishNetworkShortEventDescriptorTag: descriptor = new DishNetworkShortEventDescriptor(); break; case DishNetworkExtendedEventDescriptorTag: descriptor = new DishNetworkExtendedEventDescriptor(); break; case DishNetworkSupplementaryDescriptorTag: descriptor = new DishNetworkSupplementaryDescriptor(); break; case DishNetworkVCHIPDescriptorTag: descriptor = new DishNetworkVCHIPDescriptor(); break; case DishNetworkSeriesDescriptorTag: descriptor = new DishNetworkSeriesDescriptor(); break; case ContentDescriptorTag: descriptor = new DVBContentDescriptor(); break; default: descriptor = new DescriptorBase(); break; } descriptor.table = table; descriptor.tag = (int)byteData[index]; index++; descriptor.length = (int)byteData[index]; index++; descriptor.Process(byteData, index); return (descriptor); }
/// <summary> /// Create an instance of the descriptor class. /// </summary> /// <param name="byteData">The MPEG2 section containing the descriptor.</param> /// <param name="index">The index of the tag byte of the descriptor.</param> /// <param name="scope">The current scope.</param> /// <returns>A descriptor instance.</returns> internal static DescriptorBase Instance(byte[] byteData, int index, Scope scope) { DescriptorBase descriptor; switch ((int)byteData[index]) { case NetworkNameDescriptorTag: descriptor = new DVBNetworkNameDescriptor(); break; case SatelliteDeliverySystemDescriptorTag: descriptor = new DVBSatelliteDeliverySystemDescriptor(); break; case ServiceDescriptorTag: descriptor = new DVBServiceDescriptor(); break; case ServiceListDescriptorTag: descriptor = new DVBServiceListDescriptor(); break; case ShortEventDescriptorTag: descriptor = new DVBShortEventDescriptor(); break; case ExtendedEventDescriptorTag: descriptor = new DVBExtendedEventDescriptor(); break; case ComponentDescriptorTag: descriptor = new DVBComponentDescriptor(); break; case ContentDescriptorTag: descriptor = new DVBContentDescriptor(); break; case ParentalRatingDescriptorTag: descriptor = new DVBParentalRatingDescriptor(); break; case BouquetNameDescriptorTag: descriptor = new DVBBouquetNameDescriptor(); break; case LocalTimeOffsetDescriptorTag: descriptor = new DVBLocalTimeOffsetDescriptor(); break; case OpenTVChannelInfoDescriptorTag: descriptor = new OpenTVChannelInfoDescriptor(); break; case GenericChannelInfoDescriptorTag: switch (scope) { case Scope.Bouquet: descriptor = new FreeviewChannelInfoDescriptor(); break; case Scope.ServiceDescripton: descriptor = new ServiceChannelDescriptor(); break; default: descriptor = new DescriptorBase(); break; } break; case FreeviewChannelInfoDescriptorTag: case TurkeyChannelInfoDescriptorTag: case E2ChannelInfoDescriptorTag: if (scope == Scope.Bouquet) descriptor = new FreeviewChannelInfoDescriptor(); else descriptor = new DescriptorBase(); break; case FreeSatChannelInfoDescriptorTag: descriptor = new FreeSatChannelInfoDescriptor(); break; case ContentIdentifierDescriptorTag: descriptor = new DVBContentIdentifierDescriptor(); break; default: descriptor = new DescriptorBase(); break; } descriptor.tag = (int)byteData[index]; index++; descriptor.length = (int)byteData[index]; index++; if (descriptor.Length != 0) descriptor.Process(byteData, index); return (descriptor); }
/// <summary> /// Create an instance of the descriptor class. /// </summary> /// <param name="byteData">The MPEG2 section containing the descriptor.</param> /// <param name="index">The index of the tag byte of the descriptor.</param> /// <param name="scope">The current scope.</param> /// <returns>A descriptor instance.</returns> internal static DescriptorBase Instance(byte[] byteData, int index, Scope scope) { DescriptorBase descriptor; switch ((int)byteData[index]) { case NetworkNameDescriptorTag: descriptor = new DVBNetworkNameDescriptor(); break; case SatelliteDeliverySystemDescriptorTag: descriptor = new DVBSatelliteDeliverySystemDescriptor(); break; case ServiceDescriptorTag: descriptor = new DVBServiceDescriptor(); break; case ServiceListDescriptorTag: descriptor = new DVBServiceListDescriptor(); break; case ShortEventDescriptorTag: descriptor = new DVBShortEventDescriptor(); break; case ExtendedEventDescriptorTag: descriptor = new DVBExtendedEventDescriptor(); break; case ComponentDescriptorTag: descriptor = new DVBComponentDescriptor(); break; case ContentDescriptorTag: descriptor = new DVBContentDescriptor(); break; case ParentalRatingDescriptorTag: descriptor = new DVBParentalRatingDescriptor(); break; case BouquetNameDescriptorTag: descriptor = new DVBBouquetNameDescriptor(); break; case LocalTimeOffsetDescriptorTag: descriptor = new DVBLocalTimeOffsetDescriptor(); break; case OpenTVChannelInfoDescriptorTag: descriptor = new OpenTVChannelInfoDescriptor(); break; case GenericChannelInfoDescriptorTag: switch (scope) { case Scope.Bouquet: descriptor = new FreeviewChannelInfoDescriptor(); break; case Scope.ServiceDescripton: descriptor = new ServiceChannelDescriptor(); break; default: descriptor = new DescriptorBase(); break; } break; case FreeviewChannelInfoDescriptorTag: case TurkeyChannelInfoDescriptorTag: case E2ChannelInfoDescriptorTag: if (scope == Scope.Bouquet) { descriptor = new FreeviewChannelInfoDescriptor(); } else { descriptor = new DescriptorBase(); } break; case FreeSatChannelInfoDescriptorTag: descriptor = new FreeSatChannelInfoDescriptor(); break; case ContentIdentifierDescriptorTag: descriptor = new DVBContentIdentifierDescriptor(); break; default: descriptor = new DescriptorBase(); break; } descriptor.tag = (int)byteData[index]; index++; descriptor.length = (int)byteData[index]; index++; if (descriptor.Length != 0) { descriptor.Process(byteData, index); } return(descriptor); }
private void processDescriptor(DescriptorBase descriptor) { switch (descriptor.Tag) { case DescriptorBase.DishNetworkShortEventDescriptorTag: DishNetworkShortEventDescriptor shortEventDescriptor = descriptor as DishNetworkShortEventDescriptor; eventName = shortEventDescriptor.EventName; break; case DescriptorBase.DishNetworkExtendedEventDescriptorTag: DishNetworkExtendedEventDescriptor extendedEventDescriptor = descriptor as DishNetworkExtendedEventDescriptor; originalDescription = extendedEventDescriptor.OriginalDescription; shortDescription = extendedEventDescriptor.EventDescription; subTitle = extendedEventDescriptor.SubTitle; closedCaptions = extendedEventDescriptor.ClosedCaptions; highDefinition = extendedEventDescriptor.HighDefinition; stereo = extendedEventDescriptor.Stereo; date = extendedEventDescriptor.Date; cast = extendedEventDescriptor.Cast; break; case DescriptorBase.DishNetworkRatingDescriptorTag: DishNetworkRatingDescriptor ratingDescriptor = descriptor as DishNetworkRatingDescriptor; parentalRating = ratingDescriptor.ParentalRating; starRating = ratingDescriptor.StarRating; hasSexualContent = ratingDescriptor.HasSexualContent; hasStrongLanguage = ratingDescriptor.HasStrongLanguage; hasViolence = ratingDescriptor.HasViolence; hasNudity = ratingDescriptor.HasNudity; break; case DescriptorBase.DishNetworkSeriesDescriptorTag: DishNetworkSeriesDescriptor seriesDescriptor = descriptor as DishNetworkSeriesDescriptor; series = seriesDescriptor.Series; episode = seriesDescriptor.Episode; originalAirDate = seriesDescriptor.OriginalAirDate; break; case DescriptorBase.ContentDescriptorTag: contentType = (descriptor as DVBContentDescriptor).ContentSubType[0]; contentSubType = (descriptor as DVBContentDescriptor).UserType[0]; break; default: if (RunParameters.Instance.DebugIDs.Contains("UNKNOWNDESCRIPTORS")) { Logger.Instance.Write("Unprocessed Dish Network descriptor: 0x" + descriptor.Tag.ToString("X")); if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTORDATA")) Logger.Instance.Dump("Descriptor Data", descriptor.Data, descriptor.Data.Length); } break; } }
/// <summary> /// Create an instance of the descriptor class for Bell TV descriptors. /// </summary> /// <param name="byteData">The MPEG2 section containing the descriptor.</param> /// <param name="index">The index of the tag byte of the descriptor.</param> /// <param name="table">The table ID containing this descriptor.</param> /// <returns>A descriptor instance.</returns> internal static DescriptorBase BellTVInstance(byte[] byteData, int index, int table) { DescriptorBase descriptor; switch ((int)byteData[index]) { case ShortEventDescriptorTag: descriptor = new BellShortEventDescriptor(); break; case BellTVExtendedEventDescriptorTag: descriptor = new BellTVExtendedEventDescriptor(); break; case BellTVRatingDescriptorTag: descriptor = new BellTVRatingDescriptor(); break; case BellTVSeriesDescriptorTag: descriptor = new BellTVSeriesDescriptor(); break; case ContentDescriptorTag: descriptor = new DVBContentDescriptor(); break; default: descriptor = new DescriptorBase(); break; } descriptor.table = table; descriptor.tag = (int)byteData[index]; index++; descriptor.length = (int)byteData[index]; index++; descriptor.Process(byteData, index); return (descriptor); }
private void processDescriptor(DescriptorBase descriptor) { switch (descriptor.Tag) { case DescriptorBase.ShortEventDescriptorTag: DVBShortEventDescriptor shortEventDescriptor = descriptor as DVBShortEventDescriptor; if (eventName == null) { processShortEventDescriptor(shortEventDescriptor); } else { if (RunParameters.Instance.InputLanguage == null) { processShortEventDescriptor(shortEventDescriptor); } else { if (shortEventDescriptor.LanguageCode == RunParameters.Instance.InputLanguage) { processShortEventDescriptor(shortEventDescriptor); } else { if (shortEventDescriptor.LanguageCode == "eng") { processShortEventDescriptor(shortEventDescriptor); } } } } LanguageCode.RegisterUsage(shortEventDescriptor.LanguageCode); break; case DescriptorBase.ExtendedEventDescriptorTag: DVBExtendedEventDescriptor extendedEventDescriptor = descriptor as DVBExtendedEventDescriptor; if (extendedDescription == null) { processExtendedEventDescriptor(extendedEventDescriptor); } else { if (RunParameters.Instance.InputLanguage == null) { processExtendedEventDescriptor(extendedEventDescriptor); } else { if (extendedEventDescriptor.LanguageCode == RunParameters.Instance.InputLanguage) { processExtendedEventDescriptor(extendedEventDescriptor); } else { if (extendedEventDescriptor.LanguageCode == "eng") { processExtendedEventDescriptor(extendedEventDescriptor); } } } } LanguageCode.RegisterUsage(extendedEventDescriptor.LanguageCode); break; case DescriptorBase.ComponentDescriptorTag: if ((descriptor as DVBComponentDescriptor).ComponentTypeVideo != -1) { componentTypeVideo = (descriptor as DVBComponentDescriptor).ComponentTypeVideo; } if ((descriptor as DVBComponentDescriptor).ComponentTypeAudio != -1) { componentTypeAudio = (descriptor as DVBComponentDescriptor).ComponentTypeAudio; } if ((descriptor as DVBComponentDescriptor).ComponentTypeSubtitles != -1) { componentTypeSubtitles = (descriptor as DVBComponentDescriptor).ComponentTypeSubtitles; } break; case DescriptorBase.ContentDescriptorTag: contentType = (descriptor as DVBContentDescriptor).ContentType[0]; contentSubType = (descriptor as DVBContentDescriptor).ContentSubType[0]; break; case DescriptorBase.ParentalRatingDescriptorTag: DVBParentalRatingDescriptor parentalRatingDescriptor = descriptor as DVBParentalRatingDescriptor; if (parentalRatingDescriptor.ParentalRatings != null) { parentalRating = (descriptor as DVBParentalRatingDescriptor).ParentalRatings[0]; } break; case DescriptorBase.ContentIdentifierDescriptorTag: DVBContentIdentifierDescriptor contentIdentifierDescriptor = descriptor as DVBContentIdentifierDescriptor; if (contentIdentifierDescriptor.IsSeriesLink) { seriesID = contentIdentifierDescriptor.ContentReference; } else { if (contentIdentifierDescriptor.IsEpisodeLink) { episodeID = contentIdentifierDescriptor.ContentReference; } } break; default: if (RunParameters.Instance.DebugIDs.Contains("UNKNOWNDESCRIPTORS")) { Logger.Instance.Write("Unprocessed EIT descriptor: 0x" + descriptor.Tag.ToString("X")); if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTORDATA")) { Logger.Instance.Dump("Descriptor Data", descriptor.Data, descriptor.Data.Length); } } break; } }
/// <summary> /// Parse the entry. /// </summary> /// <param name="byteData">The MPEG2 section containing the transport stream.</param> /// <param name="index">Index of the first byte of the transport stream in the MPEG2 section.</param> /// <param name="isCable">True if the entry is for cable; false otherwise.</param> internal void Process(byte[] byteData, int index, bool isCable) { lastIndex = index; try { shortName = Utils.GetUnicodeString(byteData, lastIndex, 14).Replace((char)0x00, '?').Replace("?", ""); lastIndex += 14; majorChannelNumber = (Utils.Convert4BytesToInt(byteData, lastIndex) >> 18) & 0x3ff; minorChannelNumber = (Utils.Convert4BytesToInt(byteData, lastIndex) >> 8) & 0x3ff; lastIndex += 3; modulationMode = (int)byteData[lastIndex]; lastIndex++; frequency = Utils.Convert4BytesToInt(byteData, lastIndex); lastIndex += 4; transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; programNumber = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; etmLocation = byteData[lastIndex] >> 6; accessControlled = ((byteData[lastIndex] & 0x20) != 0); hidden = ((byteData[lastIndex] & 0x10) != 0); if (isCable) { pathSelect = ((byteData[lastIndex] & 0x08) != 0); outOfBand = ((byteData[lastIndex] & 0x04) != 0); } hideGuide = ((byteData[lastIndex] & 0x02) != 0); lastIndex++; serviceType = byteData[lastIndex] & 0x03f; lastIndex++; sourceID = Utils.Convert2BytesToInt(byteData, lastIndex); lastIndex += 2; int descriptorLoopLength = ((byteData[lastIndex] & 0x03) * 256) + (int)byteData[lastIndex + 1]; lastIndex += 2; totalLength = (lastIndex - index) + descriptorLoopLength; if (descriptorLoopLength != 0) { descriptors = new Collection <DescriptorBase>(); while (descriptorLoopLength != 0) { DescriptorBase descriptor = DescriptorBase.AtscInstance(byteData, lastIndex); descriptors.Add(descriptor); lastIndex = descriptor.Index; descriptorLoopLength -= descriptor.TotalLength; } } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("The Virtual Channel Table entry message is short")); } }
private void processDescriptor(DescriptorBase descriptor) { switch (descriptor.Tag) { case DescriptorBase.ShortEventDescriptorTag: DVBShortEventDescriptor shortEventDescriptor = descriptor as DVBShortEventDescriptor; if (RunParameters.Instance.InputLanguage == null || shortEventDescriptor.LanguageCode == RunParameters.Instance.InputLanguage) { eventName = shortEventDescriptor.EventName; shortDescription = shortEventDescriptor.ShortDescription; } LanguageCode.RegisterUsage(shortEventDescriptor.LanguageCode); break; case DescriptorBase.ComponentDescriptorTag: if ((descriptor as DVBComponentDescriptor).ComponentTypeVideo != -1) componentTypeVideo = (descriptor as DVBComponentDescriptor).ComponentTypeVideo; if ((descriptor as DVBComponentDescriptor).ComponentTypeAudio != -1) componentTypeAudio = (descriptor as DVBComponentDescriptor).ComponentTypeAudio; if ((descriptor as DVBComponentDescriptor).ComponentTypeSubtitles != -1) componentTypeSubtitles = (descriptor as DVBComponentDescriptor).ComponentTypeSubtitles; break; case DescriptorBase.ContentDescriptorTag: contentType = (descriptor as DVBContentDescriptor).ContentType[0]; contentSubType = (descriptor as DVBContentDescriptor).ContentSubType[0]; break; case DescriptorBase.ParentalRatingDescriptorTag: DVBParentalRatingDescriptor parentalRatingDescriptor = descriptor as DVBParentalRatingDescriptor; if (parentalRatingDescriptor.ParentalRatings != null) parentalRating = (descriptor as DVBParentalRatingDescriptor).ParentalRatings[0]; break; case DescriptorBase.ContentIdentifierDescriptorTag: DVBContentIdentifierDescriptor contentIdentifierDescriptor = descriptor as DVBContentIdentifierDescriptor; if (contentIdentifierDescriptor.IsSeriesLink) seriesID = contentIdentifierDescriptor.ContentReference; else { if (contentIdentifierDescriptor.IsEpisodeLink) episodeID = contentIdentifierDescriptor.ContentReference; } break; default: if (RunParameters.Instance.DebugIDs.Contains("UNKNOWNDESCRIPTORS")) { Logger.Instance.Write("Unprocessed EIT descriptor: 0x" + descriptor.Tag.ToString("X")); if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTORDATA")) Logger.Instance.Dump("Descriptor Data", descriptor.Data, descriptor.Data.Length); } break; } }