| 192 | |
| 193 | impl VRamEncoder { |
| 194 | pub fn try_get(device: &AdapterDevice, format: CodecFormat) -> Option<FeatureContext> { |
| 195 | let v: Vec<_> = Self::available(format) |
| 196 | .drain(..) |
| 197 | .filter(|e| e.luid == device.luid) |
| 198 | .collect(); |
| 199 | if v.len() > 0 { |
| 200 | // prefer ffmpeg |
| 201 | if let Some(ctx) = v.iter().find(|c| c.driver == Driver::FFMPEG) { |
| 202 | return Some(ctx.clone()); |
| 203 | } |
| 204 | Some(v[0].clone()) |
| 205 | } else { |
| 206 | None |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | pub fn available(format: CodecFormat) -> Vec<FeatureContext> { |
| 211 | let not_use = ENOCDE_NOT_USE.lock().unwrap().clone(); |