diff options
Diffstat (limited to 'src/v4l2abst.rs')
| -rw-r--r-- | src/v4l2abst.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/v4l2abst.rs b/src/v4l2abst.rs index baefea0..03983bc 100644 --- a/src/v4l2abst.rs +++ b/src/v4l2abst.rs @@ -2,7 +2,6 @@ use anyhow::{anyhow, Result}; use crate::v4l2; use chrono::{DateTime, Local}; use std::io::{Read, Write}; -use std::mem::size_of; pub struct Frame<'a>{ pub format: v4l2::ImageFormat, @@ -17,10 +16,10 @@ impl<'a> Frame<'a>{ dst.write_all(&u32::to_be_bytes(self.format.into()))?; dst.write_all(&self.timestamp.timestamp_subsec_nanos().to_be_bytes())?; dst.write_all(&self.timestamp.timestamp().to_be_bytes())?; - dst.write_all(&self.width.to_be_bytes())?; - dst.write_all(&self.height.to_be_bytes())?; - dst.write_all(&self.stride.to_be_bytes())?; - dst.write_all(&self.buf.len().to_be_bytes())?; + dst.write_all(&(self.width as u64).to_be_bytes())?; + dst.write_all(&(self.height as u64).to_be_bytes())?; + dst.write_all(&(self.stride as u64).to_be_bytes())?; + dst.write_all(&(self.buf.len() as u64).to_be_bytes())?; dst.write_all(self.buf)?; Ok(()) } @@ -39,11 +38,12 @@ impl<'a> Frame<'a>{ Ok(i64::from_be_bytes(tmp)) } fn usize(&mut self) -> Result<usize>{ - let mut tmp: [u8; size_of::<usize>()] = Default::default(); + let mut tmp: [u8; 8] = Default::default(); self.0.read_exact(&mut tmp)?; - Ok(usize::from_be_bytes(tmp)) + Ok(u64::from_be_bytes(tmp) as usize) } } + // XXX: limit allocation length? let mut src = Rh(src); let format = src.u32()?.into(); let (ns, s) = (src.u32()?, src.i64()?); |
