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:
Rafael Caricio 2022-05-06 22:26:57 +02:00
parent 1770c5ca9d
commit 5d72027943
Signed by: rafaelcaricio
GPG key ID: 3C86DBCE8E93C947

View file

@ -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
}
}