/// <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> internal override void Process(byte[] byteData, int index) { lastIndex = index; startBytes = Utils.GetBytes(byteData, lastIndex, 2); int startIndex; if ((byteData[lastIndex + 1] & 0xf8) == 0x80) { compressedLength = Length; if ((byteData[lastIndex] & 0x40) != 0) { decompressedLength = (byteData[lastIndex] & 0x3f) | ((byteData[lastIndex + 1] << 6) & 0xff); } else { decompressedLength = byteData[lastIndex] & 0x3f; } startIndex = lastIndex + 2; loggedStartIndex = 2; } else { compressedLength = Length - 1; decompressedLength = byteData[lastIndex] & 0x7f; startIndex = lastIndex + 1; loggedStartIndex = 1; } if (compressedLength <= 0) { lastIndex = index + Length; return; } eventNameBytes = Utils.GetBytes(byteData, startIndex, compressedLength); if (Table <= 0x80) { huffmanTable = 1; } else { huffmanTable = 2; } eventName = SingleTreeDictionaryEntry.DecodeData(huffmanTable, eventNameBytes); lastIndex = index + Length; Validate(); }
/// <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> internal override void Process(byte[] byteData, int index) { lastIndex = index; startBytes = Utils.GetBytes(byteData, lastIndex, 2); int startIndex; compressedLength = Length - 2; decompressedLength = byteData[lastIndex] & 0x7f; startIndex = lastIndex + 2; loggedStartIndex = 2; if (compressedLength <= 0) { lastIndex = index + Length; return; } supplementaryInformationBytes = Utils.GetBytes(byteData, startIndex, Length - (startIndex - index)); if (Table <= 0x80) { huffmanTable = 1; } else { huffmanTable = 2; } supplementaryInformation = SingleTreeDictionaryEntry.DecodeData(huffmanTable, supplementaryInformationBytes); lastIndex = index + Length; Validate(); }
/// <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> internal override void Process(byte[] byteData, int index) { lastIndex = index; startBytes = Utils.GetBytes(byteData, lastIndex, 2); int startIndex; if ((byteData[lastIndex + 1] & 0xf8) == 0x80) { compressedLength = Length; if ((byteData[lastIndex] & 0x40) != 0) { decompressedLength = (byteData[lastIndex] & 0x3f) | ((byteData[lastIndex + 1] << 6) & 0xff); } else { decompressedLength = byteData[lastIndex] & 0x3f; } startIndex = lastIndex + 2; loggedStartIndex = 2; } else { compressedLength = Length - 1; decompressedLength = byteData[lastIndex] & 0x7f; startIndex = lastIndex + 1; loggedStartIndex = 1; } if (compressedLength <= 0) { lastIndex = index + Length; return; } eventDescriptionBytes = Utils.GetBytes(byteData, startIndex, compressedLength); if (Table <= 0x80) { huffmanTable = 1; } else { huffmanTable = 2; } originalDescription = SingleTreeDictionaryEntry.DecodeData(huffmanTable, eventDescriptionBytes); int splitter = originalDescription.IndexOf("<0D>"); if (splitter != -1) { subTitle = originalDescription.Substring(0, splitter); eventDescription = originalDescription.Substring(splitter + 5, decompressedLength - subTitle.Length - 2); } else { eventDescription = originalDescription.Substring(0, decompressedLength); } int closedCaptionsIndex = eventDescription.IndexOf(" (CC)"); closedCaptions = closedCaptionsIndex != -1; if (closedCaptions) { eventDescription = eventDescription = eventDescription.Remove(closedCaptionsIndex, 5); } int highDefinitionIndex = eventDescription.IndexOf(" (HD)"); highDefinition = highDefinitionIndex != -1; if (highDefinition) { eventDescription = eventDescription.Remove(highDefinitionIndex, 5); } int stereoIndex = eventDescription.IndexOf(" (Stereo)"); stereo = stereoIndex != -1; if (stereo) { eventDescription = eventDescription.Remove(stereoIndex, 9); } int dateIndex = eventDescription.IndexOf(" (19"); if (dateIndex == -1) { dateIndex = eventDescription.IndexOf(" (20"); } if (dateIndex != -1) { date = eventDescription.Substring(dateIndex + 2, 4); eventDescription = eventDescription.Remove(dateIndex, 7); } if (eventDescription.StartsWith("Movie.")) { eventDescription = eventDescription.Remove(0, 6); } else { if (eventDescription.StartsWith("Sports.")) { eventDescription = eventDescription.Remove(0, 7); } else { if (eventDescription.StartsWith("News/Business.")) { eventDescription = eventDescription.Remove(0, 14); } else { if (eventDescription.StartsWith("Family/Children.")) { eventDescription = eventDescription.Remove(0, 16); } else { if (eventDescription.StartsWith("Education.")) { eventDescription = eventDescription.Remove(0, 10); } else { if (eventDescription.StartsWith("Series/Special.")) { eventDescription = eventDescription.Remove(0, 15); } else { if (eventDescription.StartsWith("Music/Art.")) { eventDescription = eventDescription.Remove(0, 10); } else { if (eventDescription.StartsWith("Religious.")) { eventDescription = eventDescription.Remove(0, 10); } } } } } } } } int newIndex = eventDescription.IndexOf(" New."); if (newIndex != -1) { eventDescription = eventDescription.Remove(newIndex, 5); } eventDescription = eventDescription.Trim(); string[] castParts = eventDescription.Split(new char[] { '.' }); if (castParts.Length > 2) { if (!castParts[0].Trim().StartsWith("Scheduled: ")) { cast = getCast(castParts[0]); if (cast != null) { eventDescription = eventDescription.Remove(0, castParts[0].Length + 1).Trim(); } } } lastIndex = index + Length; Validate(); }