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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 video_media_channel_->AddRecvStream( | 94 video_media_channel_->AddRecvStream( |
95 cricket::StreamParams::CreateLegacy(kVideoSsrc)); | 95 cricket::StreamParams::CreateLegacy(kVideoSsrc)); |
96 video_media_channel_->AddSendStream( | 96 video_media_channel_->AddSendStream( |
97 cricket::StreamParams::CreateLegacy(kVideoSsrc2)); | 97 cricket::StreamParams::CreateLegacy(kVideoSsrc2)); |
98 video_media_channel_->AddRecvStream( | 98 video_media_channel_->AddRecvStream( |
99 cricket::StreamParams::CreateLegacy(kVideoSsrc2)); | 99 cricket::StreamParams::CreateLegacy(kVideoSsrc2)); |
100 } | 100 } |
101 | 101 |
102 void TearDown() override { channel_manager_.Terminate(); } | 102 void TearDown() override { channel_manager_.Terminate(); } |
103 | 103 |
104 void AddVideoTrack() { | 104 void AddVideoTrack() { AddVideoTrack(false); } |
105 | |
106 void AddVideoTrack(bool is_screencast) { | |
105 rtc::scoped_refptr<VideoTrackSourceInterface> source( | 107 rtc::scoped_refptr<VideoTrackSourceInterface> source( |
106 FakeVideoTrackSource::Create()); | 108 FakeVideoTrackSource::Create(is_screencast)); |
107 video_track_ = VideoTrack::Create(kVideoTrackId, source); | 109 video_track_ = VideoTrack::Create(kVideoTrackId, source); |
108 EXPECT_TRUE(stream_->AddTrack(video_track_)); | 110 EXPECT_TRUE(stream_->AddTrack(video_track_)); |
109 } | 111 } |
110 | 112 |
111 void CreateAudioRtpSender() { CreateAudioRtpSender(nullptr); } | 113 void CreateAudioRtpSender() { CreateAudioRtpSender(nullptr); } |
112 | 114 |
113 void CreateAudioRtpSender(rtc::scoped_refptr<LocalAudioSource> source) { | 115 void CreateAudioRtpSender(rtc::scoped_refptr<LocalAudioSource> source) { |
114 audio_track_ = AudioTrack::Create(kAudioTrackId, source); | 116 audio_track_ = AudioTrack::Create(kAudioTrackId, source); |
115 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 117 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
116 audio_rtp_sender_ = | 118 audio_rtp_sender_ = |
117 new AudioRtpSender(stream_->GetAudioTracks()[0], stream_->label(), | 119 new AudioRtpSender(stream_->GetAudioTracks()[0], stream_->label(), |
118 voice_channel_, nullptr); | 120 voice_channel_, nullptr); |
119 audio_rtp_sender_->SetSsrc(kAudioSsrc); | 121 audio_rtp_sender_->SetSsrc(kAudioSsrc); |
120 VerifyVoiceChannelInput(); | 122 VerifyVoiceChannelInput(); |
121 } | 123 } |
122 | 124 |
123 void CreateVideoRtpSender() { | 125 void CreateVideoRtpSender() { CreateVideoRtpSender(false); } |
124 AddVideoTrack(); | 126 |
127 void CreateVideoRtpSender(bool is_screencast) { | |
128 AddVideoTrack(is_screencast); | |
125 video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0], | 129 video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0], |
126 stream_->label(), video_channel_); | 130 stream_->label(), video_channel_); |
127 video_rtp_sender_->SetSsrc(kVideoSsrc); | 131 video_rtp_sender_->SetSsrc(kVideoSsrc); |
128 VerifyVideoChannelInput(); | 132 VerifyVideoChannelInput(); |
129 } | 133 } |
130 | 134 |
131 void DestroyAudioRtpSender() { | 135 void DestroyAudioRtpSender() { |
132 audio_rtp_sender_ = nullptr; | 136 audio_rtp_sender_ = nullptr; |
133 VerifyVoiceChannelNoInput(); | 137 VerifyVoiceChannelNoInput(); |
134 } | 138 } |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
614 TEST_F(RtpSenderReceiverTest, VideoReceiverCanSetParameters) { | 618 TEST_F(RtpSenderReceiverTest, VideoReceiverCanSetParameters) { |
615 CreateVideoRtpReceiver(); | 619 CreateVideoRtpReceiver(); |
616 | 620 |
617 RtpParameters params = video_rtp_receiver_->GetParameters(); | 621 RtpParameters params = video_rtp_receiver_->GetParameters(); |
618 EXPECT_EQ(1u, params.encodings.size()); | 622 EXPECT_EQ(1u, params.encodings.size()); |
619 EXPECT_TRUE(video_rtp_receiver_->SetParameters(params)); | 623 EXPECT_TRUE(video_rtp_receiver_->SetParameters(params)); |
620 | 624 |
621 DestroyVideoRtpReceiver(); | 625 DestroyVideoRtpReceiver(); |
622 } | 626 } |
623 | 627 |
628 TEST_F(RtpSenderReceiverTest, PropagatesVideoTrackContentHint) { | |
629 CreateVideoRtpSender(); | |
630 | |
631 video_track_->set_enabled(true); | |
632 | |
633 // |video_track_| is not screencast by default. | |
634 EXPECT_EQ(rtc::Optional<bool>(false), | |
635 video_media_channel_->options().is_screencast); | |
636 // No content hint should be set by default. | |
637 EXPECT_EQ(VideoTrackInterface::ContentHint::kNone, | |
638 video_track_->content_hint()); | |
639 // Setting detailed should turn a non-screencast source into screencast mode. | |
640 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed); | |
641 EXPECT_EQ(rtc::Optional<bool>(true), | |
642 video_media_channel_->options().is_screencast); | |
643 // Removing the content hint should turn the track back into non-screencast | |
644 // mode. | |
645 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kNone); | |
646 EXPECT_EQ(rtc::Optional<bool>(false), | |
647 video_media_channel_->options().is_screencast); | |
648 // Setting fluid should remain in non-screencast mode (its default). | |
649 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kFluid); | |
650 EXPECT_EQ(rtc::Optional<bool>(false), | |
651 video_media_channel_->options().is_screencast); | |
652 | |
653 DestroyVideoRtpSender(); | |
654 } | |
655 | |
656 TEST_F(RtpSenderReceiverTest, PropagatesVideoTrackContentHintForScreencast) { | |
Taylor Brandstetter
2016/12/16 23:06:38
nit: I'd prefer calling this test PropagatesVideoT
pbos-webrtc
2016/12/16 23:17:06
Done.
| |
657 CreateVideoRtpSender(true); | |
658 | |
659 video_track_->set_enabled(true); | |
660 | |
661 // |video_track_| with a screencast source should be screencast by default. | |
662 EXPECT_EQ(rtc::Optional<bool>(true), | |
663 video_media_channel_->options().is_screencast); | |
664 // No content hint should be set by default. | |
665 EXPECT_EQ(VideoTrackInterface::ContentHint::kNone, | |
666 video_track_->content_hint()); | |
667 // Setting fluid should turn a screencast source into non-screencast mode. | |
668 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kFluid); | |
669 EXPECT_EQ(rtc::Optional<bool>(false), | |
670 video_media_channel_->options().is_screencast); | |
671 // Removing the content hint should turn the track back into screencast mode. | |
672 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kNone); | |
673 EXPECT_EQ(rtc::Optional<bool>(true), | |
674 video_media_channel_->options().is_screencast); | |
675 // Setting detailed should still remain in screencast mode (its default). | |
676 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed); | |
677 EXPECT_EQ(rtc::Optional<bool>(true), | |
678 video_media_channel_->options().is_screencast); | |
679 | |
680 DestroyVideoRtpSender(); | |
681 } | |
682 | |
683 TEST_F(RtpSenderReceiverTest, | |
684 PropagatesVideoTrackContentHintSetBeforeEnabling) { | |
685 AddVideoTrack(); | |
686 // Setting detailed overrides the default non-screencast mode. This should be | |
687 // applied even if the track is set on construction. | |
688 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed); | |
689 video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0], | |
690 stream_->label(), video_channel_); | |
691 video_track_->set_enabled(true); | |
692 | |
693 // Sender is not ready to send (no SSRC) so no option should have been set. | |
694 EXPECT_EQ(rtc::Optional<bool>(), | |
695 video_media_channel_->options().is_screencast); | |
696 | |
697 // Verify that the content hint is accounted for when video_rtp_sender_ does | |
698 // get enabled. | |
699 video_rtp_sender_->SetSsrc(kVideoSsrc); | |
700 EXPECT_EQ(rtc::Optional<bool>(true), | |
701 video_media_channel_->options().is_screencast); | |
702 | |
703 // And removing the hint should go back to false (to verify that false was | |
704 // default correctly). | |
705 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kNone); | |
706 EXPECT_EQ(rtc::Optional<bool>(false), | |
707 video_media_channel_->options().is_screencast); | |
708 | |
709 DestroyVideoRtpSender(); | |
710 } | |
711 | |
624 } // namespace webrtc | 712 } // namespace webrtc |
OLD | NEW |