Exemple #1
0
        /// <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"));
            }
        }
        /// <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();
        }
Exemple #3
0
        /// <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();
        }
Exemple #4
0
        /// <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>
        /// 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();
        }
Exemple #6
0
        /// <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"));
            }
        }