Java 类org.webrtc.PeerConnection 实例源码

项目:react-native-webrtc    文件:PeerConnectionObserver.java   
@Nullable
private String signalingStateString(PeerConnection.SignalingState signalingState) {
    switch (signalingState) {
        case STABLE:
            return "stable";
        case HAVE_LOCAL_OFFER:
            return "have-local-offer";
        case HAVE_LOCAL_PRANSWER:
            return "have-local-pranswer";
        case HAVE_REMOTE_OFFER:
            return "have-remote-offer";
        case HAVE_REMOTE_PRANSWER:
            return "have-remote-pranswer";
        case CLOSED:
            return "closed";
    }
    return null;
}
项目:DeviceConnect-Android    文件:MediaConnection.java   
@Override
public void onSetSuccess() {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "@@@ onSetSuccess");
    }

    PeerConnection.SignalingState state = mPeerConnection.signalingState();
    if (state == PeerConnection.SignalingState.HAVE_REMOTE_OFFER) {
        mPeerConnection.createAnswer(this, createSDPMediaConstraints());
    } else /*if (state == PeerConnection.SignalingState.HAVE_LOCAL_OFFER)*/ {
        if (mCallback != null && mSdp != null) {
            mCallback.onLocalDescription(MediaConnection.this, mSdp);
        }
        mSdp = null;
    }
}
项目:react-native-webrtc    文件:PeerConnectionObserver.java   
@Nullable
private String iceConnectionStateString(PeerConnection.IceConnectionState iceConnectionState) {
    switch (iceConnectionState) {
        case NEW:
            return "new";
        case CHECKING:
            return "checking";
        case CONNECTED:
            return "connected";
        case COMPLETED:
            return "completed";
        case FAILED:
            return "failed";
        case DISCONNECTED:
            return "disconnected";
        case CLOSED:
            return "closed";
    }
    return null;
}
项目:nc-android-webrtcpeer    文件:PeerConnectionClient.java   
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState newState) {
    executor.execute(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "IceConnectionState: " + newState);
            if (newState == IceConnectionState.CONNECTED) {
                events.onIceConnected();
            } else if (newState == IceConnectionState.DISCONNECTED) {
                events.onIceDisconnected();
            } else if (newState == IceConnectionState.FAILED) {
                reportError("ICE connection failed.");
            }
        }
    });
}
项目:AppRTC-Android    文件:RoomParametersFetcher.java   
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;
}
项目:AppRTC-Android    文件:DirectRTCClient.java   
/**
 * 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);
  }
}
项目:AppRTC-Android    文件:PeerConnectionClient.java   
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState newState) {
  executor.execute(new Runnable() {
    @Override
    public void run() {
      Log.d(TAG, "IceConnectionState: " + newState);
      if (newState == IceConnectionState.CONNECTED) {
        events.onIceConnected();
      } else if (newState == IceConnectionState.DISCONNECTED) {
        events.onIceDisconnected();
      } else if (newState == IceConnectionState.FAILED) {
        reportError("ICE connection failed.");
      }
    }
  });
}
项目:AndroidRTC    文件:PeerConnectionClient.java   
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState newState) {
    executor.execute(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "IceConnectionState: " + newState);
            if (newState == IceConnectionState.CONNECTED) {
                events.onIceConnected();
            } else if (newState == IceConnectionState.DISCONNECTED) {
                events.onIceDisconnected();
            } else if (newState == IceConnectionState.FAILED) {
                reportError("ICE connection failed.");
            }
        }
    });
}
项目:AndroidRTC    文件:DirectRTCClient.java   
/**
 * 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);
    }
}
项目:AndroidRTC    文件:PeerConnectionClientTest.java   
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;
}
项目:saltyrtc-demo    文件:WebRTC.java   
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());
}
项目:webrtc-android    文件:PeerConnectionClient.java   
@Override
        public void onIceConnectionChange(
                final PeerConnection.IceConnectionState newState) {
//          executor.execute(new Runnable() {
//              @Override
//              public void run() {
//                  Log.d(TAG, "IceConnectionState: " + newState);
//                  if (newState == IceConnectionState.CONNECTED) {
//                      events.onIceConnected();
//                  } else if (newState == IceConnectionState.DISCONNECTED) {
//                      events.onIceDisconnected();
//                  } else if (newState == IceConnectionState.FAILED) {
//                      reportError("ICE connection failed.");
//                  }
//              }
//          });
        }
项目:webrtc-android    文件:WebRtcClient.java   
public WebRtcClient(RtcListener listener, String host, PeerConnectionClient.PeerConnectionParameters params) {
    mListener = listener;
    pcParams = params;
    PeerConnectionFactory.initializeAndroidGlobals(listener, true, true,
            params.videoCodecHwAcceleration);
    factory = new PeerConnectionFactory();
    MessageHandler messageHandler = new MessageHandler();

    try {
        client = IO.socket(host);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    client.on("id", messageHandler.onId);
    client.on("message", messageHandler.onMessage);
    client.connect();

    iceServers.add(new PeerConnection.IceServer("stun:23.21.150.121"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.l.google.com:19302"));

    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));
    pcConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
}
项目:viska-android    文件:CallingActivity.java   
@Override
public void onIceGatheringChange(@Nonnull final PeerConnection.IceGatheringState state) {
  Log.d("WebRTC", "IceGatheringState is " + state);
  if (state == PeerConnection.IceGatheringState.COMPLETE
      && peerConnection.iceConnectionState() != PeerConnection.IceConnectionState.CONNECTED
      && peerConnection.iceConnectionState() != PeerConnection.IceConnectionState.CLOSED
      && progressState.getValue() != ProgressState.ENDED) {
    progressState.changeValue(ProgressState.IDLE);
    bin.add(xmpp.subscribe(
        it -> it.getSessions().get(localJid).getPluginManager().getPlugin(WebRtcPlugin.class).sendSdp(
            remoteJid,
            id,
            peerConnection.getLocalDescription(),
            ACTION_CALL_OUTBOUND.equals(getIntent().getAction())
        ),
        CallingActivity.this::fail
    ));
  }
}
项目:viska-android    文件:Application.java   
private void initializeIceServers() {
  final Document xml;
  try {
    xml = DomUtils.readDocument(getResources().openRawResource(R.raw.ice));
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
  synchronized (iceServers) {
    iceServers.clear();
    for (Node it : DomUtils.convertToList(xml.getDocumentElement().getElementsByTagName("url"))) {
      final Element element = (Element) it;
      final PeerConnection.IceServer.Builder builder = PeerConnection.IceServer.builder(
          element.getTextContent()
      );
      final String username = element.getAttribute("username");
      if (StringUtils.isNotBlank(username)) {
        builder.setUsername(username);
      }
      final String password = element.getAttribute("password");
      if (StringUtils.isNotBlank(password)) {
        builder.setPassword(password);
      }
      iceServers.add(builder.createIceServer());
    }
  }
}
项目:DeviceConnect-Android    文件:MediaConnection.java   
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState iceConnectionState) {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "@@@ onIceConnectionChange");
        Log.d(TAG, "@@@ IceConnectionState: " + iceConnectionState.toString());
    }

    switch (iceConnectionState) {
        case FAILED:
            if (mCallback != null) {
                mCallback.onError(MediaConnection.this);
            }
            // no break;
        case DISCONNECTED:
            close();
            break;
        default:
            if (BuildConfig.DEBUG) {
                Log.d(TAG, "@@@ iceConnectionState=" + iceConnectionState);
            }
            break;
    }
}
项目:voip_android    文件:PeerConnectionClient.java   
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState newState) {
    executor.execute(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "IceConnectionState: " + newState);
            if (newState == IceConnectionState.CONNECTED) {
                events.onIceConnected();
            } else if (newState == IceConnectionState.DISCONNECTED) {
                events.onIceDisconnected();
            } else if (newState == IceConnectionState.FAILED) {
                reportError("ICE connection failed.");
            }
        }
    });
}
项目:respoke-sdk-android    文件:RespokeCall.java   
/**
 *  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?
}
项目:WebRTCDemo    文件:AppRTCClient.java   
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);
  }
}
项目:restcomm-android-sdk    文件:SignalingParameters.java   
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;
}
项目:restcomm-android-sdk    文件:PeerConnectionClient.java   
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState newState) {
  executor.execute(new Runnable() {
    @Override
    public void run() {
      Log.d(TAG, "IceConnectionState: " + newState);
      if (newState == IceConnectionState.CONNECTED) {
        events.onIceConnected();
      } else if (newState == IceConnectionState.DISCONNECTED) {
        events.onIceDisconnected();
      } else if (newState == IceConnectionState.FAILED) {
        reportError("ICE connection failed.");
      }
    }
  });
}
项目:restcomm-android-sdk    文件:RCConnection.java   
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);
}
项目:apprtc-android    文件:AppRTCClient.java   
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);
  }
}
项目:licodeAndroidClient    文件:LicodeConnector.java   
void doSubscribe(final StreamDescription stream) {
    if (stream.isLocal()) {
        return;
    }

    if (stream.getMedia() != null) {
        // already subscribed!
        triggerMediaAvailable(stream);
        return;
    }

    // Uncomment to get ALL WebRTC tracing and SENSITIVE libjingle logging.
    // NOTE: this _must_ happen while |factory| is alive!
    // Logging.enableTracing("logcat:",
    // EnumSet.of(Logging.TraceLevel.TRACE_ALL),
    // Logging.Severity.LS_SENSITIVE);

    MyPcObserver pcObs = new MyPcObserver(new LicodeSdpObserver(stream,
            false), stream);
    PeerConnection pc = sFactory.createPeerConnection(mIceServers,
            makePcConstraints(), pcObs);

    stream.initRemote(pc, pcObs.getSdpObserver());
}
项目:droidkit-webrtc    文件:AppRTCClient.java   
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);
  }
}
项目:appspotdemo-mono    文件:AppRTCClient.java   
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);
  }
}
项目:react-native-webrtc    文件:PeerConnectionObserver.java   
@Override
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
    WritableMap params = Arguments.createMap();
    params.putInt("id", id);
    params.putString("iceConnectionState", iceConnectionStateString(iceConnectionState));

    webRTCModule.sendEvent("peerConnectionIceConnectionChanged", params);
}
项目:react-native-webrtc    文件:PeerConnectionObserver.java   
@Override
public void onIceGatheringChange(PeerConnection.IceGatheringState iceGatheringState) {
    Log.d(TAG, "onIceGatheringChange" + iceGatheringState.name());
    WritableMap params = Arguments.createMap();
    params.putInt("id", id);
    params.putString("iceGatheringState", iceGatheringStateString(iceGatheringState));
    webRTCModule.sendEvent("peerConnectionIceGatheringChanged", params);
}
项目:react-native-webrtc    文件:PeerConnectionObserver.java   
@Override
public void onSignalingChange(PeerConnection.SignalingState signalingState) {
    WritableMap params = Arguments.createMap();
    params.putInt("id", id);
    params.putString("signalingState", signalingStateString(signalingState));
    webRTCModule.sendEvent("peerConnectionSignalingStateChanged", params);
}
项目:react-native-webrtc    文件:PeerConnectionObserver.java   
@Nullable
private String iceGatheringStateString(PeerConnection.IceGatheringState iceGatheringState) {
    switch (iceGatheringState) {
        case NEW:
            return "new";
        case GATHERING:
            return "gathering";
        case COMPLETE:
            return "complete";
    }
    return null;
}
项目:PeSanKita-android    文件:WebRtcCallService.java   
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;
}
项目:PeSanKita-android    文件:PeerConnectionWrapper.java   
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);
}
项目:newwebrtc    文件:PnPeerConnectionClient.java   
public void execute(String peerId, JSONObject payload) throws JSONException {
    Log.d("AICAction","AddIceCandidateAction");
    PeerConnection pc = peers.get(peerId).pc;
    if (pc.getRemoteDescription() != null) {
        IceCandidate candidate = new IceCandidate(
                payload.getString("sdpMid"),
                payload.getInt("sdpMLineIndex"),
                payload.getString("candidate")
        );
        pc.addIceCandidate(candidate);
    }
}
项目:newwebrtc    文件:PnSignalingParams.java   
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;
}
项目:newwebrtc    文件:PnSignalingParams.java   
/**
     * Default media params, but specified Ice Servers
     * @param iceServers
     */
    public PnSignalingParams(List<PeerConnection.IceServer> iceServers) {
        this.iceServers       = iceServers; //defaultIceServers();
        this.pcConstraints    = defaultPcConstraints();
        this.videoConstraints = defaultVideoConstraints();
        this.audioConstraints = defaultAudioConstraints();
//        addIceServers(iceServers);
    }
项目:newwebrtc    文件:PnSignalingParams.java   
/**
 * 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);
}
项目:newwebrtc    文件:PnSignalingParams.java   
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;
}
项目:newwebrtc    文件:PnSignalingParams.java   
/**
 * Append default servers to the end of given list and set as iceServers instance variable
 * @param iceServers List of iceServers
 */
public void addIceServers(List<PeerConnection.IceServer> iceServers){
    if(this.iceServers!=null) {
        iceServers.addAll(this.iceServers);
    }
    this.iceServers = iceServers;
}
项目:newwebrtc    文件:PnSignalingParams.java   
/**
 * Instantiate iceServers if they are not already, and add Ice Server to beginning of list.
 * @param iceServers Ice Server to add
 */
public void addIceServers(PeerConnection.IceServer iceServers){
    if (this.iceServers == null){
        this.iceServers = new ArrayList<PeerConnection.IceServer>();
    }
    this.iceServers.add(0, iceServers);
}
项目:newwebrtc    文件:PnPeer.java   
@Override
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
    if (this.status.equals(STATUS_DISCONNECTED)) return; // Already hung up on.
    if (iceConnectionState == PeerConnection.IceConnectionState.DISCONNECTED) {
        pcClient.removePeer(id); // TODO: Ponder. Also, might want to Pub a disconnect.
        setStatus(STATUS_DISCONNECTED);
    }
}