| 353 | } |
| 354 | |
| 355 | pub fn set_fallback(config: &EncoderCfg) { |
| 356 | let format = match config { |
| 357 | EncoderCfg::VPX(vpx) => match vpx.codec { |
| 358 | VpxVideoCodecId::VP8 => CodecFormat::VP8, |
| 359 | VpxVideoCodecId::VP9 => CodecFormat::VP9, |
| 360 | }, |
| 361 | EncoderCfg::AOM(_) => CodecFormat::AV1, |
| 362 | #[cfg(feature = "hwcodec")] |
| 363 | EncoderCfg::HWRAM(hw) => { |
| 364 | let name = hw.name.to_lowercase(); |
| 365 | if name.contains("vp8") { |
| 366 | CodecFormat::VP8 |
| 367 | } else if name.contains("vp9") { |
| 368 | CodecFormat::VP9 |
| 369 | } else if name.contains("av1") { |
| 370 | CodecFormat::AV1 |
| 371 | } else if name.contains("h264") { |
| 372 | CodecFormat::H264 |
| 373 | } else { |
| 374 | CodecFormat::H265 |
| 375 | } |
| 376 | } |
| 377 | #[cfg(feature = "vram")] |
| 378 | EncoderCfg::VRAM(vram) => match vram.feature.data_format { |
| 379 | hwcodec::common::DataFormat::H264 => CodecFormat::H264, |
| 380 | hwcodec::common::DataFormat::H265 => CodecFormat::H265, |
| 381 | _ => { |
| 382 | log::error!( |
| 383 | "should not reach here, vram not support {:?}", |
| 384 | vram.feature.data_format |
| 385 | ); |
| 386 | return; |
| 387 | } |
| 388 | }, |
| 389 | }; |
| 390 | let current = ENCODE_CODEC_FORMAT.lock().unwrap().clone(); |
| 391 | if current != format { |
| 392 | log::info!("codec fallback: {:?} -> {:?}", current, format); |
| 393 | *ENCODE_CODEC_FORMAT.lock().unwrap() = format; |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | pub fn use_i444(config: &EncoderCfg) -> bool { |
| 398 | let decodings = PEER_DECODINGS.lock().unwrap().clone(); |