Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rustdesk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李朝发
rustdesk
Commits
4d5d0a4c
Commit
4d5d0a4c
authored
Apr 23, 2022
by
rustdesk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve video, ignore same image
parent
264db496
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
8 deletions
+37
-8
mod.rs
libs/scrap/src/common/mod.rs
+13
-0
quartz.rs
libs/scrap/src/common/quartz.rs
+3
-0
x11.rs
libs/scrap/src/common/x11.rs
+1
-1
mod.rs
libs/scrap/src/dxgi/mod.rs
+9
-1
frame.rs
libs/scrap/src/quartz/frame.rs
+5
-3
capturer.rs
libs/scrap/src/x11/capturer.rs
+6
-3
No files found.
libs/scrap/src/common/mod.rs
View file @
4d5d0a4c
...
...
@@ -30,3 +30,16 @@ pub use self::convert::*;
pub
const
STRIDE_ALIGN
:
usize
=
64
;
// commonly used in libvpx vpx_img_alloc caller
mod
vpx
;
#[inline]
pub
fn
would_block_if_equal
(
old
:
&
mut
Vec
<
u128
>
,
b
:
&
[
u8
])
->
std
::
io
::
Result
<
()
>
{
let
b
=
unsafe
{
std
::
slice
::
from_raw_parts
::
<
u128
>
(
b
.as_ptr
()
as
_
,
b
.len
()
/
16
)
};
if
b
==
&
old
[
..
]
{
return
Err
(
std
::
io
::
ErrorKind
::
WouldBlock
.into
());
}
old
.resize
(
b
.len
(),
0
);
old
.copy_from_slice
(
b
);
Ok
(())
}
libs/scrap/src/common/quartz.rs
View file @
4d5d0a4c
...
...
@@ -8,6 +8,7 @@ pub struct Capturer {
frame
:
Arc
<
Mutex
<
Option
<
quartz
::
Frame
>>>
,
use_yuv
:
bool
,
i420
:
Vec
<
u8
>
,
saved_raw_data
:
Vec
<
u128
>
,
// for faster compare and copy
}
impl
Capturer
{
...
...
@@ -38,6 +39,7 @@ impl Capturer {
frame
,
use_yuv
,
i420
:
Vec
::
new
(),
saved_raw_data
:
Vec
::
new
(),
})
}
...
...
@@ -57,6 +59,7 @@ impl Capturer {
match
frame
{
Some
(
mut
frame
)
=>
{
crate
::
would_block_if_equal
(
&
mut
self
.saved_raw_data
,
frame
.inner
())
?
;
if
self
.use_yuv
{
frame
.nv12_to_i420
(
self
.width
(),
self
.height
(),
&
mut
self
.i420
);
}
...
...
libs/scrap/src/common/x11.rs
View file @
4d5d0a4c
...
...
@@ -17,7 +17,7 @@ impl Capturer {
}
pub
fn
frame
<
'a
>
(
&
'a
mut
self
,
_timeout_ms
:
u32
)
->
io
::
Result
<
Frame
<
'a
>>
{
Ok
(
Frame
(
self
.
0
.frame
()))
Ok
(
Frame
(
self
.
0
.frame
()
?
))
}
}
...
...
libs/scrap/src/dxgi/mod.rs
View file @
4d5d0a4c
...
...
@@ -49,6 +49,7 @@ pub struct Capturer {
rotated
:
Vec
<
u8
>
,
gdi_capturer
:
Option
<
CapturerGDI
>
,
gdi_buffer
:
Vec
<
u8
>
,
saved_raw_data
:
Vec
<
u128
>
,
// for faster compare and copy
}
impl
Capturer
{
...
...
@@ -150,6 +151,7 @@ impl Capturer {
rotated
:
Vec
::
new
(),
gdi_capturer
,
gdi_buffer
:
Vec
::
new
(),
saved_raw_data
:
Vec
::
new
(),
})
}
...
...
@@ -233,7 +235,13 @@ impl Capturer {
let
result
=
{
if
let
Some
(
gdi_capturer
)
=
&
self
.gdi_capturer
{
match
gdi_capturer
.frame
(
&
mut
self
.gdi_buffer
)
{
Ok
(
_
)
=>
&
self
.gdi_buffer
,
Ok
(
_
)
=>
{
crate
::
would_block_if_equal
(
&
mut
self
.saved_raw_data
,
&
self
.gdi_buffer
,
)
?
;
&
self
.gdi_buffer
}
Err
(
err
)
=>
{
return
Err
(
io
::
Error
::
new
(
io
::
ErrorKind
::
Other
,
err
.to_string
()));
}
...
...
libs/scrap/src/quartz/frame.rs
View file @
4d5d0a4c
...
...
@@ -29,10 +29,12 @@ impl Frame {
}
}
#[inline]
pub
fn
inner
(
&
self
)
->
&
[
u8
]
{
self
.inner
}
pub
fn
nv12_to_i420
<
'a
>
(
&
'a
mut
self
,
w
:
usize
,
h
:
usize
,
i420
:
&
'a
mut
Vec
<
u8
>
)
{
if
self
.inner
.is_empty
()
{
return
;
}
unsafe
{
let
plane0
=
IOSurfaceGetBaseAddressOfPlane
(
self
.surface
,
0
);
let
stride0
=
IOSurfaceGetBytesPerRowOfPlane
(
self
.surface
,
0
);
...
...
libs/scrap/src/x11/capturer.rs
View file @
4d5d0a4c
...
...
@@ -14,6 +14,7 @@ pub struct Capturer {
size
:
usize
,
use_yuv
:
bool
,
yuv
:
Vec
<
u8
>
,
saved_raw_data
:
Vec
<
u128
>
,
// for faster compare and copy
}
impl
Capturer
{
...
...
@@ -68,6 +69,7 @@ impl Capturer {
size
,
use_yuv
,
yuv
:
Vec
::
new
(),
saved_raw_data
:
Vec
::
new
(),
};
Ok
(
c
)
}
...
...
@@ -97,15 +99,16 @@ impl Capturer {
}
}
pub
fn
frame
<
'b
>
(
&
'b
mut
self
)
->
&
'b
[
u8
]
{
pub
fn
frame
<
'b
>
(
&
'b
mut
self
)
->
std
::
io
::
Result
<&
'b
[
u8
]
>
{
self
.get_image
();
let
result
=
unsafe
{
slice
::
from_raw_parts
(
self
.buffer
,
self
.size
)
};
if
self
.use_yuv
{
crate
::
would_block_if_equal
(
&
mut
self
.saved_raw_data
,
result
)
?
;
Ok
(
if
self
.use_yuv
{
crate
::
common
::
bgra_to_i420
(
self
.display
.w
(),
self
.display
.h
(),
&
result
,
&
mut
self
.yuv
);
&
self
.yuv
[
..
]
}
else
{
result
}
}
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment