2b1317adfe631d1f88ebb0dffcb1d878c63e419e
[platform/framework/web/crosswalk.git] / src / third_party / libjingle / source / talk / app / webrtc / statstypes.h
1 /*
2  * libjingle
3  * Copyright 2012, Google Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  *  1. Redistributions of source code must retain the above copyright notice,
9  *     this list of conditions and the following disclaimer.
10  *  2. Redistributions in binary form must reproduce the above copyright notice,
11  *     this list of conditions and the following disclaimer in the documentation
12  *     and/or other materials provided with the distribution.
13  *  3. The name of the author may not be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 // This file contains structures used for retrieving statistics from an ongoing
29 // libjingle session.
30
31 #ifndef TALK_APP_WEBRTC_STATSTYPES_H_
32 #define TALK_APP_WEBRTC_STATSTYPES_H_
33
34 #include <string>
35 #include <vector>
36
37 #include "webrtc/base/basictypes.h"
38 #include "webrtc/base/stringencode.h"
39
40 namespace webrtc {
41
42 class StatsReport {
43  public:
44   StatsReport() : timestamp(0) { }
45
46   // TODO(tommi): Change this to be an enum type that holds all the
47   // kStatsValueName constants.
48   typedef const char* StatsValueName;
49
50   std::string id;  // See below for contents.
51   std::string type;  // See below for contents.
52
53   struct Value {
54     Value() : name(NULL) {}
55     // The copy ctor can't be declared as explicit due to problems with STL.
56     Value(const Value& other) : name(other.name), value(other.value) {}
57     explicit Value(StatsValueName name) : name(name) {}
58     Value(StatsValueName name, const std::string& value)
59         : name(name), value(value) {
60     }
61
62     // TODO(tommi): Remove this operator once we don't need it.
63     // The operator is provided for compatibility with STL containers.
64     // The public |name| member variable is otherwise meant to be read-only.
65     Value& operator=(const Value& other) {
66       const_cast<StatsValueName&>(name) = other.name;
67       value = other.value;
68       return *this;
69     }
70
71     // TODO(tommi): Change implementation to do a simple enum value-to-static-
72     // string conversion when client code has been updated to use this method
73     // instead of the |name| member variable.
74     const char* display_name() const { return name; }
75
76     const StatsValueName name;
77
78     std::string value;
79   };
80
81   void AddValue(StatsValueName name, const std::string& value);
82   void AddValue(StatsValueName name, int64 value);
83   template <typename T>
84   void AddValue(StatsValueName name, const std::vector<T>& value);
85   void AddBoolean(StatsValueName name, bool value);
86
87   void ReplaceValue(StatsValueName name, const std::string& value);
88
89   double timestamp;  // Time since 1970-01-01T00:00:00Z in milliseconds.
90   typedef std::vector<Value> Values;
91   Values values;
92
93   // TODO(tommi): These should all be enum values.
94
95   // StatsReport types.
96   // A StatsReport of |type| = "googSession" contains overall information
97   // about the thing libjingle calls a session (which may contain one
98   // or more RTP sessions.
99   static const char kStatsReportTypeSession[];
100
101   // A StatsReport of |type| = "googTransport" contains information
102   // about a libjingle "transport".
103   static const char kStatsReportTypeTransport[];
104
105   // A StatsReport of |type| = "googComponent" contains information
106   // about a libjingle "channel" (typically, RTP or RTCP for a transport).
107   // This is intended to be the same thing as an ICE "Component".
108   static const char kStatsReportTypeComponent[];
109
110   // A StatsReport of |type| = "googCandidatePair" contains information
111   // about a libjingle "connection" - a single source/destination port pair.
112   // This is intended to be the same thing as an ICE "candidate pair".
113   static const char kStatsReportTypeCandidatePair[];
114
115   // StatsReport of |type| = "VideoBWE" is statistics for video Bandwidth
116   // Estimation, which is global per-session.  The |id| field is "bweforvideo"
117   // (will probably change in the future).
118   static const char kStatsReportTypeBwe[];
119
120   // StatsReport of |type| = "ssrc" is statistics for a specific rtp stream.
121   // The |id| field is the SSRC in decimal form of the rtp stream.
122   static const char kStatsReportTypeSsrc[];
123
124   // StatsReport of |type| = "remoteSsrc" is statistics for a specific
125   // rtp stream, generated by the remote end of the connection.
126   static const char kStatsReportTypeRemoteSsrc[];
127
128   // StatsReport of |type| = "googTrack" is statistics for a specific media
129   // track. The |id| field is the track id.
130   static const char kStatsReportTypeTrack[];
131
132   // StatsReport of |type| = "iceCandidate" is statistics on a specific
133   // ICE Candidate. It links to its transport.
134   static const char kStatsReportTypeIceCandidate[];
135
136   // The id of StatsReport of type VideoBWE.
137   static const char kStatsReportVideoBweId[];
138
139   // A StatsReport of |type| = "googCertificate" contains an SSL certificate
140   // transmitted by one of the endpoints of this connection.  The |id| is
141   // controlled by the fingerprint, and is used to identify the certificate in
142   // the Channel stats (as "googLocalCertificateId" or
143   // "googRemoteCertificateId") and in any child certificates (as
144   // "googIssuerId").
145   static const char kStatsReportTypeCertificate[];
146
147   // StatsValue names
148   static const char kStatsValueNameAudioOutputLevel[];
149   static const char kStatsValueNameAudioInputLevel[];
150   static const char kStatsValueNameBytesSent[];
151   static const char kStatsValueNamePacketsSent[];
152   static const char kStatsValueNameBytesReceived[];
153   static const char kStatsValueNamePacketsReceived[];
154   static const char kStatsValueNamePacketsLost[];
155   static const char kStatsValueNameTransportId[];
156   static const char kStatsValueNameLocalAddress[];
157   static const char kStatsValueNameRemoteAddress[];
158   static const char kStatsValueNameWritable[];
159   static const char kStatsValueNameReadable[];
160   static const char kStatsValueNameActiveConnection[];
161
162
163   // Internal StatsValue names
164   static const char kStatsValueNameAvgEncodeMs[];
165   static const char kStatsValueNameEncodeRelStdDev[];
166   static const char kStatsValueNameEncodeUsagePercent[];
167   static const char kStatsValueNameCaptureJitterMs[];
168   static const char kStatsValueNameCaptureQueueDelayMsPerS[];
169   static const char kStatsValueNameCodecName[];
170   static const char kStatsValueNameBandwidthLimitedResolution[];
171   static const char kStatsValueNameCpuLimitedResolution[];
172   static const char kStatsValueNameViewLimitedResolution[];
173   static const char kStatsValueNameAdaptationChanges[];
174   static const char kStatsValueNameEchoCancellationQualityMin[];
175   static const char kStatsValueNameEchoDelayMedian[];
176   static const char kStatsValueNameEchoDelayStdDev[];
177   static const char kStatsValueNameEchoReturnLoss[];
178   static const char kStatsValueNameEchoReturnLossEnhancement[];
179   static const char kStatsValueNameExpandRate[];
180   static const char kStatsValueNameFirsReceived[];
181   static const char kStatsValueNameFirsSent[];
182   static const char kStatsValueNameFrameHeightInput[];
183   static const char kStatsValueNameFrameHeightReceived[];
184   static const char kStatsValueNameFrameHeightSent[];
185   static const char kStatsValueNameFrameRateReceived[];
186   static const char kStatsValueNameFrameRateDecoded[];
187   static const char kStatsValueNameFrameRateOutput[];
188   static const char kStatsValueNameDecodeMs[];
189   static const char kStatsValueNameMaxDecodeMs[];
190   static const char kStatsValueNameCurrentDelayMs[];
191   static const char kStatsValueNameTargetDelayMs[];
192   static const char kStatsValueNameJitterBufferMs[];
193   static const char kStatsValueNameMinPlayoutDelayMs[];
194   static const char kStatsValueNameRenderDelayMs[];
195   static const char kStatsValueNameCaptureStartNtpTimeMs[];
196   static const char kStatsValueNameFrameRateInput[];
197   static const char kStatsValueNameFrameRateSent[];
198   static const char kStatsValueNameFrameWidthInput[];
199   static const char kStatsValueNameFrameWidthReceived[];
200   static const char kStatsValueNameFrameWidthSent[];
201   static const char kStatsValueNameJitterReceived[];
202   static const char kStatsValueNameNacksReceived[];
203   static const char kStatsValueNameNacksSent[];
204   static const char kStatsValueNamePlisReceived[];
205   static const char kStatsValueNamePlisSent[];
206   static const char kStatsValueNamePreferredJitterBufferMs[];
207   static const char kStatsValueNameRtt[];
208   static const char kStatsValueNameAvailableSendBandwidth[];
209   static const char kStatsValueNameAvailableReceiveBandwidth[];
210   static const char kStatsValueNameTargetEncBitrate[];
211   static const char kStatsValueNameActualEncBitrate[];
212   static const char kStatsValueNameRetransmitBitrate[];
213   static const char kStatsValueNameTransmitBitrate[];
214   static const char kStatsValueNameBucketDelay[];
215   static const char kStatsValueNameInitiator[];
216   static const char kStatsValueNameTransportType[];
217   static const char kStatsValueNameContentName[];
218   static const char kStatsValueNameComponent[];
219   static const char kStatsValueNameChannelId[];
220   static const char kStatsValueNameTrackId[];
221   static const char kStatsValueNameSsrc[];
222   static const char kStatsValueNameTypingNoiseState[];
223   static const char kStatsValueNameDer[];
224   static const char kStatsValueNameFingerprint[];
225   static const char kStatsValueNameFingerprintAlgorithm[];
226   static const char kStatsValueNameIssuerId[];
227   static const char kStatsValueNameLocalCertificateId[];
228   static const char kStatsValueNameRemoteCertificateId[];
229   static const char kStatsValueNameLocalCandidateType[];
230   static const char kStatsValueNameRemoteCandidateType[];
231   static const char kStatsValueNameRecvPacketGroupArrivalTimeDebug[];
232   static const char kStatsValueNameRecvPacketGroupPropagationDeltaDebug[];
233   static const char kStatsValueNameRecvPacketGroupPropagationDeltaSumDebug[];
234   static const char kStatsValueNameDecodingCTSG[];
235   static const char kStatsValueNameDecodingCTN[];
236   static const char kStatsValueNameDecodingNormal[];
237   static const char kStatsValueNameDecodingPLC[];
238   static const char kStatsValueNameDecodingCNG[];
239   static const char kStatsValueNameDecodingPLCCNG[];
240 };
241
242 typedef std::vector<StatsReport> StatsReports;
243
244 }  // namespace webrtc
245
246 #endif  // TALK_APP_WEBRTC_STATSTYPES_H_