Do no return media-playout stats unless there is an audio receiver
which avoids those stats on datachannel-only or video-only connections. Note that a receiver always exists, regardless of the transceiver direction. BUG=None Change-Id: I1ef33a8446fafe2978ac603e658e67d51d7af904 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/330441 Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Philipp Hancke <phancke@microsoft.com> Reviewed-by: Fredrik Hernqvist <fhernqvist@google.com> Cr-Commit-Position: refs/heads/main@{#41423}
This commit is contained in:
parent
ee27f38be9
commit
c5d921899b
@ -2124,7 +2124,9 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() {
|
||||
}
|
||||
}
|
||||
|
||||
// Create the TrackMediaInfoMap for each transceiver stats object.
|
||||
// Create the TrackMediaInfoMap for each transceiver stats object
|
||||
// and keep track of whether we have at least one audio receiver.
|
||||
bool has_audio_receiver = false;
|
||||
for (auto& stats : transceiver_stats_infos_) {
|
||||
auto transceiver = stats.transceiver;
|
||||
absl::optional<cricket::VoiceMediaInfo> voice_media_info;
|
||||
@ -2159,10 +2161,14 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() {
|
||||
stats.track_media_info_map.Initialize(std::move(voice_media_info),
|
||||
std::move(video_media_info),
|
||||
senders, receivers);
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
has_audio_receiver |= !receivers.empty();
|
||||
}
|
||||
}
|
||||
|
||||
call_stats_ = pc_->GetCallStats();
|
||||
audio_device_stats_ = pc_->GetAudioDeviceStats();
|
||||
audio_device_stats_ =
|
||||
has_audio_receiver ? pc_->GetAudioDeviceStats() : absl::nullopt;
|
||||
});
|
||||
|
||||
for (auto& stats : transceiver_stats_infos_) {
|
||||
|
||||
@ -2478,6 +2478,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCAudioPlayoutStats) {
|
||||
audio_device_stats.total_playout_delay_s = 5;
|
||||
pc_->SetAudioDeviceStats(audio_device_stats);
|
||||
|
||||
pc_->AddVoiceChannel("AudioMid", "TransportName", {});
|
||||
stats_->SetupRemoteTrackAndReceiver(
|
||||
cricket::MEDIA_TYPE_AUDIO, "RemoteAudioTrackID", "RemoteStreamId", 1);
|
||||
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
auto stats_of_track_type = report->GetStatsOfType<RTCAudioPlayoutStats>();
|
||||
ASSERT_EQ(1U, stats_of_track_type.size());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user