Repo created
This commit is contained in:
parent
81b91f4139
commit
f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions
|
|
@ -0,0 +1,62 @@
|
|||
#include "AndroidContext.h"
|
||||
|
||||
#include "sdk/android/native_api/jni/jvm.h"
|
||||
#include "tgnet/FileLog.h"
|
||||
|
||||
namespace tgcalls {
|
||||
|
||||
AndroidContext::AndroidContext(JNIEnv *env, jobject peerInstance, jobject groupInstance, bool screencast) {
|
||||
VideoCapturerDeviceClass = (jclass) env->NewGlobalRef(env->FindClass("org/telegram/messenger/voip/VideoCapturerDevice"));
|
||||
jmethodID initMethodId = env->GetMethodID(VideoCapturerDeviceClass, "<init>", "(Z)V");
|
||||
javaCapturer = env->NewGlobalRef(env->NewObject(VideoCapturerDeviceClass, initMethodId, screencast));
|
||||
if (peerInstance) {
|
||||
javaPeerInstance = env->NewGlobalRef(peerInstance);
|
||||
}
|
||||
if (groupInstance) {
|
||||
javaGroupInstance = env->NewGlobalRef(groupInstance);
|
||||
}
|
||||
}
|
||||
|
||||
AndroidContext::~AndroidContext() {
|
||||
JNIEnv *env = webrtc::AttachCurrentThreadIfNeeded();
|
||||
|
||||
jmethodID onDestroyMethodId = env->GetMethodID(VideoCapturerDeviceClass, "onDestroy", "()V");
|
||||
env->CallVoidMethod(javaCapturer, onDestroyMethodId);
|
||||
env->DeleteGlobalRef(javaCapturer);
|
||||
javaCapturer = nullptr;
|
||||
|
||||
env->DeleteGlobalRef(VideoCapturerDeviceClass);
|
||||
|
||||
if (javaPeerInstance) {
|
||||
env->DeleteGlobalRef(javaPeerInstance);
|
||||
}
|
||||
if (javaGroupInstance) {
|
||||
env->DeleteGlobalRef(javaGroupInstance);
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidContext::setJavaPeerInstance(JNIEnv *env, jobject instance) {
|
||||
javaPeerInstance = env->NewGlobalRef(instance);
|
||||
}
|
||||
|
||||
void AndroidContext::setJavaGroupInstance(JNIEnv *env, jobject instance) {
|
||||
javaGroupInstance = env->NewGlobalRef(instance);
|
||||
}
|
||||
|
||||
jobject AndroidContext::getJavaPeerInstance() {
|
||||
return javaPeerInstance;
|
||||
}
|
||||
|
||||
jobject AndroidContext::getJavaGroupInstance() {
|
||||
return javaGroupInstance;
|
||||
}
|
||||
|
||||
jobject AndroidContext::getJavaCapturer() {
|
||||
return javaCapturer;
|
||||
}
|
||||
|
||||
jclass AndroidContext::getJavaCapturerClass() {
|
||||
return VideoCapturerDeviceClass;
|
||||
}
|
||||
|
||||
} // namespace tgcalls
|
||||
Loading…
Add table
Add a link
Reference in a new issue