Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try sync #20

Merged
merged 40 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5166083
Fix. Msi, reg add SoftwareSASGeneration (#7708)
fufesou Apr 14, 2024
a7a10f4
Refact. Win, file copy paste, default true (#7719)
fufesou Apr 14, 2024
7f3775a
update system2 (#7722)
jxdv Apr 14, 2024
0dba37f
Update pl.rs (#7723)
alewicki95 Apr 15, 2024
cdd9230
refactor android ffi
rustdesk Apr 15, 2024
260d0cd
fix me
rustdesk Apr 15, 2024
56d353c
fix me
rustdesk Apr 15, 2024
05f6fde
ffi.RustDesk -> ffi.FFI
rustdesk Apr 15, 2024
28340c8
fix me
rustdesk Apr 15, 2024
e9a6ca8
typo
rustdesk Apr 15, 2024
1d4c129
Update es.rs (#7733)
flusheDData Apr 16, 2024
a5d0299
Fix. Msi, remove RustDesk words (#7732)
fufesou Apr 16, 2024
9b5e5aa
fix: Msi custom app, different component guids (#7738)
fufesou Apr 16, 2024
44bce59
more java_ffi_FFI
rustdesk Apr 16, 2024
a6c1d2d
customClientConfig in dart
rustdesk Apr 16, 2024
c656c3c
typo
rustdesk Apr 16, 2024
b9792fc
bridge rust version
rustdesk Apr 16, 2024
01ec539
load android custom client for jvm startServer
rustdesk Apr 16, 2024
bc0ab88
do not load empty custom_client_config
rustdesk Apr 16, 2024
414455a
fix ci
rustdesk Apr 16, 2024
736503d
fix ci
rustdesk Apr 16, 2024
7bb4e22
fix ci
rustdesk Apr 16, 2024
990c05f
Update lv.rs (#7745)
Kleofass Apr 17, 2024
bdf8bbe
custom android
rustdesk Apr 17, 2024
4e8cbe3
buildPresetPasswordWarning for android
rustdesk Apr 17, 2024
4252b5e
enable ffmpeg native h26x software decoders for all platforms (#7750)
21pages Apr 18, 2024
9b2ec62
chore: fix some typos in comments (#7752)
writegr Apr 18, 2024
24ac7c1
remove google-services.json
rustdesk Apr 18, 2024
4d3fb77
remove hwcodec for sciter armv7 (#7753)
21pages Apr 18, 2024
edb5529
flutter_icons does not generate mipmap-ldpi, so I drop it also
rustdesk Apr 18, 2024
ae23f0d
Improve android threading, https://github.com/rustdesk/rustdesk/issue…
rustdesk Apr 18, 2024
a3c0911
fix: msi, explicit wide char api (#7764)
fufesou Apr 18, 2024
e83c28b
refact: win, virtual display (#7767)
fufesou Apr 19, 2024
5d5547f
put andriod custom client logo to settings section list (#7768)
21pages Apr 19, 2024
1ffc10e
flutter 19.6
rustdesk Apr 19, 2024
40067f5
no countdown in scam warning of android for custom build
rustdesk Apr 19, 2024
25eb8dc
typo
rustdesk Apr 19, 2024
819eea9
refact: msi (#7774)
fufesou Apr 19, 2024
0e6fa37
Update ru.rs (#7771)
solokot Apr 19, 2024
c757789
refact: msi, version and build date, check (#7775)
fufesou Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/bridge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
env:
FLUTTER_VERSION: "3.16.9"
FLUTTER_RUST_BRIDGE_VERSION: "1.80.1"
RUST_VERSION: "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503

jobs:
generate_bridge:
Expand Down Expand Up @@ -49,9 +50,9 @@ jobs:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
toolchain: ${{ env.RUST_VERSION }}
targets: ${{ matrix.job.target }}
components: ''
components: "rustfmt"

- uses: Swatinem/rust-cache@v2
with:
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/flutter-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
RUST_VERSION: "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503
CARGO_NDK_VERSION: "3.1.2"
LLVM_VERSION: "15.0.6"
FLUTTER_VERSION: "3.19.5"
FLUTTER_VERSION: "3.19.6"
FLUTTER_RUST_BRIDGE_VERSION: "1.80.1"
# for arm64 linux because official Dart SDK does not work
FLUTTER_ELINUX_VERSION: "3.16.9"
Expand Down Expand Up @@ -113,7 +113,18 @@ jobs:
shell: bash

- name: Build rustdesk
run: python3 .\build.py --portable --hwcodec --flutter --vram --skip-portable-pack
run: |
Invoke-WebRequest -Uri https://github.com/rustdesk-org/rdev/releases/download/usbmmidd_v2/usbmmidd_v2.zip -OutFile usbmmidd_v2.zip
$SHA256_SUM = '629b51e9944762bae73948171c65d09a79595cf4c771a82ebc003fbba5b24f51'
if ((Get-FileHash -Path .\usbmmidd_v2.zip -Algorithm SHA256).Hash -ne $SHA256_SUM) {
Write-Error "SHA256 sum mismatch, falling back to the non-virtual-display version"
python3 .\build.py --portable --hwcodec --flutter --vram --skip-portable-pack
} else {
Write-Host "SHA256 sum matched, using the virtual-display version"
Expand-Archive usbmmidd_v2.zip -DestinationPath .
python3 .\build.py --portable --hwcodec --flutter --vram --skip-portable-pack --virtual-display
mv -Force .\usbmmidd_v2 ./flutter/build/windows/x64/runner/Release/
}

- name: find Runner.res
# Windows: find Runner.res (compiled from ./flutter/windows/runner/Runner.rc), copy to ./Runner.res
Expand Down Expand Up @@ -169,7 +180,7 @@ jobs:
if: env.UPLOAD_ARTIFACT == 'true'
run: |
pushd ./res/msi
python preprocess.py -arp -d ../../rustdesk
python preprocess.py --arp -d ../../rustdesk
nuget restore msi.sln
msbuild msi.sln -p:Configuration=Release -p:Platform=x64 /p:TargetVersion=Windows10
mv ./Package/bin/x64/Release/en-us/Package.msi ../../SignOutput/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}-beta.msi
Expand Down Expand Up @@ -331,8 +342,7 @@ jobs:

- name: Build rustdesk
run: |
# --hwcodec not supported on macos yet
./build.py --flutter
./build.py --flutter --hwcodec

- name: create unsigned dmg
if: env.UPLOAD_ARTIFACT == 'true'
Expand Down Expand Up @@ -486,8 +496,7 @@ jobs:

- name: Build rustdesk
run: |
# --hwcodec not supported on macos yet
./build.py --flutter ${{ matrix.job.extra-build-args }}
./build.py --flutter --hwcodec ${{ matrix.job.extra-build-args }}

- name: create unsigned dmg
if: env.UPLOAD_ARTIFACT == 'true'
Expand Down Expand Up @@ -636,7 +645,7 @@ jobs:
- name: Build rustdesk lib
run: |
rustup target add ${{ matrix.job.target }}
cargo build --features flutter --release --target aarch64-apple-ios --lib
cargo build --features flutter,hwcodec --release --target aarch64-apple-ios --lib

- name: Build rustdesk
shell: bash
Expand Down Expand Up @@ -1257,7 +1266,7 @@ jobs:
export DEFAULT_FEAT=linux_headless
fi
export CARGO_INCREMENTAL=0
cargo build --lib --features flutter,flutter_texture_render,${{ matrix.job.extra-build-features }},$DEFAULT_FEAT --release
cargo build --lib --features flutter,flutter_texture_render,hwcodec,${{ matrix.job.extra-build-features }},$DEFAULT_FEAT --release

- name: Upload Artifacts
uses: actions/upload-artifact@master
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ system_shutdown = "4.0"
qrcode-generator = "4.1"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["winuser", "wincrypt", "shellscalingapi", "pdh", "synchapi", "memoryapi", "shellapi"] }
winapi = { version = "0.3", features = ["winuser", "wincrypt", "shellscalingapi", "pdh", "synchapi", "memoryapi", "shellapi", "devguid", "setupapi", "cguid", "cfgmgr32"] }
winreg = "0.11"
windows-service = "0.6"
virtual_display = { path = "libs/virtual_display", optional = true }
Expand Down
15 changes: 12 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def get_arch() -> str:


def system2(cmd):
err = os.system(cmd)
if err != 0:
print(f"Error occurred when executing: {cmd}. Exiting.")
exit_code = os.system(cmd)
if exit_code != 0:
sys.stderr.write(f"Error occurred when executing: `{cmd}`. Exiting.\n")
sys.exit(-1)


Expand Down Expand Up @@ -153,6 +153,12 @@ def make_parser():
action='store_true',
help='Skip packing, only flutter version + Windows supported'
)
parser.add_argument(
'--virtual-display',
action='store_true',
default=False,
help='Build rustdesk libs with the virtual display feature enabled'
)
parser.add_argument(
"--package",
type=str
Expand Down Expand Up @@ -293,6 +299,9 @@ def get_features(args):
features.append('appimage')
if args.unix_file_copy_paste:
features.append('unix-file-copy-paste')
if windows:
if args.virtual_display:
features.append('virtual_display_driver')
print("features:", features)
return features

Expand Down
1 change: 0 additions & 1 deletion flutter/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,3 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib") { version { strictly("$kotlin_version") } }
}

apply plugin: 'com.google.gms.google-services'
40 changes: 0 additions & 40 deletions flutter/android/app/google-services.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.carriez.flutter_hbb

import ffi.FFI

/**
* Capture screen,get video and audio,send to rust.
* Dispatch notifications
Expand Down Expand Up @@ -64,10 +66,6 @@ const val AUDIO_CHANNEL_MASK = AudioFormat.CHANNEL_IN_STEREO

class MainService : Service() {

init {
System.loadLibrary("rustdesk")
}

@Keep
@RequiresApi(Build.VERSION_CODES.N)
fun rustPointerInput(kind: String, mask: Int, x: Int, y: Int) {
Expand Down Expand Up @@ -156,23 +154,9 @@ class MainService : Service() {
private val powerManager: PowerManager by lazy { applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager }
private val wakeLock: PowerManager.WakeLock by lazy { powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP or PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "rustdesk:wakelock")}

// jvm call rust
private external fun init(ctx: Context)

/// When app start on boot, app_dir will not be passed from flutter
/// so pass a app_dir here to rust server
private external fun startServer(app_dir: String)
private external fun startService()
private external fun onVideoFrameUpdate(buf: ByteBuffer)
private external fun onAudioFrameUpdate(buf: ByteBuffer)
private external fun translateLocale(localeName: String, input: String): String
private external fun refreshScreen()
private external fun setFrameRawEnable(name: String, value: Boolean)
// private external fun sendVp9(data: ByteArray)

private fun translate(input: String): String {
Log.d(logTag, "translate:$LOCAL_NAME")
return translateLocale(LOCAL_NAME, input)
return FFI.translateLocale(LOCAL_NAME, input)
}

companion object {
Expand Down Expand Up @@ -211,7 +195,7 @@ class MainService : Service() {
override fun onCreate() {
super.onCreate()
Log.d(logTag,"MainService onCreate")
init(this)
FFI.init(this)
HandlerThread("Service", Process.THREAD_PRIORITY_BACKGROUND).apply {
start()
serviceLooper = looper
Expand All @@ -223,7 +207,7 @@ class MainService : Service() {
// keep the config dir same with flutter
val prefs = applicationContext.getSharedPreferences(KEY_SHARED_PREFERENCES, FlutterActivity.MODE_PRIVATE)
val configPath = prefs.getString(KEY_APP_DIR_CONFIG_PATH, "") ?: ""
startServer(configPath)
FFI.startServer(configPath, "")

createForegroundNotification()
}
Expand Down Expand Up @@ -278,7 +262,7 @@ class MainService : Service() {
SCREEN_INFO.dpi = dpi
if (isStart) {
stopCapture()
refreshScreen()
FFI.refreshScreen()
startCapture()
}
}
Expand Down Expand Up @@ -306,7 +290,7 @@ class MainService : Service() {
createForegroundNotification()

if (intent.getBooleanExtra(EXT_INIT_FROM_BOOT, false)) {
startService()
FFI.startService()
}
Log.d(logTag, "service starting: ${startId}:${Thread.currentThread()}")
val mediaProjectionManager =
Expand Down Expand Up @@ -354,12 +338,15 @@ class MainService : Service() {
).apply {
setOnImageAvailableListener({ imageReader: ImageReader ->
try {
if (!isStart) {
return@setOnImageAvailableListener
}
imageReader.acquireLatestImage().use { image ->
if (image == null) return@setOnImageAvailableListener
if (image == null || !isStart) return@setOnImageAvailableListener
val planes = image.planes
val buffer = planes[0].buffer
buffer.rewind()
onVideoFrameUpdate(buffer)
FFI.onVideoFrameUpdate(buffer)
}
} catch (ignored: java.lang.Exception) {
}
Expand Down Expand Up @@ -393,21 +380,24 @@ class MainService : Service() {
}
checkMediaPermission()
_isStart = true
setFrameRawEnable("video",true)
setFrameRawEnable("audio",true)
FFI.setFrameRawEnable("video",true)
FFI.setFrameRawEnable("audio",true)
return true
}

@Synchronized
fun stopCapture() {
Log.d(logTag, "Stop Capture")
setFrameRawEnable("video",false)
setFrameRawEnable("audio",false)
FFI.setFrameRawEnable("video",false)
FFI.setFrameRawEnable("audio",false)
_isStart = false
// release video
virtualDisplay?.release()
surface?.release()
imageReader?.close()
imageReader = null
// suface needs to be release after imageReader.close to imageReader access released surface
// https://github.com/rustdesk/rustdesk/issues/4118#issuecomment-1515666629
surface?.release()
videoEncoder?.let {
it.signalEndOfInputStream()
it.stop()
Expand All @@ -418,18 +408,13 @@ class MainService : Service() {

// release audio
audioRecordStat = false
audioRecorder?.release()
audioRecorder = null
minBufferSize = 0
}

fun destroy() {
Log.d(logTag, "destroy service")
_isReady = false

stopCapture()
imageReader?.close()
imageReader = null

mediaProjection = null
checkMediaPermission()
Expand Down Expand Up @@ -537,9 +522,13 @@ class MainService : Service() {
thread {
while (audioRecordStat) {
audioReader!!.readSync(audioRecorder!!)?.let {
onAudioFrameUpdate(it)
FFI.onAudioFrameUpdate(it)
}
}
// let's release here rather than onDestroy to avoid threading issue
audioRecorder?.release()
audioRecorder = null
minBufferSize = 0
Log.d(logTag, "Exit audio thread")
}
} catch (e: Exception) {
Expand Down
21 changes: 21 additions & 0 deletions flutter/android/app/src/main/kotlin/ffi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ffi.kt

package ffi

import android.content.Context
import java.nio.ByteBuffer

object FFI {
init {
System.loadLibrary("rustdesk")
}

external fun init(ctx: Context)
external fun startServer(app_dir: String, custom_client_config: String)
external fun startService()
external fun onVideoFrameUpdate(buf: ByteBuffer)
external fun onAudioFrameUpdate(buf: ByteBuffer)
external fun translateLocale(localeName: String, input: String): String
external fun refreshScreen()
external fun setFrameRawEnable(name: String, value: Boolean)
}
Binary file not shown.
Loading
Loading