本文整理汇总了Java中org.webrtc.PeerConnection.IceServer方法的典型用法代码示例。如果您正苦于以下问题:Java PeerConnection.IceServer方法的具体用法?Java PeerConnection.IceServer怎么用?Java PeerConnection.IceServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.webrtc.PeerConnection
的用法示例。
在下文中一共展示了PeerConnection.IceServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iceServersFromPCConfigJSON
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
private LinkedList<PeerConnection.IceServer> iceServersFromPCConfigJSON(String pcConfig)
throws JSONException {
JSONObject json = new JSONObject(pcConfig);
JSONArray servers = json.getJSONArray("iceServers");
LinkedList<PeerConnection.IceServer> ret = new LinkedList<PeerConnection.IceServer>();
for (int i = 0; i < servers.length(); ++i) {
JSONObject server = servers.getJSONObject(i);
String url = server.getString("urls");
String credential = server.has("credential") ? server.getString("credential") : "";
PeerConnection.IceServer turnServer =
PeerConnection.IceServer.builder(url)
.setPassword(credential)
.createIceServer();
ret.add(turnServer);
}
return ret;
}
示例2: onTCPConnected
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
/**
* If the client is the server side, this will trigger onConnectedToRoom.
*/
@Override
public void onTCPConnected(boolean isServer) {
if (isServer) {
roomState = ConnectionState.CONNECTED;
SignalingParameters parameters = new SignalingParameters(
// Ice servers are not needed for direct connections.
new LinkedList<PeerConnection.IceServer>(),
isServer, // Server side acts as the initiator on direct connections.
null, // clientId
null, // wssUrl
null, // wwsPostUrl
null, // offerSdp
null // iceCandidates
);
events.onConnectedToRoom(parameters);
}
}
示例3: onTCPConnected
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
/**
* If the client is the server side, this will trigger onConnectedToRoom.
*/
@Override
public void onTCPConnected(boolean isServer) {
if (isServer) {
roomState = ConnectionState.CONNECTED;
SignalingParameters parameters = new SignalingParameters(
// Ice servers are not needed for direct connections.
new LinkedList<PeerConnection.IceServer>(),
isServer, // Server side acts as the initiator on direct connections.
null, // clientId
null, // wssUrl
null, // wwsPostUrl
null, // offerSdp
null // iceCandidates
);
events.onConnectedToRoom(parameters);
}
}
示例4: createPeerConnectionClient
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
PeerConnectionClient createPeerConnectionClient(MockRenderer localRenderer,
MockRenderer remoteRenderer, PeerConnectionParameters peerConnectionParameters,
VideoCapturer videoCapturer, EglBase.Context eglContext) {
List<PeerConnection.IceServer> iceServers = new LinkedList<PeerConnection.IceServer>();
SignalingParameters signalingParameters =
new SignalingParameters(iceServers, true, // iceServers, initiator.
null, null, null, // clientId, wssUrl, wssPostUrl.
null, null); // offerSdp, iceCandidates.
PeerConnectionClient client = PeerConnectionClient.getInstance();
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
options.networkIgnoreMask = 0;
options.disableNetworkMonitor = true;
client.setPeerConnectionFactoryOptions(options);
client.createPeerConnectionFactory(
InstrumentationRegistry.getTargetContext(), peerConnectionParameters, this);
client.createPeerConnection(
eglContext, localRenderer, remoteRenderer, videoCapturer, signalingParameters);
client.createOffer();
return client;
}
示例5: WebRTC
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
WebRTC(WebRTCTask task, MainActivity activity) {
this.task = task;
this.activity = activity;
// Initialize Android globals
// See https://bugs.chromium.org/p/webrtc/issues/detail?id=3416
PeerConnectionFactory.initializeAndroidGlobals(activity, false);
// Set ICE servers
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
iceServers.add(new org.webrtc.PeerConnection.IceServer("stun:" + Config.STUN_SERVER));
if (Config.TURN_SERVER != null) {
iceServers.add(new org.webrtc.PeerConnection.IceServer("turn:" + Config.TURN_SERVER,
Config.TURN_USER, Config.TURN_PASS));
}
// Create peer connection
final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
this.factory = new PeerConnectionFactory(options);
this.constraints = new MediaConstraints();
this.pc = this.factory.createPeerConnection(iceServers, constraints, new PeerConnectionObserver());
// Add task message event handler
this.task.setMessageHandler(new TaskMessageHandler());
}
示例6: commonConstructor
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
/**
* Common constructor logic
*
* @param channel The signaling channel to use for the call
*/
private void commonConstructor(RespokeSignalingChannel channel) {
signalingChannel = channel;
iceServers = new ArrayList<PeerConnection.IceServer>();
queuedLocalCandidates = new ArrayList<IceCandidate>();
queuedRemoteCandidates = new ArrayList<IceCandidate>();
collectedLocalCandidates = new ArrayList<IceCandidate>();
sessionID = Respoke.makeGUID();
timestamp = new Date();
queuedRemoteCandidatesSemaphore = new Semaphore(1); // remote candidates queue mutex
localCandidatesSemaphore = new Semaphore(1); // local candidates queue mutex
if (null != signalingChannel) {
RespokeSignalingChannel.Listener signalingChannelListener = signalingChannel.GetListener();
if (null != signalingChannelListener) {
signalingChannelListener.callCreated(this);
}
}
//TODO resign active handler?
}
示例7: iceServersFromPCConfigJSON
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
private LinkedList<PeerConnection.IceServer> iceServersFromPCConfigJSON(
String pcConfig) {
try {
JSONObject json = new JSONObject(pcConfig);
JSONArray servers = json.getJSONArray("iceServers");
LinkedList<PeerConnection.IceServer> ret =
new LinkedList<PeerConnection.IceServer>();
for (int i = 0; i < servers.length(); ++i) {
JSONObject server = servers.getJSONObject(i);
String url = server.getString("urls");
String credential =
server.has("credential") ? server.getString("credential") : "";
ret.add(new PeerConnection.IceServer(url, "", credential));
}
return ret;
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
示例8: SignalingParameters
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
public SignalingParameters(
List<PeerConnection.IceServer> iceServers,
boolean initiator,
String clientId,
String sipUrl,
String wssPostUrl,
SessionDescription offerSdp,
List<IceCandidate> iceCandidates,
HashMap<String, String> sipHeaders,
boolean videoEnabled)
{
this.iceServers = iceServers;
this.initiator = initiator;
this.clientId = clientId;
this.sipUrl = sipUrl;
this.wssPostUrl = wssPostUrl;
this.offerSdp = offerSdp;
this.answerSdp = null;
this.iceCandidates = iceCandidates;
this.sipHeaders = sipHeaders;
this.videoEnabled = videoEnabled;
//this.answerIceCandidates = null;
}
示例9: external2InternalIceServer
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
private PeerConnection.IceServer external2InternalIceServer(Map<String, String> iceServer)
{
String url = "";
if (iceServer.containsKey(IceServersKeys.ICE_SERVER_URL)) {
url = iceServer.get(IceServersKeys.ICE_SERVER_URL);
}
String username = "";
if (iceServer.containsKey(IceServersKeys.ICE_SERVER_USERNAME)) {
username = iceServer.get(IceServersKeys.ICE_SERVER_USERNAME);
}
String password = "";
if (iceServer.containsKey(IceServersKeys.ICE_SERVER_PASSWORD)) {
password = iceServer.get(IceServersKeys.ICE_SERVER_PASSWORD);
}
return new PeerConnection.IceServer(url, username, password);
}
示例10: iceServersFromPCConfigJSON
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
private LinkedList<PeerConnection.IceServer> iceServersFromPCConfigJSON(
String pcConfig) {
try {
JSONObject json = new JSONObject(pcConfig);
JSONArray servers = json.getJSONArray("iceServers");
LinkedList<PeerConnection.IceServer> ret =
new LinkedList<PeerConnection.IceServer>();
for (int i = 0; i < servers.length(); ++i) {
JSONObject server = servers.getJSONObject(i);
String url = server.getString("url");
String credential =
server.has("credential") ? server.getString("credential") : "";
ret.add(new PeerConnection.IceServer(url, "", credential));
}
return ret;
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
示例11: retrieveTurnServers
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
private ListenableFutureTask<List<PeerConnection.IceServer>> retrieveTurnServers() {
Callable<List<PeerConnection.IceServer>> callable = new Callable<List<PeerConnection.IceServer>>() {
@Override
public List<PeerConnection.IceServer> call() {
LinkedList<PeerConnection.IceServer> results = new LinkedList<>();
try {
TurnServerInfo turnServerInfo = accountManager.getTurnServerInfo();
for (String url : turnServerInfo.getUrls()) {
if (url.startsWith("turn")) {
results.add(new PeerConnection.IceServer(url, turnServerInfo.getUsername(), turnServerInfo.getPassword()));
} else {
results.add(new PeerConnection.IceServer(url));
}
}
} catch (IOException e) {
Log.w(TAG, e);
}
return results;
}
};
ListenableFutureTask<List<PeerConnection.IceServer>> futureTask = new ListenableFutureTask<>(callable, null, serviceExecutor);
networkExecutor.execute(futureTask);
return futureTask;
}
示例12: PeerConnectionWrapper
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
public PeerConnectionWrapper(@NonNull Context context,
@NonNull PeerConnectionFactory factory,
@NonNull PeerConnection.Observer observer,
@NonNull VideoRenderer.Callbacks localRenderer,
@NonNull List<PeerConnection.IceServer> turnServers,
boolean hideIp)
{
List<PeerConnection.IceServer> iceServers = new LinkedList<>();
iceServers.add(STUN_SERVER);
iceServers.addAll(turnServers);
MediaConstraints constraints = new MediaConstraints();
MediaConstraints audioConstraints = new MediaConstraints();
PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(iceServers);
configuration.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE;
configuration.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE;
if (hideIp) {
configuration.iceTransportsType = PeerConnection.IceTransportsType.RELAY;
}
constraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
audioConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
this.peerConnection = factory.createPeerConnection(configuration, constraints, observer);
this.videoCapturer = createVideoCapturer(context);
MediaStream mediaStream = factory.createLocalMediaStream("ARDAMS");
this.audioSource = factory.createAudioSource(audioConstraints);
this.audioTrack = factory.createAudioTrack("ARDAMSa0", audioSource);
this.audioTrack.setEnabled(false);
mediaStream.addTrack(audioTrack);
if (videoCapturer != null) {
this.videoSource = factory.createVideoSource(videoCapturer);
this.videoTrack = factory.createVideoTrack("ARDAMSv0", videoSource);
this.videoTrack.addRenderer(new VideoRenderer(localRenderer));
this.videoTrack.setEnabled(false);
mediaStream.addTrack(videoTrack);
} else {
this.videoSource = null;
this.videoTrack = null;
}
this.peerConnection.addStream(mediaStream);
}
示例13: PnSignalingParams
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
public PnSignalingParams(
List<PeerConnection.IceServer> iceServers,
MediaConstraints pcConstraints,
MediaConstraints videoConstraints,
MediaConstraints audioConstraints) {
this.iceServers = (iceServers==null) ? defaultIceServers() : iceServers;
this.pcConstraints = (pcConstraints==null) ? defaultPcConstraints() : pcConstraints;
this.videoConstraints = (videoConstraints==null) ? defaultVideoConstraints() : videoConstraints;
this.audioConstraints = (audioConstraints==null) ? defaultAudioConstraints() : audioConstraints;
}
示例14: defaultInstance
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
/**
* The default parameters for media constraints. Might have to tweak in future.
* @return default parameters
*/
public static PnSignalingParams defaultInstance() {
MediaConstraints pcConstraints = PnSignalingParams.defaultPcConstraints();
MediaConstraints videoConstraints = PnSignalingParams.defaultVideoConstraints();
MediaConstraints audioConstraints = PnSignalingParams.defaultAudioConstraints();
List<PeerConnection.IceServer> iceServers = PnSignalingParams.defaultIceServers();
return new PnSignalingParams(iceServers, pcConstraints, videoConstraints, audioConstraints);
}
示例15: defaultIceServers
import org.webrtc.PeerConnection; //导入方法依赖的package包/类
public static List<PeerConnection.IceServer> defaultIceServers(){
List<PeerConnection.IceServer> iceServers = new ArrayList<PeerConnection.IceServer>(25);
iceServers.add(new PeerConnection.IceServer("stun:stun.l.google.com:19302"));
iceServers.add(new PeerConnection.IceServer("stun:stun.services.mozilla.com"));
iceServers.add(new PeerConnection.IceServer("turn:turn.bistri.com:80", "homeo", "homeo"));
iceServers.add(new PeerConnection.IceServer("turn:turn.anyfirewall.com:443?transport=tcp", "webrtc", "webrtc"));
// Extra Defaults - 19 STUN servers + 4 initial = 23 severs (+2 padding) = Array cap 25
iceServers.add(new PeerConnection.IceServer("stun:stun1.l.google.com:19302"));
iceServers.add(new PeerConnection.IceServer("stun:stun2.l.google.com:19302"));
iceServers.add(new PeerConnection.IceServer("stun:stun3.l.google.com:19302"));
iceServers.add(new PeerConnection.IceServer("stun:stun4.l.google.com:19302"));
iceServers.add(new PeerConnection.IceServer("stun:23.21.150.121"));
iceServers.add(new PeerConnection.IceServer("stun:stun01.sipphone.com"));
iceServers.add(new PeerConnection.IceServer("stun:stun.ekiga.net"));
iceServers.add(new PeerConnection.IceServer("stun:stun.fwdnet.net"));
iceServers.add(new PeerConnection.IceServer("stun:stun.ideasip.com"));
iceServers.add(new PeerConnection.IceServer("stun:stun.iptel.org"));
iceServers.add(new PeerConnection.IceServer("stun:stun.rixtelecom.se"));
iceServers.add(new PeerConnection.IceServer("stun:stun.schlund.de"));
iceServers.add(new PeerConnection.IceServer("stun:stunserver.org"));
iceServers.add(new PeerConnection.IceServer("stun:stun.softjoys.com"));
iceServers.add(new PeerConnection.IceServer("stun:stun.voiparound.com"));
iceServers.add(new PeerConnection.IceServer("stun:stun.voipbuster.com"));
iceServers.add(new PeerConnection.IceServer("stun:stun.voipstunt.com"));
iceServers.add(new PeerConnection.IceServer("stun:stun.voxgratia.org"));
iceServers.add(new PeerConnection.IceServer("stun:stun.xten.com"));
return iceServers;
}