OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 package org.webrtc; | 11 package org.webrtc; |
12 | 12 |
13 import android.content.Context; | |
14 import java.util.List; | 13 import java.util.List; |
15 | 14 |
16 /** | 15 /** |
17 * Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to | 16 * Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to |
18 * the PeerConnection API for clients. | 17 * the PeerConnection API for clients. |
19 */ | 18 */ |
20 public class PeerConnectionFactory { | 19 public class PeerConnectionFactory { |
21 private static volatile boolean nativeLibLoaded; | 20 private static volatile boolean nativeLibLoaded; |
22 | 21 |
23 static { | 22 static { |
24 try { | 23 try { |
25 System.loadLibrary("jingle_peerconnection_so"); | 24 System.loadLibrary("jingle_peerconnection_so"); |
26 nativeLibLoaded = true; | 25 nativeLibLoaded = true; |
27 } catch (UnsatisfiedLinkError t) { | 26 } catch (UnsatisfiedLinkError t) { |
28 nativeLibLoaded = false; | 27 nativeLibLoaded = false; |
29 } | 28 } |
30 } | 29 } |
31 | 30 |
32 private static final String TAG = "PeerConnectionFactory"; | 31 private static final String TAG = "PeerConnectionFactory"; |
33 private final long nativeFactory; | 32 private final long nativeFactory; |
34 private static Context applicationContext; | |
35 private static Thread networkThread; | 33 private static Thread networkThread; |
36 private static Thread workerThread; | 34 private static Thread workerThread; |
37 private static Thread signalingThread; | 35 private static Thread signalingThread; |
38 private EglBase localEglbase; | 36 private EglBase localEglbase; |
39 private EglBase remoteEglbase; | 37 private EglBase remoteEglbase; |
40 | 38 |
41 public static class Options { | 39 public static class Options { |
42 // Keep in sync with webrtc/base/network.h! | 40 // Keep in sync with webrtc/base/network.h! |
43 static final int ADAPTER_TYPE_UNKNOWN = 0; | 41 static final int ADAPTER_TYPE_UNKNOWN = 0; |
44 static final int ADAPTER_TYPE_ETHERNET = 1 << 0; | 42 static final int ADAPTER_TYPE_ETHERNET = 1 << 0; |
45 static final int ADAPTER_TYPE_WIFI = 1 << 1; | 43 static final int ADAPTER_TYPE_WIFI = 1 << 1; |
46 static final int ADAPTER_TYPE_CELLULAR = 1 << 2; | 44 static final int ADAPTER_TYPE_CELLULAR = 1 << 2; |
47 static final int ADAPTER_TYPE_VPN = 1 << 3; | 45 static final int ADAPTER_TYPE_VPN = 1 << 3; |
48 static final int ADAPTER_TYPE_LOOPBACK = 1 << 4; | 46 static final int ADAPTER_TYPE_LOOPBACK = 1 << 4; |
49 | 47 |
50 public int networkIgnoreMask; | 48 public int networkIgnoreMask; |
51 public boolean disableEncryption; | 49 public boolean disableEncryption; |
52 public boolean disableNetworkMonitor; | 50 public boolean disableNetworkMonitor; |
53 } | 51 } |
54 | 52 |
55 // Must be called at least once before creating a PeerConnectionFactory | 53 // Must be called at least once before creating a PeerConnectionFactory |
56 // (for example, at application startup time). | 54 // (for example, at application startup time). |
57 public static native void nativeInitializeAndroidGlobals( | 55 public static native void initializeAndroidGlobals( |
58 Context context, boolean videoHwAcceleration); | 56 android.content.Context context, boolean videoHwAcceleration); |
59 | |
60 public static void initializeAndroidGlobals(Context context, boolean videoHwAc
celeration) { | |
61 ContextUtils.initialize(context); | |
62 nativeInitializeAndroidGlobals(context, videoHwAcceleration); | |
63 } | |
64 | 57 |
65 // Older signature of initializeAndroidGlobals. The extra parameters are now m
eaningless. | 58 // Older signature of initializeAndroidGlobals. The extra parameters are now m
eaningless. |
66 @Deprecated | 59 @Deprecated |
67 public static boolean initializeAndroidGlobals(Object context, boolean initial
izeAudio, | 60 public static boolean initializeAndroidGlobals(Object context, boolean initial
izeAudio, |
68 boolean initializeVideo, boolean videoHwAcceleration) { | 61 boolean initializeVideo, boolean videoHwAcceleration) { |
69 initializeAndroidGlobals((Context) context, videoHwAcceleration); | 62 initializeAndroidGlobals((android.content.Context) context, videoHwAccelerat
ion); |
70 return true; | 63 return true; |
71 } | 64 } |
72 | 65 |
73 // Field trial initialization. Must be called before PeerConnectionFactory | 66 // Field trial initialization. Must be called before PeerConnectionFactory |
74 // is created. | 67 // is created. |
75 public static native void initializeFieldTrials(String fieldTrialsInitString); | 68 public static native void initializeFieldTrials(String fieldTrialsInitString); |
76 // Wrapper of webrtc::field_trial::FindFullName. Develop the feature with defa
ult behaviour off. | 69 // Wrapper of webrtc::field_trial::FindFullName. Develop the feature with defa
ult behaviour off. |
77 // Example usage: | 70 // Example usage: |
78 // if (PeerConnectionFactory.fieldTrialsFindFullName("WebRTCExperiment").equal
s("Enabled")) { | 71 // if (PeerConnectionFactory.fieldTrialsFindFullName("WebRTCExperiment").equal
s("Enabled")) { |
79 // method1(); | 72 // method1(); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 269 |
277 @Deprecated public native void nativeSetOptions(long nativeFactory, Options op
tions); | 270 @Deprecated public native void nativeSetOptions(long nativeFactory, Options op
tions); |
278 | 271 |
279 private static native void nativeSetVideoHwAccelerationOptions( | 272 private static native void nativeSetVideoHwAccelerationOptions( |
280 long nativeFactory, Object localEGLContext, Object remoteEGLContext); | 273 long nativeFactory, Object localEGLContext, Object remoteEGLContext); |
281 | 274 |
282 private static native void nativeThreadsCallbacks(long nativeFactory); | 275 private static native void nativeThreadsCallbacks(long nativeFactory); |
283 | 276 |
284 private static native void nativeFreeFactory(long nativeFactory); | 277 private static native void nativeFreeFactory(long nativeFactory); |
285 } | 278 } |
OLD | NEW |