statstypes.cc revision 5f93d0a140515e3b8cdd1b9a4c6f5871144e5dee
15c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org/* 25c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org * libjingle 35f93d0a140515e3b8cdd1b9a4c6f5871144e5deejlmiller@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 308e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.orgusing rtc::scoped_ptr; 318e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org 325c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.orgnamespace webrtc { 335c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org 34c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeSession[] = "googLibjingleSession"; 35c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeBwe[] = "VideoBwe"; 36c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeRemoteSsrc[] = "remoteSsrc"; 37c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeSsrc[] = "ssrc"; 38c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeTrack[] = "googTrack"; 39950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.orgconst char StatsReport::kStatsReportTypeIceLocalCandidate[] = "localcandidate"; 40950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.orgconst char StatsReport::kStatsReportTypeIceRemoteCandidate[] = 41950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org "remotecandidate"; 42c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeTransport[] = "googTransport"; 43c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeComponent[] = "googComponent"; 44c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeCandidatePair[] = "googCandidatePair"; 45c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportTypeCertificate[] = "googCertificate"; 46487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.orgconst char StatsReport::kStatsReportTypeDataChannel[] = "datachannel"; 47c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 48c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char StatsReport::kStatsReportVideoBweId[] = "bweforvideo"; 49c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 50c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::StatsReport(const StatsReport& src) 518e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org : id_(src.id_), 52c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org type(src.type), 538e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org timestamp_(src.timestamp_), 548e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org values_(src.values_) { 55c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 56c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 57c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::StatsReport(const std::string& id) 588e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org : id_(id), timestamp_(0) { 598e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org} 608e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org 618e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.orgStatsReport::StatsReport(scoped_ptr<StatsReport::Id> id) 628e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org : id_(id->ToString()), timestamp_(0) { 638e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org} 648e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org 658e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org// static 668e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.orgscoped_ptr<StatsReport::Id> StatsReport::NewTypedId( 678e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org StatsReport::StatsType type, const std::string& id) { 688e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org std::string internal_id(type); 698e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org internal_id += '_'; 708e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org internal_id += id; 718e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org return scoped_ptr<Id>(new Id(internal_id)).Pass(); 72c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 73c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 74c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport& StatsReport::operator=(const StatsReport& src) { 758e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org ASSERT(id_ == src.id_); 76c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org type = src.type; 778e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org timestamp_ = src.timestamp_; 788e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org values_ = src.values_; 79c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return *this; 80c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 81c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 82c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// Operators provided for STL container/algorithm support. 83c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgbool StatsReport::operator<(const StatsReport& other) const { 848e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org return id_ < other.id_; 85c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 86c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 87c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgbool StatsReport::operator==(const StatsReport& other) const { 888e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org return id_ == other.id_; 89c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 90c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 91c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// Special support for being able to use std::find on a container 92c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// without requiring a new StatsReport instance. 93c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgbool StatsReport::operator==(const std::string& other_id) const { 948e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org return id_ == other_id; 95c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 96c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 97c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// The copy ctor can't be declared as explicit due to problems with STL. 98c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::Value::Value(const Value& other) 99c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org : name(other.name), value(other.value) { 100c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 101c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 102c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::Value::Value(StatsValueName name) 103c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org : name(name) { 104c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 105c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 106c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::Value::Value(StatsValueName name, const std::string& value) 107c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org : name(name), value(value) { 108c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 109c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 110c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport::Value& StatsReport::Value::operator=(const Value& other) { 111c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const_cast<StatsValueName&>(name) = other.name; 112c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org value = other.value; 113c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return *this; 114c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 115c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 116c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgconst char* StatsReport::Value::display_name() const { 117c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org switch (name) { 118c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAudioOutputLevel: 119c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "audioOutputLevel"; 120c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAudioInputLevel: 121c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "audioInputLevel"; 122c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameBytesSent: 123c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "bytesSent"; 124c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePacketsSent: 125c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "packetsSent"; 126c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameBytesReceived: 127c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "bytesReceived"; 128487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.org case kStatsValueNameLabel: 129487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.org return "label"; 130c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePacketsReceived: 131c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "packetsReceived"; 132c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePacketsLost: 133c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "packetsLost"; 134487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.org case kStatsValueNameProtocol: 135487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.org return "protocol"; 136c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTransportId: 137c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "transportId"; 138c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameSsrc: 139c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "ssrc"; 140487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.org case kStatsValueNameState: 141487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.org return "state"; 142487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.org case kStatsValueNameDataChannelId: 143487a4442152e2c70146aa2d2c6ccb370233c056cdecurtis@webrtc.org return "datachannelid"; 144c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org 145c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org // 'goog' prefixed constants. 146c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameActiveConnection: 147c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googActiveConnection"; 148c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameActualEncBitrate: 149c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googActualEncBitrate"; 150c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAvailableReceiveBandwidth: 151c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googAvailableReceiveBandwidth"; 152c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAvailableSendBandwidth: 153c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googAvailableSendBandwidth"; 154c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAvgEncodeMs: 155c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googAvgEncodeMs"; 156c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameBucketDelay: 157c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googBucketDelay"; 158c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameBandwidthLimitedResolution: 159c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googBandwidthLimitedResolution"; 160c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCaptureJitterMs: 161c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCaptureJitterMs"; 162c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCaptureQueueDelayMsPerS: 163c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCaptureQueueDelayMsPerS"; 164950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org 165950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org // Candidate related attributes. Values are taken from 166950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org // http://w3c.github.io/webrtc-stats/#rtcstatstype-enum*. 167950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org case kStatsValueNameCandidateIPAddress: 168950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org return "ipAddress"; 169950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org case kStatsValueNameCandidateNetworkType: 170950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org return "networkType"; 171950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org case kStatsValueNameCandidatePortNumber: 172950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org return "portNumber"; 173950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org case kStatsValueNameCandidatePriority: 174950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org return "priority"; 175950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org case kStatsValueNameCandidateTransportType: 176950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org return "transport"; 177950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org case kStatsValueNameCandidateType: 178950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org return "candidateType"; 179950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org 180c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameChannelId: 181c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googChannelId"; 182c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCodecName: 183c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCodecName"; 184c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameComponent: 185c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googComponent"; 186c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameContentName: 187c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googContentName"; 188c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCpuLimitedResolution: 189c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCpuLimitedResolution"; 190c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingCTSG: 191c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingCTSG"; 192c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingCTN: 193c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingCTN"; 194c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingNormal: 195c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingNormal"; 196c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingPLC: 197c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingPLC"; 198c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingCNG: 199c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingCNG"; 200c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodingPLCCNG: 201c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodingPLCCNG"; 202c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDer: 203c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDerBase64"; 204c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoCancellationQualityMin: 205c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationQualityMin"; 206c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoDelayMedian: 207c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationEchoDelayMedian"; 208c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoDelayStdDev: 209c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationEchoDelayStdDev"; 210c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoReturnLoss: 211c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationReturnLoss"; 212c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEchoReturnLossEnhancement: 213c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEchoCancellationReturnLossEnhancement"; 214c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameEncodeUsagePercent: 215c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googEncodeUsagePercent"; 216c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameExpandRate: 217c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googExpandRate"; 218c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFingerprint: 219c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFingerprint"; 220c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFingerprintAlgorithm: 221c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFingerprintAlgorithm"; 222c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFirsReceived: 223c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFirsReceived"; 224c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFirsSent: 225c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFirsSent"; 226c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameHeightInput: 227c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameHeightInput"; 228c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameHeightReceived: 229c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameHeightReceived"; 230c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameHeightSent: 231c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameHeightSent"; 232c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateReceived: 233c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateReceived"; 234c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateDecoded: 235c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateDecoded"; 236c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateOutput: 237c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateOutput"; 238c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameDecodeMs: 239c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googDecodeMs"; 240c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameMaxDecodeMs: 241c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googMaxDecodeMs"; 242c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCurrentDelayMs: 243c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCurrentDelayMs"; 244c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTargetDelayMs: 245c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTargetDelayMs"; 246c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameJitterBufferMs: 247c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googJitterBufferMs"; 248c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameMinPlayoutDelayMs: 249c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googMinPlayoutDelayMs"; 250c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRenderDelayMs: 251c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRenderDelayMs"; 252c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameCaptureStartNtpTimeMs: 253c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googCaptureStartNtpTimeMs"; 254c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateInput: 255c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateInput"; 256c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameRateSent: 257c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameRateSent"; 258c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameWidthInput: 259c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameWidthInput"; 260c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameWidthReceived: 261c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameWidthReceived"; 262c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameFrameWidthSent: 263c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googFrameWidthSent"; 264c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameInitiator: 265c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googInitiator"; 266c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameIssuerId: 267c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googIssuerId"; 268c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameJitterReceived: 269c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googJitterReceived"; 270c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameLocalAddress: 271c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googLocalAddress"; 272950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org case kStatsValueNameLocalCandidateId: 273950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org return "localCandidateId"; 274c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameLocalCandidateType: 275c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googLocalCandidateType"; 276c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameLocalCertificateId: 277c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googLocalCertificateId"; 278c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameAdaptationChanges: 279c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googAdaptationChanges"; 280c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameNacksReceived: 281c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googNacksReceived"; 282c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameNacksSent: 283c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googNacksSent"; 284c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePlisReceived: 285c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googPlisReceived"; 286c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePlisSent: 287c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googPlisSent"; 288c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNamePreferredJitterBufferMs: 289c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googPreferredJitterBufferMs"; 290c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameReadable: 291c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googReadable"; 292c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRecvPacketGroupArrivalTimeDebug: 293c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googReceivedPacketGroupArrivalTimeDebug"; 294c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRecvPacketGroupPropagationDeltaDebug: 295c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googReceivedPacketGroupPropagationDeltaDebug"; 296c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRecvPacketGroupPropagationDeltaSumDebug: 297c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googReceivedPacketGroupPropagationDeltaSumDebug"; 298c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRemoteAddress: 299c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRemoteAddress"; 300950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org case kStatsValueNameRemoteCandidateId: 301950c51825109c2ca352317edef0a33777d0e6678guoweis@webrtc.org return "remoteCandidateId"; 302c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRemoteCandidateType: 303c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRemoteCandidateType"; 304c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRemoteCertificateId: 305c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRemoteCertificateId"; 306c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRetransmitBitrate: 307c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRetransmitBitrate"; 308c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameRtt: 309c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googRtt"; 310c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameSendPacketsDiscarded: 311c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "packetsDiscardedOnSend"; 312c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTargetEncBitrate: 313c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTargetEncBitrate"; 314c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTransmitBitrate: 315c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTransmitBitrate"; 316c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTransportType: 317c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTransportType"; 318c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTrackId: 319c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTrackId"; 320c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameTypingNoiseState: 321c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googTypingNoiseState"; 322c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameViewLimitedResolution: 323c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googViewLimitedResolution"; 324c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org case kStatsValueNameWritable: 325c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return "googWritable"; 326c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org default: 327c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org ASSERT(false); 328c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org break; 329c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org } 330c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org 331c57310b982cdce138723de91d7b722f8199834abtommi@webrtc.org return nullptr; 332c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 333c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 334c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue(StatsReport::StatsValueName name, 335c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const std::string& value) { 3368e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org values_.push_back(ValuePtr(new Value(name, value))); 337c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 338c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 339c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue(StatsReport::StatsValueName name, int64 value) { 340c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org AddValue(name, rtc::ToString<int64>(value)); 341c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 342c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 343c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgtemplate <typename T> 344c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue(StatsReport::StatsValueName name, 345c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const std::vector<T>& value) { 346c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org std::ostringstream oss; 347c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org oss << "["; 348c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org for (size_t i = 0; i < value.size(); ++i) { 349c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org oss << rtc::ToString<T>(value[i]); 350c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org if (i != value.size() - 1) 351c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org oss << ", "; 352c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org } 353c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org oss << "]"; 354c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org AddValue(name, oss.str()); 355c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 356c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 357c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// Implementation specializations for the variants of AddValue that we use. 358c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// TODO(tommi): Converting these ints to strings and copying strings, is not 359c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// very efficient. Figure out a way to reduce the string churn. 360c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgtemplate 361c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue<std::string>( 362c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org StatsReport::StatsValueName, const std::vector<std::string>&); 363c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 364c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgtemplate 365c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue<int>( 366c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org StatsReport::StatsValueName, const std::vector<int>&); 367c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 368c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgtemplate 369c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddValue<int64_t>( 370c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org StatsReport::StatsValueName, const std::vector<int64_t>&); 371c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 372c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::AddBoolean(StatsReport::StatsValueName name, bool value) { 373c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org AddValue(name, value ? "true" : "false"); 374c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 375c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 376c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgvoid StatsReport::ReplaceValue(StatsReport::StatsValueName name, 377c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const std::string& value) { 3788e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org Values::iterator it = std::find_if(values_.begin(), values_.end(), 3798e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org [&name](const ValuePtr& v)->bool { return v->name == name; }); 3808e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org // Values are const once added since they may be used outside of the stats 3818e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org // collection. So we remove it from values_ when replacing and add a new one. 3828e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org if (it != values_.end()) { 3838e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org if ((*it)->value == value) 384c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return; 3858e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org values_.erase(it); 386c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org } 3878e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org 3888e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org AddValue(name, value); 3898e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org} 3908e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org 3918e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.orgvoid StatsReport::ResetValues() { 3928e327c45d0940fd5bc46c3fe8d24363be07706actommi@webrtc.org values_.clear(); 393c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 394c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 395c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsSet::StatsSet() { 396c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 397c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 398c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsSet::~StatsSet() { 399c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 400c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 401c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsSet::const_iterator StatsSet::begin() const { 402c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return list_.begin(); 403c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 404c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 405c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsSet::const_iterator StatsSet::end() const { 406c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return list_.end(); 407c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 408c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 409c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport* StatsSet::InsertNew(const std::string& id) { 410c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org ASSERT(Find(id) == NULL); 411c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const StatsReport* ret = &(*list_.insert(StatsReportCopyable(id)).first); 412c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return const_cast<StatsReport*>(ret); 413c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 414c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 415c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport* StatsSet::FindOrAddNew(const std::string& id) { 416c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org StatsReport* ret = Find(id); 417c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return ret ? ret : InsertNew(id); 418c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 419c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 420c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport* StatsSet::ReplaceOrAddNew(const std::string& id) { 421c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org list_.erase(id); 422c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return InsertNew(id); 423c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 424c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org 425c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// Looks for a report with the given |id|. If one is not found, NULL 426c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org// will be returned. 427c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.orgStatsReport* StatsSet::Find(const std::string& id) { 428c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const_iterator it = std::find(begin(), end(), id); 429c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org return it == end() ? NULL : 430c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org const_cast<StatsReport*>(static_cast<const StatsReport*>(&(*it))); 431c9d155faebd5556c9ea86306dc15aa9dac0e13f7tommi@webrtc.org} 4325c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org 4335c3ee4bce6c61bb4095eb3746ba39d3eeab2ee93tommi@webrtc.org} // namespace webrtc 434