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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
use crate::data::params::CodecParams; use crate::rational::Rational64; use std::any::Any; use std::sync::Arc; /* #[derive(Debug)] pub struct UserPrivate(Option<Box<Any + Send>>); impl UserPrivate { pub fn new<T: Clone + Any + Send>(x: T) -> Self { UserPrivate(Some(Box::new(x))) } pub fn is<T: 'static>(&self) -> bool { self.0.as_ref().map_or(false, |a| a.is::<T>()) } pub fn downcast_ref<T: 'static>(&self) -> Option<&T> { self.0.as_ref().map_or(None, |a| a.downcast_ref::<T>()) } pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> { self.0.as_mut().map_or(None, |a| a.downcast_mut::<T>()) } pub fn is_some(&self) -> bool { self.0.is_some() } pub fn is_none(&self) -> bool { self.0.is_none() } } impl Clone for UserPrivate { fn clone(&self) -> Self { UserPrivate(None) } } impl PartialEq for UserPrivate { fn eq(&self, other: &UserPrivate) -> bool { self.0.is_none() && other.0.is_none() } } */ #[derive(Debug, Clone)] pub struct Stream { /// Format-specific track identifier. /// /// Negative if not supported by the underlying format or if the /// default progression should be used. /// /// Must be unique pub id: isize, pub index: usize, pub params: CodecParams, pub start: Option<u64>, pub duration: Option<u64>, pub timebase: Rational64, /// User Private field, will not be cloned pub user_private: Option<Arc<dyn Any + Send + Sync>>, // seek_index : SeekIndex } impl Stream { pub fn from_params(params: &CodecParams, timebase: Rational64) -> Self { Stream { id: -1, index: 0, params: params.clone(), start: None, duration: None, timebase, user_private: None, } } pub fn get_extradata<'a>(&'a self) -> Option<&'a [u8]> { self.params.extradata.as_ref().map(|e| e.as_slice()) } } pub struct StreamGroup<'a> { pub id: usize, pub start: u64, pub end: u64, pub streams: &'a [Stream], }