| 807 | } |
| 808 | |
| 809 | fn preference(id: Option<&str>) -> (PreferCodec, Chroma) { |
| 810 | let id = id.unwrap_or_default(); |
| 811 | if id.is_empty() { |
| 812 | return (PreferCodec::Auto, Chroma::I420); |
| 813 | } |
| 814 | let options = PeerConfig::load(id).options; |
| 815 | let codec = options |
| 816 | .get("codec-preference") |
| 817 | .map_or("".to_owned(), |c| c.to_owned()); |
| 818 | let codec = if codec == "vp8" { |
| 819 | PreferCodec::VP8 |
| 820 | } else if codec == "vp9" { |
| 821 | PreferCodec::VP9 |
| 822 | } else if codec == "av1" { |
| 823 | PreferCodec::AV1 |
| 824 | } else if codec == "h264" { |
| 825 | PreferCodec::H264 |
| 826 | } else if codec == "h265" { |
| 827 | PreferCodec::H265 |
| 828 | } else { |
| 829 | PreferCodec::Auto |
| 830 | }; |
| 831 | let chroma = if options.get("i444") == Some(&"Y".to_string()) { |
| 832 | Chroma::I444 |
| 833 | } else { |
| 834 | Chroma::I420 |
| 835 | }; |
| 836 | (codec, chroma) |
| 837 | } |
| 838 | } |
| 839 | |
| 840 | #[cfg(any(feature = "hwcodec", feature = "mediacodec"))] |