本文整理汇总了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);
}
示例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)
)
);
}
示例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;
}
示例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);
}
示例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...");
}
示例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...");
}