public bool Parse(byte[] h264Stream) { profile = 0; level = 0; refFrames = 0; currrentPos = 0; buffer = h264Stream; byte[] nal = new byte[0]; while (nal != null) { nal = ReadNALUnit(); if (nal != null) { NALUnit nu = NALUnit.Read(nal); if (nu.Type == NALUnitType.SequenceParameterSet) { SeqParameterSet param = SeqParameterSet.Read(nu.Data); if (Enum.IsDefined(typeof(H264HeaderProfile), param.profile_idc) == true) { profile = param.profile_idc; level = param.level_idc; refFrames = param.num_ref_frames; return(true); } } } } return(false); }