protected override void ParseSection(TsPacket packet, int offset, int length) { if (length < 5) { return; } int num1 = offset; byte[] buffer = packet.Buffer; int num2 = num1 + length; int num3 = num1 + 2; byte[] numArray1 = buffer; int index1 = num3; int num4 = 1; int num5 = index1 + num4; byte num6 = numArray1[index1]; int num7 = (int)num6 & 1; byte num8 = (byte)((int)num6 >> 1 & 31); byte[] numArray2 = buffer; int index2 = num5; int num9 = 1; int num10 = index2 + num9; byte num11 = numArray2[index2]; byte[] numArray3 = buffer; int index3 = num10; int num12 = 1; int offset1 = index3 + num12; byte num13 = numArray3[index3]; TsDescriptors.Parse(this._descriptorFactory, buffer, offset1, num2 - offset1); }
public void Add(TsPacket packet) { if (packet.IsStart) { this._index = 0; } else { int num = this._count + 1 & 15; if (packet.ContinuityCount != num) { return; } } this._count = packet.ContinuityCount; int payloadLength = packet.PayloadLength; if (this._index + payloadLength > this._buffer.Length) { return; } packet.CopyTo(this._buffer, this._index); this._index += payloadLength; if (null != this._handler) { this._handler(this); } }
private void AddPcr(TsPacket packet) { if (packet == null || !packet.Pcr.HasValue) { return; } this._pcrIndex = new int?(packet.TsIndex); this._pcr = packet.Pcr; }
public void Add(TsPacket packet) { if (null == this._handler) { return; } if (null != packet) { if (packet.IsStart) { if ((int)this._length == 0 && this._index > this._startIndex) { this.Flush(); } this._index = this._startIndex; this.ParseHeader(packet); } if (null != this._bufferEntry) { if (this._index + packet.BufferLength > this._bufferEntry.Buffer.Length) { int minSize = Math.Max(this._index - this._startIndex + packet.BufferLength, 512); if (this._index < this._bufferEntry.Buffer.Length / 2) { minSize *= 2; } Utility.BufferInstance bufferInstance = this._bufferPool.Allocate(minSize); Array.Copy((Array)this._bufferEntry.Buffer, this._startIndex, (Array)bufferInstance.Buffer, 0, this._index - this._startIndex); this._bufferPool.Free(this._bufferEntry); this._bufferEntry = bufferInstance; this._index -= this._startIndex; this._startIndex = 0; } packet.CopyTo(this._bufferEntry.Buffer, this._index); this._index += packet.BufferLength; } } if (packet == null || this._length > 0U && (long)(this._index - this._startIndex) == (long)this._length) { this.Flush(); } if (packet == null && null != this._bufferEntry) { this._bufferPool.Free(this._bufferEntry); this._bufferEntry = (Utility.BufferInstance)null; } if (packet != null || null == this._handler) { return; } this._handler((TsPesPacket)null); }
private void ParseHeader(TsPacket packet) { if (packet.BufferLength < 6) { return; } int bufferOffset = packet.BufferOffset; int index1 = bufferOffset; byte[] buffer = packet.Buffer; uint num1 = (uint)((int)buffer[index1] << 16 | (int)buffer[index1 + 1] << 8) | (uint)buffer[index1 + 2]; int num2 = index1 + 3; if (1 != (int)num1) { return; } byte[] numArray = buffer; int index2 = num2; int num3 = 1; int index3 = index2 + num3; this._streamId = numArray[index2]; uint num4 = (uint)buffer[index3] << 8 | (uint)buffer[index3 + 1]; int num5 = index3 + 2; int minSize = 4096; if (num4 > 0U) { this._length = num4 + (uint)(num5 - bufferOffset); minSize = (int)this._length; } else { this._length = 0U; } if (this._bufferEntry != null && this._bufferEntry.Buffer.Length - this._startIndex < minSize) { this._bufferPool.Free(this._bufferEntry); this._bufferEntry = (Utility.BufferInstance)null; } if (null == this._bufferEntry) { this._bufferEntry = this._bufferPool.Allocate(minSize); this._startIndex = 0; } this._index = this._startIndex; }
protected abstract void ParseSection(TsPacket packet, int offset, int length);
internal void Add(TsPacket packet) { if (null == packet) { return; } int bufferOffset = packet.BufferOffset; int num1 = bufferOffset; byte[] buffer = packet.Buffer; int bufferLength = packet.BufferLength; if (bufferLength < 4) { return; } byte[] numArray1 = buffer; int index1 = num1; int num2 = 1; int num3 = index1 + num2 + (int)numArray1[index1]; if (num3 + 4 >= bufferOffset + bufferLength) { return; } int offset1 = num3; byte[] numArray2 = buffer; int index2 = num3; int num4 = 1; int index3 = index2 + num4; if ((int)this._tableId != (int)numArray2[index2]) { return; } int num5 = (int)buffer[index3] << 8 | (int)buffer[index3 + 1]; int num6 = index3 + 2; bool flag = 0 != (num5 & 32768); if (0 != (num5 & 16384)) { return; } int num7 = num5 & 4095; if (num7 > 1021 || num7 + num6 - bufferOffset > bufferLength) { return; } int length1 = num7 + num6 - offset1; if (!Crc32Msb.Validate(buffer, offset1, length1)) { return; } int offset2 = num6; int length2 = num7 - 4; this.ParseSection(packet, offset2, length2); }
public bool Parse(int tsIndex, byte[] buffer, int index) { this.TsIndex = tsIndex; this._buffer = buffer; int num1 = index; this.IsSkip = false; int num2 = 71; byte[] numArray1 = buffer; int index1 = num1; int num3 = 1; int num4 = index1 + num3; int num5 = (int)numArray1[index1]; if (num2 != num5) { this.IsSkip = true; return(false); } byte[] numArray2 = buffer; int index2 = num4; int num6 = 1; int num7 = index2 + num6; this.Pid = (uint)numArray2[index2] << 8; TsPacket tsPacket = this; int num8 = (int)tsPacket.Pid; byte[] numArray3 = buffer; int index3 = num7; int num9 = 1; int num10 = index3 + num9; int num11 = (int)numArray3[index3]; int num12 = num8 | num11; tsPacket.Pid = (uint)num12; this._transportErrorIndicator = 0 != ((int)this.Pid & 32768); this.IsStart = 0 != ((int)this.Pid & 16384); this._transportPriority = 0 != ((int)this.Pid & 8192); this.Pid &= 8191U; if (8191 == (int)this.Pid) { this.IsSkip = true; return(true); } if (this._transportErrorIndicator) { this.IsSkip = true; return(true); } byte[] numArray4 = buffer; int index4 = num10; int num13 = 1; int num14 = index4 + num13; byte num15 = numArray4[index4]; this._transportScramblingControl = (int)num15 >> 6 & 3; this._adaptationFieldControl = (int)num15 >> 4 & 3; if (0 == this._adaptationFieldControl) { this.IsSkip = true; } this.ContinuityCount = (int)num15 & 15; this._payloadIndex = num14; this._payloadLength = 188 - (num14 - index); this.IsDiscontinuos = false; this.Pcr = new ulong?(); if (0 != (this._adaptationFieldControl & 2)) { byte[] numArray5 = buffer; int index5 = num14; int num16 = 1; int num17 = index5 + num16; this._adaptationLength = (int)numArray5[index5]; if (2 == this._adaptationFieldControl) { if (this._adaptationLength != 183) { Debug.WriteLine("Invalid adaptation_field_length (without payload): " + (object)this._adaptationLength); this._adaptationLength = 183; } } else if (3 == this._adaptationFieldControl && this._adaptationLength > 182 && 183 != this._adaptationLength) { Debug.WriteLine("Invalid adaptation_field_length (with payload): " + (object)this._adaptationLength); this._adaptationLength = 183; } ++this._payloadIndex; --this._payloadLength; if (this._adaptationLength > 0) { int num18 = this._adaptationLength; if (this._payloadLength < this._adaptationLength) { return(false); } this._payloadIndex += this._adaptationLength; this._payloadLength -= this._adaptationLength; byte[] numArray6 = buffer; int index6 = num17; int num19 = 1; int index7 = index6 + num19; this._adaptationFlags = numArray6[index6]; int num20 = num18 - 1; this.IsDiscontinuos = 0 != ((int)this._adaptationFlags & 128); if (0 != ((int)this._adaptationFlags & 16)) { if (num20 < 6) { return(false); } this.Pcr = new ulong?(this.ReadTime(buffer, index7)); int num21 = index7 + 6; int num22 = num20 - 6; } } } else { this._adaptationLength = 0; } return(true); }
protected override void ParseSection(TsPacket packet, int offset, int length) { if (length < 5) { return; } int index1 = offset; byte[] buffer = packet.Buffer; int num1 = index1 + length; this._transportStreamId = (int)buffer[index1] << 8 | (int)buffer[index1 + 1]; int num2 = index1 + 2; byte[] numArray1 = buffer; int index2 = num2; int num3 = 1; int num4 = index2 + num3; byte num5 = numArray1[index2]; this._currentNextIndicator = 0 != ((int)num5 & 1); byte num6 = (byte)((uint)(byte)((uint)num5 >> 1) & 31U); byte[] numArray2 = buffer; int index3 = num4; int num7 = 1; int num8 = index3 + num7; byte num9 = numArray2[index3]; byte[] numArray3 = buffer; int index4 = num8; int num10 = 1; int index5 = index4 + num10; byte num11 = numArray3[index4]; if ((int)this._lastSectionNumber > 0 && (int)num11 != (int)this._lastSectionNumber || (int)num11 < (int)num9) { return; } if (this._hasData) { if ((int)this._versionNumber != (int)num6) { return; } ++this._sectionNumber; if ((int)this._sectionNumber != (int)num9 || (int)this._lastSectionNumber != (int)num11) { return; } } else { if (0 != (int)num9) { return; } this._sectionNumber = (byte)0; this._lastSectionNumber = num11; this._versionNumber = (uint)num6; this._hasData = true; } while (index5 + 4 <= num1) { int program_number = (int)buffer[index5] << 8 | (int)buffer[index5 + 1]; int index6 = index5 + 2; uint pid = (uint)buffer[index6] << 8 | (uint)buffer[index6 + 1]; pid &= 8191U; index5 = index6 + 2; if (!Enumerable.Any <TsProgramAssociationTable.ProgramAssociation>((IEnumerable <TsProgramAssociationTable.ProgramAssociation>) this._newPrograms, (Func <TsProgramAssociationTable.ProgramAssociation, bool>)(p => (int)p.Pid == (int)pid && p.ProgramNumber == program_number)) && this._programFilter(program_number)) { this._newPrograms.Add(new TsProgramAssociationTable.ProgramAssociation() { ProgramNumber = program_number, Pid = pid }); } } if ((int)this._sectionNumber != (int)this._lastSectionNumber || !this._currentNextIndicator) { return; } this.Activate(); }
protected override void ParseSection(TsPacket packet, int offset, int length) { if (length < 9) { return; } int index1 = offset; byte[] buffer = packet.Buffer; int num1 = (int)buffer[index1] << 8 | (int)buffer[index1 + 1]; int num2 = index1 + 2; byte[] numArray1 = buffer; int index2 = num2; int num3 = 1; int num4 = index2 + num3; byte num5 = numArray1[index2]; bool flag = 0 != ((int)num5 & 1); byte num6 = (byte)((uint)(byte)((uint)num5 >> 1) & 31U); byte[] numArray2 = buffer; int index3 = num4; int num7 = 1; int num8 = index3 + num7; byte num9 = numArray2[index3]; byte[] numArray3 = buffer; int index4 = num8; int num10 = 1; int index5 = index4 + num10; byte num11 = numArray3[index4]; if ((int)num11 < (int)num9) { return; } uint num12 = (uint)buffer[index5] << 8 | (uint)buffer[index5 + 1]; int index6 = index5 + 2; this._pcrPid = num12 & 8191U; int num13 = (int)buffer[index6] << 8 | (int)buffer[index6 + 1]; int offset1 = index6 + 2; int length1 = num13 & 4095; if (offset1 - offset + length1 >= length) { return; } TsDescriptor[] tsDescriptorArray1 = (TsDescriptor[])null; if (length1 > 0) { tsDescriptorArray1 = Enumerable.ToArray <TsDescriptor>(TsDescriptors.Parse(this._descriptorFactory, buffer, offset1, length1)); } this._newProgramDescriptors = tsDescriptorArray1; int num14 = offset1 + length1; int num15 = offset + length; while (num14 + 5 <= num15) { byte[] numArray4 = buffer; int index7 = num14; int num16 = 1; int index8 = index7 + num16; byte streamType1 = numArray4[index7]; uint num17 = (uint)buffer[index8] << 8 | (uint)buffer[index8 + 1]; int index9 = index8 + 2; uint index10 = num17 & 8191U; int num18 = (int)buffer[index9] << 8 | (int)buffer[index9 + 1]; int offset2 = index9 + 2; int length2 = num18 & 4095; if (offset2 + length2 > num15) { return; } TsDescriptor[] tsDescriptorArray2 = (TsDescriptor[])null; if (length2 > 0) { tsDescriptorArray2 = Enumerable.ToArray <TsDescriptor>(TsDescriptors.Parse(this._descriptorFactory, buffer, offset2, length2)); } num14 = offset2 + length2; TsStreamType streamType2 = TsStreamType.FindStreamType(streamType1); TsProgramMapTable.ProgramMap programMap = new TsProgramMapTable.ProgramMap() { Pid = index10, StreamType = streamType2, StreamDescriptors = tsDescriptorArray2 }; this._newProgramStreams[index10] = programMap; } if ((int)num9 != (int)num11) { return; } this.MapProgramStreams(); }