| 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 | |
| 12 package org.webrtc; | 11 package org.webrtc; |
| 13 | 12 |
| 14 import java.util.Collections; | 13 import java.util.Collections; |
| 15 import java.util.LinkedList; | 14 import java.util.LinkedList; |
| 16 import java.util.List; | 15 import java.util.List; |
| 17 | 16 |
| 18 /** | 17 /** |
| 19 * Java-land version of the PeerConnection APIs; wraps the C++ API | 18 * Java-land version of the PeerConnection APIs; wraps the C++ API |
| 20 * http://www.webrtc.org/reference/native-apis, which in turn is inspired by the | 19 * http://www.webrtc.org/reference/native-apis, which in turn is inspired by the |
| 21 * JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and | 20 * JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and |
| 22 * http://www.w3.org/TR/mediacapture-streams/ | 21 * http://www.w3.org/TR/mediacapture-streams/ |
| 23 */ | 22 */ |
| 24 public class PeerConnection { | 23 public class PeerConnection { |
| 25 static { | 24 static { |
| 26 System.loadLibrary("jingle_peerconnection_so"); | 25 System.loadLibrary("jingle_peerconnection_so"); |
| 27 } | 26 } |
| 28 | 27 |
| 29 /** Tracks PeerConnectionInterface::IceGatheringState */ | 28 /** Tracks PeerConnectionInterface::IceGatheringState */ |
| 30 public enum IceGatheringState { NEW, GATHERING, COMPLETE }; | 29 public enum IceGatheringState { NEW, GATHERING, COMPLETE } |
| 31 | |
| 32 | 30 |
| 33 /** Tracks PeerConnectionInterface::IceConnectionState */ | 31 /** Tracks PeerConnectionInterface::IceConnectionState */ |
| 34 public enum IceConnectionState { | 32 public enum IceConnectionState { |
| 35 NEW, CHECKING, CONNECTED, COMPLETED, FAILED, DISCONNECTED, CLOSED | 33 NEW, |
| 36 }; | 34 CHECKING, |
| 35 CONNECTED, |
| 36 COMPLETED, |
| 37 FAILED, |
| 38 DISCONNECTED, |
| 39 CLOSED |
| 40 } |
| 37 | 41 |
| 38 /** Tracks PeerConnectionInterface::SignalingState */ | 42 /** Tracks PeerConnectionInterface::SignalingState */ |
| 39 public enum SignalingState { | 43 public enum SignalingState { |
| 40 STABLE, HAVE_LOCAL_OFFER, HAVE_LOCAL_PRANSWER, HAVE_REMOTE_OFFER, | 44 STABLE, |
| 41 HAVE_REMOTE_PRANSWER, CLOSED | 45 HAVE_LOCAL_OFFER, |
| 42 }; | 46 HAVE_LOCAL_PRANSWER, |
| 47 HAVE_REMOTE_OFFER, |
| 48 HAVE_REMOTE_PRANSWER, |
| 49 CLOSED |
| 50 } |
| 43 | 51 |
| 44 /** Java version of PeerConnectionObserver. */ | 52 /** Java version of PeerConnectionObserver. */ |
| 45 public static interface Observer { | 53 public static interface Observer { |
| 46 /** Triggered when the SignalingState changes. */ | 54 /** Triggered when the SignalingState changes. */ |
| 47 public void onSignalingChange(SignalingState newState); | 55 public void onSignalingChange(SignalingState newState); |
| 48 | 56 |
| 49 /** Triggered when the IceConnectionState changes. */ | 57 /** Triggered when the IceConnectionState changes. */ |
| 50 public void onIceConnectionChange(IceConnectionState newState); | 58 public void onIceConnectionChange(IceConnectionState newState); |
| 51 | 59 |
| 52 /** Triggered when the ICE connection receiving status changes. */ | 60 /** Triggered when the ICE connection receiving status changes. */ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 this.username = username; | 98 this.username = username; |
| 91 this.password = password; | 99 this.password = password; |
| 92 } | 100 } |
| 93 | 101 |
| 94 public String toString() { | 102 public String toString() { |
| 95 return uri + "[" + username + ":" + password + "]"; | 103 return uri + "[" + username + ":" + password + "]"; |
| 96 } | 104 } |
| 97 } | 105 } |
| 98 | 106 |
| 99 /** Java version of PeerConnectionInterface.IceTransportsType */ | 107 /** Java version of PeerConnectionInterface.IceTransportsType */ |
| 100 public enum IceTransportsType { | 108 public enum IceTransportsType { NONE, RELAY, NOHOST, ALL } |
| 101 NONE, RELAY, NOHOST, ALL | |
| 102 }; | |
| 103 | 109 |
| 104 /** Java version of PeerConnectionInterface.BundlePolicy */ | 110 /** Java version of PeerConnectionInterface.BundlePolicy */ |
| 105 public enum BundlePolicy { | 111 public enum BundlePolicy { BALANCED, MAXBUNDLE, MAXCOMPAT } |
| 106 BALANCED, MAXBUNDLE, MAXCOMPAT | |
| 107 }; | |
| 108 | 112 |
| 109 /** Java version of PeerConnectionInterface.RtcpMuxPolicy */ | 113 /** Java version of PeerConnectionInterface.RtcpMuxPolicy */ |
| 110 public enum RtcpMuxPolicy { | 114 public enum RtcpMuxPolicy { NEGOTIATE, REQUIRE } |
| 111 NEGOTIATE, REQUIRE | |
| 112 }; | |
| 113 | 115 |
| 114 /** Java version of PeerConnectionInterface.TcpCandidatePolicy */ | 116 /** Java version of PeerConnectionInterface.TcpCandidatePolicy */ |
| 115 public enum TcpCandidatePolicy { | 117 public enum TcpCandidatePolicy { ENABLED, DISABLED } |
| 116 ENABLED, DISABLED | |
| 117 }; | |
| 118 | 118 |
| 119 /** Java version of PeerConnectionInterface.CandidateNetworkPolicy */ | 119 /** Java version of PeerConnectionInterface.CandidateNetworkPolicy */ |
| 120 public enum CandidateNetworkPolicy { | 120 public enum CandidateNetworkPolicy { ALL, LOW_COST } |
| 121 ALL, LOW_COST | |
| 122 }; | |
| 123 | 121 |
| 124 /** Java version of rtc::KeyType */ | 122 /** Java version of rtc::KeyType */ |
| 125 public enum KeyType { | 123 public enum KeyType { RSA, ECDSA } |
| 126 RSA, ECDSA | |
| 127 } | |
| 128 | 124 |
| 129 /** Java version of PeerConnectionInterface.ContinualGatheringPolicy */ | 125 /** Java version of PeerConnectionInterface.ContinualGatheringPolicy */ |
| 130 public enum ContinualGatheringPolicy { | 126 public enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY } |
| 131 GATHER_ONCE, GATHER_CONTINUALLY | |
| 132 } | |
| 133 | 127 |
| 134 /** Java version of PeerConnectionInterface.RTCConfiguration */ | 128 /** Java version of PeerConnectionInterface.RTCConfiguration */ |
| 135 public static class RTCConfiguration { | 129 public static class RTCConfiguration { |
| 136 public IceTransportsType iceTransportsType; | 130 public IceTransportsType iceTransportsType; |
| 137 public List<IceServer> iceServers; | 131 public List<IceServer> iceServers; |
| 138 public BundlePolicy bundlePolicy; | 132 public BundlePolicy bundlePolicy; |
| 139 public RtcpMuxPolicy rtcpMuxPolicy; | 133 public RtcpMuxPolicy rtcpMuxPolicy; |
| 140 public TcpCandidatePolicy tcpCandidatePolicy; | 134 public TcpCandidatePolicy tcpCandidatePolicy; |
| 141 public CandidateNetworkPolicy candidateNetworkPolicy; | 135 public CandidateNetworkPolicy candidateNetworkPolicy; |
| 142 public int audioJitterBufferMaxPackets; | 136 public int audioJitterBufferMaxPackets; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 localStreams = new LinkedList<MediaStream>(); | 174 localStreams = new LinkedList<MediaStream>(); |
| 181 senders = new LinkedList<RtpSender>(); | 175 senders = new LinkedList<RtpSender>(); |
| 182 receivers = new LinkedList<RtpReceiver>(); | 176 receivers = new LinkedList<RtpReceiver>(); |
| 183 } | 177 } |
| 184 | 178 |
| 185 // JsepInterface. | 179 // JsepInterface. |
| 186 public native SessionDescription getLocalDescription(); | 180 public native SessionDescription getLocalDescription(); |
| 187 | 181 |
| 188 public native SessionDescription getRemoteDescription(); | 182 public native SessionDescription getRemoteDescription(); |
| 189 | 183 |
| 190 public native DataChannel createDataChannel( | 184 public native DataChannel createDataChannel(String label, DataChannel.Init ini
t); |
| 191 String label, DataChannel.Init init); | |
| 192 | 185 |
| 193 public native void createOffer( | 186 public native void createOffer(SdpObserver observer, MediaConstraints constrai
nts); |
| 194 SdpObserver observer, MediaConstraints constraints); | |
| 195 | 187 |
| 196 public native void createAnswer( | 188 public native void createAnswer(SdpObserver observer, MediaConstraints constra
ints); |
| 197 SdpObserver observer, MediaConstraints constraints); | |
| 198 | 189 |
| 199 public native void setLocalDescription( | 190 public native void setLocalDescription(SdpObserver observer, SessionDescriptio
n sdp); |
| 200 SdpObserver observer, SessionDescription sdp); | |
| 201 | 191 |
| 202 public native void setRemoteDescription( | 192 public native void setRemoteDescription(SdpObserver observer, SessionDescripti
on sdp); |
| 203 SdpObserver observer, SessionDescription sdp); | |
| 204 | 193 |
| 205 public native boolean setConfiguration(RTCConfiguration config); | 194 public native boolean setConfiguration(RTCConfiguration config); |
| 206 | 195 |
| 207 public boolean addIceCandidate(IceCandidate candidate) { | 196 public boolean addIceCandidate(IceCandidate candidate) { |
| 208 return nativeAddIceCandidate( | 197 return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, cand
idate.sdp); |
| 209 candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp); | |
| 210 } | 198 } |
| 211 | 199 |
| 212 public boolean removeIceCandidates(final IceCandidate[] candidates) { | 200 public boolean removeIceCandidates(final IceCandidate[] candidates) { |
| 213 return nativeRemoveIceCandidates(candidates); | 201 return nativeRemoveIceCandidates(candidates); |
| 214 } | 202 } |
| 215 | 203 |
| 216 public boolean addStream(MediaStream stream) { | 204 public boolean addStream(MediaStream stream) { |
| 217 boolean ret = nativeAddLocalStream(stream.nativeStream); | 205 boolean ret = nativeAddLocalStream(stream.nativeStream); |
| 218 if (!ret) { | 206 if (!ret) { |
| 219 return false; | 207 return false; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 295 |
| 308 private native boolean nativeAddIceCandidate( | 296 private native boolean nativeAddIceCandidate( |
| 309 String sdpMid, int sdpMLineIndex, String iceCandidateSdp); | 297 String sdpMid, int sdpMLineIndex, String iceCandidateSdp); |
| 310 | 298 |
| 311 private native boolean nativeRemoveIceCandidates(final IceCandidate[] candidat
es); | 299 private native boolean nativeRemoveIceCandidates(final IceCandidate[] candidat
es); |
| 312 | 300 |
| 313 private native boolean nativeAddLocalStream(long nativeStream); | 301 private native boolean nativeAddLocalStream(long nativeStream); |
| 314 | 302 |
| 315 private native void nativeRemoveLocalStream(long nativeStream); | 303 private native void nativeRemoveLocalStream(long nativeStream); |
| 316 | 304 |
| 317 private native boolean nativeGetStats( | 305 private native boolean nativeGetStats(StatsObserver observer, long nativeTrack
); |
| 318 StatsObserver observer, long nativeTrack); | |
| 319 | 306 |
| 320 private native RtpSender nativeCreateSender(String kind, String stream_id); | 307 private native RtpSender nativeCreateSender(String kind, String stream_id); |
| 321 | 308 |
| 322 private native List<RtpSender> nativeGetSenders(); | 309 private native List<RtpSender> nativeGetSenders(); |
| 323 | 310 |
| 324 private native List<RtpReceiver> nativeGetReceivers(); | 311 private native List<RtpReceiver> nativeGetReceivers(); |
| 325 | 312 |
| 326 private native boolean nativeStartRtcEventLog( | 313 private native boolean nativeStartRtcEventLog(int file_descriptor, int max_siz
e_bytes); |
| 327 int file_descriptor, int max_size_bytes); | |
| 328 | 314 |
| 329 private native void nativeStopRtcEventLog(); | 315 private native void nativeStopRtcEventLog(); |
| 330 | |
| 331 } | 316 } |
| OLD | NEW |