public override FrameHeader Parse(System.IO.Stream stream)
{
byte[] header=new byte[10];
if(stream.Read(header, 0, 10)!=10)
{
//TODO Create a new exception class for frame parsing errors.
throw new FrameParsingException("Could not read frame's header.");
}
if(header[0]==0)//reached the padding
{
return null;
}
int frameSize=(int)header[4]*(1<<24)+(int)header[5]*(1<<16)+(int)header[6]*(1<<8)+(int)header[7];
string frameID=Encoding.GetEncoding("ISO-8859-1").GetString(header, 0, 4);
return new FrameHeader(frameID, frameSize,header[8],header[9]);
}