Skip to main content

wedeo_format/
muxer.rs

1use bitflags::bitflags;
2
3use wedeo_core::codec_id::CodecId;
4use wedeo_core::error::Result;
5use wedeo_core::packet::Packet;
6
7use crate::demuxer::Stream;
8use crate::io::BufferedIo;
9
10bitflags! {
11    /// Output format flags.
12    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
13    pub struct OutputFormatFlags: u32 {
14        const NOFILE        = 1 << 0;
15        const NEEDNUMBER    = 1 << 1;
16        const GLOBALHEADER  = 1 << 6;
17        const NOTIMESTAMPS  = 1 << 7;
18        const VARIABLE_FPS  = 1 << 10;
19        const NODIMENSIONS  = 1 << 11;
20        const NOSTREAMS     = 1 << 12;
21        const TS_NONSTRICT  = 1 << 17;
22        const TS_NEGATIVE   = 1 << 18;
23    }
24}
25
26/// Muxer trait — the main abstraction for all muxers.
27pub trait Muxer: Send {
28    /// Write the file header.
29    fn write_header(&mut self, io: &mut BufferedIo, streams: &[Stream]) -> Result<()>;
30
31    /// Write a single packet.
32    fn write_packet(&mut self, io: &mut BufferedIo, packet: &Packet) -> Result<()>;
33
34    /// Write the file trailer (finalize).
35    fn write_trailer(&mut self, io: &mut BufferedIo) -> Result<()>;
36}
37
38/// Descriptor for an output format.
39#[derive(Debug, Clone)]
40pub struct OutputFormatDescriptor {
41    pub name: &'static str,
42    pub long_name: &'static str,
43    pub extensions: &'static str,
44    pub mime_types: &'static str,
45    pub flags: OutputFormatFlags,
46    pub audio_codec: CodecId,
47    pub video_codec: CodecId,
48}