Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: webrtc/api/test/androidtestinitializer.cc

Issue 1610243002: Move talk/app/webrtc to webrtc/api (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updated location for peerconnection_unittests.isolate Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/api/test/androidtestinitializer.cc
diff --git a/webrtc/modules/audio_device/android/ensure_initialized.cc b/webrtc/api/test/androidtestinitializer.cc
similarity index 54%
copy from webrtc/modules/audio_device/android/ensure_initialized.cc
copy to webrtc/api/test/androidtestinitializer.cc
index b63aec1f27d87a38607f6acc13412245b51d9300..4816702bdf9f0505556555c121c16f169d82c814 100644
--- a/webrtc/modules/audio_device/android/ensure_initialized.cc
+++ b/webrtc/api/test/androidtestinitializer.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ * Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -8,24 +8,32 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/audio_device/android/ensure_initialized.h"
+#include "webrtc/api/test/androidtestinitializer.h"
#include <pthread.h>
// Note: this dependency is dangerous since it reaches into Chromium's base.
// There's a risk of e.g. macro clashes. This file may only be used in tests.
+// Since we use Chromes build system for creating the gtest binary, this should
+// be fine.
#include "base/android/context_utils.h"
#include "base/android/jni_android.h"
+
+#include "webrtc/api/java/jni/classreferenceholder.h"
+#include "webrtc/api/java/jni/jni_helpers.h"
#include "webrtc/base/checks.h"
-#include "webrtc/modules/audio_device/android/audio_record_jni.h"
-#include "webrtc/modules/audio_device/android/audio_track_jni.h"
-#include "webrtc/modules/utility/include/jvm_android.h"
+#include "webrtc/base/ssladapter.h"
+#include "webrtc/voice_engine/include/voe_base.h"
namespace webrtc {
-namespace audiodevicemodule {
+
+namespace {
static pthread_once_t g_initialize_once = PTHREAD_ONCE_INIT;
+// There can only be one JNI_OnLoad in each binary. So since this is a GTEST
+// C++ runner binary, we want to initialize the same global objects we normally
+// do if this had been a Java binary.
void EnsureInitializedOnce() {
RTC_CHECK(::base::android::IsVMInitialized());
JNIEnv* jni = ::base::android::AttachCurrentThread();
@@ -33,13 +41,17 @@ void EnsureInitializedOnce() {
RTC_CHECK_EQ(0, jni->GetJavaVM(&jvm));
jobject context = ::base::android::GetApplicationContext();
- // Initialize the Java environment (currently only used by the audio manager).
- webrtc::JVM::Initialize(jvm, context);
+ RTC_CHECK_GE(webrtc_jni::InitGlobalJniVariables(jvm), 0);
+ RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
+ webrtc_jni::LoadGlobalClassReferenceHolder();
+
+ webrtc::VoiceEngine::SetAndroidObjects(jvm, context);
}
-void EnsureInitialized() {
+} // anonymous namespace
+
+void InitializeAndroidObjects() {
RTC_CHECK_EQ(0, pthread_once(&g_initialize_once, &EnsureInitializedOnce));
}
-} // namespace audiodevicemodule
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698