Skip to main content

codec/encode/
nvenc_stub.rs

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