Skip to content

Commit a5792ee

Browse files
author
Adrian
committed
- Removed turbofish in media_time_to_us/track_time_to_us
- Added `use` of symbols from `unstable` mod at the beginning - Removed unneded derives from `Microseconds`
1 parent 3433fe3 commit a5792ee

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

mp4parse/src/unstable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,14 @@ where
490490
})
491491
}
492492

493-
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
493+
#[derive(Debug, PartialEq)]
494494
pub struct Microseconds<T>(pub T);
495495

496496
/// Convert `time` in media's global (mvhd) timescale to microseconds,
497497
/// using provided `MediaTimeScale`
498498
pub fn media_time_to_us(time: MediaScaledTime, scale: MediaTimeScale) -> Option<Microseconds<u64>> {
499499
let microseconds_per_second = 1_000_000;
500-
rational_scale::<u64, u64>(time.0, scale.0, microseconds_per_second).map(Microseconds)
500+
rational_scale(time.0, scale.0, microseconds_per_second).map(Microseconds)
501501
}
502502

503503
/// Convert `time` in track's local (mdhd) timescale to microseconds,
@@ -511,7 +511,7 @@ where
511511
{
512512
assert_eq!(time.1, scale.1);
513513
let microseconds_per_second = 1_000_000;
514-
rational_scale::<T, u64>(time.0, scale.0, microseconds_per_second).map(Microseconds)
514+
rational_scale(time.0, scale.0, microseconds_per_second).map(Microseconds)
515515
}
516516

517517
#[test]

mp4parse_capi/src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ use std::io::Read;
4848

4949
// Symbols we need from our rust api.
5050
use mp4parse::serialize_opus_header;
51-
use mp4parse::unstable::CheckedInteger;
52-
use mp4parse::unstable::Indice;
51+
use mp4parse::unstable::{
52+
create_sample_table, media_time_to_us, track_time_to_us, CheckedInteger, Indice, Microseconds,
53+
};
5354
use mp4parse::AudioCodecSpecific;
5455
use mp4parse::AvifContext;
5556
use mp4parse::CodecType;
@@ -621,20 +622,19 @@ pub unsafe extern "C" fn mp4parse_get_track_info(
621622
let track = &context.tracks[track_index];
622623

623624
if let (Some(track_timescale), Some(context_timescale)) = (track.timescale, context.timescale) {
624-
let media_time: CheckedInteger<u64> = match track
625+
let media_time: CheckedInteger<_> = match track
625626
.media_time
626-
.map_or(Some(mp4parse::unstable::Microseconds(0)), |media_time| {
627-
mp4parse::unstable::track_time_to_us(media_time, track_timescale)
627+
.map_or(Some(Microseconds(0)), |media_time| {
628+
track_time_to_us(media_time, track_timescale)
628629
}) {
629630
Some(time) => time.0.into(),
630631
None => return Mp4parseStatus::Invalid,
631632
};
632-
let empty_duration: CheckedInteger<u64> = match track.empty_duration.map_or(
633-
Some(mp4parse::unstable::Microseconds(0)),
634-
|empty_duration| {
635-
mp4parse::unstable::media_time_to_us(empty_duration, context_timescale)
636-
},
637-
) {
633+
let empty_duration: CheckedInteger<_> = match track
634+
.empty_duration
635+
.map_or(Some(Microseconds(0)), |empty_duration| {
636+
media_time_to_us(empty_duration, context_timescale)
637+
}) {
638638
Some(time) => time.0.into(),
639639
None => return Mp4parseStatus::Invalid,
640640
};
@@ -644,7 +644,7 @@ pub unsafe extern "C" fn mp4parse_get_track_info(
644644
};
645645

646646
if let Some(track_duration) = track.duration {
647-
match mp4parse::unstable::track_time_to_us(track_duration, track_timescale) {
647+
match track_time_to_us(track_duration, track_timescale) {
648648
Some(duration) => info.duration = duration.0,
649649
None => return Mp4parseStatus::Invalid,
650650
}
@@ -1114,15 +1114,15 @@ fn get_indice_table(
11141114
}
11151115

11161116
let media_time = match (&track.media_time, &track.timescale) {
1117-
(&Some(t), &Some(s)) => mp4parse::unstable::track_time_to_us(t, s)
1117+
(&Some(t), &Some(s)) => track_time_to_us(t, s)
11181118
.and_then(|v| i64::try_from(v.0).ok())
11191119
.map(Into::into),
11201120
_ => None,
11211121
};
11221122

11231123
let empty_duration: Option<CheckedInteger<_>> =
11241124
match (&track.empty_duration, &context.timescale) {
1125-
(&Some(e), &Some(s)) => mp4parse::unstable::media_time_to_us(e, s)
1125+
(&Some(e), &Some(s)) => media_time_to_us(e, s)
11261126
.and_then(|v| i64::try_from(v.0).ok())
11271127
.map(Into::into),
11281128
_ => None,
@@ -1138,7 +1138,7 @@ fn get_indice_table(
11381138
_ => 0.into(),
11391139
};
11401140

1141-
if let Some(v) = mp4parse::unstable::create_sample_table(track, offset_time) {
1141+
if let Some(v) = create_sample_table(track, offset_time) {
11421142
indices.set_indices(&v);
11431143
index_table.insert(track_id, v)?;
11441144
return Ok(());
@@ -1179,7 +1179,7 @@ pub unsafe extern "C" fn mp4parse_get_fragment_info(
11791179
};
11801180

11811181
if let (Some(time), Some(scale)) = (duration, context.timescale) {
1182-
info.fragment_duration = match mp4parse::unstable::media_time_to_us(time, scale) {
1182+
info.fragment_duration = match media_time_to_us(time, scale) {
11831183
Some(time_us) => time_us.0 as u64,
11841184
None => return Mp4parseStatus::Invalid,
11851185
}

0 commit comments

Comments
 (0)