From 9fb54c59597af5312c99f3b6a8812357094a705b Mon Sep 17 00:00:00 2001 From: kevingpqi Date: Thu, 16 May 2024 11:15:50 +0800 Subject: [PATCH] Fix the hardware decoding failure issue on the Android platform. std::string requires passing the valid length as a parameter. --- src/platform/android/HardwareDecoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/android/HardwareDecoder.cpp b/src/platform/android/HardwareDecoder.cpp index 514158f544..9f9c05e6b2 100644 --- a/src/platform/android/HardwareDecoder.cpp +++ b/src/platform/android/HardwareDecoder.cpp @@ -132,7 +132,7 @@ bool HardwareDecoder::initDecoder(JNIEnv* env, const VideoFormat& format) { for (auto& header : format.headers) { char keyString[6]; snprintf(keyString, 6, "csd-%d", index); - auto key = SafeConvertToJString(env, std::string(keyString, 6)); + auto key = SafeConvertToJString(env, std::string(keyString, 5)); auto bytes = env->NewDirectByteBuffer(const_cast(header->bytes()), header->size()); env->CallVoidMethod(mediaFormat, MediaFormat_setByteBuffer, key, bytes); index++;