av_format/common.rs
1use crate::data::rational::Rational64;
2use crate::stream::Stream;
3
4/// Global media file information.
5#[derive(Debug, Clone)]
6pub struct GlobalInfo {
7 /// Duration of a media file.
8 ///
9 /// If `None`, the duration of a media file is not considered.
10 pub duration: Option<u64>,
11 /// Timebase associated to a media file.
12 ///
13 /// If `None`, the timebase of a media file is not considered.
14 pub timebase: Option<Rational64>,
15 /// List of streams present in a media file.
16 pub streams: Vec<Stream>,
17}
18
19impl GlobalInfo {
20 /// Adds a stream to the list of streams present in a media file.
21 pub fn add_stream(&mut self, mut st: Stream) -> usize {
22 let idx = self.streams.len();
23
24 if st.id < 0 {
25 st.id = st.index as isize;
26 }
27 st.index = idx;
28
29 self.streams.push(st);
30
31 idx
32 }
33}