Skip to main content

codec/encode/
amf_stub.rs

1//! Stub AMF encoder, compiled when the `amd` feature is **off**.
2//!
3//! Keeps `amf::AmfEncoder` a real type so the dispatcher in `encode/mod.rs`
4//! compiles unchanged, but construction always errors — auto-select then skips
5//! the AMD tier. Enable `--features amd` to compile the real
6//! hand-rolled AMF FFI encoder (`amf.rs`).
7
8use anyhow::{Result, bail};
9
10use super::{EncodedPacket, Encoder, EncoderConfig};
11use crate::frame::VideoFrame;
12
13pub struct AmfEncoder;
14
15impl AmfEncoder {
16    pub fn new(_config: EncoderConfig, _gpu_index: u32) -> Result<Self> {
17        bail!(
18            "AMF encode support was not compiled in; rebuild with the `amd` feature \
19             to use AMD hardware encode"
20        )
21    }
22}
23
24impl Encoder for AmfEncoder {
25    fn send_frame(&mut self, _frame: &VideoFrame) -> Result<()> {
26        unreachable!("stub AMF encoder is never constructed")
27    }
28    fn flush(&mut self) -> Result<()> {
29        unreachable!("stub AMF encoder is never constructed")
30    }
31    fn receive_packet(&mut self) -> Result<Option<EncodedPacket>> {
32        unreachable!("stub AMF encoder is never constructed")
33    }
34}