Use generic trait for SpliceTime creation
Add support for creating `SpliceTime` instances from anything that implements the trait `ClockTimeExt`. This makes redundant to implement the `From` trait for the `std::time::Duration` struct, since it implements the `ClockTimeExt` trait. Signed-off-by: Rafael Caricio <rafael@caricio.com>
This commit is contained in:
parent
1770c5ca9d
commit
5d72027943
11
src/time.rs
11
src/time.rs
|
@ -78,9 +78,14 @@ impl TransportPacketWrite for SpliceTime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Duration> for SpliceTime {
|
impl<T> From<T> for SpliceTime
|
||||||
fn from(duration: Duration) -> Self {
|
where
|
||||||
Self::from_ticks(duration.to_90k())
|
T: ClockTimeExt,
|
||||||
|
{
|
||||||
|
fn from(pts: T) -> Self {
|
||||||
|
let mut t = Self::new();
|
||||||
|
t.set_pts(Some(pts));
|
||||||
|
t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue