10e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org/*
20e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * libjingle
30e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Copyright 2012, Google Inc.
40e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *
50e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without
60e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * modification, are permitted provided that the following conditions are met:
70e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *
80e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *  1. Redistributions of source code must retain the above copyright notice,
90e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *     this list of conditions and the following disclaimer.
100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *  2. Redistributions in binary form must reproduce the above copyright notice,
110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *     this list of conditions and the following disclaimer in the documentation
120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *     and/or other materials provided with the distribution.
130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *  3. The name of the author may not be used to endorse or promote products
140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *     derived from this software without specific prior written permission.
150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *
160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org */
270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// This file contains structures used for retrieving statistics from an ongoing
290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// libjingle session.
300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#ifndef TALK_APP_WEBRTC_STATSTYPES_H_
320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#define TALK_APP_WEBRTC_STATSTYPES_H_
330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
34cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org#include <set>
350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <string>
360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <vector>
370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
382a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/basictypes.h"
39109ba4e39c525c7d0f0fa4e59e9a22bbf034ef08andrew@webrtc.org#include "webrtc/base/common.h"
402a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/stringencode.h"
410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace webrtc {
430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
44cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// TODO(tommi): Move all the implementation that's in this file and
45cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// statscollector.cc related to these types, into a new, statstypes.cc file.
46cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass StatsReport {
480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public:
49cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // TODO(tommi): Remove this ctor.
50cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsReport() : timestamp(0) {}
51cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
52cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // TODO(tommi): Make protected and disallow copy completely once not needed.
53cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsReport(const StatsReport& src)
54cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    : id(src.id),
55cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org      type(src.type),
56cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org      timestamp(src.timestamp),
57cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org      values(src.values) {}
58cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
59cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // TODO(tommi): Make this copy constructor protected.
60cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsReport& operator=(const StatsReport& src) {
61cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    ASSERT(id == src.id);
62cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    type = src.type;
63cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    timestamp = src.timestamp;
64cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    values = src.values;
65cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    return *this;
66cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  }
67cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
68cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // Constructor is protected to force use of StatsSet.
69cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // TODO(tommi): Make this ctor protected.
70cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  explicit StatsReport(const std::string& id) : id(id), timestamp(0) {}
71cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
72cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // Operators provided for STL container/algorithm support.
73cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  bool operator<(const StatsReport& other) const { return id < other.id; }
74cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  bool operator==(const StatsReport& other) const { return id == other.id; }
75cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // Special support for being able to use std::find on a container
76cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // without requiring a new StatsReport instance.
77cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  bool operator==(const std::string& other_id) const { return id == other_id; }
780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
792829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  // TODO(tommi): Change this to be an enum type that holds all the
802829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  // kStatsValueName constants.
812829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  typedef const char* StatsValueName;
822829d698040572c81ba900e906448542cfa0844atommi@webrtc.org
83cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // The unique identifier for this object.
84cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // This is used as a key for this report in ordered containers,
85cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // so it must never be changed.
86cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // TODO(tommi): Make this member variable const.
878e88c29104c511b3079a19bb3a1704ba95b70003henrike@webrtc.org  std::string id;  // See below for contents.
880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::string type;  // See below for contents.
890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  struct Value {
912829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    Value() : name(NULL) {}
922829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    // The copy ctor can't be declared as explicit due to problems with STL.
932829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    Value(const Value& other) : name(other.name), value(other.value) {}
942829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    explicit Value(StatsValueName name) : name(name) {}
952829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    Value(StatsValueName name, const std::string& value)
962829d698040572c81ba900e906448542cfa0844atommi@webrtc.org        : name(name), value(value) {
972829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    }
982829d698040572c81ba900e906448542cfa0844atommi@webrtc.org
992829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    // TODO(tommi): Remove this operator once we don't need it.
1002829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    // The operator is provided for compatibility with STL containers.
1012829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    // The public |name| member variable is otherwise meant to be read-only.
1022829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    Value& operator=(const Value& other) {
1032829d698040572c81ba900e906448542cfa0844atommi@webrtc.org      const_cast<StatsValueName&>(name) = other.name;
1042829d698040572c81ba900e906448542cfa0844atommi@webrtc.org      value = other.value;
1052829d698040572c81ba900e906448542cfa0844atommi@webrtc.org      return *this;
1062829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    }
1072829d698040572c81ba900e906448542cfa0844atommi@webrtc.org
1082829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    // TODO(tommi): Change implementation to do a simple enum value-to-static-
1092829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    // string conversion when client code has been updated to use this method
1102829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    // instead of the |name| member variable.
1112829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    const char* display_name() const { return name; }
1122829d698040572c81ba900e906448542cfa0844atommi@webrtc.org
1132829d698040572c81ba900e906448542cfa0844atommi@webrtc.org    const StatsValueName name;
1142829d698040572c81ba900e906448542cfa0844atommi@webrtc.org
1150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    std::string value;
1160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  };
1170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1182829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  void AddValue(StatsValueName name, const std::string& value);
1192829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  void AddValue(StatsValueName name, int64 value);
1208a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org  template <typename T>
1212829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  void AddValue(StatsValueName name, const std::vector<T>& value);
1222829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  void AddBoolean(StatsValueName name, bool value);
1230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1242829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  void ReplaceValue(StatsValueName name, const std::string& value);
125c583107e6b398a140dc56f9539b0e01b58af8c61henrike@webrtc.org
1260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  double timestamp;  // Time since 1970-01-01T00:00:00Z in milliseconds.
1270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  typedef std::vector<Value> Values;
1280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  Values values;
1290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1302829d698040572c81ba900e906448542cfa0844atommi@webrtc.org  // TODO(tommi): These should all be enum values.
1312829d698040572c81ba900e906448542cfa0844atommi@webrtc.org
1320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // StatsReport types.
1330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // A StatsReport of |type| = "googSession" contains overall information
1340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // about the thing libjingle calls a session (which may contain one
1350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // or more RTP sessions.
1360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportTypeSession[];
1370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // A StatsReport of |type| = "googTransport" contains information
1390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // about a libjingle "transport".
1400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportTypeTransport[];
1410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // A StatsReport of |type| = "googComponent" contains information
1430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // about a libjingle "channel" (typically, RTP or RTCP for a transport).
1440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // This is intended to be the same thing as an ICE "Component".
1450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportTypeComponent[];
1460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // A StatsReport of |type| = "googCandidatePair" contains information
1480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // about a libjingle "connection" - a single source/destination port pair.
1490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // This is intended to be the same thing as an ICE "candidate pair".
1500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportTypeCandidatePair[];
1510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // StatsReport of |type| = "VideoBWE" is statistics for video Bandwidth
1530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Estimation, which is global per-session.  The |id| field is "bweforvideo"
1540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // (will probably change in the future).
1550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportTypeBwe[];
1560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // StatsReport of |type| = "ssrc" is statistics for a specific rtp stream.
1580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // The |id| field is the SSRC in decimal form of the rtp stream.
1590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportTypeSsrc[];
1600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1615c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  // StatsReport of |type| = "remoteSsrc" is statistics for a specific
1625c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  // rtp stream, generated by the remote end of the connection.
1635c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  static const char kStatsReportTypeRemoteSsrc[];
1645c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org
1650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // StatsReport of |type| = "googTrack" is statistics for a specific media
1660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // track. The |id| field is the track id.
1670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportTypeTrack[];
1680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // StatsReport of |type| = "iceCandidate" is statistics on a specific
1700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // ICE Candidate. It links to its transport.
1710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportTypeIceCandidate[];
1720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // The id of StatsReport of type VideoBWE.
1740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsReportVideoBweId[];
1750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
17662fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  // A StatsReport of |type| = "googCertificate" contains an SSL certificate
17762fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  // transmitted by one of the endpoints of this connection.  The |id| is
17862fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  // controlled by the fingerprint, and is used to identify the certificate in
17962fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  // the Channel stats (as "googLocalCertificateId" or
18062fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  // "googRemoteCertificateId") and in any child certificates (as
18162fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  // "googIssuerId").
18262fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  static const char kStatsReportTypeCertificate[];
18362fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org
1840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // StatsValue names
1850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameAudioOutputLevel[];
1860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameAudioInputLevel[];
1870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameBytesSent[];
1880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNamePacketsSent[];
1890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameBytesReceived[];
1900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNamePacketsReceived[];
1910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNamePacketsLost[];
1920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameTransportId[];
1930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameLocalAddress[];
1940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameRemoteAddress[];
1950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameWritable[];
1960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameReadable[];
1970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameActiveConnection[];
1980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Internal StatsValue names
20197fbd309a28be4e38d138b40662507d50cab6d26sergeyu@chromium.org  static const char kStatsValueNameAvgEncodeMs[];
2025c2c63e9e7cea1266756d354efe0af02d8dfe0dfbuildbot@webrtc.org  static const char kStatsValueNameEncodeRelStdDev[];
203cfd624796c7321c5ffac2249b407cdd0d496e00awu@webrtc.org  static const char kStatsValueNameEncodeUsagePercent[];
20497fbd309a28be4e38d138b40662507d50cab6d26sergeyu@chromium.org  static const char kStatsValueNameCaptureJitterMs[];
205cfd624796c7321c5ffac2249b407cdd0d496e00awu@webrtc.org  static const char kStatsValueNameCaptureQueueDelayMsPerS[];
2060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameCodecName[];
2071114b945276ca2ded11890cf2c884d78e6188386mallinath@webrtc.org  static const char kStatsValueNameBandwidthLimitedResolution[];
2081114b945276ca2ded11890cf2c884d78e6188386mallinath@webrtc.org  static const char kStatsValueNameCpuLimitedResolution[];
2091114b945276ca2ded11890cf2c884d78e6188386mallinath@webrtc.org  static const char kStatsValueNameViewLimitedResolution[];
210d24be9140f01dbf49e0ae4154880887f7c52129cbuildbot@webrtc.org  static const char kStatsValueNameAdaptationChanges[];
2110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameEchoCancellationQualityMin[];
2120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameEchoDelayMedian[];
2130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameEchoDelayStdDev[];
2140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameEchoReturnLoss[];
2150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameEchoReturnLossEnhancement[];
2168a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org  static const char kStatsValueNameExpandRate[];
2170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFirsReceived[];
2180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFirsSent[];
219fc1e785be93c8b9bcce13c29d35af2a1ca91e6afwu@webrtc.org  static const char kStatsValueNameFrameHeightInput[];
2200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameHeightReceived[];
2210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameHeightSent[];
2220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameRateReceived[];
2230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameRateDecoded[];
2240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameRateOutput[];
2255c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  static const char kStatsValueNameDecodeMs[];
2265c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  static const char kStatsValueNameMaxDecodeMs[];
2275c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  static const char kStatsValueNameCurrentDelayMs[];
2285c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  static const char kStatsValueNameTargetDelayMs[];
2295c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  static const char kStatsValueNameJitterBufferMs[];
2305c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  static const char kStatsValueNameMinPlayoutDelayMs[];
2315c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  static const char kStatsValueNameRenderDelayMs[];
232de6aa3e68a75cbc0529ce287fe1c5ad72c8dfc11buildbot@webrtc.org  static const char kStatsValueNameCaptureStartNtpTimeMs[];
2330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameRateInput[];
2340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameRateSent[];
235fc1e785be93c8b9bcce13c29d35af2a1ca91e6afwu@webrtc.org  static const char kStatsValueNameFrameWidthInput[];
2360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameWidthReceived[];
2370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameFrameWidthSent[];
2380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameJitterReceived[];
2390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameNacksReceived[];
2400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameNacksSent[];
2417587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  static const char kStatsValueNamePlisReceived[];
2427587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  static const char kStatsValueNamePlisSent[];
24318d645088ec394abbc372c6eea18bbde78ea7993jiayl@webrtc.org  static const char kStatsValueNamePreferredJitterBufferMs[];
2440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameRtt[];
2450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameAvailableSendBandwidth[];
2460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameAvailableReceiveBandwidth[];
2470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameTargetEncBitrate[];
2480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameActualEncBitrate[];
2490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameRetransmitBitrate[];
2500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameTransmitBitrate[];
2510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameBucketDelay[];
2520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameInitiator[];
2530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameTransportType[];
2540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameContentName[];
2550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameComponent[];
2560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameChannelId[];
2570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameTrackId[];
2580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const char kStatsValueNameSsrc[];
2594ba8b9ea10385f43b19d6ed7408f4a09bdc1cbdawu@webrtc.org  static const char kStatsValueNameTypingNoiseState[];
26062fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  static const char kStatsValueNameDer[];
26162fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  static const char kStatsValueNameFingerprint[];
2628841d7bf4010478a4b3978ff2d181d9504b2bbe3mallinath@webrtc.org  static const char kStatsValueNameFingerprintAlgorithm[];
26362fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  static const char kStatsValueNameIssuerId[];
26462fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  static const char kStatsValueNameLocalCertificateId[];
26562fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org  static const char kStatsValueNameRemoteCertificateId[];
2663db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org  static const char kStatsValueNameLocalCandidateType[];
2673db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org  static const char kStatsValueNameRemoteCandidateType[];
2688a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org  static const char kStatsValueNameRecvPacketGroupArrivalTimeDebug[];
2698a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org  static const char kStatsValueNameRecvPacketGroupPropagationDeltaDebug[];
2708a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org  static const char kStatsValueNameRecvPacketGroupPropagationDeltaSumDebug[];
2716019a0f470cf75a9a5787f7900162498609f509bbuildbot@webrtc.org  static const char kStatsValueNameDecodingCTSG[];
2726019a0f470cf75a9a5787f7900162498609f509bbuildbot@webrtc.org  static const char kStatsValueNameDecodingCTN[];
2736019a0f470cf75a9a5787f7900162498609f509bbuildbot@webrtc.org  static const char kStatsValueNameDecodingNormal[];
2746019a0f470cf75a9a5787f7900162498609f509bbuildbot@webrtc.org  static const char kStatsValueNameDecodingPLC[];
2756019a0f470cf75a9a5787f7900162498609f509bbuildbot@webrtc.org  static const char kStatsValueNameDecodingCNG[];
2766019a0f470cf75a9a5787f7900162498609f509bbuildbot@webrtc.org  static const char kStatsValueNameDecodingPLCCNG[];
2770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org};
2780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
279cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// This class is provided for the cases where we need to keep
280cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// snapshots of reports around.  This is an edge case.
281cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// TODO(tommi): Move into the private section of StatsSet.
282cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.orgclass StatsReportCopyable : public StatsReport {
283cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org public:
284cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsReportCopyable(const std::string& id) : StatsReport(id) {}
285cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  explicit StatsReportCopyable(const StatsReport& src)
286cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org      : StatsReport(src) {}
287cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
288cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  using StatsReport::operator=;
289cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org};
290cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
291cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// Typedef for an array of const StatsReport pointers.
292cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// Ownership of the pointers held by this implementation is assumed to lie
293cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// elsewhere and lifetime guarantees are made by the implementation that uses
294cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// this type.  In the StatsCollector, object ownership lies with the StatsSet
295cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// class.
296cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.orgtypedef std::vector<const StatsReport*> StatsReports;
297cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
298cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// A map from the report id to the report.
299cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// This class wraps an STL container and provides a limited set of
300cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// functionality in order to keep things simple.
301cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org// TODO(tommi): Use a thread checker here (currently not in libjingle).
302cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.orgclass StatsSet {
303cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org public:
304cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsSet() {}
305cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  ~StatsSet() {}
306cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
307cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  typedef std::set<StatsReportCopyable> Container;
308cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  typedef Container::iterator iterator;
309cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  typedef Container::const_iterator const_iterator;
310cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
311cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  const_iterator begin() const { return list_.begin(); }
312cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  const_iterator end() const { return list_.end(); }
313cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
314cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // Creates a new report object with |id| that does not already
315cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // exist in the list of reports.
316cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsReport* InsertNew(const std::string& id) {
317cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    ASSERT(Find(id) == NULL);
318cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    const StatsReport* ret = &(*list_.insert(StatsReportCopyable(id)).first);
319cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    return const_cast<StatsReport*>(ret);
320cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  }
321cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
322cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsReport* FindOrAddNew(const std::string& id) {
323cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    StatsReport* ret = Find(id);
324cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    return ret ? ret : InsertNew(id);
325cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  }
326cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
327cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsReport* ReplaceOrAddNew(const std::string& id) {
328cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    list_.erase(id);
329cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    return InsertNew(id);
330cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  }
331cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
332cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // Looks for a report with the given |id|.  If one is not found, NULL
333cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  // will be returned.
334cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  StatsReport* Find(const std::string& id) {
335cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    const_iterator it = std::find(begin(), end(), id);
336cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org    return it == end() ? NULL :
337cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org        const_cast<StatsReport*>(static_cast<const StatsReport*>(&(*it)));
338cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  }
339cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org
340cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org private:
341cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org  Container list_;
342cdfebb33771edb19b50f64f292bd33b86b077745tommi@webrtc.org};
3430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}  // namespace webrtc
3450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#endif  // TALK_APP_WEBRTC_STATSTYPES_H_
347