Index: webrtc/api/trackmediainfomap_unittest.cc |
diff --git a/webrtc/api/trackmediainfomap_unittest.cc b/webrtc/api/trackmediainfomap_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6d0b095b0c4d4d0313a4edab6f261f970b89e6e6 |
--- /dev/null |
+++ b/webrtc/api/trackmediainfomap_unittest.cc |
@@ -0,0 +1,538 @@ |
+/* |
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
+ * |
+ * 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. |
+ */ |
+ |
+#include "webrtc/api/trackmediainfomap.h" |
+ |
+#include <initializer_list> |
+#include <memory> |
+#include <utility> |
+#include <vector> |
+ |
+#include "webrtc/api/audiotrack.h" |
+#include "webrtc/api/rtpreceiverinterface.h" |
+#include "webrtc/api/rtpsenderinterface.h" |
+#include "webrtc/api/test/fakertpsenderreceiver.h" |
+#include "webrtc/api/test/fakevideotracksource.h" |
+#include "webrtc/api/videotrack.h" |
+#include "webrtc/base/refcount.h" |
+#include "webrtc/media/base/mediachannel.h" |
+#include "webrtc/test/gtest.h" |
+ |
+namespace webrtc { |
+ |
+namespace { |
+ |
+RtpParameters CreateRtpParametersWithSsrcs( |
+ std::initializer_list<uint32_t> ssrcs) { |
+ RtpParameters params; |
+ for (uint32_t ssrc : ssrcs) { |
+ RtpEncodingParameters encoding_params; |
+ encoding_params.ssrc = rtc::Optional<uint32_t>(ssrc); |
+ params.encodings.push_back(encoding_params); |
+ } |
+ return params; |
+} |
+ |
+TrackMediaInfoMap CreateAndInitializeMap( |
+ std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info, |
+ std::unique_ptr<cricket::VideoMediaInfo> video_media_info, |
+ const std::vector<rtc::scoped_refptr<RtpSenderInterface>>& rtp_senders, |
+ const std::vector<rtc::scoped_refptr<RtpReceiverInterface>>& |
+ rtp_receivers) { |
+ TrackMediaInfoMap map(std::move(voice_media_info), |
+ std::move(video_media_info)); |
+ map.Initialize(rtp_senders, rtp_receivers); |
+ return map; |
+} |
+ |
+} // namespace |
+ |
+TEST(TrackMediaInfoMapTest, SingleSenderAndReceiverWithOneSsrc) { |
+ cricket::VoiceMediaInfo* voice_media_info = new cricket::VoiceMediaInfo(); |
+ cricket::VideoMediaInfo* video_media_info = new cricket::VideoMediaInfo(); |
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders; |
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>> rtp_receivers; |
+ |
+ // Local audio track and sender info using an RTP sender with SSRC 1. |
+ rtc::scoped_refptr<AudioTrack> local_audio_track = |
+ AudioTrack::Create("LocalAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> audio_sender = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({1})); |
+ audio_sender->SetTrack(local_audio_track); |
+ rtp_senders.push_back(audio_sender); |
+ |
+ 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 = 1; |
+ |
+ // Remote audio track and receiver info using an RTP sender with SSRC 2. |
+ rtc::scoped_refptr<AudioTrack> remote_audio_track = |
+ AudioTrack::Create("RemoteAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> audio_receiver = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({2})); |
+ audio_receiver->SetTrack(remote_audio_track); |
+ rtp_receivers.push_back(audio_receiver); |
+ |
+ 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 = 2; |
+ |
+ // Local video track and sender info using an RTP sender with SSRC 3. |
+ rtc::scoped_refptr<VideoTrack> local_video_track = |
+ VideoTrack::Create("LocalVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> video_sender = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({3})); |
+ video_sender->SetTrack(local_video_track); |
+ rtp_senders.push_back(video_sender); |
+ |
+ 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 = 3; |
+ |
+ // Remote video track and receiver info using an RTP sender with SSRC 4. |
+ rtc::scoped_refptr<VideoTrack> remote_video_track = |
+ VideoTrack::Create("RemoteVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> video_receiver = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({4})); |
+ video_receiver->SetTrack(remote_video_track); |
+ rtp_receivers.push_back(video_receiver); |
+ |
+ 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 = 4; |
+ |
+ TrackMediaInfoMap map = CreateAndInitializeMap( |
+ std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info), |
+ std::unique_ptr<cricket::VideoMediaInfo>(video_media_info), |
+ rtp_senders, |
+ rtp_receivers); |
+ |
+ // Local audio track <-> RTP audio sender |
+ ASSERT_TRUE(map.GetVoiceSenderInfos(*local_audio_track)); |
+ EXPECT_EQ(*map.GetVoiceSenderInfos(*local_audio_track), |
+ std::vector<cricket::VoiceSenderInfo*>({ |
+ &voice_media_info->senders[0] })); |
+ EXPECT_EQ(map.GetAudioTrack(voice_media_info->senders[0]), |
+ local_audio_track.get()); |
+ |
+ // Remote audio track <-> RTP audio receiver |
+ EXPECT_EQ(map.GetVoiceReceiverInfo(*remote_audio_track), |
+ &voice_media_info->receivers[0]); |
+ EXPECT_EQ(map.GetAudioTrack(voice_media_info->receivers[0]), |
+ remote_audio_track.get()); |
+ |
+ // Local video track <-> RTP video sender |
+ ASSERT_TRUE(map.GetVideoSenderInfos(*local_video_track)); |
+ EXPECT_EQ(*map.GetVideoSenderInfos(*local_video_track), |
+ std::vector<cricket::VideoSenderInfo*>({ |
+ &video_media_info->senders[0] })); |
+ EXPECT_EQ(map.GetVideoTrack(video_media_info->senders[0]), |
+ local_video_track.get()); |
+ |
+ // Remote video track <-> RTP video receiver |
+ EXPECT_EQ(map.GetVideoReceiverInfo(*remote_video_track), |
+ &video_media_info->receivers[0]); |
+ EXPECT_EQ(map.GetVideoTrack(video_media_info->receivers[0]), |
+ remote_video_track.get()); |
+} |
+ |
+TEST(TrackMediaInfoMapTest, SingleSenderWithMissingSsrc) { |
+ cricket::VoiceMediaInfo* voice_media_info = new cricket::VoiceMediaInfo(); |
+ cricket::VideoMediaInfo* video_media_info = new cricket::VideoMediaInfo(); |
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders; |
+ |
+ // Local audio track and sender info using an RTP sender without an SSRC. |
+ rtc::scoped_refptr<AudioTrack> local_audio_track = |
+ AudioTrack::Create("LocalAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> audio_sender = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({})); |
+ audio_sender->SetTrack(local_audio_track); |
+ rtp_senders.push_back(audio_sender); |
+ |
+ // Local video track and sender info using an RTP sender without an SSRC. |
+ rtc::scoped_refptr<VideoTrack> local_video_track = |
+ VideoTrack::Create("LocalVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> video_sender = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({})); |
+ video_sender->SetTrack(local_video_track); |
+ rtp_senders.push_back(video_sender); |
+ |
+ TrackMediaInfoMap map = CreateAndInitializeMap( |
+ std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info), |
+ std::unique_ptr<cricket::VideoMediaInfo>(video_media_info), |
+ rtp_senders, |
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>>()); |
+ |
+ EXPECT_FALSE(map.GetVoiceSenderInfos(*local_audio_track)); |
+ EXPECT_FALSE(map.GetVideoSenderInfos(*local_video_track)); |
+} |
+ |
+TEST(TrackMediaInfoMapTest, SingleSenderWithMultipleSsrcs) { |
+ cricket::VoiceMediaInfo* voice_media_info = new cricket::VoiceMediaInfo(); |
+ cricket::VideoMediaInfo* video_media_info = new cricket::VideoMediaInfo(); |
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders; |
+ |
+ // Local audio track and sender infos using RTP sender with SSRCs 1 and 2. |
+ rtc::scoped_refptr<AudioTrack> local_audio_track = |
+ AudioTrack::Create("LocalAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> audio_sender = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({1, 2})); |
+ audio_sender->SetTrack(local_audio_track); |
+ rtp_senders.push_back(audio_sender); |
+ |
+ 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 = 1; |
+ 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 = 2; |
+ |
+ // Local video track and sender infos using RTP sender with SSRCs 3 and 4. |
+ rtc::scoped_refptr<VideoTrack> local_video_track = |
+ VideoTrack::Create("LocalVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> video_sender = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({3, 4})); |
+ video_sender->SetTrack(local_video_track); |
+ rtp_senders.push_back(video_sender); |
+ |
+ video_media_info->senders.push_back(cricket::VideoSenderInfo()); |
hta-webrtc
2017/01/05 09:46:56
There's a ton of repeated code here.
Can you make
hbos
2017/01/05 15:27:56
Done.
|
+ video_media_info->senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
+ video_media_info->senders[0].local_stats[0].ssrc = 3; |
+ video_media_info->senders.push_back(cricket::VideoSenderInfo()); |
+ video_media_info->senders[1].local_stats.push_back(cricket::SsrcSenderInfo()); |
+ video_media_info->senders[1].local_stats[0].ssrc = 4; |
+ |
+ TrackMediaInfoMap map = CreateAndInitializeMap( |
+ std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info), |
+ std::unique_ptr<cricket::VideoMediaInfo>(video_media_info), |
+ rtp_senders, |
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>>()); |
+ |
+ // Local audio track <-> RTP audio senders |
+ ASSERT_TRUE(map.GetVoiceSenderInfos(*local_audio_track)); |
+ EXPECT_EQ(*map.GetVoiceSenderInfos(*local_audio_track), |
+ std::vector<cricket::VoiceSenderInfo*>({ |
+ &voice_media_info->senders[0], |
+ &voice_media_info->senders[1] })); |
+ EXPECT_EQ(map.GetAudioTrack(voice_media_info->senders[0]), |
+ local_audio_track.get()); |
+ EXPECT_EQ(map.GetAudioTrack(voice_media_info->senders[1]), |
+ local_audio_track.get()); |
+ |
+ // Local video track <-> RTP video senders |
+ ASSERT_TRUE(map.GetVideoSenderInfos(*local_video_track)); |
+ EXPECT_EQ(*map.GetVideoSenderInfos(*local_video_track), |
+ std::vector<cricket::VideoSenderInfo*>({ |
+ &video_media_info->senders[0], |
+ &video_media_info->senders[1] })); |
+ EXPECT_EQ(map.GetVideoTrack(video_media_info->senders[0]), |
+ local_video_track.get()); |
+ EXPECT_EQ(map.GetVideoTrack(video_media_info->senders[1]), |
+ local_video_track.get()); |
+} |
+ |
+TEST(TrackMediaInfoMapTest, MultipleSendersWithOneSsrc) { |
+ cricket::VoiceMediaInfo* voice_media_info = new cricket::VoiceMediaInfo(); |
+ cricket::VideoMediaInfo* video_media_info = new cricket::VideoMediaInfo(); |
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders; |
+ |
+ // Local audio track and sender infos using RTP senders with SSRC 1 and 2. |
+ rtc::scoped_refptr<AudioTrack> local_audio_track = |
+ AudioTrack::Create("LocalAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> audio_sender_ssrc1 = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({1})); |
+ audio_sender_ssrc1->SetTrack(local_audio_track); |
+ rtp_senders.push_back(audio_sender_ssrc1); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> audio_sender_ssrc2 = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({2})); |
+ audio_sender_ssrc2->SetTrack(local_audio_track); |
+ rtp_senders.push_back(audio_sender_ssrc2); |
+ |
+ 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 = 1; |
+ 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 = 2; |
+ |
+ // Local video track and sender infos using RTP senders with SSRC 3 and 4. |
+ rtc::scoped_refptr<VideoTrack> local_video_track = |
+ VideoTrack::Create("LocalVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> video_sender_ssrc3 = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({3})); |
+ video_sender_ssrc3->SetTrack(local_video_track); |
+ rtp_senders.push_back(video_sender_ssrc3); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> video_sender_ssrc4 = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({4})); |
+ video_sender_ssrc4->SetTrack(local_video_track); |
+ rtp_senders.push_back(video_sender_ssrc4); |
+ |
+ 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 = 3; |
+ video_media_info->senders.push_back(cricket::VideoSenderInfo()); |
+ video_media_info->senders[1].local_stats.push_back(cricket::SsrcSenderInfo()); |
+ video_media_info->senders[1].local_stats[0].ssrc = 4; |
+ |
+ TrackMediaInfoMap map = CreateAndInitializeMap( |
+ std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info), |
+ std::unique_ptr<cricket::VideoMediaInfo>(video_media_info), |
+ rtp_senders, |
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>>()); |
+ |
+ // Local audio track <-> RTP audio senders |
+ ASSERT_TRUE(map.GetVoiceSenderInfos(*local_audio_track)); |
+ EXPECT_EQ(*map.GetVoiceSenderInfos(*local_audio_track), |
+ std::vector<cricket::VoiceSenderInfo*>({ |
+ &voice_media_info->senders[0], |
+ &voice_media_info->senders[1] })); |
+ EXPECT_EQ(map.GetAudioTrack(voice_media_info->senders[0]), |
+ local_audio_track.get()); |
+ EXPECT_EQ(map.GetAudioTrack(voice_media_info->senders[1]), |
+ local_audio_track.get()); |
+ |
+ // Local video track <-> RTP video senders |
+ ASSERT_TRUE(map.GetVideoSenderInfos(*local_video_track)); |
+ EXPECT_EQ(*map.GetVideoSenderInfos(*local_video_track), |
+ std::vector<cricket::VideoSenderInfo*>({ |
+ &video_media_info->senders[0], |
+ &video_media_info->senders[1] })); |
+ EXPECT_EQ(map.GetVideoTrack(video_media_info->senders[0]), |
+ local_video_track.get()); |
+ EXPECT_EQ(map.GetVideoTrack(video_media_info->senders[1]), |
+ local_video_track.get()); |
+} |
+ |
+// Death tests. |
+// Disabled on Android because death tests misbehave on Android, see |
+// base/test/gtest_util.h. |
+#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
+ |
+TEST(TrackMediaInfoMapDeathTest, SingleReceiverWithMultipleSsrcs) { |
+ cricket::VoiceMediaInfo* voice_media_info = new cricket::VoiceMediaInfo(); |
+ cricket::VideoMediaInfo* video_media_info = new cricket::VideoMediaInfo(); |
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>> rtp_receivers; |
+ |
+ // Remote audio track and receiver infos using RTP receiver /w SSRCs 1 and 2. |
+ rtc::scoped_refptr<AudioTrack> remote_audio_track = |
+ AudioTrack::Create("RemoteAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> audio_receiver = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({1, 2})); |
+ audio_receiver->SetTrack(remote_audio_track); |
+ rtp_receivers.push_back(audio_receiver); |
+ |
+ 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 = 1; |
+ voice_media_info->receivers.push_back(cricket::VoiceReceiverInfo()); |
+ voice_media_info->receivers[1].local_stats.push_back( |
+ cricket::SsrcReceiverInfo()); |
+ voice_media_info->receivers[1].local_stats[0].ssrc = 2; |
+ |
+ // Remote video track and receiver infos using RTP receiver /w SSRCs 3 and 4. |
+ rtc::scoped_refptr<VideoTrack> remote_video_track = |
+ VideoTrack::Create("RemoteVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> video_receiver = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({3, 4})); |
+ video_receiver->SetTrack(remote_video_track); |
+ rtp_receivers.push_back(video_receiver); |
+ |
+ 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 = 3; |
+ video_media_info->receivers.push_back(cricket::VideoReceiverInfo()); |
+ video_media_info->receivers[1].local_stats.push_back( |
+ cricket::SsrcReceiverInfo()); |
+ video_media_info->receivers[1].local_stats[0].ssrc = 4; |
+ |
+ EXPECT_DEATH(CreateAndInitializeMap( |
+ std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info), |
+ std::unique_ptr<cricket::VideoMediaInfo>(video_media_info), |
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>>(), |
+ rtp_receivers), ""); |
+} |
+ |
+TEST(TrackMediaInfoMapDeathTest, MultipleReceiversWithOneSsrc) { |
+ cricket::VoiceMediaInfo* voice_media_info = new cricket::VoiceMediaInfo(); |
+ cricket::VideoMediaInfo* video_media_info = new cricket::VideoMediaInfo(); |
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>> rtp_receivers; |
+ |
+ // Remote audio track and receiver infos using RTP receivers /w SSRC 1 and 2. |
+ rtc::scoped_refptr<AudioTrack> remote_audio_track = |
+ AudioTrack::Create("RemoteAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> audio_receiver_ssrc1 = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({1})); |
+ audio_receiver_ssrc1->SetTrack(remote_audio_track); |
+ rtp_receivers.push_back(audio_receiver_ssrc1); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> audio_receiver_ssrc2 = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({2})); |
+ audio_receiver_ssrc2->SetTrack(remote_audio_track); |
+ rtp_receivers.push_back(audio_receiver_ssrc2); |
+ |
+ 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 = 1; |
+ voice_media_info->receivers.push_back(cricket::VoiceReceiverInfo()); |
+ voice_media_info->receivers[1].local_stats.push_back( |
+ cricket::SsrcReceiverInfo()); |
+ voice_media_info->receivers[1].local_stats[0].ssrc = 2; |
+ |
+ // Remote video track and receiver infos using RTP receivers /w SSRC 3 and 4. |
+ rtc::scoped_refptr<VideoTrack> remote_video_track = |
+ VideoTrack::Create("RemoteVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> video_receiver_ssrc3 = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({3})); |
+ video_receiver_ssrc3->SetTrack(remote_video_track); |
+ rtp_receivers.push_back(video_receiver_ssrc3); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> video_receiver_ssrc4 = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({4})); |
+ video_receiver_ssrc4->SetTrack(remote_video_track); |
+ rtp_receivers.push_back(video_receiver_ssrc4); |
+ |
+ 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 = 3; |
+ video_media_info->receivers.push_back(cricket::VideoReceiverInfo()); |
+ video_media_info->receivers[1].local_stats.push_back( |
+ cricket::SsrcReceiverInfo()); |
+ video_media_info->receivers[1].local_stats[0].ssrc = 4; |
+ |
+ EXPECT_DEATH(CreateAndInitializeMap( |
+ std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info), |
+ std::unique_ptr<cricket::VideoMediaInfo>(video_media_info), |
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>>(), |
+ rtp_receivers), ""); |
+} |
+ |
+TEST(TrackMediaInfoMapDeathTest, SingleSenderAndReceiverWithSsrcNotUnique) { |
+ cricket::VoiceMediaInfo* voice_media_info = new cricket::VoiceMediaInfo(); |
+ cricket::VideoMediaInfo* video_media_info = new cricket::VideoMediaInfo(); |
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders; |
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>> rtp_receivers; |
+ |
+ // Local audio track and sender info using an RTP sender with SSRC 1. |
+ rtc::scoped_refptr<AudioTrack> local_audio_track = |
+ AudioTrack::Create("LocalAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> audio_sender = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({1})); |
+ audio_sender->SetTrack(local_audio_track); |
+ rtp_senders.push_back(audio_sender); |
+ |
+ 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 = 1; |
+ |
+ // Remote audio track and receiver info using an RTP sender with SSRC 1. |
+ rtc::scoped_refptr<AudioTrack> remote_audio_track = |
+ AudioTrack::Create("RemoteAudioTrack", nullptr); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> audio_receiver = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_AUDIO, |
+ CreateRtpParametersWithSsrcs({1})); |
+ audio_receiver->SetTrack(remote_audio_track); |
+ rtp_receivers.push_back(audio_receiver); |
+ |
+ 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 = 1; |
+ |
+ // Local video track and sender info using an RTP sender with SSRC 1. |
+ rtc::scoped_refptr<VideoTrack> local_video_track = |
+ VideoTrack::Create("LocalVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpSender> video_sender = |
+ new FakeRtpSender(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({1})); |
+ video_sender->SetTrack(local_video_track); |
+ rtp_senders.push_back(video_sender); |
+ |
+ 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 = 1; |
+ |
+ // Remote video track and receiver info using an RTP sender with SSRC 1. |
+ rtc::scoped_refptr<VideoTrack> remote_video_track = |
+ VideoTrack::Create("RemoteVideoTrack", |
+ FakeVideoTrackSource::Create(false)); |
+ |
+ rtc::scoped_refptr<FakeRtpReceiver> video_receiver = |
+ new FakeRtpReceiver(cricket::MEDIA_TYPE_VIDEO, |
+ CreateRtpParametersWithSsrcs({1})); |
+ video_receiver->SetTrack(remote_video_track); |
+ rtp_receivers.push_back(video_receiver); |
+ |
+ 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 = 1; |
+ |
+ EXPECT_DEATH(CreateAndInitializeMap( |
+ std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info), |
+ std::unique_ptr<cricket::VideoMediaInfo>(video_media_info), |
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>>(), |
+ rtp_receivers), ""); |
+} |
+ |
+#endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
+ |
+} // namespace webrtc |