当前位置: 首页>>代码示例>>Java>>正文


Java PeerConnectionFactory.createPeerConnection方法代码示例

本文整理汇总了Java中org.webrtc.PeerConnectionFactory.createPeerConnection方法的典型用法代码示例。如果您正苦于以下问题:Java PeerConnectionFactory.createPeerConnection方法的具体用法?Java PeerConnectionFactory.createPeerConnection怎么用?Java PeerConnectionFactory.createPeerConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.webrtc.PeerConnectionFactory的用法示例。


在下文中一共展示了PeerConnectionFactory.createPeerConnection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeOutboundCall

import org.webrtc.PeerConnectionFactory; //导入方法依赖的package包/类
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);
}
 
开发者ID:seamlik,项目名称:viska-android,代码行数:21,代码来源:CallingActivity.java

示例2: initializeInboundCall

import org.webrtc.PeerConnectionFactory; //导入方法依赖的package包/类
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)
      )
  );
}
 
开发者ID:seamlik,项目名称:viska-android,代码行数:20,代码来源:CallingActivity.java

示例3: createPeerConnection

import org.webrtc.PeerConnectionFactory; //导入方法依赖的package包/类
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;
}
 
开发者ID:Serchinastico,项目名称:webrtc-workshop,代码行数:25,代码来源:PeerConnectionWrapper.java

示例4: PeerConnectionWrapper

import org.webrtc.PeerConnectionFactory; //导入方法依赖的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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:49,代码来源:PeerConnectionWrapper.java

示例5: onIceServers

import org.webrtc.PeerConnectionFactory; //导入方法依赖的package包/类
@Override
public void onIceServers(List<PeerConnection.IceServer> iceServers) {
  factory = new PeerConnectionFactory();

  MediaConstraints pcConstraints = appRtcClient.pcConstraints();
  pcConstraints.optional.add(
      new MediaConstraints.KeyValuePair("RtpDataChannels", "true"));
  pc = factory.createPeerConnection(iceServers, pcConstraints, pcObserver);

  createDataChannelToRegressionTestBug2302(pc);  // See method comment.

  // 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);

  {
    final PeerConnection finalPC = pc;
    final Runnable repeatedStatsLogger = new Runnable() {
        public void run() {
          synchronized (quit[0]) {
            if (quit[0]) {
              return;
            }
            final Runnable runnableThis = this;
            if (hudView.getVisibility() == View.INVISIBLE) {
              vsv.postDelayed(runnableThis, 1000);
              return;
            }
            boolean success = finalPC.getStats(new StatsObserver() {
                public void onComplete(final StatsReport[] reports) {
                  runOnUiThread(new Runnable() {
                      public void run() {
                        updateHUD(reports);
                      }
                    });
                  for (StatsReport report : reports) {
                    Log.d(TAG, "Stats: " + report.toString());
                  }
                  vsv.postDelayed(runnableThis, 1000);
                }
              }, null);
            if (!success) {
              throw new RuntimeException("getStats() return false!");
            }
          }
        }
      };
    vsv.postDelayed(repeatedStatsLogger, 1000);
  }

  {
    logAndToast("Creating local video source...");
    MediaStream lMS = factory.createLocalMediaStream("ARDAMS");
    if (appRtcClient.videoConstraints() != null) {
      VideoCapturer capturer = getVideoCapturer();
      videoSource = factory.createVideoSource(
          capturer, appRtcClient.videoConstraints());
      VideoTrack videoTrack =
          factory.createVideoTrack("ARDAMSv0", videoSource);
      videoTrack.addRenderer(new VideoRenderer(localRender));
      lMS.addTrack(videoTrack);
    }
    if (appRtcClient.audioConstraints() != null) {
      lMS.addTrack(factory.createAudioTrack(
          "ARDAMSa0",
          factory.createAudioSource(appRtcClient.audioConstraints())));
    }
    pc.addStream(lMS, new MediaConstraints());
  }
  logAndToast("Waiting for ICE candidates...");
}
 
开发者ID:gaku,项目名称:WebRTCDemo,代码行数:75,代码来源:AppRTCDemoActivity.java

示例6: onIceServers

import org.webrtc.PeerConnectionFactory; //导入方法依赖的package包/类
@Override
public void onIceServers(List<PeerConnection.IceServer> iceServers) {
  factory = new PeerConnectionFactory();
  pc = factory.createPeerConnection(
      iceServers, appRtcClient.pcConstraints(), pcObserver);

  // 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);

  {
    final PeerConnection finalPC = pc;
    final Runnable repeatedStatsLogger = new Runnable() {
        public void run() {
          synchronized (quit[0]) {
            if (quit[0]) {
              return;
            }
            final Runnable runnableThis = this;
            boolean success = finalPC.getStats(new StatsObserver() {
                public void onComplete(StatsReport[] reports) {
                  for (StatsReport report : reports) {
                    Log.d(TAG, "Stats: " + report.toString());
                  }
                  vsv.postDelayed(runnableThis, 10000);
                }
              }, null);
            if (!success) {
              throw new RuntimeException("getStats() return false!");
            }
          }
        }
      };
    vsv.postDelayed(repeatedStatsLogger, 10000);
  }

  {
    logAndToast("Creating local video source...");
    MediaStream lMS = factory.createLocalMediaStream("ARDAMS");
    if (appRtcClient.videoConstraints() != null) {
      VideoCapturer capturer = getVideoCapturer();
      videoSource = factory.createVideoSource(
          capturer, appRtcClient.videoConstraints());
      VideoTrack videoTrack =
          factory.createVideoTrack("ARDAMSv0", videoSource);
      videoTrack.addRenderer(new VideoRenderer(new VideoCallbacks(
          vsv, VideoStreamsView.Endpoint.LOCAL)));
      lMS.addTrack(videoTrack);
    }
    lMS.addTrack(factory.createAudioTrack("ARDAMSa0"));
    pc.addStream(lMS, new MediaConstraints());
  }
  logAndToast("Waiting for ICE candidates...");
}
 
开发者ID:kenneththorman,项目名称:appspotdemo-mono,代码行数:58,代码来源:AppRTCDemoActivity.java


注:本文中的org.webrtc.PeerConnectionFactory.createPeerConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。