fix: workaround physical display rotation (#9696)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
675ffe0381
commit
8c8a643cce
@ -156,7 +156,7 @@ pub trait TraitPixelBuffer {
|
|||||||
#[cfg(not(any(target_os = "ios")))]
|
#[cfg(not(any(target_os = "ios")))]
|
||||||
pub enum Frame<'a> {
|
pub enum Frame<'a> {
|
||||||
PixelBuffer(PixelBuffer<'a>),
|
PixelBuffer(PixelBuffer<'a>),
|
||||||
Texture(*mut c_void),
|
Texture((*mut c_void, usize)),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "ios")))]
|
#[cfg(not(any(target_os = "ios")))]
|
||||||
@ -164,7 +164,7 @@ impl Frame<'_> {
|
|||||||
pub fn valid<'a>(&'a self) -> bool {
|
pub fn valid<'a>(&'a self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Frame::PixelBuffer(pixelbuffer) => !pixelbuffer.data().is_empty(),
|
Frame::PixelBuffer(pixelbuffer) => !pixelbuffer.data().is_empty(),
|
||||||
Frame::Texture(texture) => !texture.is_null(),
|
Frame::Texture((texture, _)) => !texture.is_null(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ impl Frame<'_> {
|
|||||||
|
|
||||||
pub enum EncodeInput<'a> {
|
pub enum EncodeInput<'a> {
|
||||||
YUV(&'a [u8]),
|
YUV(&'a [u8]),
|
||||||
Texture(*mut c_void),
|
Texture((*mut c_void, usize)),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EncodeInput<'a> {
|
impl<'a> EncodeInput<'a> {
|
||||||
@ -197,7 +197,7 @@ impl<'a> EncodeInput<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn texture(&self) -> ResultType<*mut c_void> {
|
pub fn texture(&self) -> ResultType<(*mut c_void, usize)> {
|
||||||
match self {
|
match self {
|
||||||
Self::Texture(f) => Ok(*f),
|
Self::Texture(f) => Ok(*f),
|
||||||
_ => bail!("not texture frame"),
|
_ => bail!("not texture frame"),
|
||||||
|
@ -101,7 +101,12 @@ impl EncoderApi for VRamEncoder {
|
|||||||
frame: EncodeInput,
|
frame: EncodeInput,
|
||||||
ms: i64,
|
ms: i64,
|
||||||
) -> ResultType<hbb_common::message_proto::VideoFrame> {
|
) -> ResultType<hbb_common::message_proto::VideoFrame> {
|
||||||
let texture = frame.texture()?;
|
let (texture, rotation) = frame.texture()?;
|
||||||
|
if rotation != 0 {
|
||||||
|
// to-do: support rotation
|
||||||
|
// Both the encoder and display(w,h) information need to be changed.
|
||||||
|
bail!("rotation not supported");
|
||||||
|
}
|
||||||
let mut vf = VideoFrame::new();
|
let mut vf = VideoFrame::new();
|
||||||
let mut frames = Vec::new();
|
let mut frames = Vec::new();
|
||||||
for frame in self
|
for frame in self
|
||||||
|
@ -253,7 +253,17 @@ impl Capturer {
|
|||||||
|
|
||||||
pub fn frame<'a>(&'a mut self, timeout: UINT) -> io::Result<Frame<'a>> {
|
pub fn frame<'a>(&'a mut self, timeout: UINT) -> io::Result<Frame<'a>> {
|
||||||
if self.output_texture {
|
if self.output_texture {
|
||||||
Ok(Frame::Texture(self.get_texture(timeout)?))
|
let rotation = match self.display.rotation() {
|
||||||
|
DXGI_MODE_ROTATION_IDENTITY | DXGI_MODE_ROTATION_UNSPECIFIED => 0,
|
||||||
|
DXGI_MODE_ROTATION_ROTATE90 => 90,
|
||||||
|
DXGI_MODE_ROTATION_ROTATE180 => 180,
|
||||||
|
DXGI_MODE_ROTATION_ROTATE270 => 270,
|
||||||
|
_ => {
|
||||||
|
// Unsupported rotation, try anyway
|
||||||
|
0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Ok(Frame::Texture((self.get_texture(timeout)?, rotation)))
|
||||||
} else {
|
} else {
|
||||||
let width = self.width;
|
let width = self.width;
|
||||||
let height = self.height;
|
let height = self.height;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user