Skip to main content

openipc_video/api/
capabilities.rs

1use super::VideoCodec;
2
3/// Runtime support reported for one codec.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub struct CodecCapability {
6    /// Codec being described.
7    pub codec: VideoCodec,
8    /// The platform can create a decoder for this codec.
9    pub supported: bool,
10    /// A hardware decoder is advertised for this codec.
11    pub hardware_accelerated: bool,
12    /// Whether `hardware_accelerated` is a definite platform report.
13    ///
14    /// Android API 26 and WebCodecs can express a preference but cannot expose
15    /// a reliable hardware/software classification, so this is false there.
16    pub hardware_acceleration_known: bool,
17}
18
19/// Capabilities exposed by a decoder backend.
20#[derive(Debug, Clone, PartialEq, Eq)]
21pub struct DecoderCapabilities {
22    /// Stable backend identifier such as `videotoolbox`.
23    pub backend: &'static str,
24    /// Codec support advertised by the current machine.
25    pub codecs: Vec<CodecCapability>,
26    /// Decoded frames can remain in GPU-compatible platform memory.
27    pub native_surfaces: bool,
28}
29
30impl DecoderCapabilities {
31    /// Find support information for `codec`.
32    pub fn codec(&self, codec: VideoCodec) -> Option<CodecCapability> {
33        self.codecs
34            .iter()
35            .copied()
36            .find(|entry| entry.codec == codec)
37    }
38}