예제 #1
0
        /// <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));
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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());
        }
예제 #4
0
 private void getEventName(EPGEntry epgEntry, OpenTVTitleData titleData)
 {
     switch (RunParameters.Instance.CountryCode)
     {
         case "NZL":
             getSkyNZEventName(epgEntry, titleData);
             break;
         default:
             epgEntry.EventName = titleData.EventName;
             break;
     }
 }
예제 #5
0
        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);
        }
예제 #6
0
        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;;
            }
        }
예제 #7
0
        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();
            }
        }
예제 #8
0
        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);
        }
예제 #9
0
        /// <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);
        }
예제 #10
0
        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();
                }
            }
        }
예제 #11
0
        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";
        }
예제 #12
0
        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;
        }
예제 #13
0
        /// <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));
            }
        }