1 #![warn(rust_2018_idioms)] 2 #![allow(dead_code)] 3 4 pub mod audio; 5 mod error; 6 pub mod io; 7 pub mod track; 8 pub mod video; 9 10 pub use error::Error; 11 12 use bytes::Bytes; 13 use std::time::{Duration, SystemTime}; 14 15 /// A Sample contains encoded media and timing information 16 #[derive(Debug)] 17 pub struct Sample { 18 pub data: Bytes, 19 pub timestamp: SystemTime, 20 pub duration: Duration, 21 pub packet_timestamp: u32, 22 pub prev_dropped_packets: u16, 23 } 24 25 impl Default for Sample { 26 fn default() -> Self { 27 Sample { 28 data: Bytes::new(), 29 timestamp: SystemTime::now(), 30 duration: Duration::from_secs(0), 31 packet_timestamp: 0, 32 prev_dropped_packets: 0, 33 } 34 } 35 } 36 37 impl PartialEq for Sample { 38 fn eq(&self, other: &Self) -> bool { 39 let mut equal: bool = true; 40 if self.data != other.data { 41 equal = false; 42 } 43 if self.timestamp.elapsed().unwrap().as_secs() 44 != other.timestamp.elapsed().unwrap().as_secs() 45 { 46 equal = false; 47 } 48 if self.duration != other.duration { 49 equal = false; 50 } 51 if self.packet_timestamp != other.packet_timestamp { 52 equal = false; 53 } 54 if self.prev_dropped_packets != other.prev_dropped_packets { 55 equal = false; 56 } 57 equal 58 } 59 } 60