Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: webrtc/api/rtcstatscollector_unittest.cc

Issue 2605033002: RTCMediaStreamTrackStats.ssrcIds collected by RTCStatsCollector. (Closed)
Patch Set: Rebase with master (reupload from other machine to create dependent patchset) Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/api/rtcstatscollector_unittest.cc
diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/api/rtcstatscollector_unittest.cc
index 89161363a258668fd6fec90332f16b7b8a92579b..bbcb2bed162247e1174b99e65b0ca685892877b6 100644
--- a/webrtc/api/rtcstatscollector_unittest.cc
+++ b/webrtc/api/rtcstatscollector_unittest.cc
@@ -19,8 +19,11 @@
#include "webrtc/api/mediastream.h"
#include "webrtc/api/mediastreamtrack.h"
#include "webrtc/api/rtpparameters.h"
+#include "webrtc/api/rtpreceiverinterface.h"
+#include "webrtc/api/rtpsenderinterface.h"
#include "webrtc/api/stats/rtcstats_objects.h"
#include "webrtc/api/stats/rtcstatsreport.h"
+#include "webrtc/api/test/fakertpsenderreceiver.h"
#include "webrtc/api/test/mock_datachannel.h"
#include "webrtc/api/test/mock_peerconnection.h"
#include "webrtc/api/test/mock_webrtcsession.h"
@@ -309,6 +312,10 @@ class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver {
EXPECT_CALL(pc_, local_streams()).WillRepeatedly(Return(nullptr));
EXPECT_CALL(pc_, remote_streams()).WillRepeatedly(Return(nullptr));
EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_));
+ EXPECT_CALL(pc_, GetSenders()).WillRepeatedly(Return(
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>>()));
+ EXPECT_CALL(pc_, GetReceivers()).WillRepeatedly(Return(
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>>()));
EXPECT_CALL(pc_, sctp_data_channels()).WillRepeatedly(
ReturnRef(data_channels_));
EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
@@ -1240,6 +1247,61 @@ TEST_F(RTCStatsCollectorTest,
new FakeAudioProcessorForStats(remote_audio_processor_stats));
remote_stream->AddTrack(remote_audio_track);
+ // RTP sender/receivers for local/remote track to wire up SSRCs.
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders;
+ rtc::scoped_refptr<FakeRtpSender> rtp_sender =
+ new FakeRtpSender(cricket::MEDIA_TYPE_AUDIO,
+ CreateRtpParametersWithSsrc(1));
+ rtp_sender->SetTrack(local_audio_track);
+ rtp_senders.push_back(rtp_sender);
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>> rtp_receivers;
+ rtc::scoped_refptr<FakeRtpReceiver> rtp_receiver =
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_AUDIO,
+ CreateRtpParametersWithSsrc(4));
Taylor Brandstetter 2017/01/04 00:36:56 May be overkill, but you could also test what happ
+ rtp_receiver->SetTrack(remote_audio_track);
+ rtp_receivers.push_back(rtp_receiver);
+ EXPECT_CALL(test_->pc(), GetSenders()).WillRepeatedly(
+ Return(rtp_senders));
+ EXPECT_CALL(test_->pc(), GetReceivers()).WillRepeatedly(
+ Return(rtp_receivers));
+
+ // |VoiceMediaInfo| for the above referenced SSRCs
+ MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel();
+ cricket::VoiceChannel voice_channel(
+ test_->worker_thread(), test_->network_thread(), test_->media_engine(),
+ voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled,
+ kDefaultSrtpRequired);
+ cricket::VoiceMediaInfo voice_media_info;
+ voice_media_info.senders.push_back(cricket::VoiceSenderInfo());
+ voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo());
+ voice_media_info.senders[0].local_stats[0].ssrc = 101010; // noise
+ voice_media_info.senders.push_back(cricket::VoiceSenderInfo());
+ voice_media_info.senders[1].local_stats.push_back(cricket::SsrcSenderInfo());
+ voice_media_info.senders[1].local_stats[0].ssrc = 1;
+ voice_media_info.senders[1].local_stats.push_back(cricket::SsrcSenderInfo());
+ voice_media_info.senders[1].local_stats[1].ssrc = 2;
+ voice_media_info.senders[1].local_stats.push_back(cricket::SsrcSenderInfo());
+ voice_media_info.senders[1].local_stats[2].ssrc = 3;
+ voice_media_info.senders.push_back(cricket::VoiceSenderInfo());
+ voice_media_info.senders[2].local_stats.push_back(cricket::SsrcSenderInfo());
+ voice_media_info.senders[2].local_stats[0].ssrc = 202020; // noise
+ voice_media_info.receivers.push_back(cricket::VoiceReceiverInfo());
+ voice_media_info.receivers[0].local_stats.push_back(
+ cricket::SsrcReceiverInfo());
+ voice_media_info.receivers[0].local_stats[0].ssrc = 4;
+ EXPECT_CALL(*voice_media_channel, GetStats(_))
+ .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true)));
+ SessionStats session_stats;
+ session_stats.proxy_to_transport["VoiceContentName"] = "TransportName";
+ session_stats.transport_stats["TransportName"].transport_name =
+ "TransportName";
+ EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
+ }));
+ EXPECT_CALL(test_->session(), voice_channel())
+ .WillRepeatedly(Return(&voice_channel));
+
rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
RTCMediaStreamStats expected_local_stream(
@@ -1247,7 +1309,7 @@ TEST_F(RTCStatsCollectorTest,
expected_local_stream.stream_identifier = local_stream->label();
expected_local_stream.track_ids = std::vector<std::string>();
expected_local_stream.track_ids->push_back(
- "RTCMediaStreamTrack_LocalAudioTrackID");
+ "RTCMediaStreamTrack_local_LocalAudioTrackID");
ASSERT_TRUE(report->Get(expected_local_stream.id()));
EXPECT_EQ(expected_local_stream,
report->Get(expected_local_stream.id())->cast_to<
@@ -1258,18 +1320,20 @@ TEST_F(RTCStatsCollectorTest,
expected_remote_stream.stream_identifier = remote_stream->label();
expected_remote_stream.track_ids = std::vector<std::string>();
expected_remote_stream.track_ids->push_back(
- "RTCMediaStreamTrack_RemoteAudioTrackID");
+ "RTCMediaStreamTrack_remote_RemoteAudioTrackID");
ASSERT_TRUE(report->Get(expected_remote_stream.id()));
EXPECT_EQ(expected_remote_stream,
report->Get(expected_remote_stream.id())->cast_to<
RTCMediaStreamStats>());
RTCMediaStreamTrackStats expected_local_audio_track(
- "RTCMediaStreamTrack_LocalAudioTrackID", report->timestamp_us());
+ "RTCMediaStreamTrack_local_LocalAudioTrackID", report->timestamp_us());
expected_local_audio_track.track_identifier = local_audio_track->id();
expected_local_audio_track.remote_source = false;
expected_local_audio_track.ended = true;
expected_local_audio_track.detached = false;
+ expected_local_audio_track.ssrc_ids =
+ std::vector<std::string>({ "1", "2", "3" });
expected_local_audio_track.audio_level = 1.0;
expected_local_audio_track.echo_return_loss = 42.0;
expected_local_audio_track.echo_return_loss_enhancement = 52.0;
@@ -1279,11 +1343,12 @@ TEST_F(RTCStatsCollectorTest,
RTCMediaStreamTrackStats>());
RTCMediaStreamTrackStats expected_remote_audio_track(
- "RTCMediaStreamTrack_RemoteAudioTrackID", report->timestamp_us());
+ "RTCMediaStreamTrack_remote_RemoteAudioTrackID", report->timestamp_us());
expected_remote_audio_track.track_identifier = remote_audio_track->id();
expected_remote_audio_track.remote_source = true;
expected_remote_audio_track.ended = false;
expected_remote_audio_track.detached = false;
+ expected_remote_audio_track.ssrc_ids = std::vector<std::string>({ "4" });
expected_remote_audio_track.audio_level = 0.0;
expected_remote_audio_track.echo_return_loss = 13.0;
expected_remote_audio_track.echo_return_loss_enhancement = 37.0;
@@ -1319,7 +1384,7 @@ TEST_F(RTCStatsCollectorTest,
rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
RTCMediaStreamTrackStats expected_local_audio_track(
- "RTCMediaStreamTrack_LocalAudioTrackID", report->timestamp_us());
+ "RTCMediaStreamTrack_local_LocalAudioTrackID", report->timestamp_us());
expected_local_audio_track.track_identifier = local_audio_track->id();
expected_local_audio_track.remote_source = false;
expected_local_audio_track.ended = true;
@@ -1377,6 +1442,53 @@ TEST_F(RTCStatsCollectorTest,
remote_video_track_source);
remote_stream->AddTrack(remote_video_track);
+ // RTP sender/receivers for local/remote track to wire up SSRCs.
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders;
+ rtc::scoped_refptr<FakeRtpSender> rtp_sender =
+ new FakeRtpSender(cricket::MEDIA_TYPE_VIDEO,
+ CreateRtpParametersWithSsrc(42));
+ rtp_sender->SetTrack(local_video_track);
+ rtp_senders.push_back(rtp_sender);
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>> rtp_receivers;
+ rtc::scoped_refptr<FakeRtpReceiver> rtp_receiver =
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_VIDEO,
+ CreateRtpParametersWithSsrc(43));
+ rtp_receiver->SetTrack(remote_video_track);
+ rtp_receivers.push_back(rtp_receiver);
+ EXPECT_CALL(test_->pc(), GetSenders()).WillRepeatedly(
+ Return(rtp_senders));
+ EXPECT_CALL(test_->pc(), GetReceivers()).WillRepeatedly(
+ Return(rtp_receivers));
+
+ // |VideoMediaInfo| for the above referenced SSRCs
+ MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel();
+ cricket::VideoChannel video_channel(
+ test_->worker_thread(), test_->network_thread(), video_media_channel,
+ nullptr, "VideoContentName", kDefaultRtcpEnabled, kDefaultSrtpRequired);
+ cricket::VideoMediaInfo video_media_info;
+ video_media_info.senders.push_back(cricket::VideoSenderInfo());
+ video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo());
+ video_media_info.senders[0].local_stats[0].ssrc = 42;
+ video_media_info.receivers.push_back(cricket::VideoReceiverInfo());
+ video_media_info.receivers[0].local_stats.push_back(
+ cricket::SsrcReceiverInfo());
+ video_media_info.receivers[0].local_stats[0].ssrc = 43;
+ video_media_info.receivers[0].local_stats.push_back(
+ cricket::SsrcReceiverInfo());
+ video_media_info.receivers[0].local_stats[1].ssrc = 44;
+ EXPECT_CALL(*video_media_channel, GetStats(_))
+ .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true)));
+ SessionStats session_stats;
+ session_stats.proxy_to_transport["VideoContentName"] = "TransportName";
+ session_stats.transport_stats["TransportName"].transport_name =
+ "TransportName";
+ EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
+ }));
+ EXPECT_CALL(test_->session(), video_channel())
+ .WillRepeatedly(Return(&video_channel));
+
rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
RTCMediaStreamStats expected_local_stream(
@@ -1384,7 +1496,7 @@ TEST_F(RTCStatsCollectorTest,
expected_local_stream.stream_identifier = local_stream->label();
expected_local_stream.track_ids = std::vector<std::string>();
expected_local_stream.track_ids->push_back(
- "RTCMediaStreamTrack_LocalVideoTrackID");
+ "RTCMediaStreamTrack_local_LocalVideoTrackID");
ASSERT_TRUE(report->Get(expected_local_stream.id()));
EXPECT_EQ(expected_local_stream,
report->Get(expected_local_stream.id())->cast_to<
@@ -1395,18 +1507,19 @@ TEST_F(RTCStatsCollectorTest,
expected_remote_stream.stream_identifier = remote_stream->label();
expected_remote_stream.track_ids = std::vector<std::string>();
expected_remote_stream.track_ids->push_back(
- "RTCMediaStreamTrack_RemoteVideoTrackID");
+ "RTCMediaStreamTrack_remote_RemoteVideoTrackID");
ASSERT_TRUE(report->Get(expected_remote_stream.id()));
EXPECT_EQ(expected_remote_stream,
report->Get(expected_remote_stream.id())->cast_to<
RTCMediaStreamStats>());
RTCMediaStreamTrackStats expected_local_video_track(
- "RTCMediaStreamTrack_LocalVideoTrackID", report->timestamp_us());
+ "RTCMediaStreamTrack_local_LocalVideoTrackID", report->timestamp_us());
expected_local_video_track.track_identifier = local_video_track->id();
expected_local_video_track.remote_source = false;
expected_local_video_track.ended = false;
expected_local_video_track.detached = false;
+ expected_local_video_track.ssrc_ids = std::vector<std::string>({ "42" });
expected_local_video_track.frame_width = 1234;
expected_local_video_track.frame_height = 4321;
ASSERT_TRUE(report->Get(expected_local_video_track.id()));
@@ -1415,11 +1528,13 @@ TEST_F(RTCStatsCollectorTest,
RTCMediaStreamTrackStats>());
RTCMediaStreamTrackStats expected_remote_video_track(
- "RTCMediaStreamTrack_RemoteVideoTrackID", report->timestamp_us());
+ "RTCMediaStreamTrack_remote_RemoteVideoTrackID", report->timestamp_us());
expected_remote_video_track.track_identifier = remote_video_track->id();
expected_remote_video_track.remote_source = true;
expected_remote_video_track.ended = true;
expected_remote_video_track.detached = false;
+ expected_remote_video_track.ssrc_ids =
+ std::vector<std::string>({ "43", "44" });
expected_remote_video_track.frame_width = 1234;
expected_remote_video_track.frame_height = 4321;
ASSERT_TRUE(report->Get(expected_remote_video_track.id()));

Powered by Google App Engine
This is Rietveld 408576698