/// <summary>
        /// Parse the summary data.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the summary data.</param>
        /// <param name="index">Index of the first byte of the summary data in the MPEG2 section.</param>
        /// <param name="baseDate">The base date for the program events.</param>
        internal void Process(byte[] byteData, int index, DateTime baseDate)
        {
            lastIndex = index;

            try
            {
                eventID    = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

                length     = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1];
                lastIndex += 2;

                int recordLength = length;

                while (recordLength != 0)
                {
                    OpenTVRecordBase record = OpenTVRecordBase.Instance(byteData, lastIndex);
                    Records.Add(record);

                    lastIndex    += record.TotalLength;
                    recordLength -= record.TotalLength;
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The Open TV Summary Data message is short"));
            }
        }
        /// <summary>
        /// Create an instance of the record class.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the record.</param>
        /// <param name="index">The index of the tag byte of the record.</param>
        /// <returns>A descriptor instance.</returns>
        internal static OpenTVRecordBase Instance(byte[] byteData, int index)
        {
            OpenTVRecordBase record;

            switch ((int)byteData[index])
            {
            case OpenTVTitleDataRecord.TagValue:
                record = new OpenTVTitleDataRecord();
                break;

            case OpenTVShortDescriptionRecord.TagValue:
                record = new OpenTVShortDescriptionRecord();
                break;

            case OpenTVExtendedDescriptionRecord.TagValue:
                record = new OpenTVExtendedDescriptionRecord();
                break;

            case OpenTVSeriesLinkRecord.TagValue:
                record = new OpenTVSeriesLinkRecord();
                break;

            default:
                record = new OpenTVRecordBase();
                break;
            }

            record.tag = (int)byteData[index];
            index++;

            record.length = (int)byteData[index];
            index++;

            record.Process(byteData, index);

            return(record);
        }
Beispiel #3
0
        /// <summary>
        /// Parse the title data.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the title data.</param>
        /// <param name="index">Index of the first byte of the title data in the MPEG2 section.</param>
        /// <param name="baseDate">The base date for the programs.</param>
        /// <param name="channel">The channel for the data.</param>
        /// <param name="pid">The PID of the section.</param>
        /// <param name="table">The table ID of the section.</param>
        internal void Process(byte[] byteData, int index, DateTime baseDate, int channel, int pid, int table)
        {
            lastIndex = index;

            this.pid      = pid;
            this.table    = table;
            this.baseDate = baseDate;

            try
            {
                eventID    = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

                length     = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1];
                lastIndex += 2;

                int recordLength = length;

                while (recordLength != 0)
                {
                    OpenTVRecordBase record = OpenTVRecordBase.Instance(byteData, lastIndex);
                    Records.Add(record);

                    lastIndex    += record.TotalLength;
                    recordLength -= record.TotalLength;
                }

                timeStamp = DateTime.Now;

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("lastIndex = " + lastIndex));
            }
        }
Beispiel #4
0
        /// <summary>
        /// Create an instance of the record class.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the record.</param>
        /// <param name="index">The index of the tag byte of the record.</param>
        /// <returns>A descriptor instance.</returns>
        internal static OpenTVRecordBase Instance(byte[] byteData, int index)
        {
            OpenTVRecordBase record;

            switch ((int)byteData[index])
            {
                case OpenTVTitleDataRecord.TagValue:
                    record = new OpenTVTitleDataRecord();
                    break;
                case OpenTVShortDescriptionRecord.TagValue:
                    record = new OpenTVShortDescriptionRecord();
                    break;
                case OpenTVExtendedDescriptionRecord.TagValue:
                    record = new OpenTVExtendedDescriptionRecord();
                    break;
                case OpenTVSeriesLinkRecord.TagValue:
                    record = new OpenTVSeriesLinkRecord();
                    break;
                default:
                    record = new OpenTVRecordBase();
                    break;
            }

            record.tag = (int)byteData[index];
            index++;

            record.length = (int)byteData[index];
            index++;

            record.Process(byteData, index);

            return (record);
        }