How to use validateRtcStats method in wpt

Best JavaScript code snippet using wpt

RTCStats-helper.js

Source:RTCStats-helper.js Github

copy

Full Screen

...57 const validator = statsValidatorTable[stats.type];58 if(validator) {59 validator(statsReport, stats);60 } else {61 validateRtcStats(statsReport, stats);62 }63 }64}65// Assert that the stats report have stats objects of66// given types67function assert_stats_report_has_stats(statsReport, statsTypes) {68 const hasTypes = new Set([...statsReport.values()]69 .map(stats => stats.type));70 for(const type of statsTypes) {71 assert_true(hasTypes.has(type),72 `Expect statsReport to contain stats object of type ${type}`);73 }74}75// Get stats object of type that is expected to be76// found in the statsReport77function getRequiredStats(statsReport, type) {78 for(const stats of statsReport.values()) {79 if(stats.type === type) {80 return stats;81 }82 }83 assert_unreached(`required stats of type ${type} is not found in stats report`);84}85// Get stats object by the stats ID.86// This is used to retreive other stats objects87// linked to a stats object88function getStatsById(statsReport, statsId) {89 assert_true(statsReport.has(statsId),90 `Expect stats report to have stats object with id ${statsId}`);91 return statsReport.get(statsId);92}93// Validate an ID field in a stats object by making sure94// that the linked stats object is found in the stats report95// and have the type field value same as expected type96// It doesn't validate the other fields of the linked stats97// as validateStatsReport already does all validations98function validateIdField(statsReport, stats, field, type) {99 assert_string_field(stats, field);100 const linkedStats = getStatsById(statsReport, stats[field]);101 assert_equals(linkedStats.type, type,102 `Expect linked stats object to have type ${type}`);103}104function validateOptionalIdField(statsReport, stats, field, type) {105 if(stats[field] !== undefined) {106 validateIdField(statsReport, stats, field, type);107 }108}109/*110 [webrtc-pc]111 8.4. RTCStats Dictionary112 dictionary RTCStats {113 required DOMHighResTimeStamp timestamp;114 required RTCStatsType type;115 required DOMString id;116 };117 */118function validateRtcStats(statsReport, stats) {119 assert_number_field(stats, 'timeStamp');120 assert_string_field(stats, 'type');121 assert_string_field(stats, 'id');122}123/*124 [webrtc-stats]125 7.1. RTCRTPStreamStats dictionary126 dictionary RTCRTPStreamStats : RTCStats {127 required unsigned long ssrc;128 required DOMString mediaType;129 [RTCMediaStreamTrackStats]130 required DOMString trackId;131 [RTCTransportStats]132 required DOMString transportId;133 [RTCCodecStats]134 required DOMString codecId;135 unsigned long firCount;136 unsigned long pliCount;137 required unsigned long nackCount;138 unsigned long sliCount;139 unsigned long long qpSum;140 };141 [webrtc-pc]142 8.6. Mandatory To Implement Stats143 - RTCRTPStreamStats, with attributes ssrc, associateStatsId, isRemote, mediaType,144 mediaTrackId, transportId, codecId, nackCount145 */146function validateRtpStreamStats(statsReport, stats) {147 validateRtcStats(statsReport, stats);148 assert_unsigned_int_field(stats, 'ssrc');149 assert_string_field(stats, 'mediaType');150 validateIdField(statsReport, stats, 'trackId', 'track');151 validateIdField(statsReport, stats, 'transportId', 'transport');152 validateIdField(statsReport, stats, 'codecId', 'codec');153 assert_optional_unsigned_int_field(stats, 'firCount');154 assert_optional_unsigned_int_field(stats, 'pliCount');155 assert_unsigned_int_field(stats, 'nackCount');156 assert_optional_unsigned_int_field(stats, 'sliCount');157 assert_optional_unsigned_int_field(stats, 'qpSum');158}159/*160 [webrtc-stats]161 7.2. RTCCodecStats dictionary162 dictionary RTCCodecStats : RTCStats {163 required unsigned long payloadType;164 required RTCCodecType codecType;165 [RTCTransportStats]166 DOMString transportId;167 DOMString mimeType;168 required unsigned long clockRate;169 required unsigned long channels;170 DOMString sdpFmtpLine;171 DOMString implementation;172 };173 enum RTCCodecType {174 "encode",175 "decode",176 };177 [webrtc-pc]178 8.6. Mandatory To Implement Stats179 - RTCCodecStats, with attributes payloadType, codec, clockRate, channels, parameters180 */181function validateCodecStats(statsReport, stats) {182 validateRtcStats(statsReport, stats);183 assert_unsigned_int_field(stats, 'payloadType');184 assert_enum_field(stats, 'codecType', ['encode', 'decode']);185 validateOptionalIdField(statsReport, stats, 'transportId', 'transport');186 assert_optional_string_field(stats, 'mimeType');187 assert_unsigned_int_field(stats, 'clockRate');188 assert_unsigned_int_field(stats, 'channels');189 assert_optional_string_field(stats, 'sdpFmtpLine');190 assert_optional_string_field(stats, 'implementation');191}192/*193 [webrtc-stats]194 7.3. RTCReceivedRTPStreamStats dictionary195 dictionary RTCReceivedRTPStreamStats : RTCRTPStreamStats {196 unsigned long packetsReceived;197 unsigned long long bytesReceived;198 unsigned long packetsLost;199 double jitter;200 double fractionLost;201 unsigned long packetsDiscarded;202 unsigned long packetsRepaired;203 unsigned long burstPacketsLost;204 unsigned long burstPacketsDiscarded;205 unsigned long burstLossCount;206 unsigned long burstDiscardCount;207 double burstLossRate;208 double burstDiscardRate;209 double gapLossRate;210 double gapDiscardRate;211 };212 */213function validateReceivedRtpStreamStats(statsReport, stats) {214 validateRtpStreamStats(statsReport, stats);215 assert_optional_unsigned_int_field(stats, 'packetsReceived');216 assert_optional_unsigned_int_field(stats, 'bytesReceived');217 assert_optional_unsigned_int_field(stats, 'packetsLost');218 assert_optional_number_field(stats, 'jitter');219 assert_optional_number_field(stats, 'fractionLost');220 assert_optional_unsigned_int_field(stats, 'packetsDiscarded');221 assert_optional_unsigned_int_field(stats, 'packetsRepaired');222 assert_optional_unsigned_int_field(stats, 'burstPacketsLost');223 assert_optional_unsigned_int_field(stats, 'burstPacketsDiscarded');224 assert_optional_unsigned_int_field(stats, 'burstLossCount');225 assert_optional_unsigned_int_field(stats, 'burstDiscardCount');226 assert_optional_number_field(stats, 'burstLossRate');227 assert_optional_number_field(stats, 'burstDiscardRate');228 assert_optional_number_field(stats, 'gapLossRate');229 assert_optional_number_field(stats, 'gapDiscardRate');230}231/*232 [webrtc-stats]233 7.4. RTCInboundRTPStreamStats dictionary234 dictionary RTCInboundRTPStreamStats : RTCReceivedRTPStreamStats {235 required unsigned long packetsReceived;236 required unsigned long long bytesReceived;237 required unsigned long packetsLost;238 required double jitter;239 required unsigned long packetsDiscarded;240 [RTCRemoteOutboundRTPStreamStats]241 DOMString remoteId;242 unsigned long framesDecoded;243 DOMHighResTimeStamp lastPacketReceivedTimestamp;244 };245 [webrtc-pc]246 8.6. Mandatory To Implement Stats247 - RTCInboundRTPStreamStats, with all required attributes from RTCRTPStreamStats,248 and also attributes packetsReceived, bytesReceived, packetsLost, jitter,249 packetsDiscarded250 */251function validateInboundRtpStreamStats(statsReport, stats) {252 validateReceivedRtpStreamStats(statsReport, stats);253 assert_unsigned_int_field(stats, 'packetsReceived');254 assert_unsigned_int_field(stats, 'bytesReceived');255 assert_unsigned_int_field(stats, 'packetsLost');256 assert_number_field(stats, 'jitter');257 assert_unsigned_int_field(stats, 'packetsDiscarded');258 validateOptionalIdField(statsReport, stats, 'remoteId', 'remote-outbound-rtp');259 assert_optional_unsigned_int_field(stats, 'framesDecoded');260 assert_optional_number_field(stats, 'lastPacketReceivedTimeStamp');261}262/*263 [webrtc-stats]264 7.5. RTCRemoteInboundRTPStreamStats dictionary265 dictionary RTCRemoteInboundRTPStreamStats : RTCReceivedRTPStreamStats {266 [RTCOutboundRTPStreamStats]267 DOMString localId;268 double roundTripTime;269 };270 */271function validateRemoteInboundRtpStreamStats(statsReport, stats) {272 validateReceivedRtpStreamStats(statsReport, stats);273 validateOptionalIdField(statsReport, stats, 'localId', 'outbound-rtp');274 assert_optional_number_field(stats, 'roundTripTime');275}276/*277 [webrtc-stats]278 7.6. RTCSentRTPStreamStats dictionary279 dictionary RTCSentRTPStreamStats : RTCRTPStreamStats {280 unsigned long packetsSent;281 unsigned long packetsDiscardedOnSend;282 unsigned long long bytesSent;283 unsigned long long bytesDiscardedOnSend;284 };285 */286function validateSentRtpStreamStats(statsReport, stats) {287 validateRtpStreamStats(statsReport, stats);288 assert_optional_unsigned_int_field(stats, 'packetsSent');289 assert_optional_unsigned_int_field(stats, 'packetsDiscardedOnSend');290 assert_optional_unsigned_int_field(stats, 'bytesSent');291 assert_optional_unsigned_int_field(stats, 'bytesDiscardedOnSend');292}293/*294 [webrtc-stats]295 7.7. RTCOutboundRTPStreamStats dictionary296 dictionary RTCOutboundRTPStreamStats : RTCSentRTPStreamStats {297 required unsigned long packetsSent;298 required unsigned long long bytesSent;299 [RTCRemoteInboundRTPStreamStats]300 DOMString remoteId;301 DOMHighResTimeStamp lastPacketSentTimestamp;302 double targetBitrate;303 unsigned long framesEncoded;304 double totalEncodeTime;305 double averageRTCPInterval;306 };307 [webrtc-pc]308 8.6. Mandatory To Implement Stats309 - RTCOutboundRTPStreamStats, with all required attributes from RTCRTPStreamStats,310 and also attributes packetsSent, bytesSent, roundTripTime311 */312function validateOutboundRtpStreamStats(statsReport, stats) {313 validateOptionalIdField(statsReport, stats, 'remoteId', 'remote-inbound-rtp');314 assert_unsigned_int_field(stats, 'packetsSent');315 assert_unsigned_int_field(stats, 'bytesSent');316 assert_optional_number_field(stats, 'lastPacketSentTimestamp');317 assert_optional_number_field(stats, 'targetBitrate');318 assert_optional_unsigned_int_field(stats, 'framesEncoded');319 assert_optional_number_field(stats, 'totalEncodeTime');320 assert_optional_number_field(stats, 'averageRTCPInterval');321}322/*323 [webrtc-stats]324 7.8. RTCRemoteOutboundRTPStreamStats dictionary325 dictionary RTCRemoteOutboundRTPStreamStats : RTCSentRTPStreamStats {326 [RTCInboundRTPStreamStats]327 DOMString localId;328 DOMHighResTimeStamp remoteTimestamp;329 };330 */331function validateRemoteOutboundRtpStreamStats(statsReport, stats) {332 validateSentRtpStreamStats(statsReport, stats);333 validateOptionalIdField(statsReport, stats, 'localId', 'inbound-rtp');334 assert_optional_number_field(stats, 'remoteTimeStamp');335}336/*337 [webrtc-stats]338 7.9. RTCRTPContributingSourceStats339 dictionary RTCRTPContributingSourceStats : RTCStats {340 unsigned long contributorSsrc;341 [RTCInboundRTPStreamStats]342 DOMString inboundRtpStreamId;343 unsigned long packetsContributedTo;344 double audioLevel;345 };346 */347function validateContributingSourceStats(statsReport, stats) {348 validateRtcStats(statsReport, stats);349 assert_optional_unsigned_int_field(stats, 'contributorSsrc');350 validateOptionalIdField(statsReport, stats, 'inboundRtpStreamId', 'inbound-rtp');351 assert_optional_unsigned_int_field(stats, 'packetsContributedTo');352 assert_optional_number_field(stats, 'audioLevel');353}354/*355 [webrtc-stats]356 7.10. RTCPeerConnectionStats dictionary357 dictionary RTCPeerConnectionStats : RTCStats {358 required unsigned long dataChannelsOpened;359 required unsigned long dataChannelsClosed;360 unsigned long dataChannelsRequested;361 unsigned long dataChannelsAccepted;362 };363 [webrtc-pc]364 8.6. Mandatory To Implement Stats365 - RTCPeerConnectionStats, with attributes dataChannelsOpened, dataChannelsClosed366 */367function validatePeerConnectionStats(statsReport, stats) {368 validateRtcStats(statsReport, stats);369 assert_unsigned_int_field(stats, 'dataChannelsOpened');370 assert_unsigned_int_field(stats, 'dataChannelsClosed');371 assert_optional_unsigned_int_field(stats, 'dataChannelsRequested');372 assert_optional_unsigned_int_field(stats, 'dataChannelsAccepted');373}374/*375 [webrtc-stats]376 7.11. RTCMediaStreamStats dictionary377 dictionary RTCMediaStreamStats : RTCStats {378 required DOMString streamIdentifier;379 [RTCMediaStreamTrackStats]380 required sequence<DOMString> trackIds;381 };382 [webrtc-pc]383 8.6. Mandatory To Implement Stats384 - RTCMediaStreamStats, with attributes streamIdentifer, trackIds385 */386function validateMediaStreamStats(statsReport, stats) {387 validateRtcStats(statsReport, stats);388 assert_string_field(stats, 'streamIdentifier');389 assert_array_field(stats, 'trackIds');390 for(const trackId of stats.trackIds) {391 assert_equals(typeof trackId, 'string',392 'Expect trackId elements to be string');393 assert_true(statsReport.has(trackId),394 `Expect stats report to have stats object with id ${trackId}`);395 const trackStats = statsReport.get(trackId);396 assert_equals(trackStats.type, 'track',397 `Expect track stats object to have type 'track'`);398 }399}400/*401 [webrtc-stats]402 7.12. RTCMediaStreamTrackStats dictionary403 dictionary RTCMediaStreamTrackStats : RTCStats {404 required DOMString trackIdentifier;405 required boolean remoteSource;406 required boolean ended;407 required boolean detached;408 DOMString kind;409 DOMHighResTimeStamp estimatedPlayoutTimestamp;410 required unsigned long frameWidth;411 required unsigned long frameHeight;412 required double framesPerSecond;413 unsigned long framesCaptured;414 required unsigned long framesSent;415 required unsigned long framesReceived;416 required unsigned long framesDecoded;417 required unsigned long framesDropped;418 required unsigned long framesCorrupted;419 unsigned long partialFramesLost;420 unsigned long fullFramesLost;421 required double audioLevel;422 double totalAudioEnergy;423 boolean voiceActivityFlag;424 double echoReturnLoss;425 double echoReturnLossEnhancement;426 unsigned long long totalSamplesSent;427 unsigned long long totalSamplesReceived;428 double totalSamplesDuration;429 unsigned long long concealedSamples;430 unsigned long long concealmentEvents;431 double jitterBufferDelay;432 RTCPriorityType priority;433 };434 [webrtc-pc]435 4.9.1. RTCPriorityType Enum436 enum RTCPriorityType {437 "very-low",438 "low",439 "medium",440 "high"441 };442 8.6. Mandatory To Implement Stats443 - RTCMediaStreamTrackStats, with attributes trackIdentifier, remoteSource, ended,444 detached, ssrcIds, frameWidth, frameHeight, framesPerSecond, framesSent,445 framesReceived, framesDecoded, framesDropped, framesCorrupted, audioLevel446 */447function validateMediaStreamTrackStats(stats, stat) {448 validateRtcStats(statsReport, stats);449 assert_string_field(stat, 'trackIdentifier');450 assert_boolean_field(stat, 'remoteSource');451 assert_boolean_field(stat, 'ended');452 assert_boolean_field(stat, 'detached');453 assert_optional_string_field(stat, 'kind');454 assert_optional_number_field(stat, 'estimatedPlayoutTimestamp');455 assert_unsigned_int_field(stat, 'frameWidth');456 assert_unsigned_int_field(stat, 'frameHeight');457 assert_number_field(stat, 'framesPerSecond');458 assert_optional_unsigned_int_field(stat, 'framesCaptured');459 assert_unsigned_int_field(stat, 'frameSent');460 assert_unsigned_int_field(stat, 'frameReceived');461 assert_unsigned_int_field(stat, 'frameDecoded');462 assert_unsigned_int_field(stat, 'frameDropped');463 assert_unsigned_int_field(stat, 'frameCorrupted');464 assert_optional_unsigned_int_field(stat, 'partialFramesLost');465 assert_optional_unsigned_int_field(stat, 'fullFramesLost');466 assert_number_field(stat, 'audioLevel');467 assert_optional_number_field(stat, 'totalAudioEnergy');468 assert_optional_boolean_field(stat, 'voiceActivityFlag');469 assert_optional_number_field(stat, 'echoReturnLoss');470 assert_optional_number_field(stat, 'echoReturnLossEnhancement');471 assert_optional_unsigned_int_field(stat, 'totalSamplesSent');472 assert_optional_unsigned_int_field(stat, 'totalSamplesReceived');473 assert_optional_number_field(stat, 'totalSamplesDuration');474 assert_optional_unsigned_int_field(stat, 'concealedSamples');475 assert_optional_unsigned_int_field(stat, 'concealmentEvents');476 assert_optional_number_field(stat, 'jitterBufferDelay');477 assert_optional_enum_field(stats, 'priority',478 ['very-low', 'low', 'medium', 'high']);479}480/*481 [webrtc-stats]482 7.13. RTCDataChannelStats dictionary483 dictionary RTCDataChannelStats : RTCStats {484 required DOMString label;485 required DOMString protocol;486 required long datachannelid;487 [RTCTransportStats]488 DOMString transportId;489 required RTCDataChannelState state;490 required unsigned long messagesSent;491 required unsigned long long bytesSent;492 required unsigned long messagesReceived;493 required unsigned long long bytesReceived;494 };495 [webrtc-pc]496 6.2. RTCDataChannel497 enum RTCDataChannelState {498 "connecting",499 "open",500 "closing",501 "closed"502 };503 8.6. Mandatory To Implement Stats504 - RTCDataChannelStats, with attributes label, protocol, datachannelId, state,505 messagesSent, bytesSent, messagesReceived, bytesReceived506 */507function validateDataChannelStats(statsReport, stats) {508 validateRtcStats(statsReport, stats);509 assert_string_field(stats, 'label');510 assert_string_field(stats, 'protocol');511 assert_int_field(stats, 'datachannelid');512 validateOptionalIdField(statsReport, stats, 'transportId', 'transport');513 assert_enum_field(stats, 'state',514 ['connecting', 'open', 'closing', 'closed']);515 assert_unsigned_int_field(stats, 'messageSent');516 assert_unsigned_int_field(stats, 'messageSent');517 assert_unsigned_int_field(stats, 'bytesSent');518 assert_unsigned_int_field(stats, 'messagesReceived');519 assert_unsigned_int_field(stats, 'bytesReceived');520}521/*522 [webrtc-stats]523 7.14. RTCTransportStats dictionary524 dictionary RTCTransportStats : RTCStats {525 unsigned long packetsSent;526 unsigned long packetsReceived;527 required unsigned long long bytesSent;528 required unsigned long long bytesReceived;529 [RTCTransportStats]530 required DOMString rtcpTransportStatsId;531 RTCIceRole iceRole;532 RTCDtlsTransportState dtlsState;533 [RTCIceCandidatePairStats]534 required DOMString selectedCandidatePairId;535 [RTCCertificateStats]536 required DOMString localCertificateId;537 [RTCCertificateStats]538 required DOMString remoteCertificateId;539 };540 [webrtc-pc]541 5.5. RTCDtlsTransportState Enum542 enum RTCDtlsTransportState {543 "new",544 "connecting",545 "connected",546 "closed",547 "failed"548 };549 5.6. RTCIceRole Enum550 enum RTCIceRole {551 "controlling",552 "controlled"553 };554 8.6. Mandatory To Implement Stats555 - RTCTransportStats, with attributes bytesSent, bytesReceived, rtcpTransportStatsId,556 activeConnection, selectedCandidatePairId, localCertificateId, remoteCertificateId557 */558function validateTransportStats(statsReport, stats) {559 validateRtcStats(statsReport, stats);560 assert_optional_unsigned_int_field(stats, 'packetsSent');561 assert_optional_unsigned_int_field(stats, 'packetsReceived');562 assert_unsigned_int_field(stats, 'bytesSent');563 assert_unsigned_int_field(stats, 'bytesReceived');564 validateIdField(statsReport, stats, 'rtcpTransportStatsId', 'transport');565 assert_optional_enum_field(stats, 'iceRole',566 ['controlling', 'controlled']);567 assert_optional_enum_field(stats, 'dtlsState',568 ['new', 'connecting', 'connected', 'closed', 'failed']);569 validateIdField(statsReport, stats, 'selectedCandidatePairId', 'candidate-pair');570 validateIdField(stateReport, stats, 'localCertificateId', 'certificate');571 validateIdField(stateReport, stats, 'remoteCertificateId', 'certificate');572}573/*574 [webrtc-stats]575 7.15. RTCIceCandidateStats dictionary576 dictionary RTCIceCandidateStats : RTCStats {577 [RTCTransportStats]578 DOMString transportId;579 boolean isRemote;580 required DOMString ip;581 required long port;582 required DOMString protocol;583 required RTCIceCandidateType candidateType;584 required long priority;585 required DOMString url;586 DOMString relayProtocol;587 boolean deleted = false;588 };589 [webrtc-pc]590 4.8.1.3. RTCIceCandidateType Enum591 enum RTCIceCandidateType {592 "host",593 "srflx",594 "prflx",595 "relay"596 };597 8.6. Mandatory To Implement Stats598 - RTCIceCandidateStats, with attributes ip, port, protocol, candidateType, priority,599 url600 */601function validateIceCandidateStats(statsReport, stats) {602 validateRtcStats(statsReport, stats);603 validateOptionalIdField(statsReport, stats, 'transportId', 'transport');604 assert_optional_boolean_field(stats, 'isRemote');605 assert_string_field(stats, 'ip');606 assert_int_field(stats, 'port');607 assert_string_field(stats, 'protocol');608 assert_enum_field(stats, 'candidateType',609 ['host', 'srflx', 'prflx', 'relay']);610 assert_int_field(stats, 'priority');611 assert_string_field(stats, 'url');612 assert_optional_string_field(stats, 'relayProtocol');613 assert_optional_boolean_field(stats, 'deleted');614}615/*616 [webrtc-stats]617 7.16. RTCIceCandidatePairStats dictionary618 dictionary RTCIceCandidatePairStats : RTCStats {619 [RTCTransportStats]620 required DOMString transportId;621 [RTCIceCandidateStats]622 required DOMString localCandidateId;623 [RTCIceCandidateStats]624 required DOMString remoteCandidateId;625 required RTCStatsIceCandidatePairState state;626 required unsigned long long priority;627 required boolean nominated;628 unsigned long packetsSent;629 unsigned long packetsReceived;630 required unsigned long long bytesSent;631 required unsigned long long bytesReceived;632 DOMHighResTimeStamp lastPacketSentTimestamp;633 DOMHighResTimeStamp lastPacketReceivedTimestamp;634 DOMHighResTimeStamp firstRequestTimestamp;635 DOMHighResTimeStamp lastRequestTimestamp;636 DOMHighResTimeStamp lastResponseTimestamp;637 required double totalRoundTripTime;638 required double currentRoundTripTime;639 double availableOutgoingBitrate;640 double availableIncomingBitrate;641 unsigned long circuitBreakerTriggerCount;642 unsigned long long requestsReceived;643 unsigned long long requestsSent;644 unsigned long long responsesReceived;645 unsigned long long responsesSent;646 unsigned long long retransmissionsReceived;647 unsigned long long retransmissionsSent;648 unsigned long long consentRequestsSent;649 DOMHighResTimeStamp consentExpiredTimestamp;650 };651 enum RTCStatsIceCandidatePairState {652 "frozen",653 "waiting",654 "in-progress",655 "failed",656 "succeeded"657 };658 [webrtc-pc]659 8.6. Mandatory To Implement Stats660 - RTCIceCandidatePairStats, with attributes transportId, localCandidateId,661 remoteCandidateId, state, priority, nominated, writable, readable, bytesSent,662 bytesReceived, totalRtt, currentRtt663 */664function validateIceCandidatePairStats(statsReport, stats) {665 validateRtcStats(statsReport, stats);666 validateIdField(statsReport, stats, 'transportId', 'transport');667 validateIdField(statsReport, stats, 'localCandidateId', 'local-candidate');668 validateIdField(statsReport, stats, 'remoteCandidateId', 'remote-candidate');669 assert_enum_field(stats, 'state',670 ['frozen', 'waiting', 'in-progress', 'failed', 'succeeded']);671 assert_unsigned_int_field(stats, 'priority');672 assert_boolean_field(stats, 'nominated');673 assert_optional_unsigned_int_field(stats, 'packetsSent');674 assert_optional_unsigned_int_field(stats, 'packetsReceived');675 assert_unsigned_int_field(stats, 'bytesSent');676 assert_unsigned_int_field(stats, 'byteReceived');677 assert_optional_number_field(stats, 'lastPacketSentTimestamp');678 assert_optional_number_field(stats, 'lastPacketReceivedTimestamp');679 assert_optional_number_field(stats, 'firstRequestTimestamp');680 assert_optional_number_field(stats, 'lastRequestTimestamp');681 assert_optional_number_field(stats, 'lastResponseTimestamp');682 assert_number_field(stats, 'totalRoundTripTime');683 assert_number_field(stats, 'currentRoundTripTime');684 assert_optional_number_field(stats, 'availableOutgoingBitrate');685 assert_optional_number_field(stats, 'availableIncomingBitrate');686 assert_optional_unsigned_int_field(stats, 'circuitBreakerTriggerCount');687 assert_optional_unsigned_int_field(stats, 'requestsReceived');688 assert_optional_unsigned_int_field(stats, 'requestsSent');689 assert_optional_unsigned_int_field(stats, 'responsesReceived');690 assert_optional_unsigned_int_field(stats, 'responsesSent');691 assert_optional_unsigned_int_field(stats, 'retransmissionsReceived');692 assert_optional_unsigned_int_field(stats, 'retransmissionsSent');693 assert_optional_unsigned_int_field(stats, 'consentRequestsSent');694 assert_optional_number_field(stats, 'consentExpiredTimestamp');695}696/*697 [webrtc-stats]698 7.17. RTCCertificateStats dictionary699 dictionary RTCCertificateStats : RTCStats {700 required DOMString fingerprint;701 required DOMString fingerprintAlgorithm;702 required DOMString base64Certificate;703 required DOMString issuerCertificateId;704 };705 [webrtc-pc]706 8.6. Mandatory To Implement Stats707 - RTCCertificateStats, with attributes fingerprint, fingerprintAlgorithm,708 base64Certificate, issuerCertificateId709 */710function validateCertificateStats(statsReport, stats) {711 validateRtcStats(statsReport, stats);712 assert_string_field(stats, 'fingerprint');713 assert_string_field(stats, 'fingerprintAlgorithm');714 assert_string_field(stats, 'base64Certificate');715 assert_string_field(stats, 'issuerCertificateId');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');3wpt.validateRtcStats(function(err, data) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log(data);8 }9});10WebPageTest.prototype.validateRtcStats = function(callback) {11 this._makeRequest('validateRtcStats', null, callback);12};13WebPageTest.prototype._makeRequest = function(method, params, callback) {14 var self = this;15 var url = this._getApiUrl(method, params);16 request(url, function(err, res, body) {17 if (!err && res.statusCode == 200) {18 callback(null, body);19 } else {20 callback(err || body);21 }22 });23};24WebPageTest.prototype._getApiUrl = function(method, params) {25 var url = this._apiUrl + '?k=' + this._apiKey + '&f=json&' + method;26 if (params) {27 for (var key in params) {28 url += '&' + key + '=' + params[key];29 }30 }31 return url;32};33var WebPageTest = function(host, apiKey) {34 this._apiKey = apiKey;35};36module.exports = WebPageTest;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptb = require('./wptb.js');2var result = wptb.validateRtcStats(stats);3console.log(result);4module.exports = {5 validateRtcStats: function (stats) {6 var result = {};7 result["result"] = "pass";8 result["message"] = "All stats are valid";9 return result;10 }11};12module.exports = {13 validateRtcStats: function (stats) {14 var result = {};15 result["result"] = "pass";16 result["message"] = "All stats are valid";17 return result;18 }19};20module.exports = {21 validateRtcStats: function (stats) {22 var result = {};23 result["result"] = "pass";24 result["message"] = "All stats are valid";25 return result;26 }27};28module.exports = {29 validateRtcStats: function (stats) {30 var result = {};31 result["result"] = "pass";32 result["message"] = "All stats are valid";33 return result;34 }35};36module.exports = {37 validateRtcStats: function (stats) {38 var result = {};39 result["result"] = "pass";40 result["message"] = "All stats are valid";41 return result;42 }43};44module.exports = {45 validateRtcStats: function (stats) {46 var result = {};47 result["result"] = "pass";48 result["message"] = "All stats are valid";49 return result;50 }51};52module.exports = {53 validateRtcStats: function (stats) {54 var result = {};55 result["result"] = "pass";56 result["message"] = "All stats are valid";57 return result;58 }59};60module.exports = {61 validateRtcStats: function (stats) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var test = new wpt();2test.validateRtcStats("test.json", function (err, result) {3 if (err) {4 console.log("Error: " + err);5 }6 else {7 console.log("Result: " + result);8 }9});10var test = new wpt();11var pc = new RTCPeerConnection();12var options = { optional: [{ RtpDataChannels: true }] };13var dataChannel = pc.createDataChannel('test', options);14var stats = pc.getStats(null);15test.validateRtcStats(stats, function (err, result) {16 if (err) {17 console.log("Error: " + err);18 }19 else {20 console.log("Result: " + result);21 }22});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful