Index: talk/app/webrtc/java/jni/eglbase_jni.h |
diff --git a/talk/app/webrtc/java/jni/jni_onload.cc b/talk/app/webrtc/java/jni/eglbase_jni.h |
similarity index 63% |
copy from talk/app/webrtc/java/jni/jni_onload.cc |
copy to talk/app/webrtc/java/jni/eglbase_jni.h |
index 9664ecdca6b2020f05fc9ca08a82638debb88e7f..1015d90b925d0afe35284ec5b348a02174aedf87 100644 |
--- a/talk/app/webrtc/java/jni/jni_onload.cc |
+++ b/talk/app/webrtc/java/jni/eglbase_jni.h |
@@ -1,6 +1,6 @@ |
/* |
* libjingle |
- * Copyright 2015 Google Inc. |
+ * Copyright 2016 Google Inc. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are met: |
@@ -23,33 +23,38 @@ |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ * |
*/ |
+#ifndef TALK_APP_WEBRTC_JAVA_JNI_EGLBASE_JNI_H_ |
+#define TALK_APP_WEBRTC_JAVA_JNI_EGLBASE_JNI_H_ |
+ |
#include <jni.h> |
-#undef JNIEXPORT |
-#define JNIEXPORT __attribute__((visibility("default"))) |
-#include "talk/app/webrtc/java/jni/classreferenceholder.h" |
-#include "talk/app/webrtc/java/jni/jni_helpers.h" |
-#include "webrtc/base/ssladapter.h" |
+#include "webrtc/base/constructormagic.h" |
namespace webrtc_jni { |
-extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { |
- jint ret = InitGlobalJniVariables(jvm); |
- RTC_DCHECK_GE(ret, 0); |
- if (ret < 0) |
- return -1; |
+// Helper class used for creating a Java instance of org/webrtc/EglBase. |
+class EglBase { |
+ public: |
+ EglBase(); |
+ ~EglBase(); |
- RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()"; |
- LoadGlobalClassReferenceHolder(); |
+ // Creates an new java EglBase instance. |egl_base_context| must be a valid |
+ // EglBase$Context. |
+ // Returns false if |egl_base_context| is a null Java object or if an |
+ // exception occur in Java. |
+ bool CreateEglBase(JNIEnv* jni, jobject egl_base_context); |
+ jobject egl_base_context() const { return egl_base_context_; } |
- return ret; |
-} |
+ private: |
+ jobject egl_base_ = nullptr; // instance of org/webrtc/EglBase |
+ jobject egl_base_context_ = nullptr; // instance of EglBase$Context |
-extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM *jvm, void *reserved) { |
- FreeGlobalClassReferenceHolder(); |
- RTC_CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()"; |
-} |
+ RTC_DISALLOW_COPY_AND_ASSIGN(EglBase); |
+}; |
} // namespace webrtc_jni |
+ |
+#endif // TALK_APP_WEBRTC_JAVA_JNI_EGLBASE_JNI_H_ |