MCPcopy Create free account
hub / github.com/Recordscript/recordscript / available

Method available

libs/scrap/src/common/vram.rs:210–253  ·  view source on GitHub ↗
(format: CodecFormat)

Source from the content-addressed store, hash-verified

208 }
209
210 pub fn available(format: CodecFormat) -> Vec<FeatureContext> {
211 let not_use = ENOCDE_NOT_USE.lock().unwrap().clone();
212 if not_use.values().any(|not_use| *not_use) {
213 log::info!("currently not use vram encoders: {not_use:?}");
214 return vec![];
215 }
216 let data_format = match format {
217 CodecFormat::H264 => DataFormat::H264,
218 CodecFormat::H265 => DataFormat::H265,
219 _ => return vec![],
220 };
221 let v: Vec<_> = get_available_config()
222 .map(|c| c.e)
223 .unwrap_or_default()
224 .drain(..)
225 .filter(|c| c.data_format == data_format)
226 .collect();
227 if crate::hwcodec::HwRamEncoder::try_get(format).is_some() {
228 // has fallback, no need to require all adapters support
229 v
230 } else {
231 let Ok(displays) = crate::Display::all() else {
232 log::error!("failed to get displays");
233 return vec![];
234 };
235 if displays.is_empty() {
236 log::error!("no display found");
237 return vec![];
238 }
239 let luids = displays
240 .iter()
241 .map(|d| d.adapter_luid())
242 .collect::<Vec<_>>();
243 if luids
244 .iter()
245 .all(|luid| v.iter().any(|f| Some(f.luid) == *luid))
246 {
247 v
248 } else {
249 log::info!("not all adapters support {data_format:?}, luids = {luids:?}");
250 vec![]
251 }
252 }
253 }
254
255 pub fn encode(&mut self, texture: *mut c_void) -> ResultType<Vec<EncodeFrame>> {
256 match self.encoder.encode(texture) {

Callers

nothing calls this directly

Calls 6

get_available_configFunction · 0.85
is_emptyMethod · 0.80
iterMethod · 0.80
cloneMethod · 0.45
adapter_luidMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected