2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 // Platform-specific initialization bits, if any, go here.
16 namespace videocapturemodule {
17 void EnsureInitialized() {}
18 } // namespace videocapturemodule
25 #include "base/android/jni_android.h"
26 #include "webrtc/base/checks.h"
27 #include "webrtc/modules/video_capture/video_capture_internal.h"
30 namespace videocapturemodule {
32 static pthread_once_t g_initialize_once = PTHREAD_ONCE_INIT;
34 void EnsureInitializedOnce() {
35 JNIEnv* jni = ::base::android::AttachCurrentThread();
36 jobject context = ::base::android::GetApplicationContext();
38 CHECK_EQ(0, jni->GetJavaVM(&jvm));
39 CHECK_EQ(0, webrtc::SetCaptureAndroidVM(jvm, context));
42 void EnsureInitialized() {
43 CHECK_EQ(0, pthread_once(&g_initialize_once, &EnsureInitializedOnce));
46 } // namespace videocapturemodule