PeerCastStation.MKV.Element.ReadHeader C# (CSharp) Method

ReadHeader() public static method

public static ReadHeader ( Stream s ) : Element
s Stream
return Element
    public static Element ReadHeader(Stream s)
    {
      var id  = VInt.ReadUInt(s);
      var sz  = VInt.ReadUInt(s);
      return new Element(id, sz);
    }

Usage Example

 public bool TryParseContentType(byte[] header, out string content_type, out string mime_type)
 {
     try {
         using (var stream = new MemoryStream(header)) {
             var elt = Element.ReadHeader(stream);
             if (4 < elt.ID.Length || 8 < elt.Size.Length ||
                 !elt.ID.BinaryEquals(Elements.EBML))
             {
                 content_type = null;
                 mime_type    = null;
                 return(false);
             }
             elt.ReadBody(stream);
             var ebml = new EBML(elt);
             if (ebml.DocType == "webm")
             {
                 content_type = "WEBM";
                 mime_type    = "video/webm";
             }
             else
             {
                 content_type = "MKV";
                 mime_type    = "video/x-matroska";
             }
             return(true);
         }
     }
     catch (EndOfStreamException) {
         content_type = null;
         mime_type    = null;
         return(false);
     }
 }
All Usage Examples Of PeerCastStation.MKV.Element::ReadHeader