[+] load错误问题解决

This commit is contained in:
acgist
2023-04-22 15:38:29 +08:00
parent d6ff6ec271
commit c6a5f1d1e0
4 changed files with 21 additions and 7 deletions

View File

@@ -182,8 +182,8 @@ public class MainActivity extends AppCompatActivity implements Serializable {
} }
this.threadHandler.post(() -> { this.threadHandler.post(() -> {
// 进入房间 // 进入房间
// Taoyao.taoyao.roomEnter("91f81c0a-0556-4087-b9a4-5889fac36fb6", null); Taoyao.taoyao.roomEnter("4ca4b920-a422-473d-9954-660df424270f", null);
Taoyao.taoyao.sessionCall("taoyao"); // Taoyao.taoyao.sessionCall("taoyao");
}); });
} }

View File

@@ -4,6 +4,8 @@
#include "Log.hpp" #include "Log.hpp"
#include "mediasoupclient.hpp" #include "mediasoupclient.hpp"
#include "sdk/android/src/jni/jvm.h"
namespace acgist { namespace acgist {
} }

View File

@@ -2,8 +2,21 @@
namespace acgist { namespace acgist {
/**
* 非常重要
* 如果没有配置很多方法莫名其妙报错
*
* @param env JNIEnv
*/
void initWebrtcJni(JNIEnv* env) {
JavaVM* javaVM;
env->GetJavaVM(&javaVM);
webrtc::jni::InitGlobalJniVariables(javaVM);
}
extern "C" JNIEXPORT void JNICALL extern "C" JNIEXPORT void JNICALL
Java_com_acgist_taoyao_media_MediaManager_nativeInit(JNIEnv* env, jobject me) { Java_com_acgist_taoyao_media_MediaManager_nativeInit(JNIEnv* env, jobject me) {
initWebrtcJni(env);
std::string version = mediasoupclient::Version(); std::string version = mediasoupclient::Version();
LOG_I("加载MediasoupClient", version.data()); LOG_I("加载MediasoupClient", version.data());
mediasoupclient::Initialize(); mediasoupclient::Initialize();

View File

@@ -360,11 +360,10 @@ namespace acgist {
jlong factoryPointer, jobject jRtcConfiguration jlong factoryPointer, jobject jRtcConfiguration
) { ) {
Room* room = (Room*) nativeRoomPointer; Room* room = (Room*) nativeRoomPointer;
webrtc::PeerConnectionInterface::RTCConfiguration rtcConfiguration(webrtc::PeerConnectionInterface::RTCConfigurationType::kSafe); // webrtc::PeerConnectionInterface::RTCConfiguration rtcConfiguration(webrtc::PeerConnectionInterface::RTCConfigurationType::kSafe);
// webrtc::jni::JavaToNativeMediaConstraints(); webrtc::PeerConnectionInterface::RTCConfiguration rtcConfiguration(webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive);
// webrtc::PeerConnectionInterface::RTCConfiguration rtcConfiguration(webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive); webrtc::JavaParamRef<jobject> jRtcConfigurationRef(env, jRtcConfiguration);
// TODO为什么不能转换测试是否因为stun配置问题 // 注意
webrtc::JavaParamRef<jobject> jRtcConfigurationRef(jRtcConfiguration);
webrtc::jni::JavaToNativeRTCConfiguration(env, jRtcConfigurationRef, &rtcConfiguration); webrtc::jni::JavaToNativeRTCConfiguration(env, jRtcConfigurationRef, &rtcConfiguration);
const char* rtpCapabilities = env->GetStringUTFChars(jRtpCapabilities, nullptr); const char* rtpCapabilities = env->GetStringUTFChars(jRtpCapabilities, nullptr);
room->enterRoom( room->enterRoom(