2014-04-09 01:18:32 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 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
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Platform-specific initialization bits, if any, go here.
|
|
|
|
|
|
2014-09-17 11:44:51 +00:00
|
|
|
#ifndef ANDROID
|
2014-04-09 01:18:32 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace videocapturemodule {
|
|
|
|
|
void EnsureInitialized() {}
|
|
|
|
|
} // namespace videocapturemodule
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2014-09-17 11:44:51 +00:00
|
|
|
#else
|
2014-04-09 01:18:32 +00:00
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
|
|
#include "base/android/jni_android.h"
|
2014-09-17 11:44:51 +00:00
|
|
|
#include "webrtc/base/checks.h"
|
|
|
|
|
#include "webrtc/modules/video_capture/video_capture_internal.h"
|
2014-04-09 21:19:55 +00:00
|
|
|
|
2014-04-09 01:18:32 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
namespace videocapturemodule {
|
|
|
|
|
|
|
|
|
|
static pthread_once_t g_initialize_once = PTHREAD_ONCE_INIT;
|
|
|
|
|
|
|
|
|
|
void EnsureInitializedOnce() {
|
|
|
|
|
JNIEnv* jni = ::base::android::AttachCurrentThread();
|
2014-06-06 18:40:44 +00:00
|
|
|
jobject context = ::base::android::GetApplicationContext();
|
2014-04-09 01:18:32 +00:00
|
|
|
JavaVM* jvm = NULL;
|
2014-09-17 11:44:51 +00:00
|
|
|
CHECK_EQ(0, jni->GetJavaVM(&jvm));
|
|
|
|
|
CHECK_EQ(0, webrtc::SetCaptureAndroidVM(jvm, context));
|
2014-04-09 01:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnsureInitialized() {
|
2014-09-17 11:44:51 +00:00
|
|
|
CHECK_EQ(0, pthread_once(&g_initialize_once, &EnsureInitializedOnce));
|
2014-04-09 01:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace videocapturemodule
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2014-09-17 11:44:51 +00:00
|
|
|
#endif // !ANDROID
|