mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-21 04:01:01 +03:00
fix black screen issue when controlling the second screen on versions that lack multiple display support while using vram decoding (#7836)
* avoid create unnecessary video decoder Signed-off-by: 21pages <pages21@163.com> * controlled side uses the most frequent selected codec Signed-off-by: 21pages <pages21@163.com> * fix black screen when control old version's second screen For versions that do not support multiple displays, the display parameter is always 0, need set type of current display Signed-off-by: 21pages <pages21@163.com> --------- Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -221,7 +221,6 @@ impl Encoder {
|
||||
let h265_useable =
|
||||
_all_support_h265_decoding && (h265vram_encoding || h265hw_encoding.is_some());
|
||||
let mut name = ENCODE_CODEC_NAME.lock().unwrap();
|
||||
let mut preference = PreferCodec::Auto;
|
||||
let preferences: Vec<_> = decodings
|
||||
.iter()
|
||||
.filter(|(_, s)| {
|
||||
@@ -233,9 +232,20 @@ impl Encoder {
|
||||
})
|
||||
.map(|(_, s)| s.prefer)
|
||||
.collect();
|
||||
if preferences.len() > 0 && preferences.iter().all(|&p| p == preferences[0]) {
|
||||
preference = preferences[0].enum_value_or(PreferCodec::Auto);
|
||||
// find the most frequent preference
|
||||
let mut counts = Vec::new();
|
||||
for pref in &preferences {
|
||||
match counts.iter_mut().find(|(p, _)| p == pref) {
|
||||
Some((_, count)) => *count += 1,
|
||||
None => counts.push((pref.clone(), 1)),
|
||||
}
|
||||
}
|
||||
let max_count = counts.iter().map(|(_, count)| *count).max().unwrap_or(0);
|
||||
let (most_frequent, _) = counts
|
||||
.into_iter()
|
||||
.find(|(_, count)| *count == max_count)
|
||||
.unwrap_or((PreferCodec::Auto.into(), 0));
|
||||
let preference = most_frequent.enum_value_or(PreferCodec::Auto);
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut auto_codec = CodecName::VP9;
|
||||
|
||||
Reference in New Issue
Block a user