From 232b6a16cce32648b9ee9eab9170631d9e76151d Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Wed, 29 May 2019 11:05:01 +0200 Subject: [PATCH] Propagate screenshare info into video track and it's source. If screen share is set, then we need to tell video source, that it is screen share source. Also video track should be aware, that it is screen share track. It is required to choose proper video encoding settings. Bug: webrtc:10138 Change-Id: I5c82584ae0325a303a495554d87962a98b676694 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/138278 Commit-Queue: Artem Titov Reviewed-by: Karl Wiberg Reviewed-by: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/master@{#28098} --- pc/peer_connection_rampup_tests.cc | 2 +- ...me_generator_capturer_video_track_source.h | 21 ++++++++++++------- test/pc/e2e/peer_connection_quality_test.cc | 6 +++++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pc/peer_connection_rampup_tests.cc b/pc/peer_connection_rampup_tests.cc index 93a2724d95..dd769e684c 100644 --- a/pc/peer_connection_rampup_tests.cc +++ b/pc/peer_connection_rampup_tests.cc @@ -122,7 +122,7 @@ class PeerConnectionWrapperForRampUpTest : public PeerConnectionWrapper { Clock* clock) { video_track_sources_.emplace_back( new rtc::RefCountedObject( - config, clock)); + config, clock, /*is_screencast=*/false)); video_track_sources_.back()->Start(); return rtc::scoped_refptr( pc_factory()->CreateVideoTrack(rtc::CreateRandomUuid(), diff --git a/pc/test/frame_generator_capturer_video_track_source.h b/pc/test/frame_generator_capturer_video_track_source.h index 06b4193bc7..229a66a233 100644 --- a/pc/test/frame_generator_capturer_video_track_source.h +++ b/pc/test/frame_generator_capturer_video_track_source.h @@ -40,12 +40,12 @@ class FrameGeneratorCapturerVideoTrackSource : public VideoTrackSource { int num_squares_generated = 50; }; - explicit FrameGeneratorCapturerVideoTrackSource(Clock* clock) - : FrameGeneratorCapturerVideoTrackSource(Config(), clock) {} - - FrameGeneratorCapturerVideoTrackSource(Config config, Clock* clock) + FrameGeneratorCapturerVideoTrackSource(Config config, + Clock* clock, + bool is_screencast) : VideoTrackSource(false /* remote */), - task_queue_factory_(CreateDefaultTaskQueueFactory()) { + task_queue_factory_(CreateDefaultTaskQueueFactory()), + is_screencast_(is_screencast) { video_capturer_ = absl::make_unique( clock, test::FrameGenerator::CreateSquareGenerator( @@ -55,10 +55,12 @@ class FrameGeneratorCapturerVideoTrackSource : public VideoTrackSource { video_capturer_->Init(); } - explicit FrameGeneratorCapturerVideoTrackSource( - std::unique_ptr video_capturer) + FrameGeneratorCapturerVideoTrackSource( + std::unique_ptr video_capturer, + bool is_screencast) : VideoTrackSource(false /* remote */), - video_capturer_(std::move(video_capturer)) {} + video_capturer_(std::move(video_capturer)), + is_screencast_(is_screencast) {} ~FrameGeneratorCapturerVideoTrackSource() = default; @@ -70,6 +72,8 @@ class FrameGeneratorCapturerVideoTrackSource : public VideoTrackSource { SetState(kMuted); } + bool is_screencast() const override { return is_screencast_; } + protected: rtc::VideoSourceInterface* source() override { return video_capturer_.get(); @@ -78,6 +82,7 @@ class FrameGeneratorCapturerVideoTrackSource : public VideoTrackSource { private: const std::unique_ptr task_queue_factory_; std::unique_ptr video_capturer_; + const bool is_screencast_; }; } // namespace webrtc diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index 7e7a47c59b..d3ddb2ad9d 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -646,13 +646,17 @@ PeerConnectionE2EQualityTest::MaybeAddVideo(TestPeer* peer) { capturer->Init(); rtc::scoped_refptr source = new rtc::RefCountedObject( - std::move(capturer)); + std::move(capturer), + /*is_screencast=*/video_config.screen_share_config.has_value()); out.push_back(source); RTC_LOG(INFO) << "Adding video with video_config.stream_label=" << video_config.stream_label.value(); rtc::scoped_refptr track = peer->pc_factory()->CreateVideoTrack(video_config.stream_label.value(), source); + if (video_config.screen_share_config) { + track->set_content_hint(VideoTrackInterface::ContentHint::kText); + } peer->AddTrack(track, {video_config.stream_label.value()}); } return out;