OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 // Platform-specific initialization bits, if any, go here. | 11 // Platform-specific initialization bits, if any, go here. |
12 | 12 |
13 #ifndef ANDROID | 13 #ifndef ANDROID |
14 | 14 |
15 namespace webrtc { | 15 namespace webrtc { |
16 namespace videocapturemodule { | 16 namespace videocapturemodule { |
17 void EnsureInitialized() {} | 17 void EnsureInitialized() {} |
18 } // namespace videocapturemodule | 18 } // namespace videocapturemodule |
19 } // namespace webrtc | 19 } // namespace webrtc |
20 | 20 |
21 #else | 21 #else |
22 | 22 |
23 #include <pthread.h> | 23 #include <pthread.h> |
24 | 24 |
25 // Note: this dependency is dangerous since it reaches into Chromium's | 25 // Note: this dependency is dangerous since it reaches into Chromium's base. |
26 // base. You can't include anything in this file that includes WebRTC's | 26 // There's a risk of e.g. macro clashes. This file may only be used in tests. |
27 // base/checks.h, for instance, since it will clash with Chromium's | |
28 // logging.h. Therefore, the CHECKs in this file will actually use | |
29 // Chromium's checks rather than the WebRTC ones. | |
30 #include "base/android/jni_android.h" | 27 #include "base/android/jni_android.h" |
| 28 #include "webrtc/base/checks.h" |
31 #include "webrtc/modules/video_capture/video_capture_internal.h" | 29 #include "webrtc/modules/video_capture/video_capture_internal.h" |
32 | 30 |
33 namespace webrtc { | 31 namespace webrtc { |
34 namespace videocapturemodule { | 32 namespace videocapturemodule { |
35 | 33 |
36 static pthread_once_t g_initialize_once = PTHREAD_ONCE_INIT; | 34 static pthread_once_t g_initialize_once = PTHREAD_ONCE_INIT; |
37 | 35 |
38 void EnsureInitializedOnce() { | 36 void EnsureInitializedOnce() { |
39 JNIEnv* jni = ::base::android::AttachCurrentThread(); | 37 JNIEnv* jni = ::base::android::AttachCurrentThread(); |
40 jobject context = ::base::android::GetApplicationContext(); | 38 jobject context = ::base::android::GetApplicationContext(); |
41 JavaVM* jvm = NULL; | 39 JavaVM* jvm = NULL; |
42 CHECK_EQ(0, jni->GetJavaVM(&jvm)); | 40 RTC_CHECK_EQ(0, jni->GetJavaVM(&jvm)); |
43 CHECK_EQ(0, webrtc::SetCaptureAndroidVM(jvm, context)); | 41 RTC_CHECK_EQ(0, webrtc::SetCaptureAndroidVM(jvm, context)); |
44 } | 42 } |
45 | 43 |
46 void EnsureInitialized() { | 44 void EnsureInitialized() { |
47 CHECK_EQ(0, pthread_once(&g_initialize_once, &EnsureInitializedOnce)); | 45 RTC_CHECK_EQ(0, pthread_once(&g_initialize_once, &EnsureInitializedOnce)); |
48 } | 46 } |
49 | 47 |
50 } // namespace videocapturemodule | 48 } // namespace videocapturemodule |
51 } // namespace webrtc | 49 } // namespace webrtc |
52 | 50 |
53 #endif // !ANDROID | 51 #endif // !ANDROID |
OLD | NEW |