2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2012 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/statscollector.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/peerconnection.h"
|
2014-07-29 17:36:52 +00:00
|
|
|
#include "webrtc/base/base64.h"
|
2015-03-16 09:52:30 +00:00
|
|
|
#include "webrtc/base/checks.h"
|
2014-07-29 17:36:52 +00:00
|
|
|
#include "webrtc/base/scoped_ptr.h"
|
|
|
|
|
#include "webrtc/base/timing.h"
|
2016-02-12 06:47:59 +01:00
|
|
|
#include "webrtc/pc/channel.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
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
template<typename ValueType>
|
|
|
|
|
struct TypeForAdd {
|
2015-03-04 15:25:19 +00:00
|
|
|
const StatsReport::StatsValueName name;
|
2015-03-12 16:35:55 +00:00
|
|
|
const ValueType& value;
|
2015-03-04 15:25:19 +00:00
|
|
|
};
|
|
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
typedef TypeForAdd<bool> BoolForAdd;
|
|
|
|
|
typedef TypeForAdd<float> FloatForAdd;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
typedef TypeForAdd<int64_t> Int64ForAdd;
|
2015-03-12 16:35:55 +00:00
|
|
|
typedef TypeForAdd<int> IntForAdd;
|
2014-07-15 19:22:37 +00:00
|
|
|
|
2015-10-14 15:02:44 -07:00
|
|
|
StatsReport::Id GetTransportIdFromProxy(const ProxyTransportMap& map,
|
2015-03-12 16:35:55 +00:00
|
|
|
const std::string& proxy) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(!proxy.empty());
|
2015-10-14 15:02:44 -07:00
|
|
|
auto found = map.find(proxy);
|
|
|
|
|
if (found == map.end()) {
|
2015-03-12 16:35:55 +00:00
|
|
|
return StatsReport::Id();
|
2015-10-14 15:02:44 -07:00
|
|
|
}
|
2014-07-15 19:22:37 +00:00
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
return StatsReport::NewComponentId(
|
|
|
|
|
found->second, cricket::ICE_CANDIDATE_COMPONENT_RTP);
|
2014-07-15 19:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-22 15:06:43 -07:00
|
|
|
StatsReport* AddTrackReport(StatsCollection* reports,
|
|
|
|
|
const std::string& track_id) {
|
2014-07-09 07:38:38 +00:00
|
|
|
// Adds an empty track report.
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport::Id id(
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport::NewTypedId(StatsReport::kStatsReportTypeTrack, track_id));
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport* report = reports->ReplaceOrAddNew(id);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddString(StatsReport::kStatsValueNameTrackId, track_id);
|
2015-06-22 15:06:43 -07:00
|
|
|
return report;
|
2014-07-09 07:38:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
template <class TrackVector>
|
2015-06-22 15:06:43 -07:00
|
|
|
void CreateTrackReports(const TrackVector& tracks, StatsCollection* reports,
|
|
|
|
|
TrackIdMap& track_ids) {
|
|
|
|
|
for (const auto& track : tracks) {
|
|
|
|
|
const std::string& track_id = track->id();
|
|
|
|
|
StatsReport* report = AddTrackReport(reports, track_id);
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(report != nullptr);
|
2015-06-22 15:06:43 -07:00
|
|
|
track_ids[track_id] = report;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-04 15:25:19 +00:00
|
|
|
void ExtractCommonSendProperties(const cricket::MediaSenderInfo& info,
|
|
|
|
|
StatsReport* report) {
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name);
|
|
|
|
|
report->AddInt64(StatsReport::kStatsValueNameBytesSent, info.bytes_sent);
|
|
|
|
|
report->AddInt64(StatsReport::kStatsValueNameRtt, info.rtt_ms);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 07:35:32 -07:00
|
|
|
void ExtractCommonReceiveProperties(const cricket::MediaReceiverInfo& info,
|
|
|
|
|
StatsReport* report) {
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-27 17:27:35 -08:00
|
|
|
void SetAudioProcessingStats(StatsReport* report,
|
|
|
|
|
bool typing_noise_detected,
|
|
|
|
|
int echo_return_loss,
|
|
|
|
|
int echo_return_loss_enhancement,
|
|
|
|
|
int echo_delay_median_ms,
|
|
|
|
|
float aec_quality_min,
|
|
|
|
|
int echo_delay_std_ms) {
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameTypingNoiseState,
|
|
|
|
|
typing_noise_detected);
|
|
|
|
|
report->AddFloat(StatsReport::kStatsValueNameEchoCancellationQualityMin,
|
|
|
|
|
aec_quality_min);
|
|
|
|
|
const IntForAdd ints[] = {
|
|
|
|
|
{ StatsReport::kStatsValueNameEchoReturnLoss, echo_return_loss },
|
|
|
|
|
{ StatsReport::kStatsValueNameEchoReturnLossEnhancement,
|
|
|
|
|
echo_return_loss_enhancement },
|
|
|
|
|
{ StatsReport::kStatsValueNameEchoDelayMedian, echo_delay_median_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameEchoDelayStdDev, echo_delay_std_ms },
|
|
|
|
|
};
|
|
|
|
|
for (const auto& i : ints)
|
|
|
|
|
report->AddInt(i.name, i.value);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
void ExtractStats(const cricket::VoiceReceiverInfo& info, StatsReport* report) {
|
2015-08-28 07:35:32 -07:00
|
|
|
ExtractCommonReceiveProperties(info, report);
|
2015-03-04 15:25:19 +00:00
|
|
|
const FloatForAdd floats[] = {
|
|
|
|
|
{ StatsReport::kStatsValueNameExpandRate, info.expand_rate },
|
|
|
|
|
{ StatsReport::kStatsValueNameSecondaryDecodedRate,
|
|
|
|
|
info.secondary_decoded_rate },
|
|
|
|
|
{ StatsReport::kStatsValueNameSpeechExpandRate, info.speech_expand_rate },
|
2015-06-02 09:24:52 +02:00
|
|
|
{ StatsReport::kStatsValueNameAccelerateRate, info.accelerate_rate },
|
|
|
|
|
{ StatsReport::kStatsValueNamePreemptiveExpandRate,
|
|
|
|
|
info.preemptive_expand_rate },
|
2015-03-04 15:25:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const IntForAdd ints[] = {
|
|
|
|
|
{ StatsReport::kStatsValueNameAudioOutputLevel, info.audio_level },
|
|
|
|
|
{ StatsReport::kStatsValueNameCurrentDelayMs, info.delay_estimate_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameDecodingCNG, info.decoding_cng },
|
|
|
|
|
{ StatsReport::kStatsValueNameDecodingCTN, info.decoding_calls_to_neteq },
|
|
|
|
|
{ StatsReport::kStatsValueNameDecodingCTSG,
|
|
|
|
|
info.decoding_calls_to_silence_generator },
|
|
|
|
|
{ StatsReport::kStatsValueNameDecodingNormal, info.decoding_normal },
|
|
|
|
|
{ StatsReport::kStatsValueNameDecodingPLC, info.decoding_plc },
|
|
|
|
|
{ StatsReport::kStatsValueNameDecodingPLCCNG, info.decoding_plc_cng },
|
|
|
|
|
{ StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameJitterReceived, info.jitter_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsLost, info.packets_lost },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsReceived, info.packets_rcvd },
|
|
|
|
|
{ StatsReport::kStatsValueNamePreferredJitterBufferMs,
|
|
|
|
|
info.jitter_buffer_preferred_ms },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const auto& f : floats)
|
|
|
|
|
report->AddFloat(f.name, f.value);
|
|
|
|
|
|
|
|
|
|
for (const auto& i : ints)
|
|
|
|
|
report->AddInt(i.name, i.value);
|
|
|
|
|
|
|
|
|
|
report->AddInt64(StatsReport::kStatsValueNameBytesReceived,
|
2013-07-10 00:45:36 +00:00
|
|
|
info.bytes_rcvd);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs,
|
2014-06-03 09:42:15 +00:00
|
|
|
info.capture_start_ntp_time_ms);
|
2016-01-28 01:27:15 -08:00
|
|
|
report->AddString(StatsReport::kStatsValueNameMediaType, "audio");
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractStats(const cricket::VoiceSenderInfo& info, StatsReport* report) {
|
2015-03-04 15:25:19 +00:00
|
|
|
ExtractCommonSendProperties(info, report);
|
|
|
|
|
|
2015-11-27 17:27:35 -08:00
|
|
|
SetAudioProcessingStats(
|
|
|
|
|
report, info.typing_noise_detected, info.echo_return_loss,
|
|
|
|
|
info.echo_return_loss_enhancement, info.echo_delay_median_ms,
|
|
|
|
|
info.aec_quality_min, info.echo_delay_std_ms);
|
2015-03-04 15:25:19 +00:00
|
|
|
|
2015-11-27 17:27:35 -08:00
|
|
|
RTC_DCHECK_GE(info.audio_level, 0);
|
2015-03-04 15:25:19 +00:00
|
|
|
const IntForAdd ints[] = {
|
2015-11-27 17:27:35 -08:00
|
|
|
{ StatsReport::kStatsValueNameAudioInputLevel, info.audio_level},
|
2015-03-04 15:25:19 +00:00
|
|
|
{ StatsReport::kStatsValueNameJitterReceived, info.jitter_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsLost, info.packets_lost },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsSent, info.packets_sent },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const auto& i : ints)
|
|
|
|
|
report->AddInt(i.name, i.value);
|
2016-01-28 01:27:15 -08:00
|
|
|
report->AddString(StatsReport::kStatsValueNameMediaType, "audio");
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) {
|
2015-08-28 07:35:32 -07:00
|
|
|
ExtractCommonReceiveProperties(info, report);
|
2015-12-18 16:01:11 +01:00
|
|
|
report->AddString(StatsReport::kStatsValueNameCodecImplementationName,
|
|
|
|
|
info.decoder_implementation_name);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddInt64(StatsReport::kStatsValueNameBytesReceived,
|
2013-07-10 00:45:36 +00:00
|
|
|
info.bytes_rcvd);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs,
|
2014-05-06 21:36:31 +00:00
|
|
|
info.capture_start_ntp_time_ms);
|
2015-03-04 15:25:19 +00:00
|
|
|
const IntForAdd ints[] = {
|
|
|
|
|
{ StatsReport::kStatsValueNameCurrentDelayMs, info.current_delay_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameDecodeMs, info.decode_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameFirsSent, info.firs_sent },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameHeightReceived, info.frame_height },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameRateDecoded, info.framerate_decoded },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameRateOutput, info.framerate_output },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameRateReceived, info.framerate_rcvd },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameWidthReceived, info.frame_width },
|
|
|
|
|
{ StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameMaxDecodeMs, info.max_decode_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameMinPlayoutDelayMs,
|
|
|
|
|
info.min_playout_delay_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameNacksSent, info.nacks_sent },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsLost, info.packets_lost },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsReceived, info.packets_rcvd },
|
|
|
|
|
{ StatsReport::kStatsValueNamePlisSent, info.plis_sent },
|
|
|
|
|
{ StatsReport::kStatsValueNameRenderDelayMs, info.render_delay_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameTargetDelayMs, info.target_delay_ms },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const auto& i : ints)
|
|
|
|
|
report->AddInt(i.name, i.value);
|
2016-01-28 01:27:15 -08:00
|
|
|
report->AddString(StatsReport::kStatsValueNameMediaType, "video");
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExtractStats(const cricket::VideoSenderInfo& info, StatsReport* report) {
|
2015-03-04 15:25:19 +00:00
|
|
|
ExtractCommonSendProperties(info, report);
|
|
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
report->AddString(StatsReport::kStatsValueNameCodecImplementationName,
|
|
|
|
|
info.encoder_implementation_name);
|
2013-12-13 12:29:34 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameBandwidthLimitedResolution,
|
|
|
|
|
(info.adapt_reason & 0x2) > 0);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameCpuLimitedResolution,
|
|
|
|
|
(info.adapt_reason & 0x1) > 0);
|
2013-12-13 12:29:34 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameViewLimitedResolution,
|
|
|
|
|
(info.adapt_reason & 0x4) > 0);
|
2015-03-04 15:25:19 +00:00
|
|
|
|
|
|
|
|
const IntForAdd ints[] = {
|
|
|
|
|
{ StatsReport::kStatsValueNameAdaptationChanges, info.adapt_changes },
|
|
|
|
|
{ StatsReport::kStatsValueNameAvgEncodeMs, info.avg_encode_ms },
|
|
|
|
|
{ StatsReport::kStatsValueNameEncodeUsagePercent,
|
|
|
|
|
info.encode_usage_percent },
|
|
|
|
|
{ StatsReport::kStatsValueNameFirsReceived, info.firs_rcvd },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameHeightInput, info.input_frame_height },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameHeightSent, info.send_frame_height },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameRateInput, info.framerate_input },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameRateSent, info.framerate_sent },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameWidthInput, info.input_frame_width },
|
|
|
|
|
{ StatsReport::kStatsValueNameFrameWidthSent, info.send_frame_width },
|
|
|
|
|
{ StatsReport::kStatsValueNameNacksReceived, info.nacks_rcvd },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsLost, info.packets_lost },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsSent, info.packets_sent },
|
|
|
|
|
{ StatsReport::kStatsValueNamePlisReceived, info.plis_rcvd },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const auto& i : ints)
|
|
|
|
|
report->AddInt(i.name, i.value);
|
2016-01-28 01:27:15 -08:00
|
|
|
report->AddString(StatsReport::kStatsValueNameMediaType, "video");
|
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-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
report->set_timestamp(stats_gathering_started);
|
|
|
|
|
const IntForAdd ints[] = {
|
|
|
|
|
{ StatsReport::kStatsValueNameAvailableSendBandwidth,
|
|
|
|
|
info.available_send_bandwidth },
|
|
|
|
|
{ StatsReport::kStatsValueNameAvailableReceiveBandwidth,
|
|
|
|
|
info.available_recv_bandwidth },
|
|
|
|
|
{ StatsReport::kStatsValueNameTargetEncBitrate, info.target_enc_bitrate },
|
|
|
|
|
{ StatsReport::kStatsValueNameActualEncBitrate, info.actual_enc_bitrate },
|
|
|
|
|
{ StatsReport::kStatsValueNameRetransmitBitrate, info.retransmit_bitrate },
|
|
|
|
|
{ StatsReport::kStatsValueNameTransmitBitrate, info.transmit_bitrate },
|
|
|
|
|
};
|
|
|
|
|
for (const auto& i : ints)
|
|
|
|
|
report->AddInt(i.name, i.value);
|
|
|
|
|
report->AddInt64(StatsReport::kStatsValueNameBucketDelay, info.bucket_delay);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
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,
|
2015-03-12 16:35:55 +00:00
|
|
|
const StatsReport::Id& 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) {
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t 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;
|
|
|
|
|
}
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(false);
|
2014-12-16 23:01:31 +00:00
|
|
|
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:
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(false);
|
2014-12-16 23:01:31 +00:00
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
StatsCollector::StatsCollector(PeerConnection* pc)
|
|
|
|
|
: pc_(pc), stats_gathering_started_(0) {
|
|
|
|
|
RTC_DCHECK(pc_);
|
2014-07-14 20:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatsCollector::~StatsCollector() {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->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) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(stream != NULL);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
|
2015-06-22 15:06:43 -07:00
|
|
|
&reports_, track_ids_);
|
2013-07-10 00:45:36 +00:00
|
|
|
CreateTrackReports<VideoTrackVector>(stream->GetVideoTracks(),
|
2015-06-22 15:06:43 -07:00
|
|
|
&reports_, track_ids_);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-03 18:30:11 +00:00
|
|
|
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(audio_track != NULL);
|
2015-03-16 09:52:30 +00:00
|
|
|
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
|
2015-03-12 16:35:55 +00:00
|
|
|
for (const auto& track : local_audio_tracks_)
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(track.first != audio_track || track.second != ssrc);
|
2015-03-12 16:35:55 +00:00
|
|
|
#endif
|
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-03-12 16:35:55 +00:00
|
|
|
StatsReport::Id id(StatsReport::NewTypedId(StatsReport::kStatsReportTypeTrack,
|
|
|
|
|
audio_track->id()));
|
|
|
|
|
StatsReport* report = reports_.Find(id);
|
2015-01-21 11:36:18 +00:00
|
|
|
if (!report) {
|
2015-03-12 16:35:55 +00:00
|
|
|
report = reports_.InsertNew(id);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddString(StatsReport::kStatsValueNameTrackId, audio_track->id());
|
2015-01-21 11:36:18 +00:00
|
|
|
}
|
2014-03-03 18:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(audio_track != NULL);
|
2015-03-12 16:35:55 +00:00
|
|
|
local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(),
|
|
|
|
|
local_audio_tracks_.end(),
|
|
|
|
|
[audio_track, ssrc](const LocalAudioTrackVector::value_type& track) {
|
|
|
|
|
return track.first == audio_track && track.second == ssrc;
|
|
|
|
|
}));
|
2014-03-03 18:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
2014-08-15 08:38:30 +00:00
|
|
|
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
2013-07-10 00:45:36 +00:00
|
|
|
StatsReports* reports) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(reports != NULL);
|
|
|
|
|
RTC_DCHECK(reports->empty());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
|
|
|
|
|
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(
|
2015-10-14 11:33:11 -07:00
|
|
|
StatsReport::kStatsReportTypeSession, pc_->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);
|
2015-03-12 16:35:55 +00:00
|
|
|
if (v && v->string_val() == track->id())
|
2015-01-21 11:36:18 +00:00
|
|
|
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) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->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;
|
|
|
|
|
|
2016-03-01 12:42:03 -08:00
|
|
|
// TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no
|
|
|
|
|
// pc_->session().
|
2015-10-14 11:33:11 -07:00
|
|
|
if (pc_->session()) {
|
2015-03-12 16:35:55 +00:00
|
|
|
// TODO(tommi): All of these hop over to the worker thread to fetch
|
|
|
|
|
// information. We could use an AsyncInvoker to run all of these and post
|
|
|
|
|
// the information back to the signaling thread where we can create and
|
|
|
|
|
// update stats reports. That would also clean up the threading story a bit
|
|
|
|
|
// since we'd be creating/updating the stats report objects consistently on
|
|
|
|
|
// the same thread (this class has no locks right now).
|
2013-07-10 00:45:36 +00:00
|
|
|
ExtractSessionInfo();
|
|
|
|
|
ExtractVoiceInfo();
|
2014-02-13 23:18:49 +00:00
|
|
|
ExtractVideoInfo(level);
|
2015-01-15 22:55:07 +00:00
|
|
|
ExtractDataInfo();
|
2015-06-22 15:06:43 -07:00
|
|
|
UpdateTrackReports();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
StatsReport* StatsCollector::PrepareReport(
|
|
|
|
|
bool local,
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
const StatsReport::Id& transport_id,
|
|
|
|
|
StatsReport::Direction direction) {
|
|
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport::Id id(StatsReport::NewIdWithDirection(
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
local ? StatsReport::kStatsReportTypeSsrc
|
|
|
|
|
: StatsReport::kStatsReportTypeRemoteSsrc,
|
|
|
|
|
rtc::ToString<uint32_t>(ssrc), direction));
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport* report = reports_.Find(id);
|
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)
|
2015-03-12 16:35:55 +00:00
|
|
|
track_id = v->string_val();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
if (!report)
|
|
|
|
|
report = reports_.InsertNew(id);
|
2013-10-25 21:18:33 +00:00
|
|
|
|
2015-01-21 11:36:18 +00:00
|
|
|
// FYI - for remote reports, the timestamp will be overwritten later.
|
|
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2013-10-25 21:18:33 +00:00
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
report->AddInt64(StatsReport::kStatsValueNameSsrc, ssrc);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddString(StatsReport::kStatsValueNameTrackId, track_id);
|
2013-10-25 21:18:33 +00:00
|
|
|
// Add the mapping of SSRC to transport.
|
2015-03-12 16:35:55 +00:00
|
|
|
report->AddId(StatsReport::kStatsValueNameTransportId, transport_id);
|
2013-10-25 21:18:33 +00:00
|
|
|
return report;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport* StatsCollector::AddOneCertificateReport(
|
|
|
|
|
const rtc::SSLCertificate* cert, const StatsReport* issuer) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-01-21 11:36:18 +00:00
|
|
|
|
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))
|
2015-03-12 16:35:55 +00:00
|
|
|
return nullptr;
|
2013-10-13 17:18:27 +00:00
|
|
|
|
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)
|
2015-03-12 16:35:55 +00:00
|
|
|
return nullptr;
|
2014-02-13 23:18:49 +00:00
|
|
|
|
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;
|
2015-03-24 09:19:06 +00:00
|
|
|
rtc::Base64::EncodeFromArray(der_buffer.data(), der_buffer.size(),
|
|
|
|
|
&der_base64);
|
2013-10-09 15:37:36 +00:00
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport::Id id(StatsReport::NewTypedId(
|
|
|
|
|
StatsReport::kStatsReportTypeCertificate, fingerprint));
|
|
|
|
|
StatsReport* report = reports_.ReplaceOrAddNew(id);
|
2015-01-19 20:41:26 +00:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddString(StatsReport::kStatsValueNameFingerprint, fingerprint);
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameFingerprintAlgorithm,
|
|
|
|
|
digest_algorithm);
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameDer, der_base64);
|
2015-03-12 16:35:55 +00:00
|
|
|
if (issuer)
|
|
|
|
|
report->AddId(StatsReport::kStatsValueNameIssuerId, issuer->id());
|
|
|
|
|
return report;
|
2013-10-09 15:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport* StatsCollector::AddCertificateReports(
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::SSLCertificate* cert) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->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.
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(cert != NULL);
|
2013-10-09 15:37:36 +00:00
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport* issuer = nullptr;
|
2016-03-15 12:53:24 -07:00
|
|
|
rtc::scoped_ptr<rtc::SSLCertChain> chain = cert->GetChain();
|
|
|
|
|
if (chain) {
|
2013-10-09 15:37:36 +00:00
|
|
|
// 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);
|
2015-03-12 16:35:55 +00:00
|
|
|
issuer = AddOneCertificateReport(&cert_i, issuer);
|
2013-10-09 15:37:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Add the leaf certificate.
|
2015-03-12 16:35:55 +00:00
|
|
|
return AddOneCertificateReport(cert, issuer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatsReport* StatsCollector::AddConnectionInfoReport(
|
|
|
|
|
const std::string& content_name, int component, int connection_id,
|
|
|
|
|
const StatsReport::Id& channel_report_id,
|
|
|
|
|
const cricket::ConnectionInfo& info) {
|
|
|
|
|
StatsReport::Id id(StatsReport::NewCandidatePairId(content_name, component,
|
|
|
|
|
connection_id));
|
|
|
|
|
StatsReport* report = reports_.ReplaceOrAddNew(id);
|
|
|
|
|
report->set_timestamp(stats_gathering_started_);
|
|
|
|
|
|
|
|
|
|
const BoolForAdd bools[] = {
|
2015-09-21 11:48:28 -07:00
|
|
|
{StatsReport::kStatsValueNameActiveConnection, info.best_connection},
|
|
|
|
|
{StatsReport::kStatsValueNameReceiving, info.receiving},
|
|
|
|
|
{StatsReport::kStatsValueNameWritable, info.writable},
|
2015-03-12 16:35:55 +00:00
|
|
|
};
|
|
|
|
|
for (const auto& b : bools)
|
|
|
|
|
report->AddBoolean(b.name, b.value);
|
|
|
|
|
|
|
|
|
|
report->AddId(StatsReport::kStatsValueNameChannelId, channel_report_id);
|
|
|
|
|
report->AddId(StatsReport::kStatsValueNameLocalCandidateId,
|
|
|
|
|
AddCandidateReport(info.local_candidate, true)->id());
|
|
|
|
|
report->AddId(StatsReport::kStatsValueNameRemoteCandidateId,
|
|
|
|
|
AddCandidateReport(info.remote_candidate, false)->id());
|
|
|
|
|
|
|
|
|
|
const Int64ForAdd int64s[] = {
|
|
|
|
|
{ StatsReport::kStatsValueNameBytesReceived, info.recv_total_bytes },
|
|
|
|
|
{ StatsReport::kStatsValueNameBytesSent, info.sent_total_bytes },
|
|
|
|
|
{ StatsReport::kStatsValueNamePacketsSent, info.sent_total_packets },
|
|
|
|
|
{ StatsReport::kStatsValueNameRtt, info.rtt },
|
|
|
|
|
{ StatsReport::kStatsValueNameSendPacketsDiscarded,
|
|
|
|
|
info.sent_discarded_packets },
|
|
|
|
|
};
|
|
|
|
|
for (const auto& i : int64s)
|
|
|
|
|
report->AddInt64(i.name, i.value);
|
|
|
|
|
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameLocalAddress,
|
|
|
|
|
info.local_candidate.address().ToString());
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameLocalCandidateType,
|
|
|
|
|
info.local_candidate.type());
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameRemoteAddress,
|
|
|
|
|
info.remote_candidate.address().ToString());
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameRemoteCandidateType,
|
|
|
|
|
info.remote_candidate.type());
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameTransportType,
|
|
|
|
|
info.local_candidate.protocol());
|
|
|
|
|
|
|
|
|
|
return report;
|
2013-10-09 15:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport* StatsCollector::AddCandidateReport(
|
2014-12-16 23:01:31 +00:00
|
|
|
const cricket::Candidate& candidate,
|
2015-01-21 11:36:18 +00:00
|
|
|
bool local) {
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport::Id id(StatsReport::NewCandidateId(local, candidate.id()));
|
|
|
|
|
StatsReport* report = reports_.Find(id);
|
2014-12-16 23:01:31 +00:00
|
|
|
if (!report) {
|
2015-03-12 16:35:55 +00:00
|
|
|
report = reports_.InsertNew(id);
|
2015-01-21 11:36:18 +00:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
|
|
|
|
if (local) {
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddString(StatsReport::kStatsValueNameCandidateNetworkType,
|
|
|
|
|
AdapterTypeToStatsType(candidate.network_type()));
|
2014-12-16 23:01:31 +00:00
|
|
|
}
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddString(StatsReport::kStatsValueNameCandidateIPAddress,
|
|
|
|
|
candidate.address().ipaddr().ToString());
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameCandidatePortNumber,
|
|
|
|
|
candidate.address().PortAsString());
|
|
|
|
|
report->AddInt(StatsReport::kStatsValueNameCandidatePriority,
|
|
|
|
|
candidate.priority());
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameCandidateType,
|
|
|
|
|
IceCandidateTypeToStatsType(candidate.type()));
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameCandidateTransportType,
|
|
|
|
|
candidate.protocol());
|
2014-12-16 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
return report;
|
2014-12-16 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
void StatsCollector::ExtractSessionInfo() {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-03-12 16:35:55 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Extract information from the base session.
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport::Id id(StatsReport::NewTypedId(
|
2015-10-14 11:33:11 -07:00
|
|
|
StatsReport::kStatsReportTypeSession, pc_->session()->id()));
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport* report = reports_.ReplaceOrAddNew(id);
|
2015-01-19 20:41:26 +00:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2014-08-15 08:38:30 +00:00
|
|
|
report->AddBoolean(StatsReport::kStatsValueNameInitiator,
|
2015-10-14 15:02:44 -07:00
|
|
|
pc_->session()->initial_offerer());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-10-14 15:02:44 -07:00
|
|
|
SessionStats stats;
|
2015-10-14 11:33:11 -07:00
|
|
|
if (!pc_->session()->GetTransportStats(&stats)) {
|
2015-03-16 19:31:40 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2014-07-24 20:41:20 +00:00
|
|
|
|
2015-03-16 19:31:40 +00:00
|
|
|
// Store the proxy map away for use in SSRC reporting.
|
|
|
|
|
// TODO(tommi): This shouldn't be necessary if we post the stats back to the
|
|
|
|
|
// signaling thread after fetching them on the worker thread, then just use
|
|
|
|
|
// the proxy map directly from the session stats.
|
|
|
|
|
// As is, if GetStats() failed, we could be using old (incorrect?) proxy
|
|
|
|
|
// data.
|
|
|
|
|
proxy_to_transport_ = stats.proxy_to_transport;
|
|
|
|
|
|
|
|
|
|
for (const auto& transport_iter : stats.transport_stats) {
|
|
|
|
|
// 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.
|
|
|
|
|
//
|
|
|
|
|
StatsReport::Id local_cert_report_id, remote_cert_report_id;
|
2015-08-27 10:12:24 +02:00
|
|
|
rtc::scoped_refptr<rtc::RTCCertificate> certificate;
|
2015-10-14 11:33:11 -07:00
|
|
|
if (pc_->session()->GetLocalCertificate(
|
|
|
|
|
transport_iter.second.transport_name, &certificate)) {
|
2015-08-27 10:12:24 +02:00
|
|
|
StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate()));
|
2015-03-16 19:31:40 +00:00
|
|
|
if (r)
|
|
|
|
|
local_cert_report_id = r->id();
|
|
|
|
|
}
|
2014-07-24 20:41:20 +00:00
|
|
|
|
2015-03-16 19:31:40 +00:00
|
|
|
rtc::scoped_ptr<rtc::SSLCertificate> cert;
|
2015-10-14 11:33:11 -07:00
|
|
|
if (pc_->session()->GetRemoteSSLCertificate(
|
|
|
|
|
transport_iter.second.transport_name, cert.accept())) {
|
2015-03-16 19:31:40 +00:00
|
|
|
StatsReport* r = AddCertificateReports(cert.get());
|
|
|
|
|
if (r)
|
|
|
|
|
remote_cert_report_id = r->id();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const auto& channel_iter : transport_iter.second.channel_stats) {
|
|
|
|
|
StatsReport::Id id(StatsReport::NewComponentId(
|
2015-09-23 11:50:27 -07:00
|
|
|
transport_iter.second.transport_name, channel_iter.component));
|
2015-03-16 19:31:40 +00:00
|
|
|
StatsReport* channel_report = reports_.ReplaceOrAddNew(id);
|
|
|
|
|
channel_report->set_timestamp(stats_gathering_started_);
|
|
|
|
|
channel_report->AddInt(StatsReport::kStatsValueNameComponent,
|
|
|
|
|
channel_iter.component);
|
|
|
|
|
if (local_cert_report_id.get()) {
|
|
|
|
|
channel_report->AddId(StatsReport::kStatsValueNameLocalCertificateId,
|
|
|
|
|
local_cert_report_id);
|
|
|
|
|
}
|
|
|
|
|
if (remote_cert_report_id.get()) {
|
|
|
|
|
channel_report->AddId(StatsReport::kStatsValueNameRemoteCertificateId,
|
|
|
|
|
remote_cert_report_id);
|
|
|
|
|
}
|
2015-11-18 19:41:53 -08:00
|
|
|
int srtp_crypto_suite = channel_iter.srtp_crypto_suite;
|
|
|
|
|
if (srtp_crypto_suite != rtc::SRTP_INVALID_CRYPTO_SUITE &&
|
|
|
|
|
rtc::SrtpCryptoSuiteToName(srtp_crypto_suite).length()) {
|
|
|
|
|
channel_report->AddString(
|
|
|
|
|
StatsReport::kStatsValueNameSrtpCipher,
|
|
|
|
|
rtc::SrtpCryptoSuiteToName(srtp_crypto_suite));
|
2015-03-16 19:31:40 +00:00
|
|
|
}
|
2015-11-18 19:41:53 -08:00
|
|
|
int ssl_cipher_suite = channel_iter.ssl_cipher_suite;
|
|
|
|
|
if (ssl_cipher_suite != rtc::TLS_NULL_WITH_NULL_NULL &&
|
|
|
|
|
rtc::SSLStreamAdapter::SslCipherSuiteToName(ssl_cipher_suite)
|
|
|
|
|
.length()) {
|
2015-09-30 21:48:54 -07:00
|
|
|
channel_report->AddString(
|
|
|
|
|
StatsReport::kStatsValueNameDtlsCipher,
|
2015-11-18 19:41:53 -08:00
|
|
|
rtc::SSLStreamAdapter::SslCipherSuiteToName(ssl_cipher_suite));
|
2015-03-16 19:31:40 +00:00
|
|
|
}
|
2015-03-12 16:35:55 +00:00
|
|
|
|
2015-03-16 19:31:40 +00:00
|
|
|
int connection_id = 0;
|
|
|
|
|
for (const cricket::ConnectionInfo& info :
|
|
|
|
|
channel_iter.connection_infos) {
|
|
|
|
|
StatsReport* connection_report = AddConnectionInfoReport(
|
|
|
|
|
transport_iter.first, channel_iter.component, connection_id++,
|
|
|
|
|
channel_report->id(), info);
|
|
|
|
|
if (info.best_connection) {
|
|
|
|
|
channel_report->AddId(
|
|
|
|
|
StatsReport::kStatsValueNameSelectedCandidatePairId,
|
|
|
|
|
connection_report->id());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatsCollector::ExtractVoiceInfo() {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2014-12-15 09:44:48 +00:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
if (!pc_->session()->voice_channel()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
cricket::VoiceMediaInfo voice_info;
|
2015-10-14 11:33:11 -07:00
|
|
|
if (!pc_->session()->voice_channel()->GetStats(&voice_info)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_ERROR) << "Failed to get voice channel stats.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-03-12 16:35:55 +00:00
|
|
|
|
|
|
|
|
// TODO(tommi): The above code should run on the worker thread and post the
|
|
|
|
|
// results back to the signaling thread, where we can add data to the reports.
|
|
|
|
|
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
StatsReport::Id transport_id(GetTransportIdFromProxy(
|
|
|
|
|
proxy_to_transport_, pc_->session()->voice_channel()->content_name()));
|
2015-03-12 16:35:55 +00:00
|
|
|
if (!transport_id.get()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_ERROR) << "Failed to get transport name for proxy "
|
2015-10-14 11:33:11 -07:00
|
|
|
<< pc_->session()->voice_channel()->content_name();
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2015-03-12 16:35:55 +00:00
|
|
|
|
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) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2014-12-15 09:44:48 +00:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
if (!pc_->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-10-14 11:33:11 -07:00
|
|
|
if (!pc_->session()->video_channel()->GetStats(&video_info)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_ERROR) << "Failed to get video channel stats.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-03-12 16:35:55 +00:00
|
|
|
|
|
|
|
|
// TODO(tommi): The above code should run on the worker thread and post the
|
|
|
|
|
// results back to the signaling thread, where we can add data to the reports.
|
|
|
|
|
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
StatsReport::Id transport_id(GetTransportIdFromProxy(
|
|
|
|
|
proxy_to_transport_, pc_->session()->video_channel()->content_name()));
|
2015-03-12 16:35:55 +00:00
|
|
|
if (!transport_id.get()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_ERROR) << "Failed to get transport name for proxy "
|
2015-10-14 11:33:11 -07:00
|
|
|
<< pc_->session()->video_channel()->content_name();
|
2013-07-10 00:45:36 +00:00
|
|
|
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-03-12 16:35:55 +00:00
|
|
|
StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
|
|
|
|
|
StatsReport* report = reports_.FindOrAddNew(report_id);
|
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() {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-01-15 22:55:07 +00:00
|
|
|
|
2015-03-12 16:35:55 +00:00
|
|
|
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
for (const auto& dc : pc_->sctp_data_channels()) {
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport::Id id(StatsReport::NewTypedIntId(
|
2015-02-03 22:09:37 +00:00
|
|
|
StatsReport::kStatsReportTypeDataChannel, dc->id()));
|
2015-03-12 16:35:55 +00:00
|
|
|
StatsReport* report = reports_.ReplaceOrAddNew(id);
|
2015-02-03 22:09:37 +00:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2015-03-04 15:25:19 +00:00
|
|
|
report->AddString(StatsReport::kStatsValueNameLabel, dc->label());
|
|
|
|
|
report->AddInt(StatsReport::kStatsValueNameDataChannelId, dc->id());
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameProtocol, dc->protocol());
|
|
|
|
|
report->AddString(StatsReport::kStatsValueNameState,
|
|
|
|
|
DataChannelInterface::DataStateString(dc->state()));
|
2015-01-15 22:55:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2014-03-03 18:30:11 +00:00
|
|
|
// Loop through the existing local audio tracks.
|
2015-03-12 16:35:55 +00:00
|
|
|
for (const auto& it : local_audio_tracks_) {
|
|
|
|
|
AudioTrackInterface* track = it.first;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc = it.second;
|
|
|
|
|
StatsReport* report =
|
|
|
|
|
GetReport(StatsReport::kStatsReportTypeSsrc,
|
|
|
|
|
rtc::ToString<uint32_t>(ssrc), 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);
|
2015-03-12 16:35:55 +00:00
|
|
|
if (!v || v->string_val() != track->id())
|
2014-03-03 18:30:11 +00:00
|
|
|
continue;
|
|
|
|
|
|
2015-06-22 15:06:43 -07:00
|
|
|
report->set_timestamp(stats_gathering_started_);
|
2014-03-03 18:30:11 +00:00
|
|
|
UpdateReportFromAudioTrack(track, report);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
|
|
|
|
StatsReport* report) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(track != NULL);
|
2014-03-03 18:30:11 +00:00
|
|
|
|
2015-11-27 17:27:35 -08:00
|
|
|
// Don't overwrite report values if they're not available.
|
|
|
|
|
int signal_level;
|
|
|
|
|
if (track->GetSignalLevel(&signal_level)) {
|
|
|
|
|
RTC_DCHECK_GE(signal_level, 0);
|
|
|
|
|
report->AddInt(StatsReport::kStatsValueNameAudioInputLevel, signal_level);
|
|
|
|
|
}
|
2014-03-03 18:30:11 +00:00
|
|
|
|
2015-11-27 17:27:35 -08:00
|
|
|
auto audio_processor(track->GetAudioProcessor());
|
2014-03-03 18:30:11 +00:00
|
|
|
|
2015-11-27 17:27:35 -08:00
|
|
|
if (audio_processor.get()) {
|
|
|
|
|
AudioProcessorInterface::AudioProcessorStats stats;
|
2015-03-04 15:25:19 +00:00
|
|
|
audio_processor->GetStats(&stats);
|
|
|
|
|
|
2015-11-27 17:27:35 -08:00
|
|
|
SetAudioProcessingStats(
|
|
|
|
|
report, stats.typing_noise_detected, stats.echo_return_loss,
|
|
|
|
|
stats.echo_return_loss_enhancement, stats.echo_delay_median_ms,
|
|
|
|
|
stats.aec_quality_min, stats.echo_delay_std_ms);
|
|
|
|
|
}
|
2014-03-03 18:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
|
|
|
|
|
std::string* track_id,
|
2015-01-21 11:36:18 +00:00
|
|
|
StatsReport::Direction direction) {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-01-21 11:36:18 +00:00
|
|
|
if (direction == StatsReport::kSend) {
|
2015-10-14 11:33:11 -07:00
|
|
|
if (!pc_->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-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(direction == StatsReport::kReceive);
|
2015-10-14 11:33:11 -07:00
|
|
|
if (!pc_->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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-22 15:06:43 -07:00
|
|
|
void StatsCollector::UpdateTrackReports() {
|
2015-10-14 11:33:11 -07:00
|
|
|
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
2015-06-22 15:06:43 -07:00
|
|
|
|
|
|
|
|
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
|
|
|
|
|
|
|
|
|
for (const auto& entry : track_ids_) {
|
|
|
|
|
StatsReport* report = entry.second;
|
|
|
|
|
report->set_timestamp(stats_gathering_started_);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|