OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 /** | 33 /** |
34 * Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to | 34 * Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to |
35 * the PeerConnection API for clients. | 35 * the PeerConnection API for clients. |
36 */ | 36 */ |
37 public class PeerConnectionFactory { | 37 public class PeerConnectionFactory { |
38 static { | 38 static { |
39 System.loadLibrary("jingle_peerconnection_so"); | 39 System.loadLibrary("jingle_peerconnection_so"); |
40 } | 40 } |
41 | 41 |
| 42 private static final String TAG = "PeerConnectionFactory"; |
42 private final long nativeFactory; | 43 private final long nativeFactory; |
| 44 private static Thread workerThread; |
| 45 private static Thread signalingThread; |
43 | 46 |
44 public static class Options { | 47 public static class Options { |
45 // Keep in sync with webrtc/base/network.h! | 48 // Keep in sync with webrtc/base/network.h! |
46 static final int ADAPTER_TYPE_UNKNOWN = 0; | 49 static final int ADAPTER_TYPE_UNKNOWN = 0; |
47 static final int ADAPTER_TYPE_ETHERNET = 1 << 0; | 50 static final int ADAPTER_TYPE_ETHERNET = 1 << 0; |
48 static final int ADAPTER_TYPE_WIFI = 1 << 1; | 51 static final int ADAPTER_TYPE_WIFI = 1 << 1; |
49 static final int ADAPTER_TYPE_CELLULAR = 1 << 2; | 52 static final int ADAPTER_TYPE_CELLULAR = 1 << 2; |
50 static final int ADAPTER_TYPE_VPN = 1 << 3; | 53 static final int ADAPTER_TYPE_VPN = 1 << 3; |
51 static final int ADAPTER_TYPE_LOOPBACK = 1 << 4; | 54 static final int ADAPTER_TYPE_LOOPBACK = 1 << 4; |
52 | 55 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 132 |
130 public void setOptions(Options options) { | 133 public void setOptions(Options options) { |
131 nativeSetOptions(nativeFactory, options); | 134 nativeSetOptions(nativeFactory, options); |
132 } | 135 } |
133 | 136 |
134 public void setVideoHwAccelerationOptions(Object renderEGLContext) { | 137 public void setVideoHwAccelerationOptions(Object renderEGLContext) { |
135 nativeSetVideoHwAccelerationOptions(nativeFactory, renderEGLContext); | 138 nativeSetVideoHwAccelerationOptions(nativeFactory, renderEGLContext); |
136 } | 139 } |
137 | 140 |
138 public void dispose() { | 141 public void dispose() { |
139 freeFactory(nativeFactory); | 142 nativeFreeFactory(nativeFactory); |
| 143 signalingThread = null; |
| 144 workerThread = null; |
| 145 } |
| 146 |
| 147 public void threadsCallbacks() { |
| 148 nativeThreadsCallbacks(nativeFactory); |
| 149 } |
| 150 |
| 151 public static void printStackTraces() { |
| 152 if (workerThread != null) { |
| 153 Logging.d(TAG, "Worker thread stacks trace:"); |
| 154 for (StackTraceElement stackTrace : workerThread.getStackTrace()) { |
| 155 Logging.d(TAG, stackTrace.toString()); |
| 156 } |
| 157 } |
| 158 if (signalingThread != null) { |
| 159 Logging.d(TAG, "Signaling thread stacks trace:"); |
| 160 for (StackTraceElement stackTrace : signalingThread.getStackTrace()) { |
| 161 Logging.d(TAG, stackTrace.toString()); |
| 162 } |
| 163 } |
| 164 } |
| 165 |
| 166 private static void onWorkerThreadReady() { |
| 167 workerThread = Thread.currentThread(); |
| 168 Logging.d(TAG, "onWorkerThreadReady"); |
| 169 } |
| 170 |
| 171 private static void onSignalingThreadReady() { |
| 172 signalingThread = Thread.currentThread(); |
| 173 Logging.d(TAG, "onSignalingThreadReady"); |
140 } | 174 } |
141 | 175 |
142 private static native long nativeCreatePeerConnectionFactory(); | 176 private static native long nativeCreatePeerConnectionFactory(); |
143 | 177 |
144 private static native long nativeCreateObserver( | 178 private static native long nativeCreateObserver( |
145 PeerConnection.Observer observer); | 179 PeerConnection.Observer observer); |
146 | 180 |
147 private static native long nativeCreatePeerConnection( | 181 private static native long nativeCreatePeerConnection( |
148 long nativeFactory, PeerConnection.RTCConfiguration rtcConfig, | 182 long nativeFactory, PeerConnection.RTCConfiguration rtcConfig, |
149 MediaConstraints constraints, long nativeObserver); | 183 MediaConstraints constraints, long nativeObserver); |
(...skipping 12 matching lines...) Expand all Loading... |
162 long nativeFactory, MediaConstraints constraints); | 196 long nativeFactory, MediaConstraints constraints); |
163 | 197 |
164 private static native long nativeCreateAudioTrack( | 198 private static native long nativeCreateAudioTrack( |
165 long nativeFactory, String id, long nativeSource); | 199 long nativeFactory, String id, long nativeSource); |
166 | 200 |
167 public native void nativeSetOptions(long nativeFactory, Options options); | 201 public native void nativeSetOptions(long nativeFactory, Options options); |
168 | 202 |
169 private static native void nativeSetVideoHwAccelerationOptions( | 203 private static native void nativeSetVideoHwAccelerationOptions( |
170 long nativeFactory, Object renderEGLContext); | 204 long nativeFactory, Object renderEGLContext); |
171 | 205 |
172 private static native void freeFactory(long nativeFactory); | 206 private static native void nativeThreadsCallbacks(long nativeFactory); |
| 207 |
| 208 private static native void nativeFreeFactory(long nativeFactory); |
173 } | 209 } |
OLD | NEW |