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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 VideoTrack::Create(kVideoTrackId, source, rtc::Thread::Current()); | 125 VideoTrack::Create(kVideoTrackId, source, rtc::Thread::Current()); |
126 EXPECT_TRUE(local_stream_->AddTrack(video_track_)); | 126 EXPECT_TRUE(local_stream_->AddTrack(video_track_)); |
127 } | 127 } |
128 | 128 |
129 void CreateAudioRtpSender() { CreateAudioRtpSender(nullptr); } | 129 void CreateAudioRtpSender() { CreateAudioRtpSender(nullptr); } |
130 | 130 |
131 void CreateAudioRtpSender(rtc::scoped_refptr<LocalAudioSource> source) { | 131 void CreateAudioRtpSender(rtc::scoped_refptr<LocalAudioSource> source) { |
132 audio_track_ = AudioTrack::Create(kAudioTrackId, source); | 132 audio_track_ = AudioTrack::Create(kAudioTrackId, source); |
133 EXPECT_TRUE(local_stream_->AddTrack(audio_track_)); | 133 EXPECT_TRUE(local_stream_->AddTrack(audio_track_)); |
134 audio_rtp_sender_ = | 134 audio_rtp_sender_ = |
135 new AudioRtpSender(local_stream_->GetAudioTracks()[0], | 135 new rtc::RefCountedObject<AudioRtpSender>( |
136 {local_stream_->label()}, voice_channel_, nullptr); | 136 local_stream_->GetAudioTracks()[0], |
137 std::vector<std::string>({local_stream_->label()}), | |
nisse-webrtc
2017/09/18 08:28:57
The compiler template magic failed without explici
kwiberg-webrtc
2017/09/18 09:13:50
Not that I know of. See e.g. https://stackoverflow
nisse-webrtc
2017/09/18 09:20:05
Hmm. From there, it looks like it might work to wr
| |
138 voice_channel_, nullptr); | |
137 audio_rtp_sender_->SetSsrc(kAudioSsrc); | 139 audio_rtp_sender_->SetSsrc(kAudioSsrc); |
138 audio_rtp_sender_->GetOnDestroyedSignal()->connect( | 140 audio_rtp_sender_->GetOnDestroyedSignal()->connect( |
139 this, &RtpSenderReceiverTest::OnAudioSenderDestroyed); | 141 this, &RtpSenderReceiverTest::OnAudioSenderDestroyed); |
140 VerifyVoiceChannelInput(); | 142 VerifyVoiceChannelInput(); |
141 } | 143 } |
142 | 144 |
143 void OnAudioSenderDestroyed() { audio_sender_destroyed_signal_fired_ = true; } | 145 void OnAudioSenderDestroyed() { audio_sender_destroyed_signal_fired_ = true; } |
144 | 146 |
145 void CreateVideoRtpSender() { CreateVideoRtpSender(false); } | 147 void CreateVideoRtpSender() { CreateVideoRtpSender(false); } |
146 | 148 |
147 void CreateVideoRtpSender(bool is_screencast) { | 149 void CreateVideoRtpSender(bool is_screencast) { |
148 AddVideoTrack(is_screencast); | 150 AddVideoTrack(is_screencast); |
149 video_rtp_sender_ = | 151 video_rtp_sender_ = |
150 new VideoRtpSender(local_stream_->GetVideoTracks()[0], | 152 new rtc::RefCountedObject<VideoRtpSender>( |
151 {local_stream_->label()}, video_channel_); | 153 local_stream_->GetVideoTracks()[0], |
154 std::vector<std::string>({local_stream_->label()}), video_channel_); | |
152 video_rtp_sender_->SetSsrc(kVideoSsrc); | 155 video_rtp_sender_->SetSsrc(kVideoSsrc); |
153 VerifyVideoChannelInput(); | 156 VerifyVideoChannelInput(); |
154 } | 157 } |
155 | 158 |
156 void DestroyAudioRtpSender() { | 159 void DestroyAudioRtpSender() { |
157 audio_rtp_sender_ = nullptr; | 160 audio_rtp_sender_ = nullptr; |
158 VerifyVoiceChannelNoInput(); | 161 VerifyVoiceChannelNoInput(); |
159 } | 162 } |
160 | 163 |
161 void DestroyVideoRtpSender() { | 164 void DestroyVideoRtpSender() { |
162 video_rtp_sender_ = nullptr; | 165 video_rtp_sender_ = nullptr; |
163 VerifyVideoChannelNoInput(); | 166 VerifyVideoChannelNoInput(); |
164 } | 167 } |
165 | 168 |
166 void CreateAudioRtpReceiver() { | 169 void CreateAudioRtpReceiver() { |
167 audio_rtp_receiver_ = | 170 audio_rtp_receiver_ = new rtc::RefCountedObject<AudioRtpReceiver>( |
168 new AudioRtpReceiver(kAudioTrackId, kAudioSsrc, voice_channel_); | 171 kAudioTrackId, kAudioSsrc, voice_channel_); |
169 audio_track_ = audio_rtp_receiver_->audio_track(); | 172 audio_track_ = audio_rtp_receiver_->audio_track(); |
170 VerifyVoiceChannelOutput(); | 173 VerifyVoiceChannelOutput(); |
171 } | 174 } |
172 | 175 |
173 void CreateVideoRtpReceiver() { | 176 void CreateVideoRtpReceiver() { |
174 video_rtp_receiver_ = new VideoRtpReceiver( | 177 video_rtp_receiver_ = new rtc::RefCountedObject<VideoRtpReceiver>( |
175 kVideoTrackId, rtc::Thread::Current(), kVideoSsrc, video_channel_); | 178 kVideoTrackId, rtc::Thread::Current(), kVideoSsrc, video_channel_); |
176 video_track_ = video_rtp_receiver_->video_track(); | 179 video_track_ = video_rtp_receiver_->video_track(); |
177 VerifyVideoChannelOutput(); | 180 VerifyVideoChannelOutput(); |
178 } | 181 } |
179 | 182 |
180 void DestroyAudioRtpReceiver() { | 183 void DestroyAudioRtpReceiver() { |
181 audio_rtp_receiver_ = nullptr; | 184 audio_rtp_receiver_ = nullptr; |
182 VerifyVoiceChannelNoOutput(); | 185 VerifyVoiceChannelNoOutput(); |
183 } | 186 } |
184 | 187 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 audio_track_->GetSource()->SetVolume(0.9); | 405 audio_track_->GetSource()->SetVolume(0.9); |
403 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume)); | 406 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume)); |
404 EXPECT_EQ(0.9, volume); | 407 EXPECT_EQ(0.9, volume); |
405 | 408 |
406 DestroyAudioRtpReceiver(); | 409 DestroyAudioRtpReceiver(); |
407 } | 410 } |
408 | 411 |
409 // Test that the media channel isn't enabled for sending if the audio sender | 412 // Test that the media channel isn't enabled for sending if the audio sender |
410 // doesn't have both a track and SSRC. | 413 // doesn't have both a track and SSRC. |
411 TEST_F(RtpSenderReceiverTest, AudioSenderWithoutTrackAndSsrc) { | 414 TEST_F(RtpSenderReceiverTest, AudioSenderWithoutTrackAndSsrc) { |
412 audio_rtp_sender_ = new AudioRtpSender(voice_channel_, nullptr); | 415 audio_rtp_sender_ = |
416 new rtc::RefCountedObject<AudioRtpSender>(voice_channel_, nullptr); | |
413 rtc::scoped_refptr<AudioTrackInterface> track = | 417 rtc::scoped_refptr<AudioTrackInterface> track = |
414 AudioTrack::Create(kAudioTrackId, nullptr); | 418 AudioTrack::Create(kAudioTrackId, nullptr); |
415 | 419 |
416 // Track but no SSRC. | 420 // Track but no SSRC. |
417 EXPECT_TRUE(audio_rtp_sender_->SetTrack(track)); | 421 EXPECT_TRUE(audio_rtp_sender_->SetTrack(track)); |
418 VerifyVoiceChannelNoInput(); | 422 VerifyVoiceChannelNoInput(); |
419 | 423 |
420 // SSRC but no track. | 424 // SSRC but no track. |
421 EXPECT_TRUE(audio_rtp_sender_->SetTrack(nullptr)); | 425 EXPECT_TRUE(audio_rtp_sender_->SetTrack(nullptr)); |
422 audio_rtp_sender_->SetSsrc(kAudioSsrc); | 426 audio_rtp_sender_->SetSsrc(kAudioSsrc); |
423 VerifyVoiceChannelNoInput(); | 427 VerifyVoiceChannelNoInput(); |
424 } | 428 } |
425 | 429 |
426 // Test that the media channel isn't enabled for sending if the video sender | 430 // Test that the media channel isn't enabled for sending if the video sender |
427 // doesn't have both a track and SSRC. | 431 // doesn't have both a track and SSRC. |
428 TEST_F(RtpSenderReceiverTest, VideoSenderWithoutTrackAndSsrc) { | 432 TEST_F(RtpSenderReceiverTest, VideoSenderWithoutTrackAndSsrc) { |
429 video_rtp_sender_ = new VideoRtpSender(video_channel_); | 433 video_rtp_sender_ = new rtc::RefCountedObject<VideoRtpSender>(video_channel_); |
430 | 434 |
431 // Track but no SSRC. | 435 // Track but no SSRC. |
432 EXPECT_TRUE(video_rtp_sender_->SetTrack(video_track_)); | 436 EXPECT_TRUE(video_rtp_sender_->SetTrack(video_track_)); |
433 VerifyVideoChannelNoInput(); | 437 VerifyVideoChannelNoInput(); |
434 | 438 |
435 // SSRC but no track. | 439 // SSRC but no track. |
436 EXPECT_TRUE(video_rtp_sender_->SetTrack(nullptr)); | 440 EXPECT_TRUE(video_rtp_sender_->SetTrack(nullptr)); |
437 video_rtp_sender_->SetSsrc(kVideoSsrc); | 441 video_rtp_sender_->SetSsrc(kVideoSsrc); |
438 VerifyVideoChannelNoInput(); | 442 VerifyVideoChannelNoInput(); |
439 } | 443 } |
440 | 444 |
441 // Test that the media channel is enabled for sending when the audio sender | 445 // Test that the media channel is enabled for sending when the audio sender |
442 // has a track and SSRC, when the SSRC is set first. | 446 // has a track and SSRC, when the SSRC is set first. |
443 TEST_F(RtpSenderReceiverTest, AudioSenderEarlyWarmupSsrcThenTrack) { | 447 TEST_F(RtpSenderReceiverTest, AudioSenderEarlyWarmupSsrcThenTrack) { |
444 audio_rtp_sender_ = new AudioRtpSender(voice_channel_, nullptr); | 448 audio_rtp_sender_ = |
449 new rtc::RefCountedObject<AudioRtpSender>(voice_channel_, nullptr); | |
445 rtc::scoped_refptr<AudioTrackInterface> track = | 450 rtc::scoped_refptr<AudioTrackInterface> track = |
446 AudioTrack::Create(kAudioTrackId, nullptr); | 451 AudioTrack::Create(kAudioTrackId, nullptr); |
447 audio_rtp_sender_->SetSsrc(kAudioSsrc); | 452 audio_rtp_sender_->SetSsrc(kAudioSsrc); |
448 audio_rtp_sender_->SetTrack(track); | 453 audio_rtp_sender_->SetTrack(track); |
449 VerifyVoiceChannelInput(); | 454 VerifyVoiceChannelInput(); |
450 | 455 |
451 DestroyAudioRtpSender(); | 456 DestroyAudioRtpSender(); |
452 } | 457 } |
453 | 458 |
454 // Test that the media channel is enabled for sending when the audio sender | 459 // Test that the media channel is enabled for sending when the audio sender |
455 // has a track and SSRC, when the SSRC is set last. | 460 // has a track and SSRC, when the SSRC is set last. |
456 TEST_F(RtpSenderReceiverTest, AudioSenderEarlyWarmupTrackThenSsrc) { | 461 TEST_F(RtpSenderReceiverTest, AudioSenderEarlyWarmupTrackThenSsrc) { |
457 audio_rtp_sender_ = new AudioRtpSender(voice_channel_, nullptr); | 462 audio_rtp_sender_ = |
463 new rtc::RefCountedObject<AudioRtpSender>(voice_channel_, nullptr); | |
458 rtc::scoped_refptr<AudioTrackInterface> track = | 464 rtc::scoped_refptr<AudioTrackInterface> track = |
459 AudioTrack::Create(kAudioTrackId, nullptr); | 465 AudioTrack::Create(kAudioTrackId, nullptr); |
460 audio_rtp_sender_->SetTrack(track); | 466 audio_rtp_sender_->SetTrack(track); |
461 audio_rtp_sender_->SetSsrc(kAudioSsrc); | 467 audio_rtp_sender_->SetSsrc(kAudioSsrc); |
462 VerifyVoiceChannelInput(); | 468 VerifyVoiceChannelInput(); |
463 | 469 |
464 DestroyAudioRtpSender(); | 470 DestroyAudioRtpSender(); |
465 } | 471 } |
466 | 472 |
467 // Test that the media channel is enabled for sending when the video sender | 473 // Test that the media channel is enabled for sending when the video sender |
468 // has a track and SSRC, when the SSRC is set first. | 474 // has a track and SSRC, when the SSRC is set first. |
469 TEST_F(RtpSenderReceiverTest, VideoSenderEarlyWarmupSsrcThenTrack) { | 475 TEST_F(RtpSenderReceiverTest, VideoSenderEarlyWarmupSsrcThenTrack) { |
470 AddVideoTrack(); | 476 AddVideoTrack(); |
471 video_rtp_sender_ = new VideoRtpSender(video_channel_); | 477 video_rtp_sender_ = new rtc::RefCountedObject<VideoRtpSender>(video_channel_); |
472 video_rtp_sender_->SetSsrc(kVideoSsrc); | 478 video_rtp_sender_->SetSsrc(kVideoSsrc); |
473 video_rtp_sender_->SetTrack(video_track_); | 479 video_rtp_sender_->SetTrack(video_track_); |
474 VerifyVideoChannelInput(); | 480 VerifyVideoChannelInput(); |
475 | 481 |
476 DestroyVideoRtpSender(); | 482 DestroyVideoRtpSender(); |
477 } | 483 } |
478 | 484 |
479 // Test that the media channel is enabled for sending when the video sender | 485 // Test that the media channel is enabled for sending when the video sender |
480 // has a track and SSRC, when the SSRC is set last. | 486 // has a track and SSRC, when the SSRC is set last. |
481 TEST_F(RtpSenderReceiverTest, VideoSenderEarlyWarmupTrackThenSsrc) { | 487 TEST_F(RtpSenderReceiverTest, VideoSenderEarlyWarmupTrackThenSsrc) { |
482 AddVideoTrack(); | 488 AddVideoTrack(); |
483 video_rtp_sender_ = new VideoRtpSender(video_channel_); | 489 video_rtp_sender_ = new rtc::RefCountedObject<VideoRtpSender>(video_channel_); |
484 video_rtp_sender_->SetTrack(video_track_); | 490 video_rtp_sender_->SetTrack(video_track_); |
485 video_rtp_sender_->SetSsrc(kVideoSsrc); | 491 video_rtp_sender_->SetSsrc(kVideoSsrc); |
486 VerifyVideoChannelInput(); | 492 VerifyVideoChannelInput(); |
487 | 493 |
488 DestroyVideoRtpSender(); | 494 DestroyVideoRtpSender(); |
489 } | 495 } |
490 | 496 |
491 // Test that the media channel stops sending when the audio sender's SSRC is set | 497 // Test that the media channel stops sending when the audio sender's SSRC is set |
492 // to 0. | 498 // to 0. |
493 TEST_F(RtpSenderReceiverTest, AudioSenderSsrcSetToZero) { | 499 TEST_F(RtpSenderReceiverTest, AudioSenderSsrcSetToZero) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 | 710 |
705 // Test that makes sure any content hints that are set on a track before | 711 // Test that makes sure any content hints that are set on a track before |
706 // VideoRtpSender is ready to send are still applied when it gets ready to send. | 712 // VideoRtpSender is ready to send are still applied when it gets ready to send. |
707 TEST_F(RtpSenderReceiverTest, | 713 TEST_F(RtpSenderReceiverTest, |
708 PropagatesVideoTrackContentHintSetBeforeEnabling) { | 714 PropagatesVideoTrackContentHintSetBeforeEnabling) { |
709 AddVideoTrack(); | 715 AddVideoTrack(); |
710 // Setting detailed overrides the default non-screencast mode. This should be | 716 // Setting detailed overrides the default non-screencast mode. This should be |
711 // applied even if the track is set on construction. | 717 // applied even if the track is set on construction. |
712 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed); | 718 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed); |
713 video_rtp_sender_ = | 719 video_rtp_sender_ = |
714 new VideoRtpSender(local_stream_->GetVideoTracks()[0], | 720 new rtc::RefCountedObject<VideoRtpSender>( |
715 {local_stream_->label()}, video_channel_); | 721 local_stream_->GetVideoTracks()[0], |
722 std::vector<std::string>({local_stream_->label()}), video_channel_); | |
716 video_track_->set_enabled(true); | 723 video_track_->set_enabled(true); |
717 | 724 |
718 // Sender is not ready to send (no SSRC) so no option should have been set. | 725 // Sender is not ready to send (no SSRC) so no option should have been set. |
719 EXPECT_EQ(rtc::Optional<bool>(), | 726 EXPECT_EQ(rtc::Optional<bool>(), |
720 video_media_channel_->options().is_screencast); | 727 video_media_channel_->options().is_screencast); |
721 | 728 |
722 // Verify that the content hint is accounted for when video_rtp_sender_ does | 729 // Verify that the content hint is accounted for when video_rtp_sender_ does |
723 // get enabled. | 730 // get enabled. |
724 video_rtp_sender_->SetSsrc(kVideoSsrc); | 731 video_rtp_sender_->SetSsrc(kVideoSsrc); |
725 EXPECT_EQ(rtc::Optional<bool>(true), | 732 EXPECT_EQ(rtc::Optional<bool>(true), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 // Make sure the signal from "GetOnDestroyedSignal()" fires when the sender is | 797 // Make sure the signal from "GetOnDestroyedSignal()" fires when the sender is |
791 // destroyed, which is needed for the DTMF sender. | 798 // destroyed, which is needed for the DTMF sender. |
792 TEST_F(RtpSenderReceiverTest, TestOnDestroyedSignal) { | 799 TEST_F(RtpSenderReceiverTest, TestOnDestroyedSignal) { |
793 CreateAudioRtpSender(); | 800 CreateAudioRtpSender(); |
794 EXPECT_FALSE(audio_sender_destroyed_signal_fired_); | 801 EXPECT_FALSE(audio_sender_destroyed_signal_fired_); |
795 audio_rtp_sender_ = nullptr; | 802 audio_rtp_sender_ = nullptr; |
796 EXPECT_TRUE(audio_sender_destroyed_signal_fired_); | 803 EXPECT_TRUE(audio_sender_destroyed_signal_fired_); |
797 } | 804 } |
798 | 805 |
799 } // namespace webrtc | 806 } // namespace webrtc |
OLD | NEW |