/// <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>
        internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;

            int descriptorLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1];

            lastIndex += 2;

            if (descriptorLength != 0)
            {
                descriptors = new Collection <DescriptorBase>();

                while (descriptorLength > 0)
                {
                    DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex);

                    if (!descriptor.IsEmpty)
                    {
                        descriptors.Add(descriptor);

                        lastIndex         = descriptor.Index;
                        descriptorLength -= descriptor.TotalLength;
                    }
                    else
                    {
                        lastIndex        += DescriptorBase.MinimumDescriptorLength;
                        descriptorLength -= DescriptorBase.MinimumDescriptorLength;
                    }
                }
            }
        }
示例#2
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>
        internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex         = mpeg2Header.Index;
            bouquetID         = mpeg2Header.TableIDExtension;
            sectionNumber     = mpeg2Header.SectionNumber;
            lastSectionNumber = mpeg2Header.LastSectionNumber;

            int bouquetDescriptorLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1];

            lastIndex += 2;

            if (bouquetDescriptorLength != 0)
            {
                bouquetDescriptors = new Collection <DescriptorBase>();

                while (bouquetDescriptorLength > 0)
                {
                    DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, Scope.Bouquet);

                    if (!descriptor.IsEmpty)
                    {
                        bouquetDescriptors.Add(descriptor);
                        lastIndex = descriptor.Index;

                        bouquetDescriptorLength -= descriptor.TotalLength;
                    }
                    else
                    {
                        lastIndex += DescriptorBase.MinimumDescriptorLength;
                        bouquetDescriptorLength -= DescriptorBase.MinimumDescriptorLength;
                    }
                }
            }

            int transportStreamLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1];

            lastIndex += 2;

            if (transportStreamLoopLength != 0)
            {
                transportStreams = new Collection <TransportStream>();

                while (transportStreamLoopLength > 0)
                {
                    TransportStream transportStream = new TransportStream();
                    transportStream.Process(byteData, lastIndex, Scope.Bouquet);
                    transportStreams.Add(transportStream);

                    lastIndex = transportStream.Index;
                    transportStreamLoopLength -= transportStream.TotalLength;
                }
            }

            lastIndex += transportStreamLoopLength;
        }
示例#3
0
        /// <summary>
        /// Parse the service description.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the service description.</param>
        /// <param name="index">Index of the first byte of the service description in the MPEG2 section.</param>
        internal void Process(byte[] byteData, int index)
        {
            lastIndex = index;

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

                eitSchedule         = ((int)byteData[lastIndex] & 0x02) != 0;
                eitPresentFollowing = ((int)byteData[lastIndex] & 0x01) != 0;
                lastIndex++;

                runningStatus = (int)(byteData[lastIndex] >> 5);
                scrambled     = ((int)byteData[lastIndex] & 0x10) >> 4 == 1;

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

                while (descriptorLoopLength != 0)
                {
                    DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, Scope.ServiceDescripton);

                    if (!descriptor.IsEmpty)
                    {
                        if (descriptor as DVBServiceDescriptor != null)
                        {
                            serviceDescriptor = descriptor as DVBServiceDescriptor;
                        }
                        else
                        {
                            if (descriptor as ServiceChannelDescriptor != null)
                            {
                                serviceChannelDescriptor = descriptor as ServiceChannelDescriptor;
                            }
                        }

                        lastIndex             = descriptor.Index;
                        descriptorLoopLength -= descriptor.TotalLength;
                    }
                    else
                    {
                        lastIndex            += DescriptorBase.MinimumDescriptorLength;
                        descriptorLoopLength -= DescriptorBase.MinimumDescriptorLength;
                    }
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The DVB Service Description 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>
        internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;
            serviceID = mpeg2Header.TableIDExtension;

            pcrPID     = ((byteData[lastIndex] & 0x1f) * 256) + byteData[lastIndex + 1];
            lastIndex += 2;

            int programInfoLength = ((byteData[lastIndex] & 0x0f) * 256) + byteData[lastIndex + 1];

            lastIndex += 2;

            if (programInfoLength != 0)
            {
                while (programInfoLength > 0)
                {
                    descriptors = new Collection <DescriptorBase>();

                    while (programInfoLength > 0)
                    {
                        DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex);

                        if (!descriptor.IsEmpty)
                        {
                            descriptors.Add(descriptor);

                            lastIndex         += descriptor.TotalLength;
                            programInfoLength -= descriptor.TotalLength;
                        }
                        else
                        {
                            lastIndex         += DescriptorBase.MinimumDescriptorLength;
                            programInfoLength -= DescriptorBase.MinimumDescriptorLength;
                        }
                    }
                }
            }

            streamInfos = new Collection <StreamInfo>();

            while (lastIndex < byteData.Length - 4)
            {
                StreamInfo streamInfo = new StreamInfo();
                streamInfo.Process(byteData, lastIndex);

                streamInfos.Add(streamInfo);

                lastIndex = streamInfo.Index;
            }

            Validate();
        }
示例#5
0
        /// <summary>
        /// Parse the entry.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the entry.</param>
        /// <param name="index">Index of the event identification byte in the MPEG2 section.</param>
        public void Process(byte[] byteData, int index)
        {
            lastIndex = index;

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

                getStartTime(byteData, lastIndex);
                lastIndex += 5;

                getDuration(byteData, lastIndex);
                lastIndex += 3;

                runningStatus = (int)(byteData[lastIndex] >> 5);
                scrambled     = ((int)byteData[lastIndex] & 0x10) >> 4 == 1;

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

                while (descriptorLoopLength != 0)
                {
                    DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex);

                    if (!descriptor.IsEmpty)
                    {
                        processDescriptor(descriptor);
                        descriptor.LogMessage();

                        lastIndex             = descriptor.Index;
                        descriptorLoopLength -= descriptor.TotalLength;
                    }
                    else
                    {
                        lastIndex            += DescriptorBase.MinimumDescriptorLength;
                        descriptorLoopLength -= DescriptorBase.MinimumDescriptorLength;
                    }
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The EIT message is short"));
            }
        }
示例#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="scope">The scope of the processing..</param>
        internal void Process(byte[] byteData, int index, Scope scope)
        {
            lastIndex = index;

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

                originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

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

                totalLength = descriptorLoopLength + 6;

                if (descriptorLoopLength != 0)
                {
                    descriptors = new Collection <DescriptorBase>();

                    while (descriptorLoopLength != 0)
                    {
                        DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, scope);

                        if (!descriptor.IsEmpty)
                        {
                            descriptors.Add(descriptor);

                            lastIndex             = descriptor.Index;
                            descriptorLoopLength -= descriptor.TotalLength;
                        }
                        else
                        {
                            lastIndex            += DescriptorBase.MinimumDescriptorLength;
                            descriptorLoopLength -= DescriptorBase.MinimumDescriptorLength;
                        }
                    }
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The DVB Transport Stream message is short"));
            }
        }
示例#7
0
        /// <summary>
        /// Parse the stream information.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the stream information.</param>
        /// <param name="index">Index of the first byte of the stream information in the MPEG2 section.</param>
        internal void Process(byte[] byteData, int index)
        {
            lastIndex = index;

            try
            {
                streamType = (int)byteData[lastIndex];
                lastIndex++;

                programID  = ((byteData[lastIndex] & 0x1f) * 256) + byteData[lastIndex + 1];
                lastIndex += 2;

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

                if (esInfoLength != 0)
                {
                    descriptors = new Collection <DescriptorBase>();

                    while (esInfoLength > 0)
                    {
                        DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex);

                        if (!descriptor.IsEmpty)
                        {
                            descriptors.Add(descriptor);

                            lastIndex    += descriptor.TotalLength;
                            esInfoLength -= descriptor.TotalLength;
                        }
                        else
                        {
                            lastIndex    += DescriptorBase.MinimumDescriptorLength;
                            esInfoLength -= DescriptorBase.MinimumDescriptorLength;
                        }
                    }
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The DVB Stream Info message is short"));
            }
        }