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 | 11 |
12 package org.webrtc; | 12 package org.webrtc; |
13 | 13 |
14 import java.util.List; | 14 import java.util.List; |
15 | 15 |
16 /** | 16 /** |
17 * Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to | 17 * Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to |
18 * the PeerConnection API for clients. | 18 * the PeerConnection API for clients. |
19 */ | 19 */ |
20 public class PeerConnectionFactory { | 20 public class PeerConnectionFactory { |
21 static { | 21 static { |
22 System.loadLibrary("jingle_peerconnection_so"); | 22 System.loadLibrary("jingle_peerconnection_so"); |
23 } | 23 } |
24 | 24 |
25 private static final String TAG = "PeerConnectionFactory"; | 25 private static final String TAG = "PeerConnectionFactory"; |
26 private final long nativeFactory; | 26 private final long nativeFactory; |
| 27 private static Thread networkThread; |
27 private static Thread workerThread; | 28 private static Thread workerThread; |
28 private static Thread signalingThread; | 29 private static Thread signalingThread; |
29 private EglBase localEglbase; | 30 private EglBase localEglbase; |
30 private EglBase remoteEglbase; | 31 private EglBase remoteEglbase; |
31 | 32 |
32 public static class Options { | 33 public static class Options { |
33 // Keep in sync with webrtc/base/network.h! | 34 // Keep in sync with webrtc/base/network.h! |
34 static final int ADAPTER_TYPE_UNKNOWN = 0; | 35 static final int ADAPTER_TYPE_UNKNOWN = 0; |
35 static final int ADAPTER_TYPE_ETHERNET = 1 << 0; | 36 static final int ADAPTER_TYPE_ETHERNET = 1 << 0; |
36 static final int ADAPTER_TYPE_WIFI = 1 << 1; | 37 static final int ADAPTER_TYPE_WIFI = 1 << 1; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 remoteEglbase.release(); | 192 remoteEglbase.release(); |
192 } | 193 } |
193 localEglbase = EglBase.create(localEglContext); | 194 localEglbase = EglBase.create(localEglContext); |
194 remoteEglbase = EglBase.create(remoteEglContext); | 195 remoteEglbase = EglBase.create(remoteEglContext); |
195 nativeSetVideoHwAccelerationOptions(nativeFactory, localEglbase.getEglBaseCo
ntext(), | 196 nativeSetVideoHwAccelerationOptions(nativeFactory, localEglbase.getEglBaseCo
ntext(), |
196 remoteEglbase.getEglBaseContext()); | 197 remoteEglbase.getEglBaseContext()); |
197 } | 198 } |
198 | 199 |
199 public void dispose() { | 200 public void dispose() { |
200 nativeFreeFactory(nativeFactory); | 201 nativeFreeFactory(nativeFactory); |
| 202 networkThread = null; |
| 203 workerThread = null; |
201 signalingThread = null; | 204 signalingThread = null; |
202 workerThread = null; | |
203 if (localEglbase != null) | 205 if (localEglbase != null) |
204 localEglbase.release(); | 206 localEglbase.release(); |
205 if (remoteEglbase != null) | 207 if (remoteEglbase != null) |
206 remoteEglbase.release(); | 208 remoteEglbase.release(); |
207 } | 209 } |
208 | 210 |
209 public void threadsCallbacks() { | 211 public void threadsCallbacks() { |
210 nativeThreadsCallbacks(nativeFactory); | 212 nativeThreadsCallbacks(nativeFactory); |
211 } | 213 } |
212 | 214 |
213 private static void printStackTrace(Thread thread, String threadName) { | 215 private static void printStackTrace(Thread thread, String threadName) { |
214 if (thread != null) { | 216 if (thread != null) { |
215 StackTraceElement[] stackTraces = thread.getStackTrace(); | 217 StackTraceElement[] stackTraces = thread.getStackTrace(); |
216 if (stackTraces.length > 0) { | 218 if (stackTraces.length > 0) { |
217 Logging.d(TAG, threadName + " stacks trace:"); | 219 Logging.d(TAG, threadName + " stacks trace:"); |
218 for (StackTraceElement stackTrace : stackTraces) { | 220 for (StackTraceElement stackTrace : stackTraces) { |
219 Logging.d(TAG, stackTrace.toString()); | 221 Logging.d(TAG, stackTrace.toString()); |
220 } | 222 } |
221 } | 223 } |
222 } | 224 } |
223 } | 225 } |
224 | 226 |
225 public static void printStackTraces() { | 227 public static void printStackTraces() { |
| 228 printStackTrace(networkThread, "Network thread"); |
226 printStackTrace(workerThread, "Worker thread"); | 229 printStackTrace(workerThread, "Worker thread"); |
227 printStackTrace(signalingThread, "Signaling thread"); | 230 printStackTrace(signalingThread, "Signaling thread"); |
228 } | 231 } |
229 | 232 |
| 233 private static void onNetworkThreadReady() { |
| 234 networkThread = Thread.currentThread(); |
| 235 Logging.d(TAG, "onNetworkThreadReady"); |
| 236 } |
| 237 |
230 private static void onWorkerThreadReady() { | 238 private static void onWorkerThreadReady() { |
231 workerThread = Thread.currentThread(); | 239 workerThread = Thread.currentThread(); |
232 Logging.d(TAG, "onWorkerThreadReady"); | 240 Logging.d(TAG, "onWorkerThreadReady"); |
233 } | 241 } |
234 | 242 |
235 private static void onSignalingThreadReady() { | 243 private static void onSignalingThreadReady() { |
236 signalingThread = Thread.currentThread(); | 244 signalingThread = Thread.currentThread(); |
237 Logging.d(TAG, "onSignalingThreadReady"); | 245 Logging.d(TAG, "onSignalingThreadReady"); |
238 } | 246 } |
239 | 247 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 @Deprecated | 284 @Deprecated |
277 public native void nativeSetOptions(long nativeFactory, Options options); | 285 public native void nativeSetOptions(long nativeFactory, Options options); |
278 | 286 |
279 private static native void nativeSetVideoHwAccelerationOptions( | 287 private static native void nativeSetVideoHwAccelerationOptions( |
280 long nativeFactory, Object localEGLContext, Object remoteEGLContext); | 288 long nativeFactory, Object localEGLContext, Object remoteEGLContext); |
281 | 289 |
282 private static native void nativeThreadsCallbacks(long nativeFactory); | 290 private static native void nativeThreadsCallbacks(long nativeFactory); |
283 | 291 |
284 private static native void nativeFreeFactory(long nativeFactory); | 292 private static native void nativeFreeFactory(long nativeFactory); |
285 } | 293 } |
OLD | NEW |