-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
128 changed files
with
3,299 additions
and
1,809 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/DeviceHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package deckers.thibault.aves.channel.calls | ||
|
||
import android.os.Build | ||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
|
||
class DeviceHandler : MethodCallHandler { | ||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { | ||
when (call.method) { | ||
"getPerformanceClass" -> result.success(getPerformanceClass()) | ||
else -> result.notImplemented() | ||
} | ||
} | ||
|
||
private fun getPerformanceClass(): Int { | ||
// TODO TLAD uncomment when the future is here | ||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
// return Build.VERSION.MEDIA_PERFORMANCE_CLASS | ||
// } | ||
return Build.VERSION.SDK_INT | ||
} | ||
|
||
companion object { | ||
const val CHANNEL = "deckers.thibault/aves/device" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
android/app/src/main/kotlin/deckers/thibault/aves/metadata/QuickTimeMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package deckers.thibault.aves.metadata | ||
|
||
import java.math.BigInteger | ||
import java.nio.charset.Charset | ||
import java.util.* | ||
|
||
class QuickTimeMetadataBlock(val type: String, val value: String, val language: String) | ||
|
||
object QuickTimeMetadata { | ||
// QuickTime Profile Tags | ||
// cf https://exiftool.org/TagNames/QuickTime.html#Profile | ||
const val PROF_UUID = "50524f46-21d2-4fce-bb88-695cfac9c740" | ||
|
||
// QuickTime UserMedia Tags | ||
// cf https://exiftool.org/TagNames/QuickTime.html#UserMedia | ||
const val USMT_UUID = "55534d54-21d2-4fce-bb88-695cfac9c740" | ||
|
||
private const val METADATA_BOX_ID = "MTDT" | ||
|
||
fun parseUuidUsmt(data: ByteArray): List<QuickTimeMetadataBlock> { | ||
val blocks = ArrayList<QuickTimeMetadataBlock>() | ||
val boxHeader = BoxHeader(data) | ||
if (boxHeader.boxType == METADATA_BOX_ID) { | ||
blocks.addAll(parseQuicktimeMtdtBox(boxHeader, data)) | ||
} | ||
return blocks | ||
} | ||
|
||
private fun parseQuicktimeMtdtBox(boxHeader: BoxHeader, data: ByteArray): List<QuickTimeMetadataBlock> { | ||
val blocks = ArrayList<QuickTimeMetadataBlock>() | ||
var bytes = data | ||
val blockCount = BigInteger(bytes.copyOfRange(8, 10)).toInt() | ||
bytes = bytes.copyOfRange(10, boxHeader.boxDataSize) | ||
|
||
for (i in 0 until blockCount) { | ||
val blockSize = BigInteger(bytes.copyOfRange(0, 2)).toInt() | ||
val blockType = BigInteger(bytes.copyOfRange(2, 6)).toInt() | ||
val language = parseLanguage(bytes.copyOfRange(6, 8)) | ||
val encoding = BigInteger(bytes.copyOfRange(8, 10)).toInt() | ||
val payload = bytes.copyOfRange(10, blockSize) | ||
|
||
val payloadString = when (encoding) { | ||
// 0x00: short array | ||
0x00 -> { | ||
payload | ||
.asList() | ||
.chunked(2) | ||
.map { (h, l) -> ((h.toInt() shl 8) + l.toInt()).toShort() } | ||
.joinToString() | ||
} | ||
// 0x01: string | ||
0x01 -> String(payload, Charset.forName("UTF-16BE")).trim() | ||
// 0x101: artwork/icon | ||
else -> "0x${payload.joinToString("") { "%02x".format(it) }}" | ||
} | ||
|
||
val blockTypeString = when (blockType) { | ||
0x01 -> "Title" | ||
0x03 -> "Creation Time" | ||
0x04 -> "Software" | ||
0x0A -> "Track property" | ||
0x0B -> "Time zone" | ||
0x0C -> "Modification Time" | ||
else -> "0x${"%02x".format(blockType)}" | ||
} | ||
|
||
blocks.add( | ||
QuickTimeMetadataBlock( | ||
type = blockTypeString, | ||
value = payloadString, | ||
language = language, | ||
) | ||
) | ||
bytes = bytes.copyOfRange(blockSize, bytes.size) | ||
} | ||
|
||
return blocks | ||
} | ||
|
||
// ISO 639 language code written as 3 groups of 5 bits for each letter (ascii code - 0x60) | ||
// e.g. 0x55c4 -> 10101 01110 00100 -> 21 14 4 -> "und" | ||
private fun parseLanguage(bytes: ByteArray): String { | ||
val i = BigInteger(bytes).toInt() | ||
val c1 = Character.toChars((i shr 10 and 0x1F) + 0x60)[0] | ||
val c2 = Character.toChars((i shr 5 and 0x1F) + 0x60)[0] | ||
val c3 = Character.toChars((i and 0x1F) + 0x60)[0] | ||
return "$c1$c2$c3" | ||
} | ||
} | ||
|
||
class BoxHeader(bytes: ByteArray) { | ||
var boxDataSize: Int = 0 | ||
var boxType: String | ||
|
||
init { | ||
boxDataSize = BigInteger(bytes.copyOfRange(0, 4)).toInt() | ||
boxType = String(bytes.copyOfRange(4, 8)) | ||
} | ||
} |
Oops, something went wrong.