fix me
This commit is contained in:
parent
cdd92303b8
commit
260d0cdc67
@ -1,6 +1,6 @@
|
|||||||
package com.carriez.flutter_hbb
|
package com.carriez.flutter_hbb
|
||||||
|
|
||||||
import ffi.*
|
import ffi.RustDesk
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Capture screen,get video and audio,send to rust.
|
* Capture screen,get video and audio,send to rust.
|
||||||
@ -195,7 +195,7 @@ class MainService : Service() {
|
|||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
Log.d(logTag,"MainService onCreate")
|
Log.d(logTag,"MainService onCreate")
|
||||||
init(this)
|
RustDesk.init(this)
|
||||||
HandlerThread("Service", Process.THREAD_PRIORITY_BACKGROUND).apply {
|
HandlerThread("Service", Process.THREAD_PRIORITY_BACKGROUND).apply {
|
||||||
start()
|
start()
|
||||||
serviceLooper = looper
|
serviceLooper = looper
|
||||||
@ -207,7 +207,7 @@ class MainService : Service() {
|
|||||||
// keep the config dir same with flutter
|
// keep the config dir same with flutter
|
||||||
val prefs = applicationContext.getSharedPreferences(KEY_SHARED_PREFERENCES, FlutterActivity.MODE_PRIVATE)
|
val prefs = applicationContext.getSharedPreferences(KEY_SHARED_PREFERENCES, FlutterActivity.MODE_PRIVATE)
|
||||||
val configPath = prefs.getString(KEY_APP_DIR_CONFIG_PATH, "") ?: ""
|
val configPath = prefs.getString(KEY_APP_DIR_CONFIG_PATH, "") ?: ""
|
||||||
startServer(configPath)
|
RustDesk.startServer(configPath)
|
||||||
|
|
||||||
createForegroundNotification()
|
createForegroundNotification()
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ class MainService : Service() {
|
|||||||
SCREEN_INFO.dpi = dpi
|
SCREEN_INFO.dpi = dpi
|
||||||
if (isStart) {
|
if (isStart) {
|
||||||
stopCapture()
|
stopCapture()
|
||||||
refreshScreen()
|
RustDesk.refreshScreen()
|
||||||
startCapture()
|
startCapture()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ class MainService : Service() {
|
|||||||
createForegroundNotification()
|
createForegroundNotification()
|
||||||
|
|
||||||
if (intent.getBooleanExtra(EXT_INIT_FROM_BOOT, false)) {
|
if (intent.getBooleanExtra(EXT_INIT_FROM_BOOT, false)) {
|
||||||
startService()
|
RustDesk.startService()
|
||||||
}
|
}
|
||||||
Log.d(logTag, "service starting: ${startId}:${Thread.currentThread()}")
|
Log.d(logTag, "service starting: ${startId}:${Thread.currentThread()}")
|
||||||
val mediaProjectionManager =
|
val mediaProjectionManager =
|
||||||
@ -343,7 +343,7 @@ class MainService : Service() {
|
|||||||
val planes = image.planes
|
val planes = image.planes
|
||||||
val buffer = planes[0].buffer
|
val buffer = planes[0].buffer
|
||||||
buffer.rewind()
|
buffer.rewind()
|
||||||
onVideoFrameUpdate(buffer)
|
RustDesk.onVideoFrameUpdate(buffer)
|
||||||
}
|
}
|
||||||
} catch (ignored: java.lang.Exception) {
|
} catch (ignored: java.lang.Exception) {
|
||||||
}
|
}
|
||||||
@ -377,16 +377,16 @@ class MainService : Service() {
|
|||||||
}
|
}
|
||||||
checkMediaPermission()
|
checkMediaPermission()
|
||||||
_isStart = true
|
_isStart = true
|
||||||
setFrameRawEnable("video",true)
|
RustDesk.setFrameRawEnable("video",true)
|
||||||
setFrameRawEnable("audio",true)
|
RustDesk.setFrameRawEnable("audio",true)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun stopCapture() {
|
fun stopCapture() {
|
||||||
Log.d(logTag, "Stop Capture")
|
Log.d(logTag, "Stop Capture")
|
||||||
setFrameRawEnable("video",false)
|
RustDesk.setFrameRawEnable("video",false)
|
||||||
setFrameRawEnable("audio",false)
|
RustDesk.setFrameRawEnable("audio",false)
|
||||||
_isStart = false
|
_isStart = false
|
||||||
// release video
|
// release video
|
||||||
virtualDisplay?.release()
|
virtualDisplay?.release()
|
||||||
@ -521,7 +521,7 @@ class MainService : Service() {
|
|||||||
thread {
|
thread {
|
||||||
while (audioRecordStat) {
|
while (audioRecordStat) {
|
||||||
audioReader!!.readSync(audioRecorder!!)?.let {
|
audioReader!!.readSync(audioRecorder!!)?.let {
|
||||||
onAudioFrameUpdate(it)
|
RustDesk.onAudioFrameUpdate(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d(logTag, "Exit audio thread")
|
Log.d(logTag, "Exit audio thread")
|
||||||
|
@ -5,15 +5,17 @@ package ffi
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
|
|
||||||
init {
|
object RustDesk {
|
||||||
System.loadLibrary("rustdesk")
|
init {
|
||||||
}
|
System.loadLibrary("rustdesk")
|
||||||
|
}
|
||||||
|
|
||||||
external fun init(ctx: Context)
|
external fun init(ctx: Context)
|
||||||
external fun startServer(app_dir: String)
|
external fun startServer(app_dir: String)
|
||||||
external fun startService()
|
external fun startService()
|
||||||
external fun onVideoFrameUpdate(buf: ByteBuffer)
|
external fun onVideoFrameUpdate(buf: ByteBuffer)
|
||||||
external fun onAudioFrameUpdate(buf: ByteBuffer)
|
external fun onAudioFrameUpdate(buf: ByteBuffer)
|
||||||
external fun translateLocale(localeName: String, input: String): String
|
external fun translateLocale(localeName: String, input: String): String
|
||||||
external fun refreshScreen()
|
external fun refreshScreen()
|
||||||
external fun setFrameRawEnable(name: String, value: Boolean)
|
external fun setFrameRawEnable(name: String, value: Boolean)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user