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