Skip to main content

rave_nvcodec/
nvenc_stub.rs

1#![allow(missing_docs)]
2//! CPU-only stub for builds without NVDEC/NVENC system dependencies.
3
4use rave_core::codec_traits::{BitstreamSink, FrameEncoder};
5use rave_core::error::{EngineError, Result};
6use rave_core::types::FrameEnvelope;
7
8pub use crate::config::NvEncConfig;
9
10/// Stub NVENC encoder used when `rave_nvcodec_stub` cfg is active.
11pub struct NvEncoder;
12
13impl NvEncoder {
14    pub fn new(
15        cuda_context: *mut std::ffi::c_void,
16        sink: Box<dyn BitstreamSink>,
17        config: NvEncConfig,
18    ) -> Result<Self> {
19        let _ = (cuda_context, sink, config);
20        Err(EngineError::Encode(
21            "rave-nvcodec built in stub mode: NVENC is unavailable on this build host".into(),
22        ))
23    }
24}
25
26impl FrameEncoder for NvEncoder {
27    fn encode(&mut self, frame: FrameEnvelope) -> Result<()> {
28        let _ = frame;
29        Err(EngineError::Encode(
30            "rave-nvcodec built in stub mode: NVENC is unavailable at runtime".into(),
31        ))
32    }
33
34    fn flush(&mut self) -> Result<()> {
35        Err(EngineError::Encode(
36            "rave-nvcodec built in stub mode: NVENC is unavailable at runtime".into(),
37        ))
38    }
39}