Skip to main content

rave_nvcodec/
nvenc_stub.rs

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