Runt
2025-04-04 49be01c8fd58a15b16012dc528673343ff7d73b9
app/src/main/cpp/media_encoder_call.cpp
@@ -28,6 +28,7 @@
    jmd_encode_yuv = env->GetMethodID(clazz,"encodeYUV","([B)V");
    jmd_encode_pcm = env->GetMethodID(clazz,"encodePCM","([B)V");
    jmd_get_sps_pps = env->GetMethodID(clazz,"getSpsPpsData","()[B");
    jmd_get_audio_seq = env->GetMethodID(clazz,"getAudioSeqData","()[B");
}
void MediaEncoderCall::encodeYUV(uint8_t* yuvBuffer, int width, int height) {
@@ -62,9 +63,17 @@
}
void MediaEncoderCall::getSpsPps(uint8_t **data,int *length){
    getJvmBytes(jmd_get_sps_pps,data,length);
}
void MediaEncoderCall::getAudioSeqData(uint8_t **data,int *length){
    getJvmBytes(jmd_get_audio_seq,data,length);
}
void MediaEncoderCall::getJvmBytes(jmethodID method,uint8_t **data,int *length){
    JNIEnv *env_child;
    javaVM->AttachCurrentThread(&env_child, 0);
    jbyteArray bytes = reinterpret_cast<jbyteArray> (env_child->CallObjectMethod(instance, jmd_get_sps_pps));
    jbyteArray bytes = reinterpret_cast<jbyteArray> (env_child->CallObjectMethod(instance, method));
    if (!bytes) {
        LOGE("Java returned null byte array");
        return;