我必须在android应用程序中实现WebRTC,因为我使用的是libjingle库,版本为11139.在这里我总是得到pc(PeerConnection class instance)总是空的.我检查过的值
factory(PeerConnectionFactory)
iceServers(LinkedList<IceServers>
mediaConstraints
Peer.this(PCObserver interface))
Run Code Online (Sandbox Code Playgroud)
但他们都不是空的.那么为什么我总是得到结果null.我在这里做错了吗???
pc = factory.createPeerConnection(iceServers, mediaConstraints, Peer.this);
Run Code Online (Sandbox Code Playgroud)
编辑:
public CallManager(TagoveApplication context, CustomSocket server, CallType callType) {
this.server = server;
this.context = context;
initializeFactoryFieldTrials(); //initialize peer conn factory field trials
PeerConnectionFactory.initializeAndroidGlobals(context, true, true, true);
//PeerConnectionFactory.initializeAndroidGlobals(context, true, true, true, VideoRendererGui.getEGLContext());
factory = new PeerConnectionFactory();
iceServers.add(new PeerConnection.IceServer("turn:xxx.xxx.xxx.xxx:xxxx?transport=udp", "xxxxxxxx", "xxxxxxxxx"));
iceServers.add(new PeerConnection.IceServer("stun:stunserver.org"));
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"));
pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));
pcConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")); …Run Code Online (Sandbox Code Playgroud)