linux android use cpal (#9914)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-11-14 21:01:41 +08:00
committed by GitHub
parent 9e4cc91a14
commit 06c7bc137f
11 changed files with 79 additions and 331 deletions

View File

@@ -30,6 +30,10 @@ import com.hjq.permissions.XXPermissions
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import kotlin.concurrent.thread
@@ -57,6 +61,7 @@ class MainActivity : FlutterActivity() {
channelTag
)
initFlutterChannel(flutterMethodChannel!!)
flutterEngine.plugins.add(ContextPlugin())
thread { setCodecInfo() }
}
@@ -389,3 +394,16 @@ class MainActivity : FlutterActivity() {
stopService(Intent(this, FloatingWindowService::class.java))
}
}
// https://cjycode.com/flutter_rust_bridge/guides/how-to/ndk-init
class ContextPlugin : FlutterPlugin, MethodCallHandler {
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
FFI.initContext(flutterPluginBinding.applicationContext)
}
override fun onMethodCall(call: MethodCall, result: Result) {
result.notImplemented()
}
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
}
}

View File

@@ -11,6 +11,7 @@ object FFI {
}
external fun init(ctx: Context)
external fun initContext(ctx: Context)
external fun startServer(app_dir: String, custom_client_config: String)
external fun startService()
external fun onVideoFrameUpdate(buf: ByteBuffer)