add avif encoding
This commit is contained in:
1 parent
d51e0bdc21
commit
5160409cf0
2 files changed
+47
-13
No files matched your search
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -172,8 +172,8 @@ class PeripheralManager(
|
|||||||
nextSeq = 0
|
nextSeq = 0
|
||||||
credits = BleSpec.WINDOW_CREDITS
|
credits = BleSpec.WINDOW_CREDITS
|
||||||
fileCrc = CRC32()
|
fileCrc = CRC32()
|
||||||
outFile = File(context.cacheDir, "incoming_image_${System.currentTimeMillis()}.bin")
|
outFile = null //File(context.cacheDir, "incoming_image_${System.currentTimeMillis()}.bin")
|
||||||
statusText.value = "Ready to receive → ${outFile?.absolutePath}"
|
statusText.value = "Ready to receive" //"Ready to receive → ${outFile?.absolutePath}"
|
||||||
}
|
}
|
||||||
|
|
||||||
/** value = [ seq(u32) | len(u16) | crc32(u32) | payload(len) ] */
|
/** value = [ seq(u32) | len(u16) | crc32(u32) | payload(len) ] */
|
||||||
@@ -197,22 +197,50 @@ class PeripheralManager(
|
|||||||
|
|
||||||
// Start frame
|
// Start frame
|
||||||
if (seq == 0xFFFFFFFFL) {
|
if (seq == 0xFFFFFFFFL) {
|
||||||
if (len == 8 && payload.size == 8) {
|
if (len != 10 || payload.size != 10) {
|
||||||
val s = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN)
|
|
||||||
val totalLen = s.long
|
|
||||||
totalExpected.value = totalLen
|
|
||||||
bytesReceived.value = 0L
|
|
||||||
nextSeq = 0
|
|
||||||
statusText.value = "Start: total=$totalLen"
|
|
||||||
sendCredits(force = true)
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
// 다른 len 값으로 온 Start는 거부
|
|
||||||
statusText.value = "Malformed start: len=$len"
|
statusText.value = "Malformed start: len=$len"
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
val ver = payload[0].toInt() and 0xFF
|
||||||
|
if (ver != 1) {
|
||||||
|
statusText.value = "Unsupported ver=$ver"
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// totalLen24 (LE, 3 bytes)
|
||||||
|
val total = (payload[1].toInt() and 0xFF) or
|
||||||
|
((payload[2].toInt() and 0xFF) shl 8) or
|
||||||
|
((payload[3].toInt() and 0xFF) shl 16)
|
||||||
|
|
||||||
|
val extLen = payload[4].toInt() and 0xFF
|
||||||
|
if (extLen > 5) {
|
||||||
|
statusText.value = "Bad extLen=$extLen"
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
val ext = buildString {
|
||||||
|
for (i in 0 until extLen) {
|
||||||
|
val ch = payload[5 + i].toInt() and 0xFF
|
||||||
|
if (ch == 0) break
|
||||||
|
append(ch.toChar())
|
||||||
|
}
|
||||||
|
}.lowercase().filter { it.isLetterOrDigit() }
|
||||||
|
|
||||||
|
totalExpected.value = total.toLong()
|
||||||
|
bytesReceived.value = 0L
|
||||||
|
nextSeq = 0
|
||||||
|
fileCrc = CRC32()
|
||||||
|
credits = BleSpec.WINDOW_CREDITS
|
||||||
|
|
||||||
|
// 파일 이름/확장자 생성
|
||||||
|
val safeExt = if (ext.isNotEmpty()) ext else "bin"
|
||||||
|
val base = "incoming_${System.currentTimeMillis()}"
|
||||||
|
outFile = File(context.cacheDir, "$base.$safeExt")
|
||||||
|
|
||||||
|
statusText.value = "Start: total=$total, ext=$safeExt → ${outFile?.name}"
|
||||||
|
sendCredits(force = true)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (seq != nextSeq) {
|
if (seq != nextSeq) {
|
||||||
notifyStatus(code = 2, arg = nextSeq)
|
notifyStatus(code = 2, arg = nextSeq)
|
||||||
statusText.value = "Seq mismatch: got=$seq expected=$nextSeq"
|
statusText.value = "Seq mismatch: got=$seq expected=$nextSeq"
|
||||||
|
|||||||
Reference in new issue
Block a user