use gst::glib;
use gst::prelude::*;
mod boxes;
mod imp;
glib::wrapper! {
pub(crate) struct MP4MuxPad(ObjectSubclass<imp::MP4MuxPad>) @extends gst_base::AggregatorPad, gst::Pad, gst::Object;
}
glib::wrapper! {
pub(crate) struct MP4Mux(ObjectSubclass<imp::MP4Mux>) @extends gst_base::Aggregator, gst::Element, gst::Object;
}
glib::wrapper! {
pub(crate) struct ISOMP4Mux(ObjectSubclass<imp::ISOMP4Mux>) @extends MP4Mux, gst_base::Aggregator, gst::Element, gst::Object;
}
glib::wrapper! {
pub(crate) struct ONVIFMP4Mux(ObjectSubclass<imp::ONVIFMP4Mux>) @extends MP4Mux, gst_base::Aggregator, gst::Element, gst::Object;
}
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
#[cfg(feature = "doc")]
{
MP4Mux::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
MP4MuxPad::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
}
gst::Element::register(
Some(plugin),
"isomp4mux",
gst::Rank::Marginal,
ISOMP4Mux::static_type(),
)?;
gst::Element::register(
Some(plugin),
"onvifmp4mux",
gst::Rank::Marginal,
ONVIFMP4Mux::static_type(),
)?;
Ok(())
}
#[derive(Debug, Copy, Clone)]
pub(crate) enum DeltaFrames {
IntraOnly,
PredictiveOnly,
Bidirectional,
}
impl DeltaFrames {
pub(crate) fn requires_dts(&self) -> bool {
matches!(self, Self::Bidirectional)
}
pub(crate) fn intra_only(&self) -> bool {
matches!(self, Self::IntraOnly)
}
}
#[derive(Debug)]
pub(crate) struct Sample {
sync_point: bool,
duration: gst::ClockTime,
composition_time_offset: Option<i64>,
size: u32,
}
#[derive(Debug)]
pub(crate) struct Chunk {
offset: u64,
samples: Vec<Sample>,
}
#[derive(Debug)]
pub(crate) struct Stream {
caps: gst::Caps,
delta_frames: DeltaFrames,
trak_timescale: u32,
start_dts: Option<gst::Signed<gst::ClockTime>>,
earliest_pts: gst::ClockTime,
end_pts: gst::ClockTime,
chunks: Vec<Chunk>,
}
#[derive(Debug)]
pub(crate) struct Header {
#[allow(dead_code)]
variant: Variant,
movie_timescale: u32,
streams: Vec<Stream>,
}
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum Variant {
ISO,
ONVIF,
}