Chrome 117 में, लेगसी getStats()
WebRTC API को हटा दिया जाएगा. इसलिए, इसका इस्तेमाल करने वाले ऐप्लिकेशन को स्टैंडर्ड एपीआई पर माइग्रेट करना होगा. इस लेख में, कोड को माइग्रेट करने का तरीका बताया गया है. साथ ही, यह भी बताया गया है कि अगर आपको यह बदलाव करने के लिए ज़्यादा समय चाहिए, तो क्या करें.
अब तक, WebRTC getStats()
API के दो वर्शन उपलब्ध थे. स्टैंडर्ड बनाने की प्रोसेस से पहले का getStats() एपीआई, जो कॉलबैक आर्ग्युमेंट लेता है. साथ ही, स्टैंडर्ड और ज़्यादातर प्लैटफ़ॉर्म पर काम करने वाला एपीआई, जो प्रॉमिस दिखाता है.
स्टैंडर्ड एपीआई में ज़्यादा सुविधाएं होती हैं. साथ ही, इसमें अच्छी तरह से परिभाषित मेट्रिक होती हैं, जिन्हें W3C स्पेसिफ़िकेशन WebRTC के Statistics API के लिए आइडेंटिफ़ायर में सार्वजनिक तौर पर दस्तावेज़ में दर्ज किया गया है. स्पेसिफ़िकेशन में, इस गाइड में दी गई हर मेट्रिक के साथ-साथ कई अन्य मेट्रिक के बारे में जानकारी शामिल होती है.
Chrome 117 से, लेगसी getStats()
एपीआई, स्टेबल रिलीज़ चैनल में अपवाद दिखाएगा. अपवाद दिखाने की सुविधा को धीरे-धीरे रोल आउट किया जाएगा. स्टैंडर्ड एपीआई पर आसानी से ट्रांज़िशन करने के लिए, इस गाइड का पालन करें.
आंकड़ों के लेगसी और स्टैंडर्ड टाइप
स्टैंडर्ड आंकड़ों के टाइप की पूरी सूची देखने के लिए, स्पेसिफ़िकेशन में RTCStatsType एनम देखें. इसमें यह जानकारी शामिल होती है कि आंकड़े की कौनसी डिक्शनरी की परिभाषा, हर टाइप के लिए इकट्ठा की गई मेट्रिक के बारे में बताती है.
आंकड़ों के सभी ऑब्जेक्ट में एक आईडी एट्रिब्यूट होता है, जो कई getStats()
कॉल में मौजूद ऑब्जेक्ट की यूनीक पहचान करता है. हर बार जब इस तरीके को कॉल किया जाएगा, तो उसी ऑब्जेक्ट का आईडी एक ही रहेगा. यह मेट्रिक में बदलाव की दर का हिसाब लगाने के लिए मददगार है. अगले सेक्शन में इसका एक उदाहरण दिया गया है. आईडी, पहचान फ़ाइलों के बीच संबंध भी बनाते हैं. उदाहरण के लिए, outbound-rtp
स्टैटिस्टिक्स ऑब्जेक्ट, outbound-rtp.mediaSourceId
एट्रिब्यूट की मदद से, उससे जुड़े media-source
स्टैटिस्टिक्स ऑब्जेक्ट का रेफ़रंस देता है. सभी ...Id
संबंधों को ड्रॉ करने पर, आपको एक ग्राफ़ दिखता है.
लेगसी एपीआई में, यहां दिए गए आंकड़े मौजूद होते हैं. ये आंकड़े, स्टैंडर्ड आंकड़ों से मेल खाते हैं:
लेगसी टाइप |
स्टैंडर्ड टाइप |
---|---|
ssrc
|
यह RTP स्ट्रीम और उससे जुड़ी MediaStreamTrack की मेट्रिक दिखाता है.इसके लिए स्टैंडर्ड टाइप inbound-rtp (आरटीपी स्ट्रीम पाने और उससे जुड़े रिमोट MediaStreamTrack के लिए), outbound-rtp (आरटीपी स्ट्रीम भेजने के लिए) और media-source (आरटीपी स्ट्रीम भेजने से जुड़ी लोकल MediaStreamTrack मेट्रिक के लिए) हैं. आरटीपी स्ट्रीम मेट्रिक में, आरटीपी स्ट्रीम के लिए इस्तेमाल किए गए एन्कोडर या डिकोडर के बारे में भी जानकारी होती है. |
VideoBwe
|
बैंडविड्थ का अनुमान लगाने वाली मेट्रिक, टारगेट बिटरेट, एन्कोडर बिटरेट, और असल बिटरेट. इस तरह की मेट्रिक, आरटीपी मेट्रिक ( outbound-rtp और inbound-rtp ) और आईसीई कैंडिडेट पेयर मेट्रिक (candidate-pair ) का हिस्सा होती हैं. |
googComponent
|
ट्रांसपोर्ट (आईसीई और डीटीएलएस) को दिखाता है. स्टैंडर्ड वर्शन transport है. |
localcandidate and remotecandidate
|
आईसीई कैंडिडेट को दिखाता है. स्टैंडर्ड वर्शन local-candidate और remote-candidate है. |
googCandidatePair
|
ICE कैंडिडेट पेयर को दिखाता है. यह एक लोकल और एक रिमोट कैंडिडेट का पेयर होता है. स्टैंडर्ड वर्शन candidate-pair है. |
googCertificate
|
DTLS ट्रांसपोर्ट का इस्तेमाल करने वाले सर्टिफ़िकेट को दिखाता है. स्टैंडर्ड वर्शन certificate है. |
googLibjingleSession
|
RTCPeerConnection को दिखाता है. इसका कॉन्टेंट, स्टैंडर्ड में मौजूद किसी भी चीज़ से मैप नहीं होता. हालांकि, स्टैंडर्ड में RTCPeerConnection : peer-connection से जुड़ा एक टाइप होता है. |
पुराने एपीआई में मौजूद नहीं है |
आंकड़ों के इन टाइप को स्टैंडर्ड एपीआई में जोड़ा गया है, जिनका कोई लेगसी टाइप नहीं है:
|
लेगसी से स्टैंडर्ड मेट्रिक मैपिंग
इस मैपिंग का मकसद, डेवलपर को यह पता लगाने में मदद करना है कि कौनसी लेगसी मेट्रिक, कौनसी स्टैंडर्ड मेट्रिक से मेल खाती है. हालांकि, ध्यान दें कि मिलती-जुलती मेट्रिक में अलग-अलग इकाइयों का इस्तेमाल किया जा सकता है या उसे तुरंत दिखने वाली वैल्यू के बजाय कुल काउंटर के तौर पर दिखाया जा सकता है. मेट्रिक की परिभाषाओं के लिए स्पेसिफ़िकेशन देखें.
स्टैंडर्ड एपीआई, किराये के बजाय कुल काउंटर दिखाना पसंद करता है. इसका मतलब है कि लेगसी एपीआई की तरह ही दर (उदाहरण के लिए, बिटरेट) पाने के लिए, ऐप्लिकेशन को दो getStats()
कॉल के बीच के डेल्टा को लेकर औसत दर का हिसाब लगाना होगा. उदाहरण के लिए:
// Periodically (e.g. every second or every 10 seconds)...
const currReport = await pc.getStats();
// Calculate bitrate since the last getStats() call.
// Handling of undefined is omitted for clarity.
const currOutboundRtp = currReport.values().find(s => s.type == 'outbound-rtp');
const prevOutboundRtp = prevReport.get(currOutboundRtp.id);
const deltaBits = (currOutboundRtp.bytesSent - prevOutboundRtp.bytesSent) * 8;
const deltaSeconds = (currOutboundRtp.timestamp - prevOutboundRtp.timestamp) / 1000;
logBitrateMeasurement(deltaBits / deltaSeconds);
// Remember the report for next time.
prevReport = currReport;
इस तरह से किराये और औसत का हिसाब लगाना, एक अतिरिक्त और मुश्किल चरण की तरह लग सकता है. हालांकि, इसका फ़ायदा यह है कि आपको अपनी पसंद के किसी भी समयावधि के लिए औसत मिल सकता है. स्टैंडर्ड एपीआई को उतनी बार कॉल नहीं किया जाता जितना कि लेगसी एपीआई को कॉल किया जाता है. इससे परफ़ॉर्मेंस से जुड़े कुछ फ़ायदे मिलते हैं.
लेगसी मेट्रिक
googCertificate |
स्टैंडर्ड पत्राचार
certificate |
---|---|
.googFingerprint
|
.fingerprint
|
.googFingerprintAlgorithm
|
.fingerprintAlgorithm
|
.googDerBase64
|
.base64Certificate
|
लेगसी मेट्रिक
googComponent |
स्टैंडर्ड पत्राचार
transport |
---|---|
.localCertificateId
|
.localCertificateId
|
.remoteCertificateId
|
.remoteCertificateId
|
.selectedCandidatePairId
|
.selectedCandidatePairId
|
.dtlsCipher
|
.dtlsCipher
|
.srtpCipher
|
.srtpCipher
|
लेगसी मेट्रिक
localcandidate |
स्टैंडर्ड पत्राचार
local-candidate या candidate-pair |
---|---|
.stunKeepaliveRequestsSent
|
candidate-pair.requestsSent (candidate-pair.localCandidateId के ज़रिए रिवर्स लुकअप candidate-pair ) |
.portNumber
|
local-candidate.port
|
.networkType
|
local-candidate.networkType
|
.ipAddress
|
local-candidate.address
|
.stunKeepaliveResponsesReceived
|
candidate-pair.responsesReceived
|
.stunKeepaliveRttTotal
|
candidate-pair.totalRoundTripTime
|
.transport
|
local-candidate.protocol
|
.candidateType
|
local-candidate.candidateType
|
.priority
|
local-candidate.priority
|
लेगसी मेट्रिक
remotecandidate |
स्टैंडर्ड पत्राचार
remote-candidate |
---|---|
ऊपर बताए गए localcandidate के जैसे ही. |
ऊपर दिए गए local-candidate के जैसा ही. |
लेगसी मेट्रिक
googCandidatePair |
स्टैंडर्ड पत्राचार
candidate-pair |
---|---|
.responsesSent
|
candidate-pair.responsesSent
|
.requestsReceived
|
candidate-pair.requestsReceived
|
.googRemoteCandidateType
|
remote-candidate.candidateType ( candidate-pair.remoteCandidateId के ज़रिए remote-candidate लुकअप करें) |
.googReadable
|
googReadable एक बूलियन है, जो यह दिखाता है कि हमने हाल ही में candidate-pair.requestsReceived या candidate-pair.responsesReceived को बढ़ाया है या नहीं
|
.googLocalAddress
|
local-candidate.address ( candidate-pair.localCandidateId के ज़रिए local-candidate लुकअप करें) |
.consentRequestsSent
|
candidate-pair.consentRequestsSent
|
.googTransportType
|
local-candidate.protocol और remote-candidate.protocol के बराबर. |
.googChannelId
|
candidate-pair.transportId
|
.googLocalCandidateType
|
local-candidate.candidateType
|
.googWritable
|
googWritable एक बूलियन है, जो यह दिखाता है कि क्या हमने हाल ही में candidate-pair.responsesReceived को बढ़ाया है या नहीं
|
.googRemoteAddress
|
remote-candidate.address
|
.googRtt
|
candidate-pair.currentRoundTripTime
|
.googActiveConnection
|
सक्रिय कनेक्शन से उस कैंडिडेट पेयर का मतलब है जिसे ट्रांसपोर्ट ने फ़िलहाल चुना है. जैसे, जहां candidate-pair.id == transport.selectedCandidatePairId |
.packetsDiscardedOnSend
|
candidate-pair.packetsDiscardedOnSend
|
.bytesReceived
|
candidate-pair.bytesReceived
|
.responsesReceived
|
candidate-pair.responsesReceived
|
.remoteCandidateId
|
candidate-pair.remoteCandidateId
|
.localCandidateId
|
candidate-pair.localCandidateId
|
.bytesSent
|
candidate-pair.bytesSent
|
.packetsSent
|
candidate-pair.packetsSent
|
.bytesReceived
|
candidate-pair.bytesReceived
|
.bytesReceived
|
candidate-pair.bytesReceived
|
लेगसी मेट्रिक
ssrc |
स्टैंडर्ड पत्राचार
inbound-rtp , outbound-rtp , media-source |
---|---|
.audioInputLevel
|
media-source.audioLevel . लेगसी मेट्रिक की रेंज [0..32768] है, लेकिन स्टैंडर्ड मेट्रिक की रेंज [0..1] है. |
.audioOutputLevel
|
inbound-rtp.audioLevel . लेगसी मेट्रिक की रेंज [0..32768] है, लेकिन स्टैंडर्ड मेट्रिक की रेंज [0..1] है. |
.packetsLost
|
inbound-rtp.packetsLost
|
.googTrackId
|
स्थानीय MediaStreamTrack के लिए media-source.trackIdentifier और रिमोट MediaStreamTrack के लिए inbound-rtp.trackIdentifier |
.googRtt
|
remote-inbound-rtp.roundTripTime (outbound-rtp.remoteId देखें) |
.googEchoCancellationReturnLossEnhancement
|
inbound-rtp.echoReturnLossEnhancement
|
.googCodecName
|
कोडेक का नाम, "टाइप/सब-टाइप" MIME टाइप का सब-टाइप है, codec.mimeType (inbound-rtp.codecId और outbound-rtp.codecId देखें) |
.transportId
|
inbound-rtp.transportId और outbound-rtp.transportId |
.mediaType
|
inbound-rtp.kind और outbound-rtp.kind या media-source.kind
|
.googEchoCancellationReturnLoss
|
inbound-rtp.echoReturnLoss
|
.totalAudioEnergy
|
inbound-rtp.totalAudioEnergy और media-source.totalAudioEnergy
|
ssrc.totalSamplesDuration
|
inbound-rtp.totalSamplesDuration और media-source.totalSamplesDuration
|
.ssrc
|
inbound-rtp.ssrc और outbound-rtp.ssrc
|
.googJitterReceived
|
inbound-rtp.jitter
|
.packetsSent
|
outbound-rtp.packetsSent
|
.bytesSent
|
outbound-rtp.bytesSent
|
.googContentType
|
inbound-rtp.contentType और outbound-rtp.contentType |
.googFrameWidthInput
|
media-source.width
|
.googFrameHeightInput
|
media-source.height
|
.googFrameRateInput
|
media-source.framesPerSecond
|
.googFrameWidthSent
|
outbound-rtp.frameWidth
|
.googFrameHeightSent
|
outbound-rtp.frameHeight
|
.googFrameRateSent
|
फ़्रेम रेट भेजने की दर, outbound-rtp.framesSent में बदलाव की दर होती है. हालांकि, इसे असल में outbound-rtp.framesPerSecond के तौर पर लागू किया जाता है, जो फ़्रेम रेट को एन्कोड करता है. |
.googFrameWidthReceived
|
inbound-rtp.frameWidth
|
.googFrameHeightReceived
|
inbound-rtp.frameHeight
|
.googFrameRateDecoded
|
inbound-rtp.framesDecoded में बदलाव की दर |
.googFrameRateOutput
|
inbound-rtp.framesDecoded - inbound-rtp.framesDropped के बदलाव की दर |
.hugeFramesSent
|
outbound-rtp.hugeFramesSent
|
.qpSum
|
|
.framesEncoded
|
outbound-rtp.framesEncoded
|
.googAvgEncodeMs
|
|
.codecImplementationName
|
|
.googCpuLimitedResolution
|
अगर outbound-rtp.qualityLimitationReason == "cpu" है, तो सही है |
.googBandwidthLimitedResolution
|
अगर outbound-rtp.qualityLimitationReason == "bandwidth" है, तो सही है |
.googAdaptationChanges
|
लेगसी मेट्रिक, qualityLimitationReason से जुड़ी वजहों से रिज़ॉल्यूशन या फ़्रेम रेट में हुए बदलावों की संख्या की गिनती करती है. इसकी जानकारी, अन्य मेट्रिक से मिल सकती है.उदाहरण के लिए, भेजे गए रिज़ॉल्यूशन या फ़्रेमरेट का सोर्स रिज़ॉल्यूशन या फ़्रेमरेट से अलग होना. हालांकि, हमारे पास सीमित समय है, इसलिए outbound-rtp.qualityLimitationDurations , रिज़ॉल्यूशन या फ़्रेमरेट में बदलाव होने की फ़्रीक्वेंसी के मुकाबले ज़्यादा काम का हो सकता है. |
.googNacksReceived
|
inbound-rtp.nackCount
|
.googNacksSent
|
inbound-rtp.nackCount
|
.googPlisReceived
|
inbound-rtp.pliCount
|
.googPlisSent
|
inbound-rtp.pliCount
|
.googFirsReceived
|
inbound-rtp.firCount
|
.googFirsSent
|
inbound-rtp.firCount
|
.googSecondaryDecodedRate
|
गड़बड़ी ठीक करने वाले पैकेट का हाल ही का अनुपात: inbound-rtp.fecPacketsReceived - inbound-rtp.fecPacketsDiscarded |
.packetsReceived
|
inbound-rtp.packetsReceived
|
.googJitterBufferMs
|
inbound-rtp.jitterBufferDelay / inbound-rtp.jitterBufferEmittedCount
|
.googTargetDelayMs (वीडियो) |
inbound-rtp.jitterBufferTargetDelay / inbound-rtp.jitterBufferEmittedCount
|
.googPreferredJitterBufferMs (ऑडियो) |
inbound-rtp.jitterBufferTargetDelay / inbound-rtp.jitterBufferEmittedCount
|
.googExpandRate
|
छिपाए गए सैंपल का हाल ही का अनुपात: inbound-rtp.concealedSamples / inbound-rtp.totalSamplesReceived |
.googSpeechExpandRate
|
स्ट्रीम के दौरान, छिपाए गए सैंपल का हाल ही का अनुपात: (inbound-rtp.concealedSamples - inbound-rtp.silentConcealedSamples ) / inbound-rtp.concealedSamples |
.googAccelerateRate
|
हाल ही में, वीडियो चलाने की स्पीड बढ़ाने के लिए हटाए गए सैंपल का अनुपात: inbound-rtp.removedSamplesForAcceleration / inbound-rtp.totalSamplesReceived |
.googPreemptiveExpandRate
|
प्लेआउट की स्पीड कम करने के लिए, सिंथेटिक तरीके से बनाए गए सैंपल का हाल ही का अनुपात: inbound-rtp.insertedSamplesForDeceleration / inbound-rtp.totalSamplesReceived |
.googSecondaryDiscardedRate
|
inbound-rtp.fecPacketsDiscarded
|
.bytesReceived
|
inbound-rtp.bytesReceived
|
s.googCurrentDelayMs
|
inbound-rtp.jitterBufferDelay + media-playout.totalPlayoutDelay
|
.googDecodeMs
|
inbound-rtp.totalDecodeTime / inbound-rtp.framesDecoded
|
.googTimingFrameInfo
|
बस एक ही goog-मेट्रिक बची है. inbound-rtp.googTimingFrameInfo |
.framesDecoded
|
inbound-rtp.framesDecoded
|
लेगसी मेट्रिक
VideoBwe |
स्टैंडर्ड पत्राचार
outbound-rtp और candidate-pair |
---|---|
.googTargetEncBitrate
|
outbound-rtp.targetBitrate को एक तय समय की वैल्यू के तौर पर या outbound-rtp.totalEncodedBytesTarget / outbound-rtp.framesEncoded को औसत के तौर पर |
.googActualEncBitrate
|
एन्कोडर से जनरेट किए गए बाइट, पेलोड बाइट होते हैं. इनमें फिर से भेजे गए बाइट शामिल नहीं होते: outbound-rtp.bytesSent - outbound-rtp.retransmittedBytesSent के बदलाव की दर |
.googBucketDelay
|
outbound-rtp.totalPacketSendDelay / outbound-rtp.packetsSent
|
.googTransmitBitrate
|
हर आरटीपी स्ट्रीम बिटरेट के लिए outbound-rtp.headerBytesSent + outbound-rtp.bytesSent , हर आईसीई कैंडिडेट बिटरेट के लिए candidate-pair.bytesSent या हर ट्रांसपोर्ट बिटरेट के लिए transport.bytesSent में बदलाव की दर |
.googRetransmitBitrate
|
outbound-rtp.retransmittedBytesSent में बदलाव की रेंज |
.googAvailableSendBandwidth
|
candidate-pair.availableOutgoingBitrate
|
.googAvailableReceiveBandwidth
|
candidate-pair.availableIncomingBitrate
|
स्टैंडर्ड एपीआई, सिमकास्ट के बारे में जानता है
अगर सिम्युलकास्ट का इस्तेमाल किया जाता है, तो हो सकता है कि आपने देखा हो कि लेगसी एपीआई सिर्फ़ एक एसएसआरसी की रिपोर्ट करता है. भले ही, तीन अलग-अलग एसएसआरसी पर तीन आरटीपी स्ट्रीम भेजने के लिए, सिम्युलकास्ट का इस्तेमाल किया जा रहा हो.
स्टैंडर्ड एपीआई में यह सीमा नहीं होती. यह तीन outbound-rtp
आंकड़ों के ऑब्जेक्ट दिखाएगा, हर SSRC के लिए एक. इसका मतलब है कि हर आरटीपी स्ट्रीम का अलग से विश्लेषण किया जा सकता है. हालांकि, इसका यह भी मतलब है कि सभी आरटीपी भेजने वाली स्ट्रीम की कुल बिटरेट पाने के लिए, आपको उन्हें खुद इकट्ठा करना होगा.
दूसरी ओर, scalabilityMode
API की मदद से कॉन्फ़िगर की गई कई स्पेस लेयर वाली एसवीसी स्ट्रीम या आरटीपी स्ट्रीम, अब भी एक outbound-rtp
के तौर पर दिखती हैं. ऐसा इसलिए होता है, क्योंकि इन्हें एक ही एसएसआरसी पर भेजा जाता है.
अगर आपको माइग्रेशन के लिए ज़्यादा समय चाहिए
Chrome 117 में लेगसी एपीआई हटाए जाने के बाद, इसका इस्तेमाल करने पर अपवाद जनरेट होगा. अगर आपने समय पर अपना कोड माइग्रेट नहीं किया है, तो RTCPeerConnection कॉलबैक पर आधारित getStats() API के लिए ऑरिजिन ट्रायल की मदद से, रजिस्टर की गई वेबसाइटों को माइग्रेट करने के लिए ज़्यादा समय मिलता है. ऑरिजिन ट्रायल टोकन की मदद से, Chrome के वर्शन 121 तक, getStats() एपीआई का इस्तेमाल किया जा सकता है.