/// <summary> /// Parse the title header. /// </summary> /// <param name="byteData">The MPEG2 section containing the title header.</param> /// <param name="index">Index of the first byte of the title header in the MPEG2 section.</param> /// <param name="mpeg2Header">The MPEG2 header of the section.</param> /// <param name="pid">The PID of the section.</param> /// <param name="tid">The table ID of the section.</param> internal void Process(byte[] byteData, int index, Mpeg2ExtendedHeader mpeg2Header, int pid, int tid) { lastIndex = index; channelID = mpeg2Header.TableIDExtension; try { baseDate = getDate(Utils.Convert2BytesToInt(byteData, lastIndex)); lastIndex += 2; while (lastIndex < byteData.Length - 4) { OpenTVTitleData data = new OpenTVTitleData(); data.Process(byteData, lastIndex, baseDate, channelID, pid, tid); if (!data.IsEmpty) { if (titleData == null) { titleData = new Collection <OpenTVTitleData>(); } titleData.Add(data); } lastIndex = data.Index; } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("lastIndex = " + lastIndex)); } }
private OpenTVSummaryData getShortDescription(EPGEntry epgEntry, OpenTVTitleData titleData) { OpenTVSummaryData summary = findSummary(titleData.EventID); if (summary != null) epgEntry.ShortDescription = summary.ShortDescription; else epgEntry.ShortDescription = "No Synopsis Available"; return (summary); }
private void getParentalRating(OpenTVTitleData titleData, EPGEntry epgEntry) { if (titleData.Flags == null || titleData.Flags.Length < 2) return; epgEntry.ParentalRating = ParentalRating.FindRating(RunParameters.Instance.CountryCode, "OPENTV", (titleData.Flags[1] & 0x0f).ToString()); epgEntry.MpaaParentalRating = ParentalRating.FindMpaaRating(RunParameters.Instance.CountryCode, "OPENTV", (titleData.Flags[1] & 0x0f).ToString()); epgEntry.ParentalRatingSystem = ParentalRating.FindSystem(RunParameters.Instance.CountryCode, "OPENTV", (titleData.Flags[1] & 0x0f).ToString()); }
private void getEventName(EPGEntry epgEntry, OpenTVTitleData titleData) { switch (RunParameters.Instance.CountryCode) { case "NZL": getSkyNZEventName(epgEntry, titleData); break; default: epgEntry.EventName = titleData.EventName; break; } }
private void getEventCategory(OpenTVTitleData titleData, EPGEntry epgEntry) { if (titleData.CategoryID == 0) { getCustomCategory(epgEntry.EventName, epgEntry.ShortDescription); return; } if (RunParameters.Instance.Options.Contains("CUSTOMCATEGORYOVERRIDE")) { epgEntry.EventCategory = getCustomCategory(epgEntry.EventName, epgEntry.ShortDescription); if (epgEntry.EventCategory != null) return; } OpenTVProgramCategory category = OpenTVProgramCategory.FindCategory(titleData.CategoryID); if (category != null) { epgEntry.EventCategory = category.Description; if (category.SampleEvent == null) category.SampleEvent = epgEntry.FullScheduleDescription; category.UsedCount++; return; } else OpenTVProgramCategory.AddUndefinedCategory(titleData.CategoryID, epgEntry.FullScheduleDescription); if (RunParameters.Instance.Options.Contains("CUSTOMCATEGORYOVERRIDE")) return; epgEntry.EventCategory = getCustomCategory(epgEntry.EventName, epgEntry.ShortDescription); }
private void getAudioQuality(OpenTVTitleData titleData, EPGEntry epgEntry) { if (titleData.Flags == null || titleData.Flags.Length < 2) return; switch (titleData.Flags[0] >> 6) { case 1: epgEntry.AudioQuality = "stereo"; break; case 2: epgEntry.AudioQuality = "surround"; break; case 3: epgEntry.AudioQuality = "dolby digital"; break; default: break;; } }
private void getAspectRatio(OpenTVTitleData titleData, EPGEntry epgEntry) { if (titleData.Flags == null || titleData.Flags.Length < 2) return; if ((titleData.Flags[0] & 0x08) != 0 || epgEntry.ShortDescription.IndexOf("(WS)") != -1) { epgEntry.AspectRatio = "16:9"; if (!RunParameters.Instance.Options.Contains("NOREMOVEDATA")) epgEntry.ShortDescription = epgEntry.ShortDescription.Replace("(WS)", "").Trim(); } }
private void addSuspectTimeEntry(OpenTVTitleData newTitleData) { foreach (OpenTVTitleData oldTitleData in SuspectTimeTitleData) { if (oldTitleData.StartTime == newTitleData.StartTime) return; if (oldTitleData.StartTime > newTitleData.StartTime) { suspectTimeTitleData.Insert(SuspectTimeTitleData.IndexOf(oldTitleData), newTitleData); return; } } SuspectTimeTitleData.Add(newTitleData); }
/// <summary> /// Add title data to the channel. /// </summary> /// <param name="newTitleData">The title data to be added.</param> public void AddTitleData(OpenTVTitleData newTitleData) { if (!RunParameters.Instance.Options.Contains("ACCEPTBREAKS")) { if (newTitleData.StartTime.Second != 0) { addSuspectTimeEntry(newTitleData); return; } } foreach (OpenTVTitleData oldTitleData in TitleData) { if (oldTitleData.StartTime == newTitleData.StartTime) return; if (oldTitleData.StartTime > newTitleData.StartTime) { TitleData.Insert(TitleData.IndexOf(oldTitleData), newTitleData); return; } } TitleData.Add(newTitleData); }
private void getVideoQuality(OpenTVTitleData titleData, EPGEntry epgEntry) { if (titleData.Flags == null || titleData.Flags.Length < 2) return; if ((titleData.Flags[0] & 0x04) != 0) { epgEntry.VideoQuality = "HDTV"; if (!RunParameters.Instance.Options.Contains("NOREMOVEDATA")) { if (epgEntry.ShortDescription.EndsWith(" HD.")) epgEntry.ShortDescription = epgEntry.ShortDescription.Replace(" HD.", "").Trim(); if (epgEntry.ShortDescription.EndsWith(" HD")) epgEntry.ShortDescription = epgEntry.ShortDescription.Replace(" HD", "").Trim(); } } }
private void getSubTitles(OpenTVTitleData titleData, EPGEntry epgEntry) { if (titleData.Flags == null || titleData.Flags.Length < 2) return; if ((titleData.Flags[0] & 0x10) != 0) epgEntry.SubTitles = "teletext"; }
private void getSkyNZEventName(EPGEntry epgEntry, OpenTVTitleData titleData) { string eventName = titleData.EventName; string editedEventName; if (!titleData.EventName.StartsWith("[[")) editedEventName = eventName; else { int startIndex = eventName.IndexOf("]"); if (startIndex != -1 && eventName[startIndex + 1] == ']' && startIndex + 2 < eventName.Length) editedEventName = eventName.Substring(startIndex + 2); else editedEventName = eventName; } if (editedEventName.EndsWith(" HD")) epgEntry.EventName = editedEventName.Substring(0, editedEventName.Length - 3); else epgEntry.EventName = editedEventName; }
/// <summary> /// Parse the title header. /// </summary> /// <param name="byteData">The MPEG2 section containing the title header.</param> /// <param name="index">Index of the first byte of the title header in the MPEG2 section.</param> /// <param name="mpeg2Header">The MPEG2 header of the section.</param> /// <param name="pid">The PID of the section.</param> /// <param name="tid">The table ID of the section.</param> internal void Process(byte[] byteData, int index, Mpeg2ExtendedHeader mpeg2Header, int pid, int tid) { lastIndex = index; channelID = mpeg2Header.TableIDExtension; try { baseDate = getDate(Utils.Convert2BytesToInt(byteData, lastIndex)); lastIndex += 2; while (lastIndex < byteData.Length - 4) { OpenTVTitleData data = new OpenTVTitleData(); data.Process(byteData, lastIndex, baseDate, channelID, pid, tid); if (!data.IsEmpty) { if (titleData == null) titleData = new Collection<OpenTVTitleData>(); titleData.Add(data); } lastIndex = data.Index; } Validate(); } catch (IndexOutOfRangeException) { throw (new ArgumentOutOfRangeException("lastIndex = " + lastIndex)); } }