1、打开调试工具
打开 Chrome 浏览器,在地址栏输入chrome://webrtc-internals/
即可打开调试工具,如下图所示
Edge 83 及以上版本已采用 Chromium 作为内核,在 Edge 浏览器上也可以在地址栏输入edge://webrtc-internals/
打开调试工具,如下图所示
2、导出调试信息
如下图,点击Create Dump
即可展开,进行导出调试信息的操作
若需要调试声音,可以勾选 Enable diagnostic audio recordings
最后点击 Download the PeerConnection updates and stats data
按钮,下载相关的统计信息
3、切换获取统计信息的方式
可以在Read Stats From
处,切换获取统计信息的方式
- Standardized (promise-based) getStats() API,通过标准的(基于 promise)getStats API 获取
- Legacy Non-Standard (callback-based) getStats() API,通过遗留的非标准的(基于回调)getStats API 获取
一般使用默认的选择,即通过标准 API 获取即可
4、相关统计信息
如下图所示,点击GetUserMedia Request
字样的区块,可以看到最近浏览器请求获取用户媒体设备权限的日志,可以看到每次请求获取用户媒体设备权限的时间、来源 URL 及音视频参数等信息
4.2 通道(RTCPeerConnection
)列表
如下图所示,除GetUserMedia Request
外的其它区块就是通道列表,每个区块都是一个RTCPeerConnection
通道,可以通过点击每个区块查看每个通道的事件过程及统计信息。
我们的应用使用了 4 个通道,可以从上图看到,他们依次是:
- 第一个主流发送通道
- 第二个主流接收通道
- 第三个辅流发送通道
- 第四个辅流接收通道
4.3 查看每个通道(RTCPeerConnection
)的信息
4.3.1 查看事件信息
若调试工具webrtc-internals
先于应用页面开启,则如下图所示,可以看到完整的事件过程,每个事件都可以展开查看详细内容,从中可以跟踪相关事件信息及 SDP 信息
若调试工具webrtc-internals
晚于应用页面开启,则只能看到应用页面后续的事件信息,不能看到之前的事件信息。
如果想看到完整的事件过程,打开调试工具webrtc-internals
后,再打开应用页面,若应用页面已打开,则刷新重新加载页面即可。
4.3.2 查看统计信息
如下图所示,每个通道都有Stats Tables
统计信息,每个信息都可以展开查看详细内容,分为两部分:
- 统计数据
- 统计图表(
Stats graphs for ...
字样开头的信息)
4.3.3 统计数据说明(样例)
RTCPeerConnection (peer-connection)
名称 |
数值 |
注释 |
timestamp |
2020/7/28 下午 6:30:33 |
|
type |
peer-connection |
|
dataChannelsOpened |
0 |
生命周期内 open 状态的 DataChannel 数量 |
dataChannelsClosed |
0 |
生命周期内 close 状态的 DataChannel 数量 |
RTCTransport_0_1 (transport)
名称 |
数值 |
注释 |
timestamp |
2020/7/28 下午 6:32:03 |
|
type |
transport |
|
bytesSent |
39391140 |
发送字节数 |
[bytesSent_in_bits/s] |
45805.813414400436 |
发送比特率 |
bytesReceived |
5538693 |
接收字节数 |
[bytesReceived_in_bits/s] |
4676.677453498226 |
接收比特率 |
dtlsState |
connected |
DTLS 状态 |
selectedCandidatePairId |
RTCIceCandidatePair_p0AAYh7Z_Tf02029O |
候选者对 |
localCertificateId |
RTCCertificate_97:01:5C:9A:03:E5:38:E6:FE:8B:9A:2C:F7:29:FC:3D:2B:86:61:77:FB:1D:B0:9E:AD:AD:D5:05:E5:F9:8A:90 |
本地候选者 ID |
remoteCertificateId |
RTCCertificate_D9:AF:1E:93:28:D0:64:F3:14:5D:81:3E:BF:F4:61:1E:D1:68:AE:CA |
远端候选者 ID |
tlsVersion |
FEFD |
|
dtlsCipher |
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 |
|
srtpCipher |
AEAD_AES_256_GCM |
|
selectedCandidatePairChanges |
1 |
候选者变更计数器 |
新增
名称 |
数值 |
注释 |
packetsSent |
13804 |
发送包数 |
[packetsSent/s] |
70.61591710493629 |
|
packetsReceived |
3575 |
接收包数 |
[packetsReceived/s] |
70.61591710493629 |
|
dtlsRole |
server 或 client 或 auto |
DTLS 握手期间的角色,用于确定哪个对等方将充当 DTLS 客户端,哪个将充当 DTLS 服务器 |
iceRole |
controlling 或 controlled |
ICE 代理的角色,用于确定哪个端将发起 ICE 连接,哪个端将接受连接 |
iceLocalUsernameFragment |
2eIo |
本地用户名 |
iceState |
connected |
ice 状态 |
RTCCertificate_XXX (certificate)
名称 |
数值 |
timestamp |
2020/7/28 下午 5:24:20 |
fingerprint(指纹秘钥) |
97:01:5C:9A:03:E5:38:E6:FE:8B:9A:2C:F7:… |
fingerprintAlgorithm(指纹秘钥算法) |
sha-256 |
base64Certificate |
MIIBFjCBvaADAgE… |
RTCIceCandidatePair_XXX (candidate-pair)
名称 |
数值 |
说明 |
timestamp |
2020/7/28 下午 5:28:58 |
|
transportId |
RTCTransport_0_1 |
|
localCandidateId |
RTCIceCandidate_p0AAYh7Z |
|
remoteCandidateId |
RTCIceCandidate_Tf02029O |
|
state(状态) |
succeeded |
|
priority |
4623781745793973759 |
优先级 |
nominated |
true |
|
writable |
true |
可写 |
bytesSent(发送的字节数) |
21185440 |
|
**[bytesSent_in_bits/s]**(发送比特率) |
13440 |
|
bytesReceived |
3491205 |
|
**[bytesReceived_in_bits/s]**(接收比特率) |
4480 |
|
totalRoundTripTime |
2.059 |
STUN 连接性检查花费总时间 |
[totalRoundTripTime/responsesReceived_in_ms] |
1.000000000000334 |
|
currentRoundTripTime |
0.001 |
|
availableOutgoingBitrate(上行码率) |
300000 |
预估带宽 |
requestsReceived |
0 |
收到的连接性检查请求的总数(包括重传) |
requestsSent |
1 |
发送的连接性检查请求的总数(不包括重传) |
responsesReceived |
2575 |
收到的连接性检查响应的总数 |
responsesSent |
0 |
发送的连接性检查响应的总数 |
consentRequestsSent |
2574 |
发送的同意请求的总数 |
新增
名称 |
数值 |
说明 |
packetsSent |
66602 |
|
[packetsSent/s] |
70 |
|
packetsReceived |
21175 |
|
[packetsReceived/s] |
21 |
|
packetsDiscardedOnSend |
0 |
由于套接字错误而被丢弃的数据包总数,即在将数据包移交给套接字时发生了套接字错误。这可能是由于各种原因造成的,包括缓冲区已满或没有可用内存。 |
bytesDiscardedOnSend |
0 |
|
lastPacketReceivedTimestamp |
1681960810017 |
收到最后一个数据包的时间戳,不包括 STUN 数据包 |
lastPacketSentTimestamp |
1681960810017 |
发送最后一个数据包的时间戳,不包括 STUN 数据包 |
说明:
####### state(状态)
- frozen:表示 ICE 候选对已经被冻结,即不再尝试连接。
- waiting:表示 ICE 候选对正在等待连接。
- in-progress:表示 ICE 候选对正在尝试连接。
- failed:表示 ICE 候选对连接失败。
- succeeded:表示 ICE 候选对连接成功。
RTCIceCandidate_XXX (remote-candidate)
名称 |
数值 |
timestamp |
2020/7/28 下午 5:51:37 |
transportId |
RTCTransport_0_1 |
isRemote |
true |
ip(远端地址) |
172.16.186.220 |
port(远端端口) |
60349 |
protocol |
udp |
candidateType |
host |
priority |
1076558079 |
deleted |
false |
RTCIceCandidate_XXX (local-candidate)
名称 |
数值 |
timestamp |
2020/7/28 下午 3:41:39 |
transportId |
RTCTransport_0_1 |
isRemote |
false |
networkType |
ethernet |
ip(本地地址) |
192.168.186.99 |
port(本地端口) |
53988 |
protocol |
udp |
candidateType |
host |
priority |
2122129151 |
deleted |
false |
名称 |
数值 |
timestamp |
2020/7/28 下午 3:42:04 |
trackIdentifier |
f13d531c-457d-4fdc-a685-ab9d6d07848d |
kind |
audio |
audioLevel |
6.1037e-05 |
totalAudioEnergy(声音能量值) |
2.23667e-06 |
[Audio_Level_in_RMS] |
0.00006737952211169176 |
totalSamplesDuration(采样时长) |
39.41 |
名称 |
数值 |
timestamp |
2020/7/28 下午 6:50:34 |
trackIdentifier |
24dde0fd-93fb-43e4-9e7c-187ca30ade3e |
kind |
video |
width(宽) |
640 |
height(高) |
360 |
framesPerSecond(每秒帧数) |
16 |
名称 |
数值 |
timestamp |
2020/7/28 下午 6:10:18 |
streamIdentifier |
5M9qqLa9fnMAvL7qt5ZfJZVtzmP3kRdyLKNw |
trackIds |
[“RTCMediaStreamTrack_sender_0”] |
RTCOutboundRTPAudioStream_XXX (outbound-rtp)
名称 |
数值 |
timestamp |
2020/7/28 下午 6:12:15 |
ssrc |
648299959 |
isRemote |
false |
mediaType |
audio |
kind |
audio |
trackId |
RTCMediaStreamTrack_sender_7 |
transportId |
RTCTransport_0_1 |
codecId |
RTCCodec_1_Outbound_111 |
**[codec]**(编码格式) |
opus (111, useinbandfec=1) |
mediaSourceId |
RTCAudioSource_7 |
packetsSent |
2875 |
**[packetsSent/s]**(发送包率) |
50 |
retransmittedPacketsSent |
0 |
**[retransmittedPacketsSent/s]**(重传包率) |
0 |
bytesSent |
112617 |
**[bytesSent_in_bits/s]**(发送比特率) |
18936 |
headerBytesSent |
69000 |
**[headerBytesSent_in_bits/s]**(发送包头比特率) |
9600 |
retransmittedBytesSent |
0 |
**[retransmittedBytesSent_in_bits/s]**(重传比特率) |
0 |
remoteId |
RTCRemoteInboundRtpAudioStream_648299959 |
RTCOutboundRTPVideoStream_XXX (outbound-rtp)
名称 |
数值 |
timestamp |
2020/7/28 下午 6:19:19 |
ssrc(SSRC 编号) |
2866008429 |
isRemote |
false |
mediaType |
video |
kind(类型) |
video |
trackId |
RTCMediaStreamTrack_sender_8 |
transportId |
RTCTransport_0_1 |
codecId |
RTCCodec_2_Outbound_125 |
**[codec]**(编码格式) |
H264 (125, level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e032;x-google-start-bitrate=1000) |
firCount |
0 |
pliCount |
73 |
nackCount |
0 |
mediaSourceId |
RTCVideoSource_8 |
packetsSent |
157671 |
**[packetsSent/s]**(发送包率) |
16 |
retransmittedPacketsSent |
0 |
**[retransmittedPacketsSent/s]**(重传包率) |
0 |
bytesSent |
23341242 |
**[bytesSent_in_bits/s]**(发送比特率) |
15800 |
headerBytesSent |
3785744 |
**[headerBytesSent_in_bits/s]**(发送包头比特率) |
3072 |
retransmittedBytesSent |
0 |
**[retransmittedBytesSent_in_bits/s]**(重传比特率) |
0 |
framesEncoded |
152831 |
[framesEncoded/s] |
16 |
keyFramesEncoded(已编码关键帧数) |
115 |
totalEncodeTime |
181.663 |
[totalEncodeTime/framesEncoded_in_ms] |
0.8750000000006253 |
totalEncodedBytesTarget |
0 |
[totalEncodedBytesTarget_in_bits/s] |
0 |
framesSent |
152831 |
hugeFramesSent |
0 |
totalPacketSendDelay |
1583.23 |
[totalPacketSendDelay/packetsSent_in_ms] |
6.875000000007958 |
qualityLimitationReason |
none |
qualityLimitationResolutionChanges |
0 |
encoderImplementation(编码器实现) |
OpenH264 |
qpSum |
1847067 |
[qpSum/framesEncoded] |
12 |
remoteId |
RTCRemoteInboundRtpVideoStream_2866008429 |
frameWidth(帧宽) |
640 |
frameHeight(帧高) |
360 |
framesPerSecond(每秒帧数) |
16 |
RTCInboundRTPAudioStream_XXX (inbound-rtp)
名称 |
数值 |
timestamp |
2020/7/29 上午 9:56:58 |
ssrc |
981291154 |
isRemote |
false |
mediaType |
audio |
** kind **(类型) |
audio |
trackId |
RTCMediaStreamTrack_receiver_39 |
transportId |
RTCTransport_0_1 |
codecId |
RTCCodec_1_Inbound_120 |
**[codec]**(编码格式) |
opus (120, minptime=10;useinbandfec=1) |
packetsReceived |
56844 |
**[packetsReceived/s]**(接收包率) |
50.0500464188291 |
fecPacketsReceived |
0 |
fecPacketsDiscarded |
0 |
bytesReceived |
2160062 |
**[bytesReceived_in_bits/s]**(接收比特率) |
15239.238133605084 |
headerBytesReceived |
2501136 |
[headerBytesReceived_in_bits/s] |
17617.616339427845 |
packetsLost(丢包数) |
15 |
lastPacketReceivedTimestamp |
609191 |
jitter |
0.009 |
RTCInboundRTPVideoStream_XXX (inbound-rtp)
名称 |
数值 |
timestamp |
2020/7/29 上午 10:02:51 |
ssrc |
435698252 |
isRemote |
false |
mediaType |
video |
kind(类型) |
video |
trackId |
RTCMediaStreamTrack_receiver_46 |
transportId |
RTCTransport_0_1 |
codecId |
RTCCodec_7_Inbound_106 |
**[codec]**(编码格式) |
H264 (106, level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f) |
firCount |
0 |
pliCount |
5 |
nackCount |
15 |
packetsReceived |
45799 |
**[packetsReceived/s]**(接收包率) |
28.94211995549519 |
bytesReceived |
20438271 |
**[bytesReceived_in_bits/s]**(接收比特率) |
146499.0231898983 |
headerBytesReceived |
1465784 |
[headerBytesReceived_in_bits/s] |
7409.182708606769 |
packetsLost(丢包数) |
18 |
lastPacketReceivedTimestamp |
609544 |
framesDecoded |
44611 |
**[framesDecoded/s]**(每秒解码帧数) |
28.94211995549519 |
keyFramesDecoded(关键帧解码数) |
54 |
totalDecodeTime |
93.285 |
[totalDecodeTime/framesDecoded_in_ms] |
2.3793103448276764 |
totalInterFrameDelay |
1488.32 |
[totalInterFrameDelay/framesDecoded_in_ms] |
34.137931034483074 |
totalSquaredInterFrameDelay |
52.1927 |
[interFrameDelayStDev_in_ms] |
8.716706661908054 |
decoderImplementation |
ExternalDecoder |
RTCRemoteInboundRtpAudioStream_XXX (remote-inbound-rtp)
名称 |
数值 |
timestamp |
2020/7/28 下午 6:44:23 |
ssrc(SSRC 编号) |
648299959 |
kind(类型) |
audio |
transportId |
RTCTransport_0_1 |
codecId |
RTCCodec_1_Outbound_111 |
packetsLost(丢包数) |
0 |
jitter |
0 |
localId |
RTCOutboundRTPAudioStream_648299959 |
roundTripTime |
0.001 |
RTCRemoteInboundRtpVideoStream_XXX (remote-inbound-rtp)
名称 |
数值 |
timestamp |
2020/7/28 下午 6:44:23 |
ssrc(SSRC 编号) |
2866008429 |
kind(类型) |
video |
transportId |
RTCTransport_0_1 |
codecId |
RTCCodec_2_Outbound_125 |
packetsLost(丢包数) |
0 |
jitter |
0 |
localId |
RTCOutboundRTPVideoStream_2866008429 |
roundTripTime |
0.001 |
1、 音频
名称 |
数值 |
timestamp |
2020/7/28 下午 3:42:04 |
trackIdentifier(track 编号) |
f13d531c-457d-4fdc-a685-ab9d6d07848d |
mediaSourceId |
RTCAudioSource_7 |
remoteSource |
false |
ended |
false |
detached |
false |
kind(类型) |
audio |
2、视频
名称 |
数值 |
timestamp |
2020/7/28 下午 5:59:52 |
trackIdentifier(track 编号) |
24dde0fd-93fb-43e4-9e7c-187ca30ade3e |
mediaSourceId |
RTCVideoSource_8 |
remoteSource |
false |
ended |
false |
detached |
false |
kind(类型) |
video |
frameWidth(帧宽) |
640 |
frameHeight(帧高) |
360 |
framesSent |
133998 |
**[framesSent/s]**(每秒发送帧数) |
16.01601485402531 |
hugeFramesSent |
0 |
1、音频
名称 |
数值 |
timestamp |
2020/7/29 上午 10:46:05 |
trackIdentifier |
f3yl6DQ8S76dHOHHjCXbvA==:qj7eQTkvT-q5CAyVLtLzew== |
remoteSource |
true |
ended |
false |
detached |
false |
kind(类型) |
audio |
jitterBufferDelay |
1.14074e+07 |
[jitterBufferDelay/jitterBufferEmittedCount_in_ms] |
64.58333333333334 |
jitterBufferEmittedCount |
168742080 |
totalAudioEnergy |
0 |
[Audio_Level_in_RMS] |
0 |
totalSamplesReceived |
177985440 |
totalSamplesDuration |
4083.85 |
concealedSamples |
9929280 |
silentConcealedSamples |
9032510 |
concealmentEvents |
787 |
insertedSamplesForDeceleration |
108914 |
removedSamplesForAcceleration |
794247 |
jitterBufferFlushes |
0 |
delayedPacketOutageSamples |
720318 |
relativePacketArrivalDelay |
2525.05 |
jitterBufferTargetDelay |
1.08559e+07 |
interruptionCount |
12 |
totalInterruptionDuration |
2.433 |
audioLevel |
0 |
2、视频
名称 |
数值 |
timestamp |
2020/7/29 上午 10:53:38 |
trackIdentifier |
NWXoF57gS7CGb7TfVPq-zg==:qj7eQTkvT-q5CAyVLtLzew== |
remoteSource |
true |
ended |
false |
detached |
false |
kind(类型) |
video |
jitterBufferDelay |
5704.2 |
[jitterBufferDelay/jitterBufferEmittedCount_in_ms] |
37.931034482739804 |
jitterBufferEmittedCount |
135940 |
frameWidth |
480 |
frameHeight |
270 |
framesReceived |
135942 |
[framesReceived/s] |
29 |
[framesReceived-framesDecoded] |
1 |
framesDecoded |
135941 |
framesDropped |
0 |
freezeCount |
1 |
pauseCount |
0 |
totalFreezesDuration |
0.19 |
totalPausesDuration |
0 |
totalFramesDuration |
4535.28 |
sumOfSquaredFramesDuration |
159.925 |
4.4 统计信息关系图
4.5 W3C 标准文档
W3C 标准文档
https://www.w3.org/TR/webrtc-stats/
————————————————
版权声明:本文为 CSDN 博主「cgs1999」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/cgs1999/article/details/110084983