public static bool Read(DataStream stream, ref int width, ref int height) { AVCPacketType avcType = (AVCPacketType)stream.ReadByte(); // make sure, that this is header packet if (avcType != AVCPacketType.SequenceHeader) { return(false); } // read composition time stream.Read24Int(); AVCDecoderConfigurationRecord configuration = new AVCDecoderConfigurationRecord(stream); // do we have SPS? if ((configuration.NumOfSequenceParameterSets & 0x1F) == 0) { return(false); } // read SPS size ushort spsSize = stream.ReadUShort(); // read SPS itself byte[] spsBuffer = stream.ReadBytes(spsSize); ParseSPS(spsBuffer, out width, out height); return(true); }
public AVCPacket(Stream stream, int Count) { //Header: 00 00 00 00 //NALU: 01 00 00 00 this.Type = (AVCPacketType)stream.ReadUInt8(); //1 this.Time = (int)stream.ReadUInt24(); //CompositionTime //3 if (this.Type == AVCPacketType.AVCSequenceHeader) { this.AVCDecoderConfigurationRecord = stream.ReadBytes(Count - 4); } else { this.NALUs = stream.ReadBytes(Count - 4); }; }