Skip to main content

re_video/
lib.rs

1//! Video decoding library.
2
3mod av1;
4mod decode;
5mod demux;
6mod gop_detection;
7mod h264;
8mod h265;
9mod nalu;
10pub mod player;
11mod stable_index_deque;
12mod time;
13
14pub use av1::{AV1_TEST_INTER_FRAME, AV1_TEST_KEYFRAME};
15pub use decode::{
16    AsyncDecoder, Chunk, DecodeError, DecodeHardwareAcceleration, DecodeSettings, Frame,
17    FrameContent, FrameInfo, FrameResult, PixelFormat, Result as DecodeResult,
18    YuvMatrixCoefficients, YuvPixelLayout, YuvRange, new_decoder,
19};
20pub use demux::{
21    ChromaSubsamplingModes, KeyframeIndex, SampleIndex, SampleMetadata, SampleMetadataState,
22    SamplesStatistics, VideoCodec, VideoDataDescription, VideoDeliveryMethod, VideoEncodingDetails,
23    VideoLoadError,
24};
25pub use gop_detection::{DetectGopStartError, GopStartDetection, detect_gop_start};
26// AnnexB conversions are useful for testing.
27pub use h264::{write_avc_chunk_to_annexb, write_avc_chunk_to_nalu_stream};
28pub use h265::{write_hevc_chunk_to_annexb, write_hevc_chunk_to_nalu_stream};
29pub use nalu::AnnexBStreamState;
30// Re-export:
31#[doc(no_inline)]
32pub use {
33    re_mp4::{TrackId, TrackKind},
34    re_quota_channel::{Receiver, Sender, TryRecvError},
35    re_span::Span,
36    stable_index_deque::StableIndexDeque,
37    time::{Time, Timescale},
38};
39
40#[cfg(with_ffmpeg)]
41pub use self::decode::{FFmpegError, FFmpegVersion, FFmpegVersionParseError, ffmpeg_download_url};
42
43pub fn enabled_features() -> &'static [&'static str] {
44    &[
45        #[cfg(feature = "av1")]
46        "av1",
47        #[cfg(feature = "ffmpeg")]
48        "ffmpeg",
49        #[cfg(feature = "nasm")]
50        "nasm",
51    ]
52}
53
54/// Create a channel for use with [`new_decoder`].
55pub fn channel<T>(
56    debug_name: impl Into<String>,
57) -> (re_quota_channel::Sender<T>, re_quota_channel::Receiver<T>) {
58    let max_bytes_in_flight = 512 * 1024 * 1024; // TODO(emilk): make configurable
59    re_quota_channel::channel(debug_name, max_bytes_in_flight)
60}