Java 类org.webrtc.PeerConnectionFactory 实例源码

项目:PeSanKita-android    文件:ApplicationContext.java   
@Override
public void onCreate() {
  super.onCreate();
  initializeRandomNumberFix();
  initializeLogging();
  initializeDependencyInjection();
  initializeJobManager();
  initializeExpiringMessageManager();
  initializeGcmCheck();
  initializeSignedPreKeyCheck();
  initializePeriodicTasks();
  initializeCircumvention();

  if (Build.VERSION.SDK_INT >= 11) {
    PeerConnectionFactory.initializeAndroidGlobals(this, true, true, true);
  }
}
项目: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;
}
项目:Cable-Android    文件:ApplicationContext.java   
private void initializeWebRtc() {
  Set<String> HARDWARE_AEC_BLACKLIST = new HashSet<String>() {{
    add("Pixel");
    add("Pixel XL");
  }};

  Set<String> OPEN_SL_ES_WHITELIST = new HashSet<String>() {{
    add("Pixel");
    add("Pixel XL");
  }};

  if (Build.VERSION.SDK_INT >= 11) {
    if (HARDWARE_AEC_BLACKLIST.contains(Build.MODEL)) {
      WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true);
    }

    if (!OPEN_SL_ES_WHITELIST.contains(Build.MODEL)) {
      WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true);
    }

    PeerConnectionFactory.initializeAndroidGlobals(this, true, true, true);
  }
}
项目: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    文件: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   
private void initializeOutboundCall() {
  id = UUID.randomUUID().toString();

  final Application application = (Application) getApplication();
  final PeerConnectionFactory factory = application.getWebRtcFactory();

  final MediaStream mediaStream = factory.createLocalMediaStream(UUID.randomUUID().toString());
  mediaStream.addTrack(factory.createAudioTrack(
          UUID.randomUUID().toString(),
          factory.createAudioSource(CONSTRAINTS)
  ));

  peerConnection = factory.createPeerConnection(
      application.getBuiltInIceServers(),
      CONSTRAINTS,
      new PeerConnectionObserver()
  );
  peerConnection.addStream(mediaStream);
  peerConnection.createOffer(sdpObserver, CONSTRAINTS);
}
项目:viska-android    文件:CallingActivity.java   
private void initializeInboundCall() {
  id = getIntent().getStringExtra(EXTRA_SESSION_ID);

  final Application application = (Application) getApplication();
  final PeerConnectionFactory factory = application.getWebRtcFactory();

  peerConnection = factory.createPeerConnection(
      application.getBuiltInIceServers(),
      CONSTRAINTS,
      new PeerConnectionObserver()
  );
  peerConnection.setRemoteDescription(
      sdpObserver,
      new SessionDescription(
          SessionDescription.Type.OFFER,
          getIntent().getStringExtra(EXTRA_REMOTE_SDP)
      )
  );
}
项目:webrtcpeer-android    文件:NBMWebRTCPeer.java   
private void createPeerConnectionFactoryInternal(Context context) {
        Log.d(TAG, "Create peer connection peerConnectionFactory. Use video: " + peerConnectionParameters.videoCallEnabled);
//        isError = false;
        // Initialize field trials.
        String field_trials = FIELD_TRIAL_AUTOMATIC_RESIZE;
        // Check if VP9 is used by default.
        if (peerConnectionParameters.videoCallEnabled && peerConnectionParameters.videoCodec != null &&
                peerConnectionParameters.videoCodec.equals(NBMMediaConfiguration.NBMVideoCodec.VP9.toString())) {
            field_trials += FIELD_TRIAL_VP9;
        }
        PeerConnectionFactory.initializeFieldTrials(field_trials);

        if (!PeerConnectionFactory.initializeAndroidGlobals(context, true, true, peerConnectionParameters.videoCodecHwAcceleration)) {
            observer.onPeerConnectionError("Failed to initializeAndroidGlobals");
        }
        peerConnectionFactory = new PeerConnectionFactory();
        // ToDo: What about these options?
//        if (options != null) {
//            Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMask);
//            peerConnectionFactory.setOptions(options);
//        }
        Log.d(TAG, "Peer connection peerConnectionFactory created.");
    }
项目:UMA-AndroidWebRTC    文件:MainActivity.java   
public void CargarLibreriaNativaWebRTC() {
    final ProgressDialog ringProgressDialog = ProgressDialog.show(MainActivity.this, "Por favor espere ...", "Mientras que se descarga la informacion del servidor ...", true);
    ringProgressDialog.setCancelable(true);

    new MainActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            try {
                // Here you should write your time consuming task...
                // Let the progress ring for 10 seconds...
                if (!factoryStaticInitialized)
                {
                    abortarSi(PeerConnectionFactory.initializeAndroidGlobals(MainActivity.this, true, true));
                    factoryStaticInitialized = true;
                    //Thread.sleep(200);

                }
            }
            catch (Exception e)
            {
                Log.i(TAG, "Error en funcion Iniciar Libreria: " + e.getMessage());
            }
            ringProgressDialog.dismiss();
        }
    });
}
项目:webrtc-workshop    文件:PeerConnectionWrapper.java   
private boolean createPeerConnection(Context context) {
    boolean success = false;

    if (PeerConnectionFactory.initializeAndroidGlobals(context)) {
        PeerConnectionFactory factory = new PeerConnectionFactory();
        List<IceServer> iceServers = new ArrayList<IceServer>();
        iceServers.add(new IceServer("stun:stun.l.google.com:19302"));
        // For TURN servers the format would be:
        // new IceServer("turn:url", user, password)

        MediaConstraints mediaConstraints = new MediaConstraints();
        mediaConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "false"));
        mediaConstraints.optional.add(new MediaConstraints.KeyValuePair("RtpDataChannels", "true"));
        peerConnection = factory.createPeerConnection(iceServers, mediaConstraints, this);

        localStream = factory.createLocalMediaStream("WEBRTC_WORKSHOP_NS");
        localStream.addTrack(factory.createAudioTrack("WEBRTC_WORKSHOP_NSa1",
                factory.createAudioSource(new MediaConstraints())));
        peerConnection.addStream(localStream, new MediaConstraints());
        success = true;
    }

    return success;
}
项目:matrix-android-sdk    文件:MXWebRtcCall.java   
/**
 * Initialize globals
 */
private static void initializeAndroidGlobals(Context context) {
    if (!mIsInitialized) {
        try {
            mIsInitialized = PeerConnectionFactory.initializeAndroidGlobals(
                    context,
                    true, // enable audio initializing
                    true, // enable video initializing
                    true  // enable hardware acceleration
            );

            PeerConnectionFactory.initializeFieldTrials(null);

            mIsSupported = true;
            Log.d(LOG_TAG, "## initializeAndroidGlobals(): mIsInitialized=" + mIsInitialized);
        } catch (Throwable e) {
            Log.e(LOG_TAG, "## initializeAndroidGlobals(): Exception Msg=" + e.getMessage());
            mIsInitialized = true;
            mIsSupported = false;
        }
    }
}
项目:PeSanKita-android    文件:WebRtcCallService.java   
private void initializeResources() {
  ApplicationContext.getInstance(this).injectDependencies(this);

  this.callState             = CallState.STATE_IDLE;
  this.lockManager           = new LockManager(this);
  this.peerConnectionFactory = new PeerConnectionFactory(new PeerConnectionFactoryOptions());
  this.audioManager          = new SignalAudioManager(this);
  this.bluetoothStateManager = new BluetoothStateManager(this, this);
  this.messageSender         = messageSenderFactory.create();
  this.messageSender.setSoTimeoutMillis(TimeUnit.SECONDS.toMillis(10));
  this.accountManager.setSoTimeoutMillis(TimeUnit.SECONDS.toMillis(10));
}
项目: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 PnPeerConnectionClient(Pubnub pubnub, PnSignalingParams signalingParams, PnRTCListener rtcListener){
    this.mPubNub = pubnub;
    this.signalingParams = signalingParams;
    this.mRtcListener = rtcListener;
    this.pcFactory = new PeerConnectionFactory(); // TODO: Check it allowed, else extra param
    this.peers = new HashMap<String, PnPeer>();
    sessionID = this.mPubNub.uuid();
    init();
}
项目:Achilles_Android    文件:MainActivity.java   
/**
 * PeerConnection factory initialization
 */
private void initPeerConnectionFactory() {
    PeerConnectionFactory.initializeAndroidGlobals(getApplicationContext(), true);
    mOptions = new PeerConnectionFactory.Options();
    mOptions.networkIgnoreMask = 0;
    mPeerConnectionFactory = new PeerConnectionFactory(mOptions);
    Log.d(TAG, "Created PeerConnectionFactory.");
    mPeerConnectionFactory.setVideoHwAccelerationOptions(
            rootEglBase.getEglBaseContext(),
            rootEglBase.getEglBaseContext()
    );
}
项目:AndroidRTC    文件:WebRtcJniBootTest.java   
@Test
@SmallTest
public void testJniLoadsWithoutError() throws InterruptedException {
  PeerConnectionFactory.initializeAndroidGlobals(InstrumentationRegistry.getTargetContext(),
      true /* initializeAudio */, true /* initializeVideo */,
      false /* videoCodecHwAcceleration */);

  PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
  new PeerConnectionFactory(options);
}
项目:Cable-Android    文件:WebRtcCallService.java   
private void initializeResources() {
  ApplicationContext.getInstance(this).injectDependencies(this);

  this.callState             = CallState.STATE_IDLE;
  this.lockManager           = new LockManager(this);
  this.peerConnectionFactory = new PeerConnectionFactory(new PeerConnectionFactoryOptions());
  this.audioManager          = new SignalAudioManager(this);
  this.bluetoothStateManager = new BluetoothStateManager(this, this);
  this.messageSender         = messageSenderFactory.create();
  this.messageSender.setSoTimeoutMillis(TimeUnit.SECONDS.toMillis(10));
  this.accountManager.setSoTimeoutMillis(TimeUnit.SECONDS.toMillis(10));
}
项目:Cable-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);
}
项目:webrtc-android-codelab    文件:MainActivity.java   
public void start() {
    start.setEnabled(false);
    call.setEnabled(true);
    //Initialize PeerConnectionFactory globals.
    //Params are context, initAudio,initVideo and videoCodecHwAcceleration
    PeerConnectionFactory.initializeAndroidGlobals(this, true, true, true);

    //Create a new PeerConnectionFactory instance.
    PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
    peerConnectionFactory = new PeerConnectionFactory(options);


    //Now create a VideoCapturer instance. Callback methods are there if you want to do something! Duh!
    VideoCapturer videoCapturerAndroid = getVideoCapturer(new CustomCameraEventsHandler());

    //Create MediaConstraints - Will be useful for specifying video and audio constraints.
    audioConstraints = new MediaConstraints();
    videoConstraints = new MediaConstraints();

    //Create a VideoSource instance
    videoSource = peerConnectionFactory.createVideoSource(videoCapturerAndroid);
    localVideoTrack = peerConnectionFactory.createVideoTrack("100", videoSource);

    //create an AudioSource instance
    audioSource = peerConnectionFactory.createAudioSource(audioConstraints);
    localAudioTrack = peerConnectionFactory.createAudioTrack("101", audioSource);
    localVideoView.setVisibility(View.VISIBLE);

    //create a videoRenderer based on SurfaceViewRenderer instance
    localRenderer = new VideoRenderer(localVideoView);
    // And finally, with our VideoRenderer ready, we
    // can add our renderer to the VideoTrack.
    localVideoTrack.addRenderer(localRenderer);

}
项目:webrtc-android    文件:WebRtcClient.java   
public WebRtcClient(RtcListener listener, String host, PeerConnectionParameters params) {
        mListener = listener;
        pcParams = params;
        PeerConnectionFactory.initializeAndroidGlobals(listener, true, true,
                params.videoCodecHwAcceleration);
        factory = new PeerConnectionFactory();
        MessageHandler messageHandler = new MessageHandler();
        Log.d(TAG, "WebRtcClient..host:" + host);
        try {
            Manager man = new Manager(new URI(host));
//            client = IO.socket(host);
            client = man.socket("/hello");

        } catch (URISyntaxException e) {
            e.printStackTrace();
            Log.d(TAG, "WebRtcClient..exception");
        }
        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   
public void onAnswerButtonClicked(final View view) {
  progressState.changeValue(ProgressState.NEGOTIATING);
  showHangButton();

  final PeerConnectionFactory factory = ((Application) getApplication()).getWebRtcFactory();
  final MediaStream stream = factory.createLocalMediaStream(UUID.randomUUID().toString());
  stream.addTrack(factory.createAudioTrack(
      UUID.randomUUID().toString(),
      factory.createAudioSource(CONSTRAINTS)
  ));
  peerConnection.addStream(stream);
  peerConnection.createAnswer(sdpObserver, new MediaConstraints());
}
项目:viska-android    文件:Application.java   
@Nonnull
public synchronized PeerConnectionFactory getWebRtcFactory() {
  if (webRtcFactory == null) {
    initializeWebRtc();
  }
  return webRtcFactory;
}
项目:DeviceConnect-Android    文件:MediaConnection.java   
/**
 * Constructor.
 * @param factory Instance of PeerConnectionFactory
 * @param option option of connection
 */
MediaConnection(final PeerConnectionFactory factory, final PeerOption option) {
    mFactory = factory;
    mOption = option;
    mConnectionId = PREFIX_MEDIA_PEERJS + PeerUtil.randomToken(16);
    createPeerConnection(createIceServerList(option.getIceServer()));
}
项目:webrtcpeer-android    文件:MediaResourceManager.java   
MediaResourceManager(NBMWebRTCPeer.NBMPeerConnectionParameters peerConnectionParameters,
                            LooperExecutor executor, PeerConnectionFactory factory){
    this.peerConnectionParameters = peerConnectionParameters;
    this.localMediaStream = null;
    this.executor = executor;
    this.factory = factory;
    renderVideo = true;
    remoteVideoTracks = new HashMap<>();
    remoteVideoRenderers = new HashMap<>();
    remoteVideoMediaStreams = new HashMap<>();
    videoCallEnabled = peerConnectionParameters.videoCallEnabled;
}
项目:webrtcpeer-android    文件:PeerConnectionResourceManager.java   
PeerConnectionResourceManager(NBMPeerConnectionParameters peerConnectionParameters,
                                     LooperExecutor executor, PeerConnectionFactory factory) {

    this.peerConnectionParameters = peerConnectionParameters;
    this.executor = executor;
    this.factory = factory;
    videoCallEnabled = peerConnectionParameters.videoCallEnabled;

    // Check if H.264 is used by default.
    preferH264 = videoCallEnabled && peerConnectionParameters.videoCodec != null && peerConnectionParameters.videoCodec.equals(NBMMediaConfiguration.NBMVideoCodec.H264.toString());
    // Check if ISAC is used by default.
    preferIsac = peerConnectionParameters.audioCodec != null && peerConnectionParameters.audioCodec.equals(NBMMediaConfiguration.NBMAudioCodec.ISAC.toString());
    connections = new HashMap<>();
}
项目:UMA-AndroidWebRTC    文件:WebRTCCliente.java   
public WebRTCCliente(RTCListener listener, String host) {
  mListener = listener;
  factory = new PeerConnectionFactory();

  SocketIOClient.connect(host, new ConnectCallback() {

    @Override
    public void onConnectCompleted(Exception ex, SocketIOClient socket) {
      if (ex != null) {
        mListener.onStatusChanged("No se puedo conectar al Servidor WebSocket en la direccion: " + ex.getMessage());
        //Log.e(TAG,"WebRTCCliente connect failed: "+ex.getMessage());
        return;
      }
      mListener.onStatusChanged("Conectado al Servidor WebSocket.");

      //  Log.d(TAG, "Conectado al Servidor WebRTC.");
      MainActivity.conectado_servidor = true;
      client = socket;

      // specify which events you are interested in receiving
      client.addListener("id", messageHandler);
      client.addListener("message", messageHandler);
    }
  }, new Handler());

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

    //  Habilitar el uso de Datachannels 30.09/2014
     //  pcConstraints.optional.add(new MediaConstraints.KeyValuePair("RtpDataChannels", "true"));
    //
  pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "false"));
  pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));

}
项目:android-webrtc-api    文件:PnPeerConnectionClient.java   
public PnPeerConnectionClient(Pubnub pubnub, PnSignalingParams signalingParams, PnRTCListener rtcListener){
    this.mPubNub = pubnub;
    this.signalingParams = signalingParams;
    this.mRtcListener = rtcListener;
    this.pcFactory = new PeerConnectionFactory(); // TODO: Check it allowed, else extra param
    this.peers = new HashMap<String, PnPeer>();
    init();
}
项目:respoke-sdk-android    文件:Respoke.java   
/**
 *  Notify the shared SDK instance that the specified client has connected. This is for internal use only, and should never be called by your client application.
 *
 *  @param client  The client that just connected
 */
public void clientConnected(RespokeClient client) {
    if (null != pushToken) {
        registerPushServices();
    }

    if (!factoryStaticInitialized) {
        // Perform a one-time WebRTC global initialization
        PeerConnectionFactory.initializeAndroidGlobals(context, true, true, true, VideoRendererGui.getEGLContext());
        factoryStaticInitialized = true;
    }
}
项目:nc-android-webrtcpeer    文件:PeerConnectionClient.java   
public void setPeerConnectionFactoryOptions(PeerConnectionFactory.Options options) {
    this.options = options;
}
项目:nc-android-webrtcpeer    文件:PeerConnectionClient.java   
private void closeInternal() {
    if (factory != null && peerConnectionParameters.aecDump) {
        factory.stopAecDump();
    }
    Log.d(TAG, "Closing peer connection.");
    statsTimer.cancel();
    if (dataChannel != null) {
        dataChannel.dispose();
        dataChannel = null;
    }
    if (peerConnection != null) {
        peerConnection.dispose();
        peerConnection = null;
    }
    Log.d(TAG, "Closing audio source.");
    if (audioSource != null) {
        audioSource.dispose();
        audioSource = null;
    }
    Log.d(TAG, "Stopping capture.");
    if (videoCapturer != null) {
        try {
            videoCapturer.stopCapture();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        videoCapturerStopped = true;
        videoCapturer.dispose();
        videoCapturer = null;
    }
    Log.d(TAG, "Closing video source.");
    if (videoSource != null) {
        videoSource.dispose();
        videoSource = null;
    }
    localRender = null;
    remoteRenders = null;
    Log.d(TAG, "Closing peer connection factory.");
    if (factory != null) {
        factory.dispose();
        factory = null;
    }
    options = null;
    Log.d(TAG, "Closing peer connection done.");
    events.onPeerConnectionClosed();
    PeerConnectionFactory.stopInternalTracingCapture();
    PeerConnectionFactory.shutdownInternalTracer();
    events = null;
}
项目:AppRTC-Android    文件:PeerConnectionClient.java   
public void setPeerConnectionFactoryOptions(PeerConnectionFactory.Options options) {
  this.options = options;
}
项目:AppRTC-Android    文件:PeerConnectionClient.java   
private void closeInternal() {
  if (factory != null && peerConnectionParameters.aecDump) {
    factory.stopAecDump();
  }
  Log.d(TAG, "Closing peer connection.");
  statsTimer.cancel();
  if (dataChannel != null) {
    dataChannel.dispose();
    dataChannel = null;
  }
  if (peerConnection != null) {
    peerConnection.dispose();
    peerConnection = null;
  }
  Log.d(TAG, "Closing audio source.");
  if (audioSource != null) {
    audioSource.dispose();
    audioSource = null;
  }
  Log.d(TAG, "Stopping capture.");
  if (videoCapturer != null) {
    try {
      videoCapturer.stopCapture();
    } catch (InterruptedException e) {
      throw new RuntimeException(e);
    }
    videoCapturerStopped = true;
    videoCapturer.dispose();
    videoCapturer = null;
  }
  Log.d(TAG, "Closing video source.");
  if (videoSource != null) {
    videoSource.dispose();
    videoSource = null;
  }
  localRender = null;
  remoteRenders = null;
  Log.d(TAG, "Closing peer connection factory.");
  if (factory != null) {
    factory.dispose();
    factory = null;
  }
  options = null;
  rootEglBase.release();
  Log.d(TAG, "Closing peer connection done.");
  events.onPeerConnectionClosed();
  PeerConnectionFactory.stopInternalTracingCapture();
  PeerConnectionFactory.shutdownInternalTracer();
  events = null;
}
项目:AndroidRTC    文件:PeerConnectionClient.java   
public void setPeerConnectionFactoryOptions(PeerConnectionFactory.Options options) {
    this.options = options;
}
项目:AndroidRTC    文件:PeerConnectionClient.java   
private void closeInternal() {
    if (factory != null && peerConnectionParameters.aecDump) {
        factory.stopAecDump();
    }
    Log.d(TAG, "Closing peer connection.");
    statsTimer.cancel();
    if (dataChannel != null) {
        dataChannel.dispose();
        dataChannel = null;
    }
    if (peerConnection != null) {
        peerConnection.dispose();
        peerConnection = null;
    }
    Log.d(TAG, "Closing audio source.");
    if (audioSource != null) {
        audioSource.dispose();
        audioSource = null;
    }
    Log.d(TAG, "Stopping capture.");
    if (videoCapturer != null) {
        try {
            videoCapturer.stopCapture();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        videoCapturerStopped = true;
        videoCapturer.dispose();
        videoCapturer = null;
    }
    Log.d(TAG, "Closing video source.");
    if (videoSource != null) {
        videoSource.dispose();
        videoSource = null;
    }
    localRender = null;
    remoteRenders = null;
    Log.d(TAG, "Closing peer connection factory.");
    if (factory != null) {
        factory.dispose();
        factory = null;
    }
    options = null;
    Log.d(TAG, "Closing peer connection done.");
    events.onPeerConnectionClosed();
    PeerConnectionFactory.stopInternalTracingCapture();
    PeerConnectionFactory.shutdownInternalTracer();
    events = null;
}
项目:webrtc-android-codelab    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Initialize PeerConnectionFactory globals.
    //Params are context, initAudio,initVideo and videoCodecHwAcceleration
    PeerConnectionFactory.initializeAndroidGlobals(this, true, true, true);

    //Create a new PeerConnectionFactory instance.
    PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
    PeerConnectionFactory peerConnectionFactory = new PeerConnectionFactory(options);


    //Now create a VideoCapturer instance. Callback methods are there if you want to do something! Duh!
    VideoCapturer videoCapturerAndroid = createVideoCapturer();
    //Create MediaConstraints - Will be useful for specifying video and audio constraints. More on this later!
    MediaConstraints constraints = new MediaConstraints();

    //Create a VideoSource instance
    VideoSource videoSource = peerConnectionFactory.createVideoSource(videoCapturerAndroid);
    VideoTrack localVideoTrack = peerConnectionFactory.createVideoTrack("100", videoSource);

    //create an AudioSource instance
    AudioSource audioSource = peerConnectionFactory.createAudioSource(constraints);
    AudioTrack localAudioTrack = peerConnectionFactory.createAudioTrack("101", audioSource);

    //we will start capturing the video from the camera
    //width,height and fps
    videoCapturerAndroid.startCapture(1000, 1000, 30);

    //create surface renderer, init it and add the renderer to the track
    SurfaceViewRenderer videoView = (SurfaceViewRenderer) findViewById(R.id.surface_rendeer);
    videoView.setMirror(true);

    EglBase rootEglBase = EglBase.create();
    videoView.init(rootEglBase.getEglBaseContext(), null);

    localVideoTrack.addRenderer(new VideoRenderer(videoView));


}
项目:webrtc-android    文件:PeerConnectionClient.java   
public void setPeerConnectionFactoryOptions(PeerConnectionFactory.Options options) {
    this.options = options;
}
项目:webrtc-android    文件:PeerConnectionClient.java   
private void createPeerConnectionFactoryInternal(Context context, String host) {
    PeerConnectionFactory.initializeInternalTracer();
    if (peerConnectionParameters.tracing) {
        PeerConnectionFactory.startInternalTracingCapture(
                Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator
                        + "webrtc-trace.txt");
    }
    Log.d(TAG, "Create peer connection factory. Use video: " +
            peerConnectionParameters.videoCallEnabled);
    isError = false;

    // Initialize field trials.
    PeerConnectionFactory.initializeFieldTrials(FIELD_TRIAL_AUTOMATIC_RESIZE);

    // Check preferred video codec.
    preferredVideoCodec = VIDEO_CODEC_VP8;
    if (videoCallEnabled && peerConnectionParameters.videoCodec != null) {
        if (peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_VP9)) {
            preferredVideoCodec = VIDEO_CODEC_VP9;
        } else if (peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_H264)) {
            preferredVideoCodec = VIDEO_CODEC_H264;
        }
    }
    Log.d(TAG, "Pereferred video codec: " + preferredVideoCodec);

    // Check if ISAC is used by default.
    preferIsac = false;
    if (peerConnectionParameters.audioCodec != null
            && peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC)) {
        preferIsac = true;
    }

    // Enable/disable OpenSL ES playback.
    if (!peerConnectionParameters.useOpenSLES) {
        Log.d(TAG, "Disable OpenSL ES audio even if device supports it");
        WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true /* enable */);
    } else {
        Log.d(TAG, "Allow OpenSL ES audio if device supports it");
        WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(false);
    }

    // Create peer connection factory.
    if (!PeerConnectionFactory.initializeAndroidGlobals(context, true, true,
            peerConnectionParameters.videoCodecHwAcceleration)) {
        events.onPeerConnectionError("Failed to initializeAndroidGlobals");
    }
    if (options != null) {
        Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMask);
    }
    factory = new PeerConnectionFactory();
    Log.d(TAG, "Peer connection factory created.");


}
项目:viska-android    文件:Application.java   
private void initializeWebRtc() {
  PeerConnectionFactory.initialize(
      PeerConnectionFactory.InitializationOptions.builder(this).createInitializationOptions()
  );
  this.webRtcFactory = new PeerConnectionFactory(new PeerConnectionFactory.Options());
}
项目:krankygeek    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
    audioManager.setSpeakerphoneOn(true);

    PeerConnectionFactory.initializeAndroidGlobals(
            this,  // Context
            true,  // Audio Enabled
            true,  // Video Enabled
            true,  // Hardware Acceleration Enabled
            null); // Render EGL Context

    peerConnectionFactory = new PeerConnectionFactory();

    VideoCapturerAndroid vc = VideoCapturerAndroid.create(VideoCapturerAndroid.getNameOfFrontFacingDevice(), null);

    localVideoSource = peerConnectionFactory.createVideoSource(vc, new MediaConstraints());
    VideoTrack localVideoTrack = peerConnectionFactory.createVideoTrack(VIDEO_TRACK_ID, localVideoSource);
    localVideoTrack.setEnabled(true);

    AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints());
    AudioTrack localAudioTrack = peerConnectionFactory.createAudioTrack(AUDIO_TRACK_ID, audioSource);
    localAudioTrack.setEnabled(true);

    localMediaStream = peerConnectionFactory.createLocalMediaStream(LOCAL_STREAM_ID);
    localMediaStream.addTrack(localVideoTrack);
    localMediaStream.addTrack(localAudioTrack);

    GLSurfaceView videoView = (GLSurfaceView) findViewById(R.id.glview_call);

    VideoRendererGui.setView(videoView, null);
    try {
        otherPeerRenderer = VideoRendererGui.createGui(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true);
        VideoRenderer renderer = VideoRendererGui.createGui(50, 50, 50, 50, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true);
        localVideoTrack.addRenderer(renderer);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:DeviceConnect-Android    文件:MediaStream.java   
MediaStream(final PeerConnectionFactory factory, final PeerOption option) {
    mFactory = factory;
    mOption = option;
    createMediaConstraints(option);
    mMediaStream = createMediaStream();
}