#include "pc/legacy_stats_collector.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <cmath>
#include <list>
#include <set>
#include <utility>
#include <vector>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/audio/audio_processing_statistics.h"
#include "api/audio_codecs/audio_encoder.h"
#include "api/candidate.h"
#include "api/data_channel_interface.h"
#include "api/field_trials_view.h"
#include "api/media_types.h"
#include "api/rtp_sender_interface.h"
#include "api/scoped_refptr.h"
#include "api/sequence_checker.h"
#include "api/video/video_content_type.h"
#include "api/video/video_timing.h"
#include "call/call.h"
#include "media/base/media_channel.h"
#include "p2p/base/ice_transport_internal.h"
#include "p2p/base/p2p_constants.h"
#include "pc/channel.h"
#include "pc/channel_interface.h"
#include "pc/data_channel_utils.h"
#include "pc/rtp_receiver.h"
#include "pc/rtp_receiver_proxy.h"
#include "pc/rtp_sender_proxy.h"
#include "pc/rtp_transceiver.h"
#include "pc/transport_stats.h"
#include "rtc_base/checks.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
#include "rtc_base/trace_event.h"
namespace webrtc {
namespace {
constexpr char kUseStandardBytesStats[] = …;
const char STATSREPORT_LOCAL_PORT_TYPE[] = …;
const char STATSREPORT_STUN_PORT_TYPE[] = …;
const char STATSREPORT_PRFLX_PORT_TYPE[] = …;
const char STATSREPORT_RELAY_PORT_TYPE[] = …;
const char* STATSREPORT_ADAPTER_TYPE_ETHERNET = …;
const char* STATSREPORT_ADAPTER_TYPE_WIFI = …;
const char* STATSREPORT_ADAPTER_TYPE_WWAN = …;
const char* STATSREPORT_ADAPTER_TYPE_VPN = …;
const char* STATSREPORT_ADAPTER_TYPE_LOOPBACK = …;
const char* STATSREPORT_ADAPTER_TYPE_WILDCARD = …;
template <typename ValueType>
struct TypeForAdd { … };
BoolForAdd;
FloatForAdd;
Int64ForAdd;
IntForAdd;
StatsReport* AddTrackReport(StatsCollection* reports,
const std::string& track_id) { … }
template <class Track>
void CreateTrackReport(const Track* track,
StatsCollection* reports,
TrackIdMap* track_ids) { … }
template <class TrackVector>
void CreateTrackReports(const TrackVector& tracks,
StatsCollection* reports,
TrackIdMap* track_ids) { … }
void ExtractCommonSendProperties(const cricket::MediaSenderInfo& info,
StatsReport* report,
bool use_standard_bytes_stats) { … }
void ExtractCommonReceiveProperties(const cricket::MediaReceiverInfo& info,
StatsReport* report) { … }
void SetAudioProcessingStats(StatsReport* report,
const AudioProcessingStats& apm_stats) { … }
void ExtractStats(const cricket::VoiceReceiverInfo& info,
StatsReport* report,
bool use_standard_bytes_stats) { … }
void ExtractStats(const cricket::VoiceSenderInfo& info,
StatsReport* report,
bool use_standard_bytes_stats) { … }
void ExtractStats(const cricket::VideoReceiverInfo& info,
StatsReport* report,
bool use_standard_bytes_stats) { … }
void ExtractStats(const cricket::VideoSenderInfo& info,
StatsReport* report,
bool use_standard_bytes_stats) { … }
void ExtractStats(const cricket::BandwidthEstimationInfo& info,
double stats_gathering_started,
StatsReport* report) { … }
void ExtractRemoteStats(const cricket::MediaSenderInfo& info,
StatsReport* report) { … }
void ExtractRemoteStats(const cricket::MediaReceiverInfo& info,
StatsReport* report) { … }
std::string GetTrackIdBySsrc(
uint32_t ssrc,
StatsReport::Direction direction,
const std::map<uint32_t, std::string>& track_id_by_ssrc) { … }
template <typename T>
void ExtractStatsFromList(
const std::vector<T>& data,
const StatsReport::Id& transport_id,
LegacyStatsCollector* collector,
StatsReport::Direction direction,
const std::map<uint32_t, std::string>& track_id_by_ssrc) { … }
}
const char* IceCandidateTypeToStatsType(const cricket::Candidate& candidate) { … }
std::string GetLegacyCandidateTypeName(const cricket::Candidate& c) { … }
const char* AdapterTypeToStatsType(rtc::AdapterType type) { … }
LegacyStatsCollector::LegacyStatsCollector(PeerConnectionInternal* pc)
: … { … }
LegacyStatsCollector::~LegacyStatsCollector() { … }
double LegacyStatsCollector::GetTimeNow() { … }
void LegacyStatsCollector::AddStream(MediaStreamInterface* stream) { … }
void LegacyStatsCollector::AddTrack(MediaStreamTrackInterface* track) { … }
void LegacyStatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) { … }
void LegacyStatsCollector::RemoveLocalAudioTrack(
AudioTrackInterface* audio_track,
uint32_t ssrc) { … }
void LegacyStatsCollector::GetStats(MediaStreamTrackInterface* track,
StatsReports* reports) { … }
void LegacyStatsCollector::UpdateStats(
PeerConnectionInterface::StatsOutputLevel level) { … }
StatsReport* LegacyStatsCollector::PrepareReport(
bool local,
uint32_t ssrc,
const std::string& track_id,
const StatsReport::Id& transport_id,
StatsReport::Direction direction) { … }
StatsReport* LegacyStatsCollector::PrepareADMReport() { … }
bool LegacyStatsCollector::IsValidTrack(const std::string& track_id) { … }
StatsReport* LegacyStatsCollector::AddCertificateReports(
std::unique_ptr<rtc::SSLCertificateStats> cert_stats) { … }
StatsReport* LegacyStatsCollector::AddConnectionInfoReport(
const std::string& content_name,
int component,
int connection_id,
const StatsReport::Id& channel_report_id,
const cricket::ConnectionInfo& info) { … }
StatsReport* LegacyStatsCollector::AddCandidateReport(
const cricket::CandidateStats& candidate_stats,
bool local) { … }
std::map<std::string, std::string>
LegacyStatsCollector::ExtractSessionAndDataInfo() { … }
LegacyStatsCollector::SessionStats LegacyStatsCollector::ExtractSessionInfo_n(
const std::vector<rtc::scoped_refptr<
RtpTransceiverProxyWithInternal<RtpTransceiver>>>& transceivers,
absl::optional<std::string> sctp_transport_name,
absl::optional<std::string> sctp_mid) { … }
void LegacyStatsCollector::ExtractSessionInfo_s(SessionStats& session_stats) { … }
void LegacyStatsCollector::ExtractBweInfo() { … }
namespace {
class ChannelStatsGatherer { … };
class VoiceChannelStatsGatherer final : public ChannelStatsGatherer { … };
class VideoChannelStatsGatherer final : public ChannelStatsGatherer { … };
std::unique_ptr<ChannelStatsGatherer> CreateChannelStatsGatherer(
cricket::ChannelInterface* channel) { … }
}
void LegacyStatsCollector::ExtractMediaInfo(
const std::map<std::string, std::string>& transport_names_by_mid) { … }
void LegacyStatsCollector::ExtractSenderInfo() { … }
void LegacyStatsCollector::ExtractDataInfo_n(StatsCollection* reports) { … }
StatsReport* LegacyStatsCollector::GetReport(const StatsReport::StatsType& type,
const std::string& id,
StatsReport::Direction direction) { … }
void LegacyStatsCollector::UpdateStatsFromExistingLocalAudioTracks(
bool has_remote_tracks) { … }
void LegacyStatsCollector::UpdateReportFromAudioTrack(
AudioTrackInterface* track,
StatsReport* report,
bool has_remote_tracks) { … }
void LegacyStatsCollector::UpdateTrackReports() { … }
void LegacyStatsCollector::InvalidateCache() { … }
}