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.
13 #if !defined(ANDROID) || !defined(WEBRTC_CHROMIUM_BUILD)
16 namespace videocapturemodule {
17 void EnsureInitialized() {}
18 } // namespace videocapturemodule
21 #else // !defined(ANDROID) || !defined(WEBRTC_CHROMIUM_BUILD)
26 #include "base/android/jni_android.h"
28 // Handy alternative to assert() which suppresses unused-variable warnings when
29 // assert() is a no-op (i.e. in Release builds).
31 #define ASSERT(x) if (false && (x)); else
33 #define ASSERT(x) assert(x)
38 // Declared in webrtc/modules/video_capture/include/video_capture.h.
39 int32_t SetCaptureAndroidVM(JavaVM* javaVM);
41 namespace videocapturemodule {
43 static pthread_once_t g_initialize_once = PTHREAD_ONCE_INIT;
45 void EnsureInitializedOnce() {
46 JNIEnv* jni = ::base::android::AttachCurrentThread();
48 int status = jni->GetJavaVM(&jvm);
50 status = webrtc::SetCaptureAndroidVM(jvm) == 0;
54 void EnsureInitialized() {
55 int ret = pthread_once(&g_initialize_once, &EnsureInitializedOnce);
59 } // namespace videocapturemodule
62 #endif // ANDROID & WEBRTC_CHROMIUM_BUILD