java peer_Java PeerConnection.getStats方法代码示例

import org.webrtc.PeerConnection; //导入方法依赖的package包/类

@Override

public void onIceServers(List 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...");

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值