libobs_wrapper\encoders/
enums.rs

1use std::{convert::Infallible, str::FromStr};
2
3use crate::utils::ObsString;
4
5#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
6#[allow(non_camel_case_types)]
7pub enum ObsVideoEncoderType {
8    OBS_QSV11,
9    OBS_QSV11_AV1,
10    FFMPEG_NVENC,
11    JIM_AV1_NVENC,
12    H265_TEXTURE_AMF,
13    FFMPEG_HEVC_NVENC,
14    H264_TEXTURE_AMF,
15    AV1_TEXTURE_AMF,
16    OBS_X264,
17    Other(String),
18}
19
20impl FromStr for ObsVideoEncoderType {
21    type Err = Infallible;
22
23    fn from_str(value: &str) -> Result<Self, Self::Err> {
24        return Ok(match value {
25            "obs_qsv11" => ObsVideoEncoderType::OBS_QSV11,
26            "obs_qsv11_av1" => ObsVideoEncoderType::OBS_QSV11_AV1,
27            "ffmpeg_nvenc" => ObsVideoEncoderType::FFMPEG_NVENC,
28            "jim_av1_nvenc" => ObsVideoEncoderType::JIM_AV1_NVENC,
29            "h265_texture_amf" => ObsVideoEncoderType::H265_TEXTURE_AMF,
30            "ffmpeg_hevc_nvenc" => ObsVideoEncoderType::FFMPEG_HEVC_NVENC,
31            "h264_texture_amf" => ObsVideoEncoderType::H264_TEXTURE_AMF,
32            "av1_texture_amf" => ObsVideoEncoderType::AV1_TEXTURE_AMF,
33            "obs_x264" => ObsVideoEncoderType::OBS_X264,
34            e => ObsVideoEncoderType::Other(e.to_string()),
35        });
36    }
37}
38
39impl Into<ObsString> for ObsVideoEncoderType {
40    fn into(self) -> ObsString {
41        return match self {
42            ObsVideoEncoderType::OBS_QSV11 => ObsString::new("obs_qsv11"),
43            ObsVideoEncoderType::OBS_QSV11_AV1 => ObsString::new("obs_qsv11_av1"),
44            ObsVideoEncoderType::FFMPEG_NVENC => ObsString::new("ffmpeg_nvenc"),
45            ObsVideoEncoderType::JIM_AV1_NVENC => ObsString::new("jim_av1_nvenc"),
46            ObsVideoEncoderType::H265_TEXTURE_AMF => ObsString::new("h265_texture_amf"),
47            ObsVideoEncoderType::FFMPEG_HEVC_NVENC => ObsString::new("ffmpeg_hevc_nvenc"),
48            ObsVideoEncoderType::H264_TEXTURE_AMF => ObsString::new("h264_texture_amf"),
49            ObsVideoEncoderType::AV1_TEXTURE_AMF => ObsString::new("av1_texture_amf"),
50            ObsVideoEncoderType::OBS_X264 => ObsString::new("obs_x264"),
51            ObsVideoEncoderType::Other(e) => ObsString::new(&e),
52        };
53    }
54}
55
56// from https://github.com/FFFFFFFXXXXXXX/libobs-recorder
57#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
58#[allow(non_camel_case_types)]
59pub enum ObsAudioEncoderType {
60    JIM_AV1,
61    JIM_NVENC,
62    FFMPEG_NVENC,
63    AMD_AMF_AV1,
64    AMD_AMF_H264,
65    OBS_QSV11_AV1,
66    OBS_QSV11_H264,
67    OBS_X264,
68    Other(String),
69}
70
71impl FromStr for ObsAudioEncoderType {
72    type Err = Infallible;
73    fn from_str(s: &str) -> Result<Self, Self::Err> {
74        return Ok(match s {
75            "jim_av1" => ObsAudioEncoderType::JIM_AV1,
76            "jim_nvenc" => ObsAudioEncoderType::JIM_NVENC,
77            "ffmpeg_nvenc" => ObsAudioEncoderType::FFMPEG_NVENC,
78            "amd_amf_av1" => ObsAudioEncoderType::AMD_AMF_AV1,
79            "amd_amf_h264" => ObsAudioEncoderType::AMD_AMF_H264,
80            "obs_qsv11_av1" => ObsAudioEncoderType::OBS_QSV11_AV1,
81            "obs_qsv11_h264" => ObsAudioEncoderType::OBS_QSV11_H264,
82            "obs_x264" => ObsAudioEncoderType::OBS_X264,
83            e => ObsAudioEncoderType::Other(e.to_string()),
84        });
85    }
86}
87
88impl Into<ObsString> for ObsAudioEncoderType {
89    fn into(self) -> ObsString {
90        return match self {
91            ObsAudioEncoderType::JIM_AV1 => ObsString::new("jim_av1"),
92            ObsAudioEncoderType::JIM_NVENC => ObsString::new("jim_nvenc"),
93            ObsAudioEncoderType::FFMPEG_NVENC => ObsString::new("ffmpeg_nvenc"),
94            ObsAudioEncoderType::AMD_AMF_AV1 => ObsString::new("amd_amf_av1"),
95            ObsAudioEncoderType::AMD_AMF_H264 => ObsString::new("amd_amf_h264"),
96            ObsAudioEncoderType::OBS_QSV11_AV1 => ObsString::new("obs_qsv11_av1"),
97            ObsAudioEncoderType::OBS_QSV11_H264 => ObsString::new("obs_qsv11_h264"),
98            ObsAudioEncoderType::OBS_X264 => ObsString::new("obs_x264"),
99            ObsAudioEncoderType::Other(e) => ObsString::new(&e),
100        };
101    }
102}