| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 namespace webrtc { | 55 namespace webrtc { |
| 56 | 56 |
| 57 class RtpSenderReceiverTest : public testing::Test, | 57 class RtpSenderReceiverTest : public testing::Test, |
| 58 public sigslot::has_slots<> { | 58 public sigslot::has_slots<> { |
| 59 public: | 59 public: |
| 60 RtpSenderReceiverTest() | 60 RtpSenderReceiverTest() |
| 61 : // Create fake media engine/etc. so we can create channels to use to | 61 : // Create fake media engine/etc. so we can create channels to use to |
| 62 // test RtpSenders/RtpReceivers. | 62 // test RtpSenders/RtpReceivers. |
| 63 media_engine_(new cricket::FakeMediaEngine()), | 63 media_engine_(new cricket::FakeMediaEngine()), |
| 64 channel_manager_( | 64 channel_manager_( |
| 65 std::unique_ptr<cricket::MediaEngineInterface>(media_engine_), | 65 std::unique_ptr<cricket::MediaEngineInterface>(media_engine_), |
| 66 rtc::Thread::Current(), | 66 rtc::Thread::Current(), |
| 67 rtc::Thread::Current()), | 67 rtc::Thread::Current()), |
| 68 fake_call_(Call::Config(&event_log_)), | 68 fake_call_(Call::Config(&event_log_)), |
| 69 fake_media_controller_(&channel_manager_, &fake_call_), | 69 fake_media_controller_(&channel_manager_, &fake_call_), |
| 70 stream_(MediaStream::Create(kStreamLabel1)) { | 70 local_stream_(MediaStream::Create(kStreamLabel1)) { |
| 71 // Create channels to be used by the RtpSenders and RtpReceivers. | 71 // Create channels to be used by the RtpSenders and RtpReceivers. |
| 72 channel_manager_.Init(); | 72 channel_manager_.Init(); |
| 73 bool srtp_required = true; | 73 bool srtp_required = true; |
| 74 cricket::DtlsTransportInternal* rtp_transport = | 74 cricket::DtlsTransportInternal* rtp_transport = |
| 75 fake_transport_controller_.CreateDtlsTransport( | 75 fake_transport_controller_.CreateDtlsTransport( |
| 76 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 76 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 77 voice_channel_ = channel_manager_.CreateVoiceChannel( | 77 voice_channel_ = channel_manager_.CreateVoiceChannel( |
| 78 &fake_media_controller_, rtp_transport, nullptr, rtc::Thread::Current(), | 78 &fake_media_controller_, rtp_transport, nullptr, rtc::Thread::Current(), |
| 79 cricket::CN_AUDIO, srtp_required, cricket::AudioOptions()); | 79 cricket::CN_AUDIO, srtp_required, cricket::AudioOptions()); |
| 80 video_channel_ = channel_manager_.CreateVideoChannel( | 80 video_channel_ = channel_manager_.CreateVideoChannel( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 params.codecs.push_back(kTelephoneEventCodec); | 119 params.codecs.push_back(kTelephoneEventCodec); |
| 120 voice_media_channel_->SetSendParameters(params); | 120 voice_media_channel_->SetSendParameters(params); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void AddVideoTrack() { AddVideoTrack(false); } | 123 void AddVideoTrack() { AddVideoTrack(false); } |
| 124 | 124 |
| 125 void AddVideoTrack(bool is_screencast) { | 125 void AddVideoTrack(bool is_screencast) { |
| 126 rtc::scoped_refptr<VideoTrackSourceInterface> source( | 126 rtc::scoped_refptr<VideoTrackSourceInterface> source( |
| 127 FakeVideoTrackSource::Create(is_screencast)); | 127 FakeVideoTrackSource::Create(is_screencast)); |
| 128 video_track_ = VideoTrack::Create(kVideoTrackId, source); | 128 video_track_ = VideoTrack::Create(kVideoTrackId, source); |
| 129 EXPECT_TRUE(stream_->AddTrack(video_track_)); | 129 EXPECT_TRUE(local_stream_->AddTrack(video_track_)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void CreateAudioRtpSender() { CreateAudioRtpSender(nullptr); } | 132 void CreateAudioRtpSender() { CreateAudioRtpSender(nullptr); } |
| 133 | 133 |
| 134 void CreateAudioRtpSender(rtc::scoped_refptr<LocalAudioSource> source) { | 134 void CreateAudioRtpSender(rtc::scoped_refptr<LocalAudioSource> source) { |
| 135 audio_track_ = AudioTrack::Create(kAudioTrackId, source); | 135 audio_track_ = AudioTrack::Create(kAudioTrackId, source); |
| 136 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 136 EXPECT_TRUE(local_stream_->AddTrack(audio_track_)); |
| 137 audio_rtp_sender_ = | 137 audio_rtp_sender_ = |
| 138 new AudioRtpSender(stream_->GetAudioTracks()[0], stream_->label(), | 138 new AudioRtpSender(local_stream_->GetAudioTracks()[0], |
| 139 voice_channel_, nullptr); | 139 local_stream_->label(), voice_channel_, nullptr); |
| 140 audio_rtp_sender_->SetSsrc(kAudioSsrc); | 140 audio_rtp_sender_->SetSsrc(kAudioSsrc); |
| 141 audio_rtp_sender_->GetOnDestroyedSignal()->connect( | 141 audio_rtp_sender_->GetOnDestroyedSignal()->connect( |
| 142 this, &RtpSenderReceiverTest::OnAudioSenderDestroyed); | 142 this, &RtpSenderReceiverTest::OnAudioSenderDestroyed); |
| 143 VerifyVoiceChannelInput(); | 143 VerifyVoiceChannelInput(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void OnAudioSenderDestroyed() { audio_sender_destroyed_signal_fired_ = true; } | 146 void OnAudioSenderDestroyed() { audio_sender_destroyed_signal_fired_ = true; } |
| 147 | 147 |
| 148 void CreateVideoRtpSender() { CreateVideoRtpSender(false); } | 148 void CreateVideoRtpSender() { CreateVideoRtpSender(false); } |
| 149 | 149 |
| 150 void CreateVideoRtpSender(bool is_screencast) { | 150 void CreateVideoRtpSender(bool is_screencast) { |
| 151 AddVideoTrack(is_screencast); | 151 AddVideoTrack(is_screencast); |
| 152 video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0], | 152 video_rtp_sender_ = |
| 153 stream_->label(), video_channel_); | 153 new VideoRtpSender(local_stream_->GetVideoTracks()[0], |
| 154 local_stream_->label(), video_channel_); |
| 154 video_rtp_sender_->SetSsrc(kVideoSsrc); | 155 video_rtp_sender_->SetSsrc(kVideoSsrc); |
| 155 VerifyVideoChannelInput(); | 156 VerifyVideoChannelInput(); |
| 156 } | 157 } |
| 157 | 158 |
| 158 void DestroyAudioRtpSender() { | 159 void DestroyAudioRtpSender() { |
| 159 audio_rtp_sender_ = nullptr; | 160 audio_rtp_sender_ = nullptr; |
| 160 VerifyVoiceChannelNoInput(); | 161 VerifyVoiceChannelNoInput(); |
| 161 } | 162 } |
| 162 | 163 |
| 163 void DestroyVideoRtpSender() { | 164 void DestroyVideoRtpSender() { |
| 164 video_rtp_sender_ = nullptr; | 165 video_rtp_sender_ = nullptr; |
| 165 VerifyVideoChannelNoInput(); | 166 VerifyVideoChannelNoInput(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void CreateAudioRtpReceiver() { | 169 void CreateAudioRtpReceiver() { |
| 169 audio_track_ = AudioTrack::Create( | 170 audio_rtp_receiver_ = |
| 170 kAudioTrackId, RemoteAudioSource::Create(kAudioSsrc, NULL)); | 171 new AudioRtpReceiver(kAudioTrackId, kAudioSsrc, voice_channel_); |
| 171 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | |
| 172 audio_rtp_receiver_ = new AudioRtpReceiver(stream_, kAudioTrackId, | |
| 173 kAudioSsrc, voice_channel_); | |
| 174 audio_track_ = audio_rtp_receiver_->audio_track(); | 172 audio_track_ = audio_rtp_receiver_->audio_track(); |
| 175 VerifyVoiceChannelOutput(); | 173 VerifyVoiceChannelOutput(); |
| 176 } | 174 } |
| 177 | 175 |
| 178 void CreateVideoRtpReceiver() { | 176 void CreateVideoRtpReceiver() { |
| 179 video_rtp_receiver_ = | 177 video_rtp_receiver_ = new VideoRtpReceiver( |
| 180 new VideoRtpReceiver(stream_, kVideoTrackId, rtc::Thread::Current(), | 178 kVideoTrackId, rtc::Thread::Current(), kVideoSsrc, video_channel_); |
| 181 kVideoSsrc, video_channel_); | |
| 182 video_track_ = video_rtp_receiver_->video_track(); | 179 video_track_ = video_rtp_receiver_->video_track(); |
| 183 VerifyVideoChannelOutput(); | 180 VerifyVideoChannelOutput(); |
| 184 } | 181 } |
| 185 | 182 |
| 186 void DestroyAudioRtpReceiver() { | 183 void DestroyAudioRtpReceiver() { |
| 187 audio_rtp_receiver_ = nullptr; | 184 audio_rtp_receiver_ = nullptr; |
| 188 VerifyVoiceChannelNoOutput(); | 185 VerifyVoiceChannelNoOutput(); |
| 189 } | 186 } |
| 190 | 187 |
| 191 void DestroyVideoRtpReceiver() { | 188 void DestroyVideoRtpReceiver() { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 cricket::FakeCall fake_call_; | 253 cricket::FakeCall fake_call_; |
| 257 cricket::FakeMediaController fake_media_controller_; | 254 cricket::FakeMediaController fake_media_controller_; |
| 258 cricket::VoiceChannel* voice_channel_; | 255 cricket::VoiceChannel* voice_channel_; |
| 259 cricket::VideoChannel* video_channel_; | 256 cricket::VideoChannel* video_channel_; |
| 260 cricket::FakeVoiceMediaChannel* voice_media_channel_; | 257 cricket::FakeVoiceMediaChannel* voice_media_channel_; |
| 261 cricket::FakeVideoMediaChannel* video_media_channel_; | 258 cricket::FakeVideoMediaChannel* video_media_channel_; |
| 262 rtc::scoped_refptr<AudioRtpSender> audio_rtp_sender_; | 259 rtc::scoped_refptr<AudioRtpSender> audio_rtp_sender_; |
| 263 rtc::scoped_refptr<VideoRtpSender> video_rtp_sender_; | 260 rtc::scoped_refptr<VideoRtpSender> video_rtp_sender_; |
| 264 rtc::scoped_refptr<AudioRtpReceiver> audio_rtp_receiver_; | 261 rtc::scoped_refptr<AudioRtpReceiver> audio_rtp_receiver_; |
| 265 rtc::scoped_refptr<VideoRtpReceiver> video_rtp_receiver_; | 262 rtc::scoped_refptr<VideoRtpReceiver> video_rtp_receiver_; |
| 266 rtc::scoped_refptr<MediaStreamInterface> stream_; | 263 rtc::scoped_refptr<MediaStreamInterface> local_stream_; |
| 267 rtc::scoped_refptr<VideoTrackInterface> video_track_; | 264 rtc::scoped_refptr<VideoTrackInterface> video_track_; |
| 268 rtc::scoped_refptr<AudioTrackInterface> audio_track_; | 265 rtc::scoped_refptr<AudioTrackInterface> audio_track_; |
| 269 bool audio_sender_destroyed_signal_fired_ = false; | 266 bool audio_sender_destroyed_signal_fired_ = false; |
| 270 }; | 267 }; |
| 271 | 268 |
| 272 // Test that |voice_channel_| is updated when an audio track is associated | 269 // Test that |voice_channel_| is updated when an audio track is associated |
| 273 // and disassociated with an AudioRtpSender. | 270 // and disassociated with an AudioRtpSender. |
| 274 TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpSender) { | 271 TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpSender) { |
| 275 CreateAudioRtpSender(); | 272 CreateAudioRtpSender(); |
| 276 DestroyAudioRtpSender(); | 273 DestroyAudioRtpSender(); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 } | 707 } |
| 711 | 708 |
| 712 // Test that makes sure any content hints that are set on a track before | 709 // Test that makes sure any content hints that are set on a track before |
| 713 // VideoRtpSender is ready to send are still applied when it gets ready to send. | 710 // VideoRtpSender is ready to send are still applied when it gets ready to send. |
| 714 TEST_F(RtpSenderReceiverTest, | 711 TEST_F(RtpSenderReceiverTest, |
| 715 PropagatesVideoTrackContentHintSetBeforeEnabling) { | 712 PropagatesVideoTrackContentHintSetBeforeEnabling) { |
| 716 AddVideoTrack(); | 713 AddVideoTrack(); |
| 717 // Setting detailed overrides the default non-screencast mode. This should be | 714 // Setting detailed overrides the default non-screencast mode. This should be |
| 718 // applied even if the track is set on construction. | 715 // applied even if the track is set on construction. |
| 719 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed); | 716 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed); |
| 720 video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0], | 717 video_rtp_sender_ = |
| 721 stream_->label(), video_channel_); | 718 new VideoRtpSender(local_stream_->GetVideoTracks()[0], |
| 719 local_stream_->label(), video_channel_); |
| 722 video_track_->set_enabled(true); | 720 video_track_->set_enabled(true); |
| 723 | 721 |
| 724 // Sender is not ready to send (no SSRC) so no option should have been set. | 722 // Sender is not ready to send (no SSRC) so no option should have been set. |
| 725 EXPECT_EQ(rtc::Optional<bool>(), | 723 EXPECT_EQ(rtc::Optional<bool>(), |
| 726 video_media_channel_->options().is_screencast); | 724 video_media_channel_->options().is_screencast); |
| 727 | 725 |
| 728 // Verify that the content hint is accounted for when video_rtp_sender_ does | 726 // Verify that the content hint is accounted for when video_rtp_sender_ does |
| 729 // get enabled. | 727 // get enabled. |
| 730 video_rtp_sender_->SetSsrc(kVideoSsrc); | 728 video_rtp_sender_->SetSsrc(kVideoSsrc); |
| 731 EXPECT_EQ(rtc::Optional<bool>(true), | 729 EXPECT_EQ(rtc::Optional<bool>(true), |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 // Make sure the signal from "GetOnDestroyedSignal()" fires when the sender is | 794 // Make sure the signal from "GetOnDestroyedSignal()" fires when the sender is |
| 797 // destroyed, which is needed for the DTMF sender. | 795 // destroyed, which is needed for the DTMF sender. |
| 798 TEST_F(RtpSenderReceiverTest, TestOnDestroyedSignal) { | 796 TEST_F(RtpSenderReceiverTest, TestOnDestroyedSignal) { |
| 799 CreateAudioRtpSender(); | 797 CreateAudioRtpSender(); |
| 800 EXPECT_FALSE(audio_sender_destroyed_signal_fired_); | 798 EXPECT_FALSE(audio_sender_destroyed_signal_fired_); |
| 801 audio_rtp_sender_ = nullptr; | 799 audio_rtp_sender_ = nullptr; |
| 802 EXPECT_TRUE(audio_sender_destroyed_signal_fired_); | 800 EXPECT_TRUE(audio_sender_destroyed_signal_fired_); |
| 803 } | 801 } |
| 804 | 802 |
| 805 } // namespace webrtc | 803 } // namespace webrtc |
| OLD | NEW |