internal static FLVHeader ReadHeader(Stream stream) { FLVHeader header = new FLVHeader(); byte[] buffer = new byte[4]; stream.Read(header.signature, 0, 3); stream.Read(buffer, 0, 1); header.version = buffer[0]; stream.Read(buffer, 0, 1); header.typeflag = buffer[0]; try { header.dataoffset = (int)ByteUtil.ReadUI32(stream); } catch { } return(header); }
public FlvParser(Stream stream, Predicate <FlvTag> exec) { FLVHeader header = FLVHeader.ReadHeader(stream); if (!header.IsFlv) { this.IsFlv = false; return; } this.IsFlv = true; stream.Seek(header.Length, SeekOrigin.Begin); Tags = new List <FlvTag>(); FlvTag tag; while ((tag = FlvTag.ReadTag(stream)) != null) { if (tag is ScriptTag) { this.MetaTag = tag as ScriptTag; } Tags.Add(tag); if (Duration < tag.TimeStamp) { Duration = tag.TimeStamp; } if (exec != null) { if (!exec(tag)) { break; } } } if (Tags.Count > 1) { this.Length = stream.Length - Tags[1].Offset + 11; //+ FlvMain.c_HeaderSize; this.Rate = (this.Duration == 0 ? 0 : this.Length * 8 / this.Duration); } }
public FlvInfo() { Header = new FLVHeader(); TagList = new List <FLVTag>(); }
internal static FLVHeader ReadHeader(Stream stream) { FLVHeader header = new FLVHeader(); byte[] buffer = new byte[4]; stream.Read(header.signature, 0, 3); stream.Read(buffer, 0, 1); header.version = buffer[0]; stream.Read(buffer, 0, 1); header.typeflag = buffer[0]; try { header.dataoffset = (int)ByteUtil.ReadUI32(stream); } catch { } return header; }
public FlvInfo() { Header = new FLVHeader(); TagList = new List<FLVTag>(); }