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
1 changed files with 8 additions and 3 deletions
11
src/time.rs
11
src/time.rs
|
@ -78,9 +78,14 @@ impl TransportPacketWrite for SpliceTime {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Duration> for SpliceTime {
|
||||
fn from(duration: Duration) -> Self {
|
||||
Self::from_ticks(duration.to_90k())
|
||||
impl<T> From<T> for SpliceTime
|
||||
where
|
||||
T: ClockTimeExt,
|
||||
{
|
||||
fn from(pts: T) -> Self {
|
||||
let mut t = Self::new();
|
||||
t.set_pts(Some(pts));
|
||||
t
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue