Skip to main content

ff_sys/
lib.rs

1//! # ff-sys
2//!
3//! Low-level FFmpeg FFI bindings for Rust.
4//!
5//! This crate provides raw FFI bindings to FFmpeg libraries, generated by
6//! [bindgen](https://github.com/rust-lang/rust-bindgen). It is intended as a
7//! building block for higher-level safe wrappers.
8//!
9//! ## Safety
10//!
11//! All functions in this crate are unsafe. Higher-level safe wrappers are provided
12//! by other ff-* crates:
13//! - `ff-probe` - Media metadata extraction
14//! - `ff-decode` - Decoding and seeking
15//! - `ff-encode` - Encoding and export
16//! - `ff-filter` - Filters and effects
17
18// The hand-written wrapper modules below are held to the normal lint set plus
19// `unsafe_op_in_unsafe_fn`; only the auto-generated bindings opt out of it, inside
20// `mod raw`.
21#![deny(unsafe_op_in_unsafe_fn)]
22
23// Auto-generated bindgen output is isolated behind this module so its blanket
24// lint allow does not silence the hand-written wrapper modules. On docs.rs
25// (DOCS_RS=1) the build script emits an empty bindings.rs and sets cfg(docsrs);
26// we include the hand-written stubs instead so dependent crates compile unchanged.
27// `pub use raw::*` keeps every bindgen symbol available at the crate root, so
28// downstream `ff_sys::<name>` references are unaffected.
29mod raw {
30    #![allow(warnings)]
31    #![allow(unsafe_op_in_unsafe_fn)]
32
33    #[cfg(not(docsrs))]
34    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
35
36    #[cfg(docsrs)]
37    include!("docsrs_stubs.rs");
38}
39pub use raw::*;
40
41// Wrapper modules (real bindings only)
42#[cfg(not(docsrs))]
43pub mod avcodec;
44#[cfg(not(docsrs))]
45pub mod avformat;
46#[cfg(not(docsrs))]
47pub mod swresample;
48#[cfg(not(docsrs))]
49pub mod swscale;
50
51// Sub-modules
52#[cfg(not(docsrs))]
53mod buffersink;
54#[cfg(not(docsrs))]
55mod codec;
56#[cfg(not(docsrs))]
57mod codec_context;
58mod constants;
59mod error;
60pub mod error_codes;
61#[cfg(not(docsrs))]
62mod format_context;
63#[cfg(not(docsrs))]
64mod frame;
65#[cfg(not(docsrs))]
66mod hwdevice;
67#[cfg(not(docsrs))]
68mod packet;
69#[cfg(not(docsrs))]
70mod resample_context;
71#[cfg(not(docsrs))]
72mod scale_context;
73mod utils;
74
75// Re-exports
76#[cfg(not(docsrs))]
77pub use buffersink::{BufferSinkOutcome, buffersink_get_frame};
78#[cfg(not(docsrs))]
79pub use codec::Codec;
80#[cfg(not(docsrs))]
81pub use codec_context::{CodecContext, ReceiveOutcome};
82pub use constants::{AV_NOPTS_VALUE, AVFMT_NOFILE, AVFMT_TS_DISCONT, BUFFERSRC_FLAG_KEEP_REF};
83pub use error::AvError;
84#[cfg(not(docsrs))]
85pub use format_context::{
86    ChapterRef, ChapterSpec, CodecParameters, InputFormatContext, OutputFormatContext, StreamRef,
87};
88#[cfg(not(docsrs))]
89pub use frame::Frame;
90#[cfg(not(docsrs))]
91pub use hwdevice::HwDeviceContext;
92#[cfg(not(docsrs))]
93pub use packet::Packet;
94#[cfg(not(docsrs))]
95pub use resample_context::ResampleContext;
96#[cfg(not(docsrs))]
97pub use scale_context::ScaleContext;
98pub use utils::{av_error_string, ensure_initialized};
99// check_av_error! is re-exported at the crate root automatically via #[macro_export]