mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-03 15:10:14 +08:00
Merge pull request #728 from sandtechnology/Fix-voice
Fix #577: voice compression
This commit is contained in:
commit
279758f08f
@ -39,6 +39,7 @@ public class Voice @MiraiInternalApi constructor(
|
|||||||
public override val fileName: String,
|
public override val fileName: String,
|
||||||
public override val md5: ByteArray,
|
public override val md5: ByteArray,
|
||||||
public override val fileSize: Long,
|
public override val fileSize: Long,
|
||||||
|
public val codec: Int = 0,
|
||||||
private val _url: String
|
private val _url: String
|
||||||
) : PttMessage() {
|
) : PttMessage() {
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ internal class GroupImpl(
|
|||||||
response.fileKey,
|
response.fileKey,
|
||||||
codec
|
codec
|
||||||
)
|
)
|
||||||
Voice("${md5.toUHexString("")}.amr", md5, content.size.toLong(), "")
|
Voice("${md5.toUHexString("")}.amr", md5, content.size.toLong(), codec, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ internal fun MsgComm.Msg.toMessageChain(
|
|||||||
// 4 -> Voice(String(fileName), fileMd5, fileSize.toLong(),String(downPara))
|
// 4 -> Voice(String(fileName), fileMd5, fileSize.toLong(),String(downPara))
|
||||||
// else -> null
|
// else -> null
|
||||||
// }
|
// }
|
||||||
Voice(String(fileName), fileMd5, fileSize.toLong(), String(downPara))
|
Voice(String(fileName), fileMd5, fileSize.toLong(), format, String(downPara))
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildMessageChain(elements.size + 1 + if (pptMsg == null) 0 else 1) {
|
return buildMessageChain(elements.size + 1 + if (pptMsg == null) 0 else 1) {
|
||||||
|
@ -35,6 +35,7 @@ import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
|||||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||||
import net.mamoe.mirai.message.data.MessageChain
|
import net.mamoe.mirai.message.data.MessageChain
|
||||||
import net.mamoe.mirai.message.data.PttMessage
|
import net.mamoe.mirai.message.data.PttMessage
|
||||||
|
import net.mamoe.mirai.message.data.Voice
|
||||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||||
import kotlin.contracts.InvocationKind
|
import kotlin.contracts.InvocationKind
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
@ -145,7 +146,14 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory<MessageSvcPbSendMsg.
|
|||||||
boolValid = true,
|
boolValid = true,
|
||||||
fileSize = fileSize.toInt(),
|
fileSize = fileSize.toInt(),
|
||||||
fileType = 4,
|
fileType = 4,
|
||||||
pbReserve = byteArrayOf(0)
|
pbReserve = byteArrayOf(0),
|
||||||
|
format = let {
|
||||||
|
if (it is Voice) {
|
||||||
|
it.codec
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user