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

Side by Side Diff: webrtc/api/rtpsenderreceiver_unittest.cc

Issue 2579993003: Add support for content hints to VideoTrack. (Closed)
Patch Set: rename test + add comments 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 unified diff | Download patch
« no previous file with comments | « webrtc/api/rtpsender.cc ('k') | webrtc/api/test/fakevideotracksource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 that makes sure that a video track content hint translates to the proper
629 // value for sources that are not screencast.
630 TEST_F(RtpSenderReceiverTest, PropagatesVideoTrackContentHint) {
631 CreateVideoRtpSender();
632
633 video_track_->set_enabled(true);
634
635 // |video_track_| is not screencast by default.
636 EXPECT_EQ(rtc::Optional<bool>(false),
637 video_media_channel_->options().is_screencast);
638 // No content hint should be set by default.
639 EXPECT_EQ(VideoTrackInterface::ContentHint::kNone,
640 video_track_->content_hint());
641 // Setting detailed should turn a non-screencast source into screencast mode.
642 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed);
643 EXPECT_EQ(rtc::Optional<bool>(true),
644 video_media_channel_->options().is_screencast);
645 // Removing the content hint should turn the track back into non-screencast
646 // mode.
647 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kNone);
648 EXPECT_EQ(rtc::Optional<bool>(false),
649 video_media_channel_->options().is_screencast);
650 // Setting fluid should remain in non-screencast mode (its default).
651 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kFluid);
652 EXPECT_EQ(rtc::Optional<bool>(false),
653 video_media_channel_->options().is_screencast);
654
655 DestroyVideoRtpSender();
656 }
657
658 // Test that makes sure that a video track content hint translates to the proper
659 // value for screencast sources.
660 TEST_F(RtpSenderReceiverTest,
661 PropagatesVideoTrackContentHintForScreencastSource) {
662 CreateVideoRtpSender(true);
663
664 video_track_->set_enabled(true);
665
666 // |video_track_| with a screencast source should be screencast by default.
667 EXPECT_EQ(rtc::Optional<bool>(true),
668 video_media_channel_->options().is_screencast);
669 // No content hint should be set by default.
670 EXPECT_EQ(VideoTrackInterface::ContentHint::kNone,
671 video_track_->content_hint());
672 // Setting fluid should turn a screencast source into non-screencast mode.
673 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kFluid);
674 EXPECT_EQ(rtc::Optional<bool>(false),
675 video_media_channel_->options().is_screencast);
676 // Removing the content hint should turn the track back into screencast mode.
677 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kNone);
678 EXPECT_EQ(rtc::Optional<bool>(true),
679 video_media_channel_->options().is_screencast);
680 // Setting detailed should still remain in screencast mode (its default).
681 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed);
682 EXPECT_EQ(rtc::Optional<bool>(true),
683 video_media_channel_->options().is_screencast);
684
685 DestroyVideoRtpSender();
686 }
687
688 // Test that makes sure any content hints that are set on a track before
689 // VideoRtpSender is ready to send are still applied when it gets ready to send.
690 TEST_F(RtpSenderReceiverTest,
691 PropagatesVideoTrackContentHintSetBeforeEnabling) {
692 AddVideoTrack();
693 // Setting detailed overrides the default non-screencast mode. This should be
694 // applied even if the track is set on construction.
695 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kDetailed);
696 video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0],
697 stream_->label(), video_channel_);
698 video_track_->set_enabled(true);
699
700 // Sender is not ready to send (no SSRC) so no option should have been set.
701 EXPECT_EQ(rtc::Optional<bool>(),
702 video_media_channel_->options().is_screencast);
703
704 // Verify that the content hint is accounted for when video_rtp_sender_ does
705 // get enabled.
706 video_rtp_sender_->SetSsrc(kVideoSsrc);
707 EXPECT_EQ(rtc::Optional<bool>(true),
708 video_media_channel_->options().is_screencast);
709
710 // And removing the hint should go back to false (to verify that false was
711 // default correctly).
712 video_track_->set_content_hint(VideoTrackInterface::ContentHint::kNone);
713 EXPECT_EQ(rtc::Optional<bool>(false),
714 video_media_channel_->options().is_screencast);
715
716 DestroyVideoRtpSender();
717 }
718
624 } // namespace webrtc 719 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/rtpsender.cc ('k') | webrtc/api/test/fakevideotracksource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698