#![doc = include_str!("../README.md")]
//!
//! ---
//!
//! # API Documentation
//!
//! Safe Rust bindings for Apple's
//! [AVAssetWriter](https://developer.apple.com/documentation/avfoundation/avassetwriter),
//! [`AVOutputSettingsAssistant`](https://developer.apple.com/documentation/avfoundation/avoutputsettingsassistant),
//! and [`AVAssetExportSession`](https://developer.apple.com/documentation/avfoundation/avassetexportsession)
//! — mux, inspect, recommend settings for, and export media files on macOS.
//!
//! Designed to consume `CMSampleBuffer`s directly from
//! [`videotoolbox`](https://github.com/doom-fish/videotoolbox-rs) so the
//! recording pipeline (capture → encode → mux) stays zero-copy from
//! `IOSurface` all the way to disk.
//!
//! # Quick start
//!
//! ```rust,no_run
//! use std::path::PathBuf;
//!
//! use avassetwriter::{FileType, Writer};
//! use apple_cf::cm::CMSampleBuffer;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # let sample: &CMSampleBuffer = unreachable!("doctest stub");
//! let artifacts = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("target/example-artifacts");
//! std::fs::create_dir_all(&artifacts)?;
//! let output = artifacts.join("out.mp4");
//! let writer = Writer::create(&output, FileType::Mp4)?;
//! let input_id = writer.add_video_input_from_sample(sample)?;
//! writer.start_session((0, 60))?;
//! writer.append_sample(input_id, sample)?;
//! writer.finish()?;
//! # Ok(())
//! # }
//! ```

#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub mod async_api;

mod asset;
mod bridge_support;
mod callbacks;
pub mod caption;
mod composition;
pub mod error;
pub mod export_session;
pub mod ffi;
pub mod media_processing;
pub mod metadata;
pub mod output_settings;
pub mod time;
pub mod writer;

pub use asset::Asset;
pub use caption::{
    Caption, CaptionAnimation, CaptionBounds, CaptionConversionAdjustment,
    CaptionConversionSettings, CaptionConversionTimeRangeAdjustment, CaptionConversionValidator,
    CaptionConversionValidatorStatus, CaptionConversionWarning, CaptionDimension,
    CaptionFormatConformer, CaptionGroup, CaptionGrouper, CaptionPoint, CaptionRegion,
    CaptionRegionDisplayAlignment, CaptionRegionScroll, CaptionRegionWritingMode, CaptionRenderer,
    CaptionRendererScene, CaptionRuby, CaptionRubyAlignment, CaptionRubyPosition, CaptionRubySpan,
    CaptionSize, CaptionTextAlignment, CaptionUnitsType, MutableCaption, MutableCaptionRegion,
};
pub use composition::{
    AssetTrackSegment, AssetTrackSegmentInfo, Composition, CompositionInfo, CompositionSize,
    CompositionTimeMapping, CompositionTrack, CompositionTrackFormatDescriptionReplacement,
    CompositionTrackFormatDescriptionReplacementInfo, CompositionTrackInfo,
    CompositionTrackSegment, CompositionTrackSegmentInfo, CompositionTransform,
    FormatDescriptionSummary,
};
pub use error::AVWriterError;
pub use export_session::{ExportPreset, ExportSession, ExportStatus, TrackGroupOutputHandling};
pub use media_processing::{
    AsynchronousCIImageFilteringRequest, AsynchronousVideoCompositionRequest, AudioMix,
    AudioMixInputParameters, AudioVolumeRamp, ImageRect, MetadataItemFilter,
    MetadataItemFilterKind, MutableAudioMix, MutableAudioMixInputParameters, VideoComposition,
    VideoCompositor, VideoCompositorClass,
};
pub use metadata::{
    DateRangeMetadataGroup, KeyLoadStatus, KeyValueStatus, MetadataGroup, MetadataItem,
    MetadataItemValueRequest, MetadataSpecification, MetadataValue, MutableDateRangeMetadataGroup,
    TimedMetadataGroup,
};
pub use output_settings::OutputSettingsAssistant;
pub use time::{Time, TimeRange};
pub use writer::{
    FileType, FileTypeProfile, InputGroupInfo, InputId, InputMediaDataLocation,
    InputPassDescription, MediaType, SegmentOutput, SegmentReport, SegmentReportSampleInfo,
    SegmentTrackReport, SegmentType, TaggedPixelBuffer, TrackAssociationType, VideoPreset, Writer,
    WriterStatus,
};

/// Common imports.
pub mod prelude {
    pub use crate::asset::Asset;
    pub use crate::caption::{
        Caption, CaptionAnimation, CaptionBounds, CaptionConversionAdjustment,
        CaptionConversionSettings, CaptionConversionTimeRangeAdjustment,
        CaptionConversionValidator, CaptionConversionValidatorStatus, CaptionConversionWarning,
        CaptionDimension, CaptionFormatConformer, CaptionGroup, CaptionGrouper, CaptionPoint,
        CaptionRegion, CaptionRegionDisplayAlignment, CaptionRegionScroll,
        CaptionRegionWritingMode, CaptionRenderer, CaptionRendererScene, CaptionRuby,
        CaptionRubyAlignment, CaptionRubyPosition, CaptionRubySpan, CaptionSize,
        CaptionTextAlignment, CaptionUnitsType, MutableCaption, MutableCaptionRegion,
    };
    pub use crate::composition::{
        AssetTrackSegment, AssetTrackSegmentInfo, Composition, CompositionInfo, CompositionSize,
        CompositionTimeMapping, CompositionTrack, CompositionTrackFormatDescriptionReplacement,
        CompositionTrackFormatDescriptionReplacementInfo, CompositionTrackInfo,
        CompositionTrackSegment, CompositionTrackSegmentInfo, CompositionTransform,
        FormatDescriptionSummary,
    };
    pub use crate::error::AVWriterError;
    pub use crate::export_session::{
        ExportPreset, ExportSession, ExportStatus, TrackGroupOutputHandling,
    };
    pub use crate::media_processing::{
        AsynchronousCIImageFilteringRequest, AsynchronousVideoCompositionRequest, AudioMix,
        AudioMixInputParameters, AudioVolumeRamp, ImageRect, MetadataItemFilter,
        MetadataItemFilterKind, MutableAudioMix, MutableAudioMixInputParameters, VideoComposition,
        VideoCompositor, VideoCompositorClass,
    };
    pub use crate::metadata::{
        DateRangeMetadataGroup, KeyLoadStatus, KeyValueStatus, MetadataGroup, MetadataItem,
        MetadataItemValueRequest, MetadataSpecification, MetadataValue,
        MutableDateRangeMetadataGroup, TimedMetadataGroup,
    };
    pub use crate::output_settings::OutputSettingsAssistant;
    pub use crate::time::{Time, TimeRange};
    pub use crate::writer::{
        FileType, FileTypeProfile, InputGroupInfo, InputId, InputMediaDataLocation,
        InputPassDescription, MediaType, TaggedPixelBuffer, TrackAssociationType, VideoPreset,
        Writer, WriterStatus,
    };
}
