mediadecode-ffmpeg 0.9.0

FFmpeg adapter for the `mediadecode` abstraction layer — implements its `VideoAdapter` / `AudioAdapter` / `SubtitleAdapter` traits and the matching push-style decoder traits, with hardware-acceleration auto-probe across VideoToolbox / VAAPI / NVDEC / D3D11VA and software fallback via ffmpeg-next.
Documentation
use super::*;

/// The defaults' own coherence — that they are finite, that 8K passes
/// and the bomb does not, that no seat is shadowed by a wider one — is
/// asserted at **compile time**, in `limits.rs` beside the constants
/// themselves. Nothing here re-checks it: a `const` block that failed
/// would have stopped the build before this file was reached.
///
/// What is left for a test run is the part that is not constant — that
/// the options structs actually carry what they are handed.
#[test]
fn frame_limits_default_to_the_consts_and_take_overrides() {
  let d = FrameLimits::default();
  assert_eq!(d, FrameLimits::new());
  assert_eq!(d.max_pixels(), DEFAULT_MAX_PIXELS);
  assert_eq!(d.max_frame_bytes(), DEFAULT_MAX_FRAME_BYTES);

  let tuned = FrameLimits::new()
    .with_max_pixels(1024)
    .with_max_frame_bytes(4096);
  assert_eq!(tuned.max_pixels(), 1024);
  assert_eq!(tuned.max_frame_bytes(), 4096);

  let mut mutated = FrameLimits::new();
  mutated.set_max_pixels(7).set_max_frame_bytes(9);
  assert_eq!((mutated.max_pixels(), mutated.max_frame_bytes()), (7, 9));
  // The builder does not mutate the value it was called on.
  assert_eq!(FrameLimits::new(), d);
}

#[test]
fn packet_limits_default_to_the_const_and_take_overrides() {
  assert_eq!(PacketLimits::default(), PacketLimits::new());
  assert_eq!(
    PacketLimits::default().max_packet_bytes(),
    DEFAULT_MAX_PACKET_BYTES,
  );
  assert_eq!(
    PacketLimits::new()
      .with_max_packet_bytes(11)
      .max_packet_bytes(),
    11,
  );
  let mut mutated = PacketLimits::new();
  mutated.set_max_packet_bytes(13);
  assert_eq!(mutated.max_packet_bytes(), 13);
}

#[test]
fn demux_limits_carry_all_three_tiers() {
  let d = DemuxLimits::default();
  assert_eq!(d, DemuxLimits::new());
  assert_eq!(d.packet(), PacketLimits::new());
  assert_eq!(d.max_attachment_bytes(), DEFAULT_MAX_ATTACHMENT_BYTES);
  assert_eq!(
    d.max_total_attachment_bytes(),
    DEFAULT_MAX_TOTAL_ATTACHMENT_BYTES,
  );

  let tuned = DemuxLimits::new()
    .with_packet(PacketLimits::new().with_max_packet_bytes(1))
    .with_max_attachment_bytes(2)
    .with_max_total_attachment_bytes(3);
  assert_eq!(tuned.packet().max_packet_bytes(), 1);
  assert_eq!(tuned.max_attachment_bytes(), 2);
  assert_eq!(tuned.max_total_attachment_bytes(), 3);

  let mut mutated = DemuxLimits::new();
  mutated
    .set_packet(PacketLimits::new().with_max_packet_bytes(4))
    .set_max_attachment_bytes(5)
    .set_max_total_attachment_bytes(6);
  assert_eq!(mutated.packet().max_packet_bytes(), 4);
  assert_eq!(mutated.max_attachment_bytes(), 5);
  assert_eq!(mutated.max_total_attachment_bytes(), 6);
}