mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
unify the protobuf message of vp9/h264/h265
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -12,15 +12,11 @@ use crate::vpxcodec::*;
|
||||
use hbb_common::{
|
||||
anyhow::anyhow,
|
||||
log,
|
||||
message_proto::{test_delay, video_frame, Message, VP9s, VideoCodecState},
|
||||
message_proto::{test_delay, video_frame, EncodedVideoFrames, Message, VideoCodecState},
|
||||
ResultType,
|
||||
};
|
||||
#[cfg(feature = "hwcodec")]
|
||||
use hbb_common::{
|
||||
config::Config2,
|
||||
lazy_static,
|
||||
message_proto::{H264s, H265s},
|
||||
};
|
||||
use hbb_common::{config::Config2, lazy_static};
|
||||
|
||||
#[cfg(feature = "hwcodec")]
|
||||
lazy_static::lazy_static! {
|
||||
@@ -263,7 +259,7 @@ impl Decoder {
|
||||
#[cfg(feature = "hwcodec")]
|
||||
video_frame::Union::h264s(h264s) => {
|
||||
if let Some(decoder) = &mut self.hw.h264 {
|
||||
Decoder::handle_h264s_video_frame(decoder, h264s, rgb, &mut self.i420)
|
||||
Decoder::handle_hw_video_frame(decoder, h264s, rgb, &mut self.i420)
|
||||
} else {
|
||||
Err(anyhow!("don't support h264!"))
|
||||
}
|
||||
@@ -271,7 +267,7 @@ impl Decoder {
|
||||
#[cfg(feature = "hwcodec")]
|
||||
video_frame::Union::h265s(h265s) => {
|
||||
if let Some(decoder) = &mut self.hw.h265 {
|
||||
Decoder::handle_h265s_video_frame(decoder, h265s, rgb, &mut self.i420)
|
||||
Decoder::handle_hw_video_frame(decoder, h265s, rgb, &mut self.i420)
|
||||
} else {
|
||||
Err(anyhow!("don't support h265!"))
|
||||
}
|
||||
@@ -282,7 +278,7 @@ impl Decoder {
|
||||
|
||||
fn handle_vp9s_video_frame(
|
||||
decoder: &mut VpxDecoder,
|
||||
vp9s: &VP9s,
|
||||
vp9s: &EncodedVideoFrames,
|
||||
rgb: &mut Vec<u8>,
|
||||
) -> ResultType<bool> {
|
||||
let mut last_frame = Image::new();
|
||||
@@ -305,14 +301,14 @@ impl Decoder {
|
||||
}
|
||||
|
||||
#[cfg(feature = "hwcodec")]
|
||||
fn handle_h264s_video_frame(
|
||||
fn handle_hw_video_frame(
|
||||
decoder: &mut HwDecoder,
|
||||
h264s: &H264s,
|
||||
frames: &EncodedVideoFrames,
|
||||
rgb: &mut Vec<u8>,
|
||||
i420: &mut Vec<u8>,
|
||||
) -> ResultType<bool> {
|
||||
let mut ret = false;
|
||||
for h264 in h264s.h264s.iter() {
|
||||
for h264 in frames.frames.iter() {
|
||||
for image in decoder.decode(&h264.data)? {
|
||||
// TODO: just process the last frame
|
||||
if image.bgra(rgb, i420).is_ok() {
|
||||
@@ -322,25 +318,6 @@ impl Decoder {
|
||||
}
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
#[cfg(feature = "hwcodec")]
|
||||
fn handle_h265s_video_frame(
|
||||
decoder: &mut HwDecoder,
|
||||
h265s: &H265s,
|
||||
rgb: &mut Vec<u8>,
|
||||
i420: &mut Vec<u8>,
|
||||
) -> ResultType<bool> {
|
||||
let mut ret = false;
|
||||
for h265 in h265s.h265s.iter() {
|
||||
for image in decoder.decode(&h265.data)? {
|
||||
// TODO: just process the last frame
|
||||
if image.bgra(rgb, i420).is_ok() {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(ret);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "hwcodec")]
|
||||
|
||||
Reference in New Issue
Block a user