2013-07-10 00:45:36 +00:00
|
|
|
/*
|
|
|
|
|
* libjingle
|
2015-01-20 21:36:13 +00:00
|
|
|
* Copyright 2012 Google Inc.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "talk/app/webrtc/statscollector.h"
|
|
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2014-08-13 17:26:08 +00:00
|
|
|
#include "talk/session/media/channel.h"
|
2014-07-29 17:36:52 +00:00
|
|
|
#include "webrtc/base/base64.h"
|
|
|
|
|
#include "webrtc/base/scoped_ptr.h"
|
|
|
|
|
#include "webrtc/base/timing.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
using rtc::scoped_ptr;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
namespace {
|
|
|
|
|
|
2014-12-16 23:01:31 +00:00
|
|
|
// The following is the enum RTCStatsIceCandidateType from
|
|
|
|
|
// http://w3c.github.io/webrtc-stats/#rtcstatsicecandidatetype-enum such that
|
|
|
|
|
// our stats report for ice candidate type could conform to that.
|
|
|
|
|
const char STATSREPORT_LOCAL_PORT_TYPE[] = "host";
|
|
|
|
|
const char STATSREPORT_STUN_PORT_TYPE[] = "serverreflexive";
|
|
|
|
|
const char STATSREPORT_PRFLX_PORT_TYPE[] = "peerreflexive";
|
|
|
|
|
const char STATSREPORT_RELAY_PORT_TYPE[] = "relayed";
|
|
|
|
|
|
|
|
|
|
// Strings used by the stats collector to report adapter types. This fits the
|
|
|
|
|
// general stype of http://w3c.github.io/webrtc-stats than what
|
|
|
|
|
// AdapterTypeToString does.
|
|
|
|
|
const char* STATSREPORT_ADAPTER_TYPE_ETHERNET = "lan";
|
|
|
|
|
const char* STATSREPORT_ADAPTER_TYPE_WIFI = "wlan";
|
|
|
|
|
const char* STATSREPORT_ADAPTER_TYPE_WWAN = "wwan";
|
|
|
|
|
const char* STATSREPORT_ADAPTER_TYPE_VPN = "vpn";
|
Makes libjingle_peerconnection_android_unittest run on networkless devices.
PeerConnectionTest.java currently works, but only on a device with
network interfaces up. This is not a problem for desktop, but it is a
problem when running on Android devices since the devices in the lab
generally don't have network (due to the chaotic radio environment in
the device labs, devices are simply kept in flight mode).
The test does work if one modifies this line in the file
webrtc/base/network.cc:
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
IsIgnoredNetwork(*network));
If we remove the IFF_LOOPBACK clause, the test starts working on
an Android device in flight mode. This is nice - we're running the
call and packets interact with the OS network stack, which is good
for this end-to-end test. We can't just remove the clause though since
having loopback is undesirable for everyone except the test (right)?
so we need to make this behavior configurable.
This CL takes a stab at a complete solution where we pass a boolean
all the way through the Java PeerConnectionFactory down to the
BasicNetworkManager. This comes as a heavy price in interface
changes though. It's pretty out of proportion, but fundamentally we
need some way of telling the network manager that it is on Android
and in test mode. Passing the boolean all the way through is one way.
Another way might be to put the loopback filter behind an ifdef and
link a custom libjingle_peerconnection.so with the test. That is hacky
but doesn't pollute the interfaces. Not sure how to solve that in GYP
but it could mean some duplication between the production and
test .so files.
It would have been perfect to use flags here, but then we need to
hook up gflags parsing to some main() somewhere to make sure the
flag gets parsed, and make sure to pass that flag in our tests.
I'm not sure how that can be done.
Making the loopback filtering conditional is exactly how we solved the
equivalent problem in content_browsertests in Chrome, and it worked
great.
That's all I could think of.
BUG=4181
R=perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/36769004
Cr-Commit-Position: refs/heads/master@{#8344}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8344 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-12 09:23:59 +00:00
|
|
|
const char* STATSREPORT_ADAPTER_TYPE_LOOPBACK = "loopback";
|
2014-12-16 23:01:31 +00:00
|
|
|
|
2014-07-15 19:22:37 +00:00
|
|
|
bool GetTransportIdFromProxy(const cricket::ProxyTransportMap& map,
|
|
|
|
|
const std::string& proxy,
|
|
|
|
|
std::string* transport) {
|
|
|
|
|
// TODO(hta): Remove handling of empty proxy name once tests do not use it.
|
|
|
|
|
if (proxy.empty()) {
|
|
|
|
|
transport->clear();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cricket::ProxyTransportMap::const_iterator found = map.find(proxy);
|
|
|
|
|
if (found == map.end()) {
|
|
|
|
|
LOG(LS_ERROR) << "No transport ID mapping for " << proxy;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Component 1 is always used for RTP.
|
2015-01-21 11:36:18 +00:00
|
|
|
scoped_ptr<StatsReport::Id> id(
|
|
|
|
|
StatsReport::NewComponentId(found->second, 1));
|
|
|
|
|
// TODO(tommi): Should |transport| simply be of type StatsReport::Id?
|
|
|
|
|
// When we support more value types than string (e.g. int, double, vector etc)
|
|
|
|
|
// we should also support a value type for Id.
|
|
|
|
|
*transport = id->ToString();
|
2014-07-15 19:22:37 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
void AddTrackReport(StatsCollection* reports, const std::string& track_id) {
|
2014-07-09 07:38:38 +00:00
|
|
|
// Adds an empty track report.
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> id(
|
|
|
|
|
StatsReport::NewTypedId(StatsReport::kStatsReportTypeTrack, track_id));
|
|
|
|
|
StatsReport* report = reports->ReplaceOrAddNew(id.Pass());
|
2014-08-15 08:38:30 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameTrackId, track_id);
|
2014-07-09 07:38:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
template <class TrackVector>
|
2015-01-21 11:36:18 +00:00
|
|
|
void CreateTrackReports(const TrackVector& tracks, StatsCollection* reports) {
|
2013-07-10 00:45:36 +00:00
|
|
|
for (size_t j = 0; j < tracks.size(); ++j) {
|
|
|
|
|
webrtc::MediaStreamTrackInterface* track = tracks[j];
|
2014-07-09 07:38:38 +00:00
|
|
|
AddTrackReport(reports, track->id());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractStats(const cricket::VoiceReceiverInfo& info, StatsReport* report) {
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameAudioOutputLevel,
|
|
|
|
|
info.audio_level);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameBytesReceived,
|
|
|
|
|
info.bytes_rcvd);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameJitterReceived,
|
|
|
|
|
info.jitter_ms);
|
2014-03-07 18:56:26 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameJitterBufferMs,
|
|
|
|
|
info.jitter_buffer_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNamePreferredJitterBufferMs,
|
|
|
|
|
info.jitter_buffer_preferred_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCurrentDelayMs,
|
|
|
|
|
info.delay_estimate_ms);
|
2014-02-13 23:18:49 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameExpandRate,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::ToString<float>(info.expand_rate));
|
2015-02-18 23:50:46 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameSpeechExpandRate,
|
|
|
|
|
rtc::ToString<float>(info.speech_expand_rate));
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameSecondaryDecodedRate,
|
|
|
|
|
rtc::ToString<float>(info.secondary_decoded_rate));
|
2013-07-10 00:45:36 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsReceived,
|
|
|
|
|
info.packets_rcvd);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsLost,
|
|
|
|
|
info.packets_lost);
|
2014-05-13 17:54:10 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameDecodingCTSG,
|
|
|
|
|
info.decoding_calls_to_silence_generator);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameDecodingCTN,
|
|
|
|
|
info.decoding_calls_to_neteq);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameDecodingNormal,
|
|
|
|
|
info.decoding_normal);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameDecodingPLC,
|
|
|
|
|
info.decoding_plc);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameDecodingCNG,
|
|
|
|
|
info.decoding_cng);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameDecodingPLCCNG,
|
|
|
|
|
info.decoding_plc_cng);
|
2014-06-03 09:42:15 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameCaptureStartNtpTimeMs,
|
|
|
|
|
info.capture_start_ntp_time_ms);
|
2014-06-13 01:14:01 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameCodecName, info.codec_name);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractStats(const cricket::VoiceSenderInfo& info, StatsReport* report) {
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameAudioInputLevel,
|
|
|
|
|
info.audio_level);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameBytesSent,
|
|
|
|
|
info.bytes_sent);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsSent,
|
|
|
|
|
info.packets_sent);
|
2014-03-19 22:20:10 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsLost,
|
|
|
|
|
info.packets_lost);
|
2013-07-10 00:45:36 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameJitterReceived,
|
|
|
|
|
info.jitter_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameRtt, info.rtt_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameEchoCancellationQualityMin,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::ToString<float>(info.aec_quality_min));
|
2013-07-10 00:45:36 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameEchoDelayMedian,
|
|
|
|
|
info.echo_delay_median_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameEchoDelayStdDev,
|
|
|
|
|
info.echo_delay_std_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameEchoReturnLoss,
|
|
|
|
|
info.echo_return_loss);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameEchoReturnLossEnhancement,
|
|
|
|
|
info.echo_return_loss_enhancement);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCodecName, info.codec_name);
|
2013-09-19 05:49:50 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameTypingNoiseState,
|
|
|
|
|
info.typing_noise_detected);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) {
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameBytesReceived,
|
|
|
|
|
info.bytes_rcvd);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsReceived,
|
|
|
|
|
info.packets_rcvd);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsLost,
|
|
|
|
|
info.packets_lost);
|
|
|
|
|
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFirsSent,
|
|
|
|
|
info.firs_sent);
|
2014-02-27 17:52:04 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNamePlisSent,
|
|
|
|
|
info.plis_sent);
|
2013-07-10 00:45:36 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameNacksSent,
|
|
|
|
|
info.nacks_sent);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameWidthReceived,
|
|
|
|
|
info.frame_width);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameHeightReceived,
|
|
|
|
|
info.frame_height);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameRateReceived,
|
|
|
|
|
info.framerate_rcvd);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameRateDecoded,
|
|
|
|
|
info.framerate_decoded);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameRateOutput,
|
|
|
|
|
info.framerate_output);
|
2013-10-25 21:18:33 +00:00
|
|
|
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameDecodeMs,
|
|
|
|
|
info.decode_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameMaxDecodeMs,
|
|
|
|
|
info.max_decode_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCurrentDelayMs,
|
|
|
|
|
info.current_delay_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameTargetDelayMs,
|
|
|
|
|
info.target_delay_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameJitterBufferMs,
|
|
|
|
|
info.jitter_buffer_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameMinPlayoutDelayMs,
|
|
|
|
|
info.min_playout_delay_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameRenderDelayMs,
|
|
|
|
|
info.render_delay_ms);
|
2014-05-06 21:36:31 +00:00
|
|
|
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCaptureStartNtpTimeMs,
|
|
|
|
|
info.capture_start_ntp_time_ms);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractStats(const cricket::VideoSenderInfo& info, StatsReport* report) {
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameBytesSent,
|
|
|
|
|
info.bytes_sent);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsSent,
|
|
|
|
|
info.packets_sent);
|
2014-03-19 22:20:10 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsLost,
|
|
|
|
|
info.packets_lost);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFirsReceived,
|
|
|
|
|
info.firs_rcvd);
|
2014-02-27 17:52:04 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNamePlisReceived,
|
|
|
|
|
info.plis_rcvd);
|
2013-07-10 00:45:36 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameNacksReceived,
|
|
|
|
|
info.nacks_rcvd);
|
2014-03-28 16:22:19 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameWidthInput,
|
|
|
|
|
info.input_frame_width);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameHeightInput,
|
|
|
|
|
info.input_frame_height);
|
2013-07-10 00:45:36 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameWidthSent,
|
2014-03-28 16:22:19 +00:00
|
|
|
info.send_frame_width);
|
2013-07-10 00:45:36 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameHeightSent,
|
2014-03-28 16:22:19 +00:00
|
|
|
info.send_frame_height);
|
2013-07-10 00:45:36 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameRateInput,
|
|
|
|
|
info.framerate_input);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFrameRateSent,
|
|
|
|
|
info.framerate_sent);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameRtt, info.rtt_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCodecName, info.codec_name);
|
2013-12-13 12:29:34 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameCpuLimitedResolution,
|
|
|
|
|
(info.adapt_reason & 0x1) > 0);
|
|
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameBandwidthLimitedResolution,
|
|
|
|
|
(info.adapt_reason & 0x2) > 0);
|
|
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameViewLimitedResolution,
|
|
|
|
|
(info.adapt_reason & 0x4) > 0);
|
2014-06-24 07:24:49 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameAdaptationChanges,
|
|
|
|
|
info.adapt_changes);
|
2013-12-05 00:24:06 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameAvgEncodeMs, info.avg_encode_ms);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCaptureJitterMs,
|
|
|
|
|
info.capture_jitter_ms);
|
2013-12-11 18:25:07 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameCaptureQueueDelayMsPerS,
|
|
|
|
|
info.capture_queue_delay_ms_per_s);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameEncodeUsagePercent,
|
|
|
|
|
info.encode_usage_percent);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractStats(const cricket::BandwidthEstimationInfo& info,
|
|
|
|
|
double stats_gathering_started,
|
2014-02-13 23:18:49 +00:00
|
|
|
PeerConnectionInterface::StatsOutputLevel level,
|
2013-07-10 00:45:36 +00:00
|
|
|
StatsReport* report) {
|
2015-01-21 11:36:18 +00:00
|
|
|
ASSERT(report->type() == StatsReport::kStatsReportTypeBwe);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Clear out stats from previous GatherStats calls if any.
|
2015-01-19 20:41:26 +00:00
|
|
|
if (report->timestamp() != stats_gathering_started) {
|
|
|
|
|
report->ResetValues();
|
|
|
|
|
report->set_timestamp(stats_gathering_started);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameAvailableSendBandwidth,
|
|
|
|
|
info.available_send_bandwidth);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameAvailableReceiveBandwidth,
|
|
|
|
|
info.available_recv_bandwidth);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameTargetEncBitrate,
|
|
|
|
|
info.target_enc_bitrate);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameActualEncBitrate,
|
|
|
|
|
info.actual_enc_bitrate);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameRetransmitBitrate,
|
|
|
|
|
info.retransmit_bitrate);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameTransmitBitrate,
|
|
|
|
|
info.transmit_bitrate);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameBucketDelay,
|
|
|
|
|
info.bucket_delay);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-25 21:18:33 +00:00
|
|
|
void ExtractRemoteStats(const cricket::MediaSenderInfo& info,
|
|
|
|
|
StatsReport* report) {
|
2015-01-19 20:41:26 +00:00
|
|
|
report->set_timestamp(info.remote_stats[0].timestamp);
|
2013-10-25 21:18:33 +00:00
|
|
|
// TODO(hta): Extract some stats here.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractRemoteStats(const cricket::MediaReceiverInfo& info,
|
|
|
|
|
StatsReport* report) {
|
2015-01-19 20:41:26 +00:00
|
|
|
report->set_timestamp(info.remote_stats[0].timestamp);
|
2013-10-25 21:18:33 +00:00
|
|
|
// TODO(hta): Extract some stats here.
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Template to extract stats from a data vector.
|
2013-12-05 00:24:06 +00:00
|
|
|
// In order to use the template, the functions that are called from it,
|
|
|
|
|
// ExtractStats and ExtractRemoteStats, must be defined and overloaded
|
|
|
|
|
// for each type.
|
2013-07-10 00:45:36 +00:00
|
|
|
template<typename T>
|
|
|
|
|
void ExtractStatsFromList(const std::vector<T>& data,
|
|
|
|
|
const std::string& transport_id,
|
2014-06-12 14:57:05 +00:00
|
|
|
StatsCollector* collector,
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport::Direction direction) {
|
|
|
|
|
for (const auto& d : data) {
|
|
|
|
|
uint32 ssrc = d.ssrc();
|
2014-06-12 14:57:05 +00:00
|
|
|
// Each track can have stats for both local and remote objects.
|
2013-10-25 21:18:33 +00:00
|
|
|
// TODO(hta): Handle the case of multiple SSRCs per object.
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport* report = collector->PrepareReport(true, ssrc, transport_id,
|
|
|
|
|
direction);
|
2014-06-12 14:57:05 +00:00
|
|
|
if (report)
|
2015-01-21 11:36:18 +00:00
|
|
|
ExtractStats(d, report);
|
2014-06-12 14:57:05 +00:00
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
if (!d.remote_stats.empty()) {
|
|
|
|
|
report = collector->PrepareReport(false, ssrc, transport_id, direction);
|
|
|
|
|
if (report)
|
|
|
|
|
ExtractRemoteStats(d, report);
|
2013-10-25 21:18:33 +00:00
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2014-02-13 23:18:49 +00:00
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2014-12-16 23:01:31 +00:00
|
|
|
const char* IceCandidateTypeToStatsType(const std::string& candidate_type) {
|
|
|
|
|
if (candidate_type == cricket::LOCAL_PORT_TYPE) {
|
|
|
|
|
return STATSREPORT_LOCAL_PORT_TYPE;
|
|
|
|
|
}
|
|
|
|
|
if (candidate_type == cricket::STUN_PORT_TYPE) {
|
|
|
|
|
return STATSREPORT_STUN_PORT_TYPE;
|
|
|
|
|
}
|
|
|
|
|
if (candidate_type == cricket::PRFLX_PORT_TYPE) {
|
|
|
|
|
return STATSREPORT_PRFLX_PORT_TYPE;
|
|
|
|
|
}
|
|
|
|
|
if (candidate_type == cricket::RELAY_PORT_TYPE) {
|
|
|
|
|
return STATSREPORT_RELAY_PORT_TYPE;
|
|
|
|
|
}
|
|
|
|
|
ASSERT(false);
|
|
|
|
|
return "unknown";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* AdapterTypeToStatsType(rtc::AdapterType type) {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case rtc::ADAPTER_TYPE_UNKNOWN:
|
|
|
|
|
return "unknown";
|
|
|
|
|
case rtc::ADAPTER_TYPE_ETHERNET:
|
|
|
|
|
return STATSREPORT_ADAPTER_TYPE_ETHERNET;
|
|
|
|
|
case rtc::ADAPTER_TYPE_WIFI:
|
|
|
|
|
return STATSREPORT_ADAPTER_TYPE_WIFI;
|
|
|
|
|
case rtc::ADAPTER_TYPE_CELLULAR:
|
|
|
|
|
return STATSREPORT_ADAPTER_TYPE_WWAN;
|
|
|
|
|
case rtc::ADAPTER_TYPE_VPN:
|
|
|
|
|
return STATSREPORT_ADAPTER_TYPE_VPN;
|
Makes libjingle_peerconnection_android_unittest run on networkless devices.
PeerConnectionTest.java currently works, but only on a device with
network interfaces up. This is not a problem for desktop, but it is a
problem when running on Android devices since the devices in the lab
generally don't have network (due to the chaotic radio environment in
the device labs, devices are simply kept in flight mode).
The test does work if one modifies this line in the file
webrtc/base/network.cc:
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
IsIgnoredNetwork(*network));
If we remove the IFF_LOOPBACK clause, the test starts working on
an Android device in flight mode. This is nice - we're running the
call and packets interact with the OS network stack, which is good
for this end-to-end test. We can't just remove the clause though since
having loopback is undesirable for everyone except the test (right)?
so we need to make this behavior configurable.
This CL takes a stab at a complete solution where we pass a boolean
all the way through the Java PeerConnectionFactory down to the
BasicNetworkManager. This comes as a heavy price in interface
changes though. It's pretty out of proportion, but fundamentally we
need some way of telling the network manager that it is on Android
and in test mode. Passing the boolean all the way through is one way.
Another way might be to put the loopback filter behind an ifdef and
link a custom libjingle_peerconnection.so with the test. That is hacky
but doesn't pollute the interfaces. Not sure how to solve that in GYP
but it could mean some duplication between the production and
test .so files.
It would have been perfect to use flags here, but then we need to
hook up gflags parsing to some main() somewhere to make sure the
flag gets parsed, and make sure to pass that flag in our tests.
I'm not sure how that can be done.
Making the loopback filtering conditional is exactly how we solved the
equivalent problem in content_browsertests in Chrome, and it worked
great.
That's all I could think of.
BUG=4181
R=perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/36769004
Cr-Commit-Position: refs/heads/master@{#8344}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8344 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-12 09:23:59 +00:00
|
|
|
case rtc::ADAPTER_TYPE_LOOPBACK:
|
|
|
|
|
return STATSREPORT_ADAPTER_TYPE_LOOPBACK;
|
2014-12-16 23:01:31 +00:00
|
|
|
default:
|
|
|
|
|
ASSERT(false);
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-14 20:15:26 +00:00
|
|
|
StatsCollector::StatsCollector(WebRtcSession* session)
|
2015-01-15 22:55:07 +00:00
|
|
|
: session_(session),
|
|
|
|
|
stats_gathering_started_(0) {
|
2014-07-14 20:15:26 +00:00
|
|
|
ASSERT(session_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatsCollector::~StatsCollector() {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 22:09:37 +00:00
|
|
|
double StatsCollector::GetTimeNow() {
|
|
|
|
|
return rtc::Timing::WallTimeNow() * rtc::kNumMillisecsPerSec;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Adds a MediaStream with tracks that can be used as a |selector| in a call
|
|
|
|
|
// to GetStats.
|
|
|
|
|
void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
ASSERT(stream != NULL);
|
|
|
|
|
|
|
|
|
|
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
|
|
|
|
|
&reports_);
|
|
|
|
|
CreateTrackReports<VideoTrackVector>(stream->GetVideoTracks(),
|
|
|
|
|
&reports_);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-03 18:30:11 +00:00
|
|
|
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
|
|
|
|
uint32 ssrc) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2014-03-03 18:30:11 +00:00
|
|
|
ASSERT(audio_track != NULL);
|
|
|
|
|
for (LocalAudioTrackVector::iterator it = local_audio_tracks_.begin();
|
|
|
|
|
it != local_audio_tracks_.end(); ++it) {
|
|
|
|
|
ASSERT(it->first != audio_track || it->second != ssrc);
|
|
|
|
|
}
|
2014-07-09 07:38:38 +00:00
|
|
|
|
2014-03-03 18:30:11 +00:00
|
|
|
local_audio_tracks_.push_back(std::make_pair(audio_track, ssrc));
|
2014-07-09 07:38:38 +00:00
|
|
|
|
|
|
|
|
// Create the kStatsReportTypeTrack report for the new track if there is no
|
|
|
|
|
// report yet.
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> id(
|
|
|
|
|
StatsReport::NewTypedId(StatsReport::kStatsReportTypeTrack,
|
|
|
|
|
audio_track->id()));
|
|
|
|
|
StatsReport* report = reports_.Find(*id.get());
|
|
|
|
|
if (!report) {
|
|
|
|
|
report = reports_.InsertNew(id.Pass());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameTrackId, audio_track->id());
|
|
|
|
|
}
|
2014-03-03 18:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
|
|
|
|
|
uint32 ssrc) {
|
|
|
|
|
ASSERT(audio_track != NULL);
|
|
|
|
|
for (LocalAudioTrackVector::iterator it = local_audio_tracks_.begin();
|
|
|
|
|
it != local_audio_tracks_.end(); ++it) {
|
|
|
|
|
if (it->first == audio_track && it->second == ssrc) {
|
|
|
|
|
local_audio_tracks_.erase(it);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ASSERT(false);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-15 08:38:30 +00:00
|
|
|
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
2013-07-10 00:45:36 +00:00
|
|
|
StatsReports* reports) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
ASSERT(reports != NULL);
|
2014-08-15 08:38:30 +00:00
|
|
|
ASSERT(reports->empty());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
if (!track) {
|
2015-01-21 11:36:18 +00:00
|
|
|
reports->reserve(reports_.size());
|
|
|
|
|
for (auto* r : reports_)
|
|
|
|
|
reports->push_back(r);
|
2014-08-15 08:38:30 +00:00
|
|
|
return;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport* report = reports_.Find(StatsReport::NewTypedId(
|
|
|
|
|
StatsReport::kStatsReportTypeSession, session_->id()));
|
2014-08-15 08:38:30 +00:00
|
|
|
if (report)
|
|
|
|
|
reports->push_back(report);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
report = reports_.Find(StatsReport::NewTypedId(
|
|
|
|
|
StatsReport::kStatsReportTypeTrack, track->id()));
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-08-15 08:38:30 +00:00
|
|
|
if (!report)
|
|
|
|
|
return;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-08-15 08:38:30 +00:00
|
|
|
reports->push_back(report);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
std::string track_id;
|
2015-01-21 11:36:18 +00:00
|
|
|
for (const auto* r : reports_) {
|
|
|
|
|
if (r->type() != StatsReport::kStatsReportTypeSsrc)
|
2013-07-10 00:45:36 +00:00
|
|
|
continue;
|
2014-08-15 08:38:30 +00:00
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
const StatsReport::Value* v =
|
|
|
|
|
r->FindValue(StatsReport::kStatsValueNameTrackId);
|
|
|
|
|
if (v && v->value == track->id())
|
|
|
|
|
reports->push_back(r);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-13 23:18:49 +00:00
|
|
|
void
|
|
|
|
|
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
double time_now = GetTimeNow();
|
|
|
|
|
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
|
|
|
|
|
// ms apart will be ignored.
|
|
|
|
|
const double kMinGatherStatsPeriod = 50;
|
2014-07-09 07:38:38 +00:00
|
|
|
if (stats_gathering_started_ != 0 &&
|
|
|
|
|
stats_gathering_started_ + kMinGatherStatsPeriod > time_now) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
stats_gathering_started_ = time_now;
|
|
|
|
|
|
|
|
|
|
if (session_) {
|
|
|
|
|
ExtractSessionInfo();
|
|
|
|
|
ExtractVoiceInfo();
|
2014-02-13 23:18:49 +00:00
|
|
|
ExtractVideoInfo(level);
|
2015-01-15 22:55:07 +00:00
|
|
|
ExtractDataInfo();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport* StatsCollector::PrepareReport(
|
|
|
|
|
bool local,
|
2013-10-25 21:18:33 +00:00
|
|
|
uint32 ssrc,
|
2014-06-12 14:57:05 +00:00
|
|
|
const std::string& transport_id,
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport::Direction direction) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2014-07-29 17:36:52 +00:00
|
|
|
const std::string ssrc_id = rtc::ToString<uint32>(ssrc);
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> id(StatsReport::NewIdWithDirection(
|
|
|
|
|
local ? StatsReport::kStatsReportTypeSsrc :
|
|
|
|
|
StatsReport::kStatsReportTypeRemoteSsrc,
|
|
|
|
|
ssrc_id, direction));
|
|
|
|
|
StatsReport* report = reports_.Find(*id.get());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-07-09 07:38:38 +00:00
|
|
|
// Use the ID of the track that is currently mapped to the SSRC, if any.
|
2013-07-10 00:45:36 +00:00
|
|
|
std::string track_id;
|
2014-07-09 07:38:38 +00:00
|
|
|
if (!GetTrackIdBySsrc(ssrc, &track_id, direction)) {
|
2014-08-15 08:38:30 +00:00
|
|
|
if (!report) {
|
2014-07-09 07:38:38 +00:00
|
|
|
// The ssrc is not used by any track or existing report, return NULL
|
|
|
|
|
// in such case to indicate no report is prepared for the ssrc.
|
2013-07-10 00:45:36 +00:00
|
|
|
return NULL;
|
2014-07-09 07:38:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The ssrc is not used by any existing track. Keeps the old track id
|
|
|
|
|
// since we want to report the stats for inactive ssrc.
|
2015-01-21 11:36:18 +00:00
|
|
|
const StatsReport::Value* v =
|
|
|
|
|
report->FindValue(StatsReport::kStatsValueNameTrackId);
|
|
|
|
|
if (v)
|
|
|
|
|
track_id = v->value;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
if (!report) {
|
|
|
|
|
report = reports_.InsertNew(id.Pass());
|
|
|
|
|
} else {
|
|
|
|
|
// Clear out stats from previous GatherStats calls if any.
|
|
|
|
|
// This is required since the report will be returned for the new values.
|
|
|
|
|
// Having the old values in the report will lead to multiple values with
|
|
|
|
|
// the same name.
|
|
|
|
|
// TODO(tommi): This seems to be pretty wasteful if some of these values
|
|
|
|
|
// have not changed (we basically throw them away just to recreate them).
|
|
|
|
|
// Figure out a way to not have to do this while not breaking the existing
|
|
|
|
|
// functionality.
|
|
|
|
|
report->ResetValues();
|
2013-10-25 21:18:33 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
ASSERT(report->values().empty());
|
|
|
|
|
// FYI - for remote reports, the timestamp will be overwritten later.
|
|
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2013-10-25 21:18:33 +00:00
|
|
|
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameSsrc, ssrc_id);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameTrackId, track_id);
|
|
|
|
|
// Add the mapping of SSRC to transport.
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameTransportId,
|
|
|
|
|
transport_id);
|
|
|
|
|
return report;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-09 15:37:36 +00:00
|
|
|
std::string StatsCollector::AddOneCertificateReport(
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::SSLCertificate* cert, const std::string& issuer_id) {
|
2015-01-21 11:36:18 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
|
|
|
|
|
2013-10-09 15:37:36 +00:00
|
|
|
// TODO(bemasc): Move this computation to a helper class that caches these
|
|
|
|
|
// values to reduce CPU use in GetStats. This will require adding a fast
|
|
|
|
|
// SSLCertificate::Equals() method to detect certificate changes.
|
2013-10-13 17:18:27 +00:00
|
|
|
|
|
|
|
|
std::string digest_algorithm;
|
|
|
|
|
if (!cert->GetSignatureDigestAlgorithm(&digest_algorithm))
|
|
|
|
|
return std::string();
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<rtc::SSLFingerprint> ssl_fingerprint(
|
|
|
|
|
rtc::SSLFingerprint::Create(digest_algorithm, cert));
|
2014-02-13 23:18:49 +00:00
|
|
|
|
|
|
|
|
// SSLFingerprint::Create can fail if the algorithm returned by
|
|
|
|
|
// SSLCertificate::GetSignatureDigestAlgorithm is not supported by the
|
|
|
|
|
// implementation of SSLCertificate::ComputeDigest. This currently happens
|
|
|
|
|
// with MD5- and SHA-224-signed certificates when linked to libNSS.
|
|
|
|
|
if (!ssl_fingerprint)
|
|
|
|
|
return std::string();
|
|
|
|
|
|
2013-10-09 15:37:36 +00:00
|
|
|
std::string fingerprint = ssl_fingerprint->GetRfc4572Fingerprint();
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Buffer der_buffer;
|
2013-10-09 15:37:36 +00:00
|
|
|
cert->ToDER(&der_buffer);
|
|
|
|
|
std::string der_base64;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Base64::EncodeFromArray(
|
2013-10-09 15:37:36 +00:00
|
|
|
der_buffer.data(), der_buffer.length(), &der_base64);
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> id(
|
|
|
|
|
StatsReport::NewTypedId(
|
|
|
|
|
StatsReport::kStatsReportTypeCertificate, fingerprint));
|
|
|
|
|
StatsReport* report = reports_.ReplaceOrAddNew(id.Pass());
|
2015-01-19 20:41:26 +00:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2014-08-15 08:38:30 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameFingerprint, fingerprint);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameFingerprintAlgorithm,
|
|
|
|
|
digest_algorithm);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameDer, der_base64);
|
2013-10-09 15:37:36 +00:00
|
|
|
if (!issuer_id.empty())
|
2014-08-15 08:38:30 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameIssuerId, issuer_id);
|
2015-01-21 11:36:18 +00:00
|
|
|
// TODO(tommi): Can we avoid this?
|
2015-01-19 20:41:26 +00:00
|
|
|
return report->id().ToString();
|
2013-10-09 15:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string StatsCollector::AddCertificateReports(
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::SSLCertificate* cert) {
|
2015-01-21 11:36:18 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2013-10-09 15:37:36 +00:00
|
|
|
// Produces a chain of StatsReports representing this certificate and the rest
|
|
|
|
|
// of its chain, and adds those reports to |reports_|. The return value is
|
|
|
|
|
// the id of the leaf report. The provided cert must be non-null, so at least
|
|
|
|
|
// one report will always be provided and the returned string will never be
|
|
|
|
|
// empty.
|
|
|
|
|
ASSERT(cert != NULL);
|
|
|
|
|
|
|
|
|
|
std::string issuer_id;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<rtc::SSLCertChain> chain;
|
2013-10-09 15:37:36 +00:00
|
|
|
if (cert->GetChain(chain.accept())) {
|
|
|
|
|
// This loop runs in reverse, i.e. from root to leaf, so that each
|
|
|
|
|
// certificate's issuer's report ID is known before the child certificate's
|
|
|
|
|
// report is generated. The root certificate does not have an issuer ID
|
|
|
|
|
// value.
|
|
|
|
|
for (ptrdiff_t i = chain->GetSize() - 1; i >= 0; --i) {
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::SSLCertificate& cert_i = chain->Get(i);
|
2013-10-09 15:37:36 +00:00
|
|
|
issuer_id = AddOneCertificateReport(&cert_i, issuer_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Add the leaf certificate.
|
|
|
|
|
return AddOneCertificateReport(cert, issuer_id);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-16 23:01:31 +00:00
|
|
|
std::string StatsCollector::AddCandidateReport(
|
|
|
|
|
const cricket::Candidate& candidate,
|
2015-01-21 11:36:18 +00:00
|
|
|
bool local) {
|
|
|
|
|
scoped_ptr<StatsReport::Id> id(
|
|
|
|
|
StatsReport::NewCandidateId(local, candidate.id()));
|
|
|
|
|
StatsReport* report = reports_.Find(*id.get());
|
2014-12-16 23:01:31 +00:00
|
|
|
if (!report) {
|
2015-01-21 11:36:18 +00:00
|
|
|
report = reports_.InsertNew(id.Pass());
|
|
|
|
|
report->set_timestamp(stats_gathering_started_);
|
|
|
|
|
if (local) {
|
2014-12-16 23:01:31 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameCandidateNetworkType,
|
|
|
|
|
AdapterTypeToStatsType(candidate.network_type()));
|
|
|
|
|
}
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCandidateIPAddress,
|
|
|
|
|
candidate.address().ipaddr().ToString());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCandidatePortNumber,
|
|
|
|
|
candidate.address().PortAsString());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCandidatePriority,
|
|
|
|
|
candidate.priority());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCandidateType,
|
|
|
|
|
IceCandidateTypeToStatsType(candidate.type()));
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameCandidateTransportType,
|
|
|
|
|
candidate.protocol());
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
// TODO(tommi): Necessary?
|
|
|
|
|
return report->id().ToString();
|
2014-12-16 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
void StatsCollector::ExtractSessionInfo() {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
// Extract information from the base session.
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> id(
|
|
|
|
|
StatsReport::NewTypedId(
|
|
|
|
|
StatsReport::kStatsReportTypeSession, session_->id()));
|
|
|
|
|
StatsReport* report = reports_.ReplaceOrAddNew(id.Pass());
|
2015-01-19 20:41:26 +00:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
|
|
|
|
report->ResetValues();
|
2014-08-15 08:38:30 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameInitiator,
|
|
|
|
|
session_->initiator());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
cricket::SessionStats stats;
|
|
|
|
|
if (session_->GetStats(&stats)) {
|
|
|
|
|
// Store the proxy map away for use in SSRC reporting.
|
|
|
|
|
proxy_to_transport_ = stats.proxy_to_transport;
|
|
|
|
|
|
|
|
|
|
for (cricket::TransportStatsMap::iterator transport_iter
|
|
|
|
|
= stats.transport_stats.begin();
|
|
|
|
|
transport_iter != stats.transport_stats.end(); ++transport_iter) {
|
2013-10-09 15:37:36 +00:00
|
|
|
// Attempt to get a copy of the certificates from the transport and
|
|
|
|
|
// expose them in stats reports. All channels in a transport share the
|
|
|
|
|
// same local and remote certificates.
|
2014-07-24 20:41:20 +00:00
|
|
|
//
|
|
|
|
|
// Note that Transport::GetIdentity and Transport::GetRemoteCertificate
|
|
|
|
|
// invoke method calls on the worker thread and block this thread, but
|
|
|
|
|
// messages are still processed on this thread, which may blow way the
|
|
|
|
|
// existing transports. So we cannot reuse |transport| after these calls.
|
2013-10-09 15:37:36 +00:00
|
|
|
std::string local_cert_report_id, remote_cert_report_id;
|
2014-07-24 20:41:20 +00:00
|
|
|
|
2013-10-09 15:37:36 +00:00
|
|
|
cricket::Transport* transport =
|
|
|
|
|
session_->GetTransport(transport_iter->second.content_name);
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<rtc::SSLIdentity> identity;
|
2014-07-24 20:41:20 +00:00
|
|
|
if (transport && transport->GetIdentity(identity.accept())) {
|
|
|
|
|
local_cert_report_id =
|
|
|
|
|
AddCertificateReports(&(identity->certificate()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transport = session_->GetTransport(transport_iter->second.content_name);
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<rtc::SSLCertificate> cert;
|
2014-07-24 20:41:20 +00:00
|
|
|
if (transport && transport->GetRemoteCertificate(cert.accept())) {
|
|
|
|
|
remote_cert_report_id = AddCertificateReports(cert.get());
|
2013-10-09 15:37:36 +00:00
|
|
|
}
|
2014-07-24 20:41:20 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
for (cricket::TransportChannelStatsList::iterator channel_iter
|
|
|
|
|
= transport_iter->second.channel_stats.begin();
|
|
|
|
|
channel_iter != transport_iter->second.channel_stats.end();
|
|
|
|
|
++channel_iter) {
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> id(
|
|
|
|
|
StatsReport::NewComponentId(transport_iter->second.content_name,
|
|
|
|
|
channel_iter->component));
|
|
|
|
|
StatsReport* channel_report = reports_.ReplaceOrAddNew(id.Pass());
|
2015-01-19 20:41:26 +00:00
|
|
|
channel_report->set_timestamp(stats_gathering_started_);
|
2014-08-15 08:38:30 +00:00
|
|
|
channel_report->AddValue(StatsReport::kStatsValueNameComponent,
|
|
|
|
|
channel_iter->component);
|
2015-01-15 22:55:07 +00:00
|
|
|
if (!local_cert_report_id.empty()) {
|
2014-08-15 08:38:30 +00:00
|
|
|
channel_report->AddValue(
|
2013-10-09 15:37:36 +00:00
|
|
|
StatsReport::kStatsValueNameLocalCertificateId,
|
|
|
|
|
local_cert_report_id);
|
2015-01-15 22:55:07 +00:00
|
|
|
}
|
|
|
|
|
if (!remote_cert_report_id.empty()) {
|
2014-08-15 08:38:30 +00:00
|
|
|
channel_report->AddValue(
|
2013-10-09 15:37:36 +00:00
|
|
|
StatsReport::kStatsValueNameRemoteCertificateId,
|
|
|
|
|
remote_cert_report_id);
|
2015-01-15 22:55:07 +00:00
|
|
|
}
|
2015-03-04 01:38:30 +00:00
|
|
|
const std::string& srtp_cipher = channel_iter->srtp_cipher;
|
|
|
|
|
if (!srtp_cipher.empty()) {
|
|
|
|
|
channel_report->AddValue(
|
|
|
|
|
StatsReport::kStatsValueNameSrtpCipher,
|
|
|
|
|
srtp_cipher);
|
|
|
|
|
}
|
|
|
|
|
const std::string& ssl_cipher = channel_iter->ssl_cipher;
|
|
|
|
|
if (!ssl_cipher.empty()) {
|
|
|
|
|
channel_report->AddValue(
|
|
|
|
|
StatsReport::kStatsValueNameDtlsCipher,
|
|
|
|
|
ssl_cipher);
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
for (size_t i = 0;
|
|
|
|
|
i < channel_iter->connection_infos.size();
|
|
|
|
|
++i) {
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> id(
|
|
|
|
|
StatsReport::NewCandidatePairId(transport_iter->first,
|
|
|
|
|
channel_iter->component, static_cast<int>(i)));
|
|
|
|
|
StatsReport* report = reports_.ReplaceOrAddNew(id.Pass());
|
2015-01-19 20:41:26 +00:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Link from connection to its containing channel.
|
2015-01-21 11:36:18 +00:00
|
|
|
// TODO(tommi): Any way to avoid ToString here?
|
2014-08-15 08:38:30 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameChannelId,
|
2015-01-19 20:41:26 +00:00
|
|
|
channel_report->id().ToString());
|
2014-08-15 08:38:30 +00:00
|
|
|
|
|
|
|
|
const cricket::ConnectionInfo& info =
|
|
|
|
|
channel_iter->connection_infos[i];
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameBytesSent,
|
|
|
|
|
info.sent_total_bytes);
|
2014-11-17 19:42:14 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameSendPacketsDiscarded,
|
|
|
|
|
info.sent_discarded_packets);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNamePacketsSent,
|
|
|
|
|
info.sent_total_packets);
|
2014-08-15 08:38:30 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameBytesReceived,
|
|
|
|
|
info.recv_total_bytes);
|
|
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameWritable,
|
|
|
|
|
info.writable);
|
|
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameReadable,
|
|
|
|
|
info.readable);
|
2014-12-16 23:01:31 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameLocalCandidateId,
|
2015-01-21 11:36:18 +00:00
|
|
|
AddCandidateReport(info.local_candidate, true));
|
2014-12-16 23:01:31 +00:00
|
|
|
report->AddValue(
|
|
|
|
|
StatsReport::kStatsValueNameRemoteCandidateId,
|
2015-01-21 11:36:18 +00:00
|
|
|
AddCandidateReport(info.remote_candidate, false));
|
2014-08-15 08:38:30 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameLocalAddress,
|
|
|
|
|
info.local_candidate.address().ToString());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameRemoteAddress,
|
|
|
|
|
info.remote_candidate.address().ToString());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameRtt, info.rtt);
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameTransportType,
|
|
|
|
|
info.local_candidate.protocol());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameLocalCandidateType,
|
|
|
|
|
info.local_candidate.type());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameRemoteCandidateType,
|
|
|
|
|
info.remote_candidate.type());
|
2015-03-04 01:38:30 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameActiveConnection,
|
|
|
|
|
info.best_connection);
|
|
|
|
|
if (info.best_connection) {
|
|
|
|
|
channel_report->AddValue(
|
|
|
|
|
StatsReport::kStatsValueNameSelectedCandidatePairId,
|
|
|
|
|
report->id().ToString());
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatsCollector::ExtractVoiceInfo() {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!session_->voice_channel()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
cricket::VoiceMediaInfo voice_info;
|
|
|
|
|
if (!session_->voice_channel()->GetStats(&voice_info)) {
|
|
|
|
|
LOG(LS_ERROR) << "Failed to get voice channel stats.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::string transport_id;
|
2014-07-15 19:22:37 +00:00
|
|
|
if (!GetTransportIdFromProxy(proxy_to_transport_,
|
|
|
|
|
session_->voice_channel()->content_name(),
|
2013-07-10 00:45:36 +00:00
|
|
|
&transport_id)) {
|
|
|
|
|
LOG(LS_ERROR) << "Failed to get transport name for proxy "
|
|
|
|
|
<< session_->voice_channel()->content_name();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-01-21 11:36:18 +00:00
|
|
|
ExtractStatsFromList(voice_info.receivers, transport_id, this,
|
|
|
|
|
StatsReport::kReceive);
|
|
|
|
|
ExtractStatsFromList(voice_info.senders, transport_id, this,
|
|
|
|
|
StatsReport::kSend);
|
2014-03-03 18:30:11 +00:00
|
|
|
|
|
|
|
|
UpdateStatsFromExistingLocalAudioTracks();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-13 23:18:49 +00:00
|
|
|
void StatsCollector::ExtractVideoInfo(
|
|
|
|
|
PeerConnectionInterface::StatsOutputLevel level) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
|
|
|
|
|
|
|
|
|
if (!session_->video_channel())
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
2014-12-15 09:44:48 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
cricket::VideoMediaInfo video_info;
|
2015-03-04 08:54:32 +00:00
|
|
|
if (!session_->video_channel()->GetStats(&video_info)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_ERROR) << "Failed to get video channel stats.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::string transport_id;
|
2014-07-15 19:22:37 +00:00
|
|
|
if (!GetTransportIdFromProxy(proxy_to_transport_,
|
|
|
|
|
session_->video_channel()->content_name(),
|
2013-07-10 00:45:36 +00:00
|
|
|
&transport_id)) {
|
|
|
|
|
LOG(LS_ERROR) << "Failed to get transport name for proxy "
|
|
|
|
|
<< session_->video_channel()->content_name();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-01-21 11:36:18 +00:00
|
|
|
ExtractStatsFromList(video_info.receivers, transport_id, this,
|
|
|
|
|
StatsReport::kReceive);
|
|
|
|
|
ExtractStatsFromList(video_info.senders, transport_id, this,
|
|
|
|
|
StatsReport::kSend);
|
2013-07-10 00:45:36 +00:00
|
|
|
if (video_info.bw_estimations.size() != 1) {
|
|
|
|
|
LOG(LS_ERROR) << "BWEs count: " << video_info.bw_estimations.size();
|
|
|
|
|
} else {
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> report_id(
|
|
|
|
|
StatsReport::NewBandwidthEstimationId());
|
|
|
|
|
StatsReport* report = reports_.FindOrAddNew(report_id.Pass());
|
2013-07-10 00:45:36 +00:00
|
|
|
ExtractStats(
|
2014-02-13 23:18:49 +00:00
|
|
|
video_info.bw_estimations[0], stats_gathering_started_, level, report);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-15 22:55:07 +00:00
|
|
|
void StatsCollector::ExtractDataInfo() {
|
|
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
|
|
|
|
|
|
|
|
|
for (const auto& dc :
|
|
|
|
|
session_->mediastream_signaling()->sctp_data_channels()) {
|
2015-02-03 22:09:37 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> id(StatsReport::NewTypedIntId(
|
|
|
|
|
StatsReport::kStatsReportTypeDataChannel, dc->id()));
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport* report = reports_.ReplaceOrAddNew(id.Pass());
|
2015-02-03 22:09:37 +00:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2015-01-15 22:55:07 +00:00
|
|
|
report->AddValue(StatsReport::kStatsValueNameLabel, dc->label());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameDataChannelId, dc->id());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameProtocol, dc->protocol());
|
|
|
|
|
report->AddValue(StatsReport::kStatsValueNameState,
|
|
|
|
|
DataChannelInterface::DataStateString(dc->state()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
|
2014-06-12 14:57:05 +00:00
|
|
|
const std::string& id,
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport::Direction direction) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2014-06-12 14:57:05 +00:00
|
|
|
ASSERT(type == StatsReport::kStatsReportTypeSsrc ||
|
|
|
|
|
type == StatsReport::kStatsReportTypeRemoteSsrc);
|
2015-01-21 11:36:18 +00:00
|
|
|
return reports_.Find(StatsReport::NewIdWithDirection(type, id, direction));
|
2014-03-03 18:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport* StatsCollector::GetOrCreateReport(
|
|
|
|
|
const StatsReport::StatsType& type,
|
|
|
|
|
const std::string& id,
|
|
|
|
|
StatsReport::Direction direction) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2014-06-12 14:57:05 +00:00
|
|
|
ASSERT(type == StatsReport::kStatsReportTypeSsrc ||
|
|
|
|
|
type == StatsReport::kStatsReportTypeRemoteSsrc);
|
|
|
|
|
StatsReport* report = GetReport(type, id, direction);
|
2014-03-03 18:30:11 +00:00
|
|
|
if (report == NULL) {
|
2015-01-21 11:36:18 +00:00
|
|
|
rtc::scoped_ptr<StatsReport::Id> report_id(
|
|
|
|
|
StatsReport::NewIdWithDirection(type, id, direction));
|
|
|
|
|
report = reports_.InsertNew(report_id.Pass());
|
2013-10-25 21:18:33 +00:00
|
|
|
}
|
2014-03-03 18:30:11 +00:00
|
|
|
|
2013-10-25 21:18:33 +00:00
|
|
|
return report;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-03 18:30:11 +00:00
|
|
|
void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2014-03-03 18:30:11 +00:00
|
|
|
// Loop through the existing local audio tracks.
|
|
|
|
|
for (LocalAudioTrackVector::const_iterator it = local_audio_tracks_.begin();
|
|
|
|
|
it != local_audio_tracks_.end(); ++it) {
|
|
|
|
|
AudioTrackInterface* track = it->first;
|
|
|
|
|
uint32 ssrc = it->second;
|
2014-07-29 17:36:52 +00:00
|
|
|
std::string ssrc_id = rtc::ToString<uint32>(ssrc);
|
2014-03-03 18:30:11 +00:00
|
|
|
StatsReport* report = GetReport(StatsReport::kStatsReportTypeSsrc,
|
2014-06-12 14:57:05 +00:00
|
|
|
ssrc_id,
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport::kSend);
|
2014-03-10 20:41:22 +00:00
|
|
|
if (report == NULL) {
|
|
|
|
|
// This can happen if a local audio track is added to a stream on the
|
|
|
|
|
// fly and the report has not been set up yet. Do nothing in this case.
|
|
|
|
|
LOG(LS_ERROR) << "Stats report does not exist for ssrc " << ssrc;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-03-03 18:30:11 +00:00
|
|
|
|
|
|
|
|
// The same ssrc can be used by both local and remote audio tracks.
|
2015-01-21 11:36:18 +00:00
|
|
|
const StatsReport::Value* v =
|
|
|
|
|
report->FindValue(StatsReport::kStatsValueNameTrackId);
|
|
|
|
|
if (!v || v->value != track->id())
|
2014-03-03 18:30:11 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
UpdateReportFromAudioTrack(track, report);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
|
|
|
|
StatsReport* report) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2014-03-03 18:30:11 +00:00
|
|
|
ASSERT(track != NULL);
|
|
|
|
|
if (report == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int signal_level = 0;
|
|
|
|
|
if (track->GetSignalLevel(&signal_level)) {
|
|
|
|
|
report->ReplaceValue(StatsReport::kStatsValueNameAudioInputLevel,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::ToString<int>(signal_level));
|
2014-03-03 18:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<AudioProcessorInterface> audio_processor(
|
2014-03-03 18:30:11 +00:00
|
|
|
track->GetAudioProcessor());
|
|
|
|
|
if (audio_processor.get() == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
AudioProcessorInterface::AudioProcessorStats stats;
|
|
|
|
|
audio_processor->GetStats(&stats);
|
|
|
|
|
report->ReplaceValue(StatsReport::kStatsValueNameTypingNoiseState,
|
|
|
|
|
stats.typing_noise_detected ? "true" : "false");
|
|
|
|
|
report->ReplaceValue(StatsReport::kStatsValueNameEchoReturnLoss,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::ToString<int>(stats.echo_return_loss));
|
2014-03-03 18:30:11 +00:00
|
|
|
report->ReplaceValue(
|
|
|
|
|
StatsReport::kStatsValueNameEchoReturnLossEnhancement,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::ToString<int>(stats.echo_return_loss_enhancement));
|
2014-03-03 18:30:11 +00:00
|
|
|
report->ReplaceValue(StatsReport::kStatsValueNameEchoDelayMedian,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::ToString<int>(stats.echo_delay_median_ms));
|
2014-03-03 18:30:11 +00:00
|
|
|
report->ReplaceValue(StatsReport::kStatsValueNameEchoCancellationQualityMin,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::ToString<float>(stats.aec_quality_min));
|
2014-03-03 18:30:11 +00:00
|
|
|
report->ReplaceValue(StatsReport::kStatsValueNameEchoDelayStdDev,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::ToString<int>(stats.echo_delay_std_ms));
|
2014-03-03 18:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-12 14:57:05 +00:00
|
|
|
bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport::Direction direction) {
|
2014-12-15 09:44:48 +00:00
|
|
|
ASSERT(session_->signaling_thread()->IsCurrent());
|
2015-01-21 11:36:18 +00:00
|
|
|
if (direction == StatsReport::kSend) {
|
2014-07-14 20:15:26 +00:00
|
|
|
if (!session_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
|
2014-06-12 14:57:05 +00:00
|
|
|
LOG(LS_WARNING) << "The SSRC " << ssrc
|
|
|
|
|
<< " is not associated with a sending track";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2015-01-21 11:36:18 +00:00
|
|
|
ASSERT(direction == StatsReport::kReceive);
|
2014-07-14 20:15:26 +00:00
|
|
|
if (!session_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
|
2014-06-12 14:57:05 +00:00
|
|
|
LOG(LS_WARNING) << "The SSRC " << ssrc
|
|
|
|
|
<< " is not associated with a receiving track";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 09:44:48 +00:00
|
|
|
void StatsCollector::ClearUpdateStatsCacheForTest() {
|
2014-07-09 07:38:38 +00:00
|
|
|
stats_gathering_started_ = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace webrtc
|