use std::io::Cursor;
use byteorder::{ReadBytesExt, BigEndian};
use std::fmt;
use OggMetadataError;
pub struct Metadata {
pub pixels_width :u32,
pub pixels_height :u32,
}
impl fmt::Debug for Metadata {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "size {}x{}", self.pixels_width, self.pixels_height)
}
}
pub struct IdentHeader {
pub picture_region_width :u32,
pub picture_region_height :u32,
}
#[allow(unused_variables)]
pub fn read_header_ident(packet :&[u8]) -> Result<IdentHeader, OggMetadataError> {
let mut rdr = Cursor::new(packet);
let vmaj = try!(rdr.read_u8());
let vmin = try!(rdr.read_u8());
let vrev = try!(rdr.read_u8());
let fmbw = try!(rdr.read_u16::<BigEndian>());
let fmbh = try!(rdr.read_u16::<BigEndian>());
let picw = try!(rdr.read_uint::<BigEndian>(3)) as u32;
let pich = try!(rdr.read_uint::<BigEndian>(3)) as u32;
let hdr :IdentHeader = IdentHeader {
picture_region_width : picw,
picture_region_height : pich,
};
return Ok(hdr);
}