Android WebRTC-getStats()未提供足够的信息
我正在尝试获取所有与mediastreams相关的信息,以获得通话质量。Peerconnection.getStats()方法已被弃用,但根据我的要求提供了所有信息,如“bytesReceived”、“packetsLost”、“packetsReceived”、“googCodecName”和“GoogGitterBufferms” 现在我不能使用这个方法,因为它已被弃用。当我尝试使用新的getStats()方法时,它并没有提供所有这样的信息,而且响应也非常无序Android WebRTC-getStats()未提供足够的信息,android,webrtc,mediastream,webrtc-android,Android,Webrtc,Mediastream,Webrtc Android,我正在尝试获取所有与mediastreams相关的信息,以获得通话质量。Peerconnection.getStats()方法已被弃用,但根据我的要求提供了所有信息,如“bytesReceived”、“packetsLost”、“packetsReceived”、“googCodecName”和“GoogGitterBufferms” 现在我不能使用这个方法,因为它已被弃用。当我尝试使用新的getStats()方法时,它并没有提供所有这样的信息,而且响应也非常无序 peerConnection.
peerConnection.getStats(new RTCStatsCollectorCallback() {
@Override
public void onStatsDelivered(RTCStatsReport rtcStatsReport) {
Log.d(TAG, "RTCStatsReport: "+rtcStatsReport.getStatsMap().toString());
}
});
Response:-
{
RTCCodec_audio_Inbound_0={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_0,
payloadType: 0,
mimeType: "audio/PCMU",
clockRate: 8000
},
RTCCodec_audio_Inbound_102={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_102,
payloadType: 102,
mimeType: "audio/ILBC",
clockRate: 8000
},
RTCCodec_audio_Inbound_103={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_103,
payloadType: 103,
mimeType: "audio/ISAC",
clockRate: 16000
},
RTCCodec_audio_Inbound_105={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_105,
payloadType: 105,
mimeType: "audio/CN",
clockRate: 16000
},
RTCCodec_audio_Inbound_110={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_110,
payloadType: 110,
mimeType: "audio/telephone-event",
clockRate: 48000
},
RTCCodec_audio_Inbound_111={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_111,
payloadType: 111,
mimeType: "audio/opus",
clockRate: 48000
},
RTCCodec_audio_Inbound_113={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_113,
payloadType: 113,
mimeType: "audio/telephone-event",
clockRate: 16000
},
RTCCodec_audio_Inbound_126={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_126,
payloadType: 126,
mimeType: "audio/telephone-event",
clockRate: 8000
},
RTCCodec_audio_Inbound_13={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_13,
payloadType: 13,
mimeType: "audio/CN",
clockRate: 8000
},
RTCCodec_audio_Inbound_8={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_8,
payloadType: 8,
mimeType: "audio/PCMA",
clockRate: 8000
},
RTCCodec_audio_Inbound_9={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Inbound_9,
payloadType: 9,
mimeType: "audio/G722",
clockRate: 8000
},
RTCCodec_audio_Outbound_0={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Outbound_0,
payloadType: 0,
mimeType: "audio/PCMU",
clockRate: 8000
},
RTCCodec_audio_Outbound_102={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Outbound_102,
payloadType: 102,
mimeType: "audio/ILBC",
clockRate: 8000
},
RTCCodec_audio_Outbound_103={
timestampUs: 1557124386437087,
type: codec,
id: RTCCodec_audio_Outbound_103,
payloadType: 103,
mimeType: "audio/ISAC",
clockRate: 16000
}
}
我每秒钟都会点击getStats()方法,每次它都会给我不同数据的响应。此响应未记录在WebRTC文档的任何地方
如何使用新的getStats()方法获取“bytesReceived”、“packetsLost”、“packetsReceived”、“googCodecName”和“GoogGitterBufferms” 我在我身上看到:
{ timestampUs: 1606895449567493, type: inbound-rtp, id: RTCInboundRTPVideoStream_512, ssrc: 512, isRemote: false, mediaType: "video", kind: "video", trackId: "RTCMediaStreamTrack_receiver_2", transportId: "RTCTransport_1_1", firCount: 0, pliCount: 0, nackCount: 0, packetsReceived: 0, bytesReceived: 0, headerBytesReceived: 0, packetsLost: 0, framesReceived: 0, framesDecoded: 0, keyFramesDecoded: 0, framesDropped: 0, totalDecodeTime: 0.0, totalInterFrameDelay: 0.0, totalSquaredInterFrameDelay: 0.0, decoderImplementation: "unknown" },
{ timestampUs: 1606895449567493, type: track, id: RTCMediaStreamTrack_receiver_1, trackIdentifier: "c68ef0fb-7ac9-4008-97db-100f9a04c66e", remoteSource: true, ended: false, detached: false, kind: "audio", jitterBufferDelay: 0.0, jitterBufferEmittedCount: 0, totalAudioEnergy: 0.0, totalSamplesReceived: 0, totalSamplesDuration: 0.0, concealedSamples: 0, silentConcealedSamples: 0, concealmentEvents: 0, insertedSamplesForDeceleration: 0, removedSamplesForAcceleration: 0, jitterBufferFlushes: 0, delayedPacketOutageSamples: 0, relativePacketArrivalDelay: 0.0, jitterBufferTargetDelay: 0.0, interruptionCount: 0, totalInterruptionDuration: 0.0 },
{ timestampUs: 1606895449567493, type: track, id: RTCMediaStreamTrack_receiver_2, trackIdentifier: "05c66233-cb7f-4984-9d27-3dde1ef92a36", remoteSource: true, ended: false, detached: false, kind: "video", jitterBufferDelay: 0.0, jitterBufferEmittedCount: 0, framesReceived: 0, framesDecoded: 0, framesDropped: 0, freezeCount: 0, pauseCount: 0, totalFreezesDuration: 0.0, totalPausesDuration: 0.0, totalFramesDuration: 0.0, sumOfSquaredFramesDuration: 0.0 }
你能在你的统计数据中找到这些吗
我这样称呼它:
peerConnection.getStats(new RTCStatsCollectorCallback() {
@Override
public void onStatsDelivered(RTCStatsReport rtcStatsReport) {
longInfo("RTC Stats: \n" + rtcStatsReport.toString());
}
});
编辑:由于stats报告很长,您需要创建一个像这样的longInfo方法来查看所有内容。那应该能解决你的问题
public void longInfo(String str) {
if (str.length() > 4000) {
Log.i(TAG, str.substring(0, 4000));
longInfo(str.substring(4000));
} else
Log.i(TAG, str);
}
我也面临着这个问题here@Nitin古普塔我也面临同样的问题。你找到解决办法了吗?
public void longInfo(String str) {
if (str.length() > 4000) {
Log.i(TAG, str.substring(0, 4000));
longInfo(str.substring(4000));
} else
Log.i(TAG, str);
}