mirror of
https://github.com/alfg/mp4-rust.git
synced 2025-02-08 09:22:20 +00:00
clippy: fix warnings from latest stable rust 1.67.0 (#93)
This commit is contained in:
parent
2a374c57f2
commit
9f10bd335e
21 changed files with 63 additions and 63 deletions
|
@ -54,7 +54,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for DataBox {
|
||||||
|
|
||||||
reader.read_u32::<BigEndian>()?; // reserved = 0
|
reader.read_u32::<BigEndian>()?; // reserved = 0
|
||||||
|
|
||||||
let current = reader.seek(SeekFrom::Current(0))?;
|
let current = reader.stream_position()?;
|
||||||
let mut data = vec![0u8; (start + size - current) as usize];
|
let mut data = vec![0u8; (start + size - current) as usize];
|
||||||
reader.read_exact(&mut data)?;
|
reader.read_exact(&mut data)?;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for DinfBox {
|
||||||
|
|
||||||
let mut dref = None;
|
let mut dref = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -60,7 +60,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for DinfBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if dref.is_none() {
|
if dref.is_none() {
|
||||||
|
@ -140,7 +140,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for DrefBox {
|
||||||
fn read_box(reader: &mut R, size: u64) -> Result<Self> {
|
fn read_box(reader: &mut R, size: u64) -> Result<Self> {
|
||||||
let start = box_start(reader)?;
|
let start = box_start(reader)?;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
|
|
||||||
let (version, flags) = read_box_header_ext(reader)?;
|
let (version, flags) = read_box_header_ext(reader)?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
|
@ -166,7 +166,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for DrefBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_bytes_to(reader, start + size)?;
|
skip_bytes_to(reader, start + size)?;
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for IlstBox {
|
||||||
|
|
||||||
let mut items = HashMap::new();
|
let mut items = HashMap::new();
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -78,7 +78,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for IlstBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_bytes_to(reader, start + size)?;
|
skip_bytes_to(reader, start + size)?;
|
||||||
|
@ -123,7 +123,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for IlstItemBox {
|
||||||
|
|
||||||
let mut data = None;
|
let mut data = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -140,7 +140,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for IlstItemBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.is_none() {
|
if data.is_none() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{hdlr::HdlrBox, mdhd::MdhdBox, minf::MinfBox};
|
use crate::mp4box::{hdlr::HdlrBox, mdhd::MdhdBox, minf::MinfBox};
|
||||||
|
@ -48,7 +48,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MdiaBox {
|
||||||
let mut hdlr = None;
|
let mut hdlr = None;
|
||||||
let mut minf = None;
|
let mut minf = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -71,7 +71,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MdiaBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if mdhd.is_none() {
|
if mdhd.is_none() {
|
||||||
|
|
|
@ -97,7 +97,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MetaBox {
|
||||||
|
|
||||||
let mut ilst = None;
|
let mut ilst = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
|
|
||||||
match hdlr.handler_type {
|
match hdlr.handler_type {
|
||||||
|
@ -117,7 +117,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MetaBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(MetaBox::Mdir { ilst })
|
Ok(MetaBox::Mdir { ilst })
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{dinf::DinfBox, smhd::SmhdBox, stbl::StblBox, vmhd::VmhdBox};
|
use crate::mp4box::{dinf::DinfBox, smhd::SmhdBox, stbl::StblBox, vmhd::VmhdBox};
|
||||||
|
@ -63,7 +63,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MinfBox {
|
||||||
let mut dinf = None;
|
let mut dinf = None;
|
||||||
let mut stbl = None;
|
let mut stbl = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -89,7 +89,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MinfBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if dinf.is_none() {
|
if dinf.is_none() {
|
||||||
|
|
|
@ -293,7 +293,7 @@ pub fn write_box_header_ext<W: Write>(w: &mut W, v: u8, f: u32) -> Result<u64> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn box_start<R: Seek>(seeker: &mut R) -> Result<u64> {
|
pub fn box_start<R: Seek>(seeker: &mut R) -> Result<u64> {
|
||||||
Ok(seeker.seek(SeekFrom::Current(0))? - HEADER_SIZE)
|
Ok(seeker.stream_position()? - HEADER_SIZE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn skip_bytes<S: Seek>(seeker: &mut S, size: u64) -> Result<()> {
|
pub fn skip_bytes<S: Seek>(seeker: &mut S, size: u64) -> Result<()> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{mfhd::MfhdBox, traf::TrafBox};
|
use crate::mp4box::{mfhd::MfhdBox, traf::TrafBox};
|
||||||
|
@ -52,7 +52,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MoofBox {
|
||||||
let mut mfhd = None;
|
let mut mfhd = None;
|
||||||
let mut trafs = Vec::new();
|
let mut trafs = Vec::new();
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -72,7 +72,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MoofBox {
|
||||||
skip_box(reader, s)?;
|
skip_box(reader, s)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if mfhd.is_none() {
|
if mfhd.is_none() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::meta::MetaBox;
|
use crate::meta::MetaBox;
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
@ -71,7 +71,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MoovBox {
|
||||||
let mut mvex = None;
|
let mut mvex = None;
|
||||||
let mut traks = Vec::new();
|
let mut traks = Vec::new();
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -101,7 +101,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MoovBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if mvhd.is_none() {
|
if mvhd.is_none() {
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for Mp4aBox {
|
||||||
let samplerate = FixedPointU16::new_raw(reader.read_u32::<BigEndian>()?);
|
let samplerate = FixedPointU16::new_raw(reader.read_u32::<BigEndian>()?);
|
||||||
|
|
||||||
let mut esds = None;
|
let mut esds = None;
|
||||||
let current = reader.seek(SeekFrom::Current(0))?;
|
let current = reader.stream_position()?;
|
||||||
if current < start + size {
|
if current < start + size {
|
||||||
let header = BoxHeader::read(reader)?;
|
let header = BoxHeader::read(reader)?;
|
||||||
let BoxHeader { name, size: s } = header;
|
let BoxHeader { name, size: s } = header;
|
||||||
|
@ -181,7 +181,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for EsdsBox {
|
||||||
|
|
||||||
let mut es_desc = None;
|
let mut es_desc = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
let (desc_tag, desc_size) = read_desc(reader)?;
|
let (desc_tag, desc_size) = read_desc(reader)?;
|
||||||
|
@ -191,7 +191,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for EsdsBox {
|
||||||
}
|
}
|
||||||
_ => break,
|
_ => break,
|
||||||
}
|
}
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if es_desc.is_none() {
|
if es_desc.is_none() {
|
||||||
|
@ -313,7 +313,7 @@ impl Descriptor for ESDescriptor {
|
||||||
|
|
||||||
impl<R: Read + Seek> ReadDesc<&mut R> for ESDescriptor {
|
impl<R: Read + Seek> ReadDesc<&mut R> for ESDescriptor {
|
||||||
fn read_desc(reader: &mut R, size: u32) -> Result<Self> {
|
fn read_desc(reader: &mut R, size: u32) -> Result<Self> {
|
||||||
let start = reader.seek(SeekFrom::Current(0))?;
|
let start = reader.stream_position()?;
|
||||||
|
|
||||||
let es_id = reader.read_u16::<BigEndian>()?;
|
let es_id = reader.read_u16::<BigEndian>()?;
|
||||||
reader.read_u8()?; // XXX flags must be 0
|
reader.read_u8()?; // XXX flags must be 0
|
||||||
|
@ -321,7 +321,7 @@ impl<R: Read + Seek> ReadDesc<&mut R> for ESDescriptor {
|
||||||
let mut dec_config = None;
|
let mut dec_config = None;
|
||||||
let mut sl_config = None;
|
let mut sl_config = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size as u64;
|
let end = start + size as u64;
|
||||||
while current < end {
|
while current < end {
|
||||||
let (desc_tag, desc_size) = read_desc(reader)?;
|
let (desc_tag, desc_size) = read_desc(reader)?;
|
||||||
|
@ -336,7 +336,7 @@ impl<R: Read + Seek> ReadDesc<&mut R> for ESDescriptor {
|
||||||
skip_bytes(reader, desc_size as u64)?;
|
skip_bytes(reader, desc_size as u64)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ESDescriptor {
|
Ok(ESDescriptor {
|
||||||
|
@ -402,7 +402,7 @@ impl Descriptor for DecoderConfigDescriptor {
|
||||||
|
|
||||||
impl<R: Read + Seek> ReadDesc<&mut R> for DecoderConfigDescriptor {
|
impl<R: Read + Seek> ReadDesc<&mut R> for DecoderConfigDescriptor {
|
||||||
fn read_desc(reader: &mut R, size: u32) -> Result<Self> {
|
fn read_desc(reader: &mut R, size: u32) -> Result<Self> {
|
||||||
let start = reader.seek(SeekFrom::Current(0))?;
|
let start = reader.stream_position()?;
|
||||||
|
|
||||||
let object_type_indication = reader.read_u8()?;
|
let object_type_indication = reader.read_u8()?;
|
||||||
let byte_a = reader.read_u8()?;
|
let byte_a = reader.read_u8()?;
|
||||||
|
@ -414,7 +414,7 @@ impl<R: Read + Seek> ReadDesc<&mut R> for DecoderConfigDescriptor {
|
||||||
|
|
||||||
let mut dec_specific = None;
|
let mut dec_specific = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size as u64;
|
let end = start + size as u64;
|
||||||
while current < end {
|
while current < end {
|
||||||
let (desc_tag, desc_size) = read_desc(reader)?;
|
let (desc_tag, desc_size) = read_desc(reader)?;
|
||||||
|
@ -426,7 +426,7 @@ impl<R: Read + Seek> ReadDesc<&mut R> for DecoderConfigDescriptor {
|
||||||
skip_bytes(reader, desc_size as u64)?;
|
skip_bytes(reader, desc_size as u64)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(DecoderConfigDescriptor {
|
Ok(DecoderConfigDescriptor {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{mehd::MehdBox, trex::TrexBox};
|
use crate::mp4box::{mehd::MehdBox, trex::TrexBox};
|
||||||
|
@ -46,7 +46,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MvexBox {
|
||||||
let mut mehd = None;
|
let mut mehd = None;
|
||||||
let mut trex = None;
|
let mut trex = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -66,7 +66,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MvexBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if trex.is_none() {
|
if trex.is_none() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{
|
use crate::mp4box::{
|
||||||
|
@ -86,7 +86,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for StblBox {
|
||||||
let mut stco = None;
|
let mut stco = None;
|
||||||
let mut co64 = None;
|
let mut co64 = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -123,7 +123,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for StblBox {
|
||||||
skip_box(reader, s)?;
|
skip_box(reader, s)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if stsd.is_none() {
|
if stsd.is_none() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{tfdt::TfdtBox, tfhd::TfhdBox, trun::TrunBox};
|
use crate::mp4box::{tfdt::TfdtBox, tfhd::TfhdBox, trun::TrunBox};
|
||||||
|
@ -53,7 +53,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for TrafBox {
|
||||||
let mut tfdt = None;
|
let mut tfdt = None;
|
||||||
let mut trun = None;
|
let mut trun = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -76,7 +76,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for TrafBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if tfhd.is_none() {
|
if tfhd.is_none() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::meta::MetaBox;
|
use crate::meta::MetaBox;
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
@ -62,7 +62,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for TrakBox {
|
||||||
let mut meta = None;
|
let mut meta = None;
|
||||||
let mut mdia = None;
|
let mut mdia = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -88,7 +88,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for TrakBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if tkhd.is_none() {
|
if tkhd.is_none() {
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for UdtaBox {
|
||||||
|
|
||||||
let mut meta = None;
|
let mut meta = None;
|
||||||
|
|
||||||
let mut current = reader.seek(SeekFrom::Current(0))?;
|
let mut current = reader.stream_position()?;
|
||||||
let end = start + size;
|
let end = start + size;
|
||||||
while current < end {
|
while current < end {
|
||||||
// Get box header.
|
// Get box header.
|
||||||
|
@ -66,7 +66,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for UdtaBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_bytes_to(reader, start + size)?;
|
skip_bytes_to(reader, start + size)?;
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl Mp4Box for Vp09Box {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn summary(&self) -> Result<String> {
|
fn summary(&self) -> Result<String> {
|
||||||
Ok(format!("{:?}", self))
|
Ok(format!("{self:?}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl Mp4Box for VpccBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn summary(&self) -> Result<String> {
|
fn summary(&self) -> Result<String> {
|
||||||
Ok(format!("{:?}", self))
|
Ok(format!("{self:?}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{Read, Seek, SeekFrom};
|
use std::io::{Read, Seek};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::meta::MetaBox;
|
use crate::meta::MetaBox;
|
||||||
|
@ -19,7 +19,7 @@ pub struct Mp4Reader<R> {
|
||||||
|
|
||||||
impl<R: Read + Seek> Mp4Reader<R> {
|
impl<R: Read + Seek> Mp4Reader<R> {
|
||||||
pub fn read_header(mut reader: R, size: u64) -> Result<Self> {
|
pub fn read_header(mut reader: R, size: u64) -> Result<Self> {
|
||||||
let start = reader.seek(SeekFrom::Current(0))?;
|
let start = reader.stream_position()?;
|
||||||
|
|
||||||
let mut ftyp = None;
|
let mut ftyp = None;
|
||||||
let mut moov = None;
|
let mut moov = None;
|
||||||
|
@ -64,7 +64,7 @@ impl<R: Read + Seek> Mp4Reader<R> {
|
||||||
skip_box(&mut reader, s)?;
|
skip_box(&mut reader, s)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = reader.seek(SeekFrom::Current(0))?;
|
current = reader.stream_position()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ftyp.is_none() {
|
if ftyp.is_none() {
|
||||||
|
|
|
@ -784,7 +784,7 @@ impl Mp4TrackWriter {
|
||||||
if self.chunk_buffer.is_empty() {
|
if self.chunk_buffer.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let chunk_offset = writer.seek(SeekFrom::Current(0))?;
|
let chunk_offset = writer.stream_position()?;
|
||||||
|
|
||||||
writer.write_all(&self.chunk_buffer)?;
|
writer.write_all(&self.chunk_buffer)?;
|
||||||
|
|
||||||
|
|
16
src/types.rs
16
src/types.rs
|
@ -75,14 +75,14 @@ impl FixedPointU16 {
|
||||||
impl fmt::Debug for BoxType {
|
impl fmt::Debug for BoxType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let fourcc: FourCC = From::from(*self);
|
let fourcc: FourCC = From::from(*self);
|
||||||
write!(f, "{}", fourcc)
|
write!(f, "{fourcc}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for BoxType {
|
impl fmt::Display for BoxType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let fourcc: FourCC = From::from(*self);
|
let fourcc: FourCC = From::from(*self);
|
||||||
write!(f, "{}", fourcc)
|
write!(f, "{fourcc}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ impl fmt::Debug for FourCC {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let code: u32 = self.into();
|
let code: u32 = self.into();
|
||||||
let string = String::from_utf8_lossy(&self.value[..]);
|
let string = String::from_utf8_lossy(&self.value[..]);
|
||||||
write!(f, "{} / {:#010X}", string, code)
|
write!(f, "{string} / {code:#010X}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ impl fmt::Display for TrackType {
|
||||||
TrackType::Audio => DISPLAY_TYPE_AUDIO,
|
TrackType::Audio => DISPLAY_TYPE_AUDIO,
|
||||||
TrackType::Subtitle => DISPLAY_TYPE_SUBTITLE,
|
TrackType::Subtitle => DISPLAY_TYPE_SUBTITLE,
|
||||||
};
|
};
|
||||||
write!(f, "{}", s)
|
write!(f, "{s}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ pub enum MediaType {
|
||||||
impl fmt::Display for MediaType {
|
impl fmt::Display for MediaType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let s: &str = self.into();
|
let s: &str = self.into();
|
||||||
write!(f, "{}", s)
|
write!(f, "{s}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ impl fmt::Display for AvcProfile {
|
||||||
AvcProfile::AvcExtended => "Extended",
|
AvcProfile::AvcExtended => "Extended",
|
||||||
AvcProfile::AvcHigh => "High",
|
AvcProfile::AvcHigh => "High",
|
||||||
};
|
};
|
||||||
write!(f, "{}", profile)
|
write!(f, "{profile}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ impl fmt::Display for AudioObjectType {
|
||||||
AudioObjectType::SpatialAudioObjectCodingDialogueEnhancement => "SAOC-DE",
|
AudioObjectType::SpatialAudioObjectCodingDialogueEnhancement => "SAOC-DE",
|
||||||
AudioObjectType::AudioSync => "Audio Sync",
|
AudioObjectType::AudioSync => "Audio Sync",
|
||||||
};
|
};
|
||||||
write!(f, "{}", type_str)
|
write!(f, "{type_str}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ impl fmt::Display for ChannelConfig {
|
||||||
ChannelConfig::FiveOne => "five.one",
|
ChannelConfig::FiveOne => "five.one",
|
||||||
ChannelConfig::SevenOne => "seven.one",
|
ChannelConfig::SevenOne => "seven.one",
|
||||||
};
|
};
|
||||||
write!(f, "{}", s)
|
write!(f, "{s}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl<W: Write + Seek> Mp4Writer<W> {
|
||||||
ftyp.write_box(&mut writer)?;
|
ftyp.write_box(&mut writer)?;
|
||||||
|
|
||||||
// TODO largesize
|
// TODO largesize
|
||||||
let mdat_pos = writer.seek(SeekFrom::Current(0))?;
|
let mdat_pos = writer.stream_position()?;
|
||||||
BoxHeader::new(BoxType::MdatBox, HEADER_SIZE).write(&mut writer)?;
|
BoxHeader::new(BoxType::MdatBox, HEADER_SIZE).write(&mut writer)?;
|
||||||
BoxHeader::new(BoxType::WideBox, HEADER_SIZE).write(&mut writer)?;
|
BoxHeader::new(BoxType::WideBox, HEADER_SIZE).write(&mut writer)?;
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ impl<W: Write + Seek> Mp4Writer<W> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_mdat_size(&mut self) -> Result<()> {
|
fn update_mdat_size(&mut self) -> Result<()> {
|
||||||
let mdat_end = self.writer.seek(SeekFrom::Current(0))?;
|
let mdat_end = self.writer.stream_position()?;
|
||||||
let mdat_size = mdat_end - self.mdat_pos;
|
let mdat_size = mdat_end - self.mdat_pos;
|
||||||
if mdat_size > std::u32::MAX as u64 {
|
if mdat_size > std::u32::MAX as u64 {
|
||||||
self.writer.seek(SeekFrom::Start(self.mdat_pos))?;
|
self.writer.seek(SeekFrom::Start(self.mdat_pos))?;
|
||||||
|
|
Loading…
Reference in a new issue