示例#1
0
        public virtual void OnTsPacket(byte[] tsPacket)
        {
            TsHeader header = TsHeader.Decode(tsPacket);

            if (((_pid < 0x1fff) && (header.Pid == _pid)) && header.HasPayload)
            {
                int payLoadStart = header.PayLoadStart;
                int num2         = 0;
                if (header.PayloadUnitStartIndicator)
                {
                    num2 = (payLoadStart + tsPacket[payLoadStart]) + 1;
                    if (_section.BufferPos == 0)
                    {
                        payLoadStart += tsPacket[payLoadStart] + 1;
                    }
                    else
                    {
                        payLoadStart++;
                    }
                }
                while (payLoadStart < 0xbc)
                {
                    if (_section.BufferPos == 0)
                    {
                        if (!header.PayloadUnitStartIndicator)
                        {
                            return;
                        }
                        if (tsPacket[payLoadStart] == 0xff)
                        {
                            return;
                        }
                        int sectionLen = this.SnapshotSectionLength(tsPacket, payLoadStart);
                        payLoadStart = this.StartNewTsSection(tsPacket, payLoadStart, sectionLen);
                    }
                    else
                    {
                        if (_section.section_length == -1)
                        {
                            _section.CalcSectionLength(tsPacket, payLoadStart);
                        }
                        if (_section.section_length == 0)
                        {
                            _section.Reset();
                            return;
                        }
                        int num4 = _section.section_length - _section.BufferPos;
                        if ((num2 != 0) && ((payLoadStart + num4) > num2))
                        {
                            num4                    = num2 - payLoadStart;
                            payLoadStart            = this.AddToSection(tsPacket, payLoadStart, num4);
                            _section.section_length = _section.BufferPos - 1;
                            payLoadStart            = num2;
                            incompleteSections++;
                        }
                        else
                        {
                            payLoadStart = this.AddToSection(tsPacket, payLoadStart, num4);
                        }
                    }
                    if (_section.SectionComplete() && (_section.section_length > 0))
                    {
                        this.OnNewSection(_section);
                        if (this.OnSectionDecoded != null)
                        {
                            this.OnSectionDecoded(_section);
                        }
                        _section.Reset();
                    }
                    num2 = 0;
                }
            }
        }
示例#2
0
 public void Reset()
 {
     m_section.Reset();
 }