custom codec

This commit is contained in:
mzdluo123 2020-08-18 11:50:52 +08:00
parent f779ac08ac
commit e6374c8849
No known key found for this signature in database
GPG Key ID: 9F7BC2C154107A1D
2 changed files with 11 additions and 6 deletions

View File

@ -469,14 +469,15 @@ internal class GroupImpl(
}
return bot.network.run {
val response: PttStore.GroupPttUp.Response.RequireUpload =
PttStore.GroupPttUp(bot.client, bot.id, id, md5, content.size.toLong()).sendAndExpect()
PttStore.GroupPttUp(bot.client, bot.id, id, md5, content.size.toLong(), codec).sendAndExpect()
HighwayHelper.uploadPttToServers(
bot,
response.uploadIpList.zip(response.uploadPortList),
content,
md5,
response.uKey,
response.fileKey
response.fileKey,
codec
)
Voice("${md5.toUHexString("")}.amr", md5, content.size.toLong(), "")
}

View File

@ -190,7 +190,9 @@ internal object HighwayHelper {
servers: List<Pair<Int, Int>>,
content: ByteArray,
md5: ByteArray,
uKey: ByteArray, fileKey: ByteArray
uKey: ByteArray,
fileKey: ByteArray,
codec: Int
) {
servers.retryWithServers(10 * 1000, {
throw IllegalStateException("cannot upload ptt, failed on all servers.", it)
@ -199,7 +201,7 @@ internal object HighwayHelper {
"[Highway] Uploading ptt to ${s}:$i, size=${content.size.toLong().sizeToString()}"
}
val time = measureTime {
uploadPttToServer(s, i, content, md5, uKey, fileKey)
uploadPttToServer(s, i, content, md5, uKey, fileKey, codec)
}
bot.network.logger.verbose {
"[Highway] Uploading ptt: succeed at ${(content.size.toDouble() / 1024 / time.inSeconds).roundToInt()} KiB/s"
@ -214,7 +216,9 @@ internal object HighwayHelper {
serverPort: Int,
content: ByteArray,
md5: ByteArray,
uKey: ByteArray, fileKey: ByteArray
uKey: ByteArray,
fileKey: ByteArray,
codec: Int
) {
MiraiPlatformUtils.Http.post<String> {
url("http://$serverIp:$serverPort")
@ -224,7 +228,7 @@ internal object HighwayHelper {
parameter("filesize", content.size)
parameter("bmd5", md5.toUHexString(""))
parameter("mType", "pttDu")
parameter("voice_encodec", 0)
parameter("voice_encodec", codec)
body = content
}
}