statstypes.cc revision c57310b982cdce138723de91d7b722f8199834ab
15c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org/* 25c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * libjingle 35c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * Copyright 2014, Google Inc. 45c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * 55c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * Redistribution and use in source and binary forms, with or without 65c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * modification, are permitted provided that the following conditions are met: 75c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * 85c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 95c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * this list of conditions and the following disclaimer. 105c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 115c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * this list of conditions and the following disclaimer in the documentation 125c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * and/or other materials provided with the distribution. 135c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * 3. The name of the author may not be used to endorse or promote products 145c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * derived from this software without specific prior written permission. 155c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * 165c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 175c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 185c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 195c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 215c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 225c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 235c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 245c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 255c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org */ 275c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org 285c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org#include "talk/app/webrtc/statstypes.h" 295c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org 305c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.orgnamespace webrtc { 315c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org 32c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeSession[] = "googLibjingleSession"; 33c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeBwe[] = "VideoBwe"; 34c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeRemoteSsrc[] = "remoteSsrc"; 35c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeSsrc[] = "ssrc"; 36c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeTrack[] = "googTrack"; 37c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeIceCandidate[] = "iceCandidate"; 38c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeTransport[] = "googTransport"; 39c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeComponent[] = "googComponent"; 40c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeCandidatePair[] = "googCandidatePair"; 41c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeCertificate[] = "googCertificate"; 42c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 43c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportVideoBweId[] = "bweforvideo"; 44c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 45c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::StatsReport(const StatsReport& src) 46c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org : id(src.id), 47c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org type(src.type), 48c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org timestamp(src.timestamp), 49c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org values(src.values) { 50c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 51c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 52c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::StatsReport(const std::string& id) 53c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org : id(id), timestamp(0) { 54c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 55c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 56c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport& StatsReport::operator=(const StatsReport& src) { 57c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org ASSERT(id == src.id); 58c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org type = src.type; 59c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org timestamp = src.timestamp; 60c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org values = src.values; 61c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return *this; 62c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 63c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 64c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// Operators provided for STL container/algorithm support. 65c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgbool StatsReport::operator<(const StatsReport& other) const { 66c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return id < other.id; 67c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 68c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 69c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgbool StatsReport::operator==(const StatsReport& other) const { 70c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return id == other.id; 71c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 72c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 73c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// Special support for being able to use std::find on a container 74c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// without requiring a new StatsReport instance. 75c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgbool StatsReport::operator==(const std::string& other_id) const { 76c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return id == other_id; 77c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 78c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 79c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// The copy ctor can't be declared as explicit due to problems with STL. 80c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::Value::Value(const Value& other) 81c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org : name(other.name), value(other.value) { 82c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 83c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 84c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::Value::Value(StatsValueName name) 85c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org : name(name) { 86c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 87c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 88c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::Value::Value(StatsValueName name, const std::string& value) 89c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org : name(name), value(value) { 90c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 91c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 92c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::Value& StatsReport::Value::operator=(const Value& other) { 93c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const_cast<StatsValueName&>(name) = other.name; 94c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org value = other.value; 95c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return *this; 96c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 97c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 98c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char* StatsReport::Value::display_name() const { 99c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org switch (name) { 100c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAudioOutputLevel: 101c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "audioOutputLevel"; 102c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAudioInputLevel: 103c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "audioInputLevel"; 104c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameBytesSent: 105c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "bytesSent"; 106c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePacketsSent: 107c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "packetsSent"; 108c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameBytesReceived: 109c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "bytesReceived"; 110c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePacketsReceived: 111c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "packetsReceived"; 112c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePacketsLost: 113c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "packetsLost"; 114c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTransportId: 115c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "transportId"; 116c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameSsrc: 117c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "ssrc"; 118c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org 119c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org // 'goog' prefixed constants. 120c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameActiveConnection: 121c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googActiveConnection"; 122c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameActualEncBitrate: 123c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googActualEncBitrate"; 124c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAvailableReceiveBandwidth: 125c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googAvailableReceiveBandwidth"; 126c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAvailableSendBandwidth: 127c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googAvailableSendBandwidth"; 128c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAvgEncodeMs: 129c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googAvgEncodeMs"; 130c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameBucketDelay: 131c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googBucketDelay"; 132c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameBandwidthLimitedResolution: 133c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googBandwidthLimitedResolution"; 134c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCaptureJitterMs: 135c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCaptureJitterMs"; 136c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCaptureQueueDelayMsPerS: 137c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCaptureQueueDelayMsPerS"; 138c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameChannelId: 139c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googChannelId"; 140c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCodecName: 141c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCodecName"; 142c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameComponent: 143c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googComponent"; 144c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameContentName: 145c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googContentName"; 146c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCpuLimitedResolution: 147c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCpuLimitedResolution"; 148c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingCTSG: 149c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingCTSG"; 150c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingCTN: 151c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingCTN"; 152c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingNormal: 153c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingNormal"; 154c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingPLC: 155c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingPLC"; 156c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingCNG: 157c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingCNG"; 158c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingPLCCNG: 159c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingPLCCNG"; 160c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDer: 161c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDerBase64"; 162c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoCancellationQualityMin: 163c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationQualityMin"; 164c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoDelayMedian: 165c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationEchoDelayMedian"; 166c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoDelayStdDev: 167c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationEchoDelayStdDev"; 168c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoReturnLoss: 169c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationReturnLoss"; 170c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoReturnLossEnhancement: 171c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationReturnLossEnhancement"; 172c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEncodeUsagePercent: 173c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEncodeUsagePercent"; 174c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameExpandRate: 175c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googExpandRate"; 176c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFingerprint: 177c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFingerprint"; 178c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFingerprintAlgorithm: 179c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFingerprintAlgorithm"; 180c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFirsReceived: 181c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFirsReceived"; 182c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFirsSent: 183c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFirsSent"; 184c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameHeightInput: 185c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameHeightInput"; 186c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameHeightReceived: 187c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameHeightReceived"; 188c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameHeightSent: 189c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameHeightSent"; 190c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateReceived: 191c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateReceived"; 192c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateDecoded: 193c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateDecoded"; 194c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateOutput: 195c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateOutput"; 196c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodeMs: 197c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodeMs"; 198c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameMaxDecodeMs: 199c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googMaxDecodeMs"; 200c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCurrentDelayMs: 201c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCurrentDelayMs"; 202c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTargetDelayMs: 203c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTargetDelayMs"; 204c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameJitterBufferMs: 205c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googJitterBufferMs"; 206c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameMinPlayoutDelayMs: 207c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googMinPlayoutDelayMs"; 208c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRenderDelayMs: 209c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRenderDelayMs"; 210c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCaptureStartNtpTimeMs: 211c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCaptureStartNtpTimeMs"; 212c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateInput: 213c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateInput"; 214c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateSent: 215c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateSent"; 216c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameWidthInput: 217c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameWidthInput"; 218c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameWidthReceived: 219c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameWidthReceived"; 220c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameWidthSent: 221c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameWidthSent"; 222c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameInitiator: 223c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googInitiator"; 224c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameIssuerId: 225c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googIssuerId"; 226c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameJitterReceived: 227c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googJitterReceived"; 228c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameLocalAddress: 229c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googLocalAddress"; 230c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameLocalCandidateType: 231c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googLocalCandidateType"; 232c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameLocalCertificateId: 233c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googLocalCertificateId"; 234c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAdaptationChanges: 235c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googAdaptationChanges"; 236c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameNacksReceived: 237c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googNacksReceived"; 238c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameNacksSent: 239c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googNacksSent"; 240c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePlisReceived: 241c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googPlisReceived"; 242c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePlisSent: 243c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googPlisSent"; 244c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePreferredJitterBufferMs: 245c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googPreferredJitterBufferMs"; 246c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameReadable: 247c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googReadable"; 248c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRecvPacketGroupArrivalTimeDebug: 249c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googReceivedPacketGroupArrivalTimeDebug"; 250c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRecvPacketGroupPropagationDeltaDebug: 251c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googReceivedPacketGroupPropagationDeltaDebug"; 252c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRecvPacketGroupPropagationDeltaSumDebug: 253c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googReceivedPacketGroupPropagationDeltaSumDebug"; 254c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRemoteAddress: 255c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRemoteAddress"; 256c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRemoteCandidateType: 257c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRemoteCandidateType"; 258c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRemoteCertificateId: 259c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRemoteCertificateId"; 260c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRetransmitBitrate: 261c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRetransmitBitrate"; 262c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRtt: 263c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRtt"; 264c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameSendPacketsDiscarded: 265c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "packetsDiscardedOnSend"; 266c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTargetEncBitrate: 267c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTargetEncBitrate"; 268c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTransmitBitrate: 269c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTransmitBitrate"; 270c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTransportType: 271c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTransportType"; 272c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTrackId: 273c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTrackId"; 274c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTypingNoiseState: 275c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTypingNoiseState"; 276c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameViewLimitedResolution: 277c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googViewLimitedResolution"; 278c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameWritable: 279c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googWritable"; 280c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org default: 281c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org ASSERT(false); 282c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org break; 283c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org } 284c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org 285c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return nullptr; 286c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 287c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 288c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue(StatsReport::StatsValueName name, 289c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const std::string& value) { 290c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org values.push_back(Value(name, value)); 291c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 292c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 293c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue(StatsReport::StatsValueName name, int64 value) { 294c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org AddValue(name, rtc::ToString<int64>(value)); 295c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 296c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 297c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgtemplate <typename T> 298c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue(StatsReport::StatsValueName name, 299c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const std::vector<T>& value) { 300c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org std::ostringstream oss; 301c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org oss << "["; 302c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org for (size_t i = 0; i < value.size(); ++i) { 303c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org oss << rtc::ToString<T>(value[i]); 304c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org if (i != value.size() - 1) 305c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org oss << ", "; 306c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org } 307c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org oss << "]"; 308c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org AddValue(name, oss.str()); 309c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 310c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 311c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// Implementation specializations for the variants of AddValue that we use. 312c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// TODO(tommi): Converting these ints to strings and copying strings, is not 313c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// very efficient. Figure out a way to reduce the string churn. 314c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgtemplate 315c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue<std::string>( 316c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org StatsReport::StatsValueName, const std::vector<std::string>&); 317c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 318c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgtemplate 319c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue<int>( 320c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org StatsReport::StatsValueName, const std::vector<int>&); 321c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 322c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgtemplate 323c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue<int64_t>( 324c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org StatsReport::StatsValueName, const std::vector<int64_t>&); 325c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 326c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddBoolean(StatsReport::StatsValueName name, bool value) { 327c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org AddValue(name, value ? "true" : "false"); 328c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 329c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 330c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::ReplaceValue(StatsReport::StatsValueName name, 331c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const std::string& value) { 332c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org for (Values::iterator it = values.begin(); it != values.end(); ++it) { 333c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org if ((*it).name == name) { 334c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org it->value = value; 335c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return; 336c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org } 337c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org } 338c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org // It is not reachable here, add an ASSERT to make sure the overwriting is 339c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org // always a success. 340c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org ASSERT(false); 341c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 342c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 343c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsSet::StatsSet() { 344c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 345c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 346c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsSet::~StatsSet() { 347c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 348c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 349c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsSet::const_iterator StatsSet::begin() const { 350c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return list_.begin(); 351c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 352c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 353c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsSet::const_iterator StatsSet::end() const { 354c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return list_.end(); 355c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 356c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 357c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport* StatsSet::InsertNew(const std::string& id) { 358c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org ASSERT(Find(id) == NULL); 359c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const StatsReport* ret = &(*list_.insert(StatsReportCopyable(id)).first); 360c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return const_cast<StatsReport*>(ret); 361c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 362c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 363c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport* StatsSet::FindOrAddNew(const std::string& id) { 364c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org StatsReport* ret = Find(id); 365c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return ret ? ret : InsertNew(id); 366c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 367c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 368c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport* StatsSet::ReplaceOrAddNew(const std::string& id) { 369c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org list_.erase(id); 370c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return InsertNew(id); 371c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 372c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 373c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// Looks for a report with the given |id|. If one is not found, NULL 374c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// will be returned. 375c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport* StatsSet::Find(const std::string& id) { 376c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const_iterator it = std::find(begin(), end(), id); 377c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return it == end() ? NULL : 378c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const_cast<StatsReport*>(static_cast<const StatsReport*>(&(*it))); 379c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 3805c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org 3815c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org} // namespace webrtc 382