android: for software encoding and screen size > 1200, display size reduced to half (#8167)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-05-28 12:43:13 +08:00
committed by GitHub
parent b0c21e927b
commit 036d10cfbe
10 changed files with 83 additions and 1 deletions

View File

@@ -55,6 +55,8 @@ const val MIME_TYPE = MediaFormat.MIMETYPE_VIDEO_VP9
// video const
const val MAX_SCREEN_SIZE = 1200
const val VIDEO_KEY_BIT_RATE = 1024_000
const val VIDEO_KEY_FRAME_RATE = 30
@@ -170,6 +172,14 @@ class MainService : Service() {
Log.d(logTag, "from rust:stop_capture")
stopCapture()
}
"is_hardware_codec" -> {
val isHwCodec = arg1.toBoolean()
if (isHardwareCodec != isHwCodec) {
isHardwareCodec = isHwCodec
updateScreenInfo(resources.configuration.orientation)
}
}
else -> {
}
}
@@ -245,6 +255,7 @@ class MainService : Service() {
super.onDestroy()
}
private var isHardwareCodec: Boolean? = null;
private fun updateScreenInfo(orientation: Int) {
var w: Int
var h: Int
@@ -277,6 +288,12 @@ class MainService : Service() {
Log.d(logTag,"updateScreenInfo:w:$w,h:$h")
var scale = 1
if (w != 0 && h != 0) {
if (isHardwareCodec == false && (w > MAX_SCREEN_SIZE || h > MAX_SCREEN_SIZE)) {
scale = 2
w /= scale
h /= scale
dpi /= scale
}
if (SCREEN_INFO.width != w) {
SCREEN_INFO.width = w
SCREEN_INFO.height = h