scuffle_transmuxer/
define.rs

1use bytes::Bytes;
2use scuffle_av1::AV1CodecConfigurationRecord;
3use scuffle_flv::audio::header::legacy::{SoundSize, SoundType};
4use scuffle_h264::AVCDecoderConfigurationRecord;
5use scuffle_h265::HEVCDecoderConfigurationRecord;
6use scuffle_mp4::codec::{AudioCodec, VideoCodec};
7
8pub(crate) enum VideoSequenceHeader {
9    Avc(AVCDecoderConfigurationRecord),
10    Hevc(HEVCDecoderConfigurationRecord),
11    Av1(AV1CodecConfigurationRecord),
12}
13
14pub(crate) struct AudioSequenceHeader {
15    pub sound_size: SoundSize,
16    pub sound_type: SoundType,
17    pub data: AudioSequenceHeaderData,
18}
19
20pub(crate) enum AudioSequenceHeaderData {
21    Aac(Bytes),
22}
23
24#[derive(Debug, Clone)]
25pub enum TransmuxResult {
26    InitSegment {
27        video_settings: VideoSettings,
28        audio_settings: AudioSettings,
29        data: Bytes,
30    },
31    MediaSegment(MediaSegment),
32}
33
34#[derive(Debug, Clone, PartialEq)]
35pub struct VideoSettings {
36    pub width: u32,
37    pub height: u32,
38    pub framerate: f64,
39    pub bitrate: u32,
40    pub codec: VideoCodec,
41    pub timescale: u32,
42}
43
44#[derive(Debug, Clone, PartialEq)]
45pub struct AudioSettings {
46    pub sample_rate: u32,
47    pub channels: u8,
48    pub bitrate: u32,
49    pub codec: AudioCodec,
50    pub timescale: u32,
51}
52
53#[derive(Debug, Clone, Copy, PartialEq, Eq)]
54pub enum MediaType {
55    Video,
56    Audio,
57}
58
59#[derive(Debug, Clone)]
60pub struct MediaSegment {
61    pub data: Bytes,
62    pub ty: MediaType,
63    pub keyframe: bool,
64    pub timestamp: u64,
65}
66
67impl TransmuxResult {
68    pub fn into_bytes(self) -> Bytes {
69        match self {
70            TransmuxResult::InitSegment { data, .. } => data,
71            TransmuxResult::MediaSegment(data) => data.data,
72        }
73    }
74}