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 <titovartem@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28098}
This commit is contained in:
Artem Titov 2019-05-29 11:05:01 +02:00 committed by Commit Bot
parent 98266a4af1
commit 232b6a16cc
3 changed files with 19 additions and 10 deletions

View File

@ -122,7 +122,7 @@ class PeerConnectionWrapperForRampUpTest : public PeerConnectionWrapper {
Clock* clock) {
video_track_sources_.emplace_back(
new rtc::RefCountedObject<FrameGeneratorCapturerVideoTrackSource>(
config, clock));
config, clock, /*is_screencast=*/false));
video_track_sources_.back()->Start();
return rtc::scoped_refptr<VideoTrackInterface>(
pc_factory()->CreateVideoTrack(rtc::CreateRandomUuid(),

View File

@ -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<test::FrameGeneratorCapturer>(
clock,
test::FrameGenerator::CreateSquareGenerator(
@ -55,10 +55,12 @@ class FrameGeneratorCapturerVideoTrackSource : public VideoTrackSource {
video_capturer_->Init();
}
explicit FrameGeneratorCapturerVideoTrackSource(
std::unique_ptr<test::FrameGeneratorCapturer> video_capturer)
FrameGeneratorCapturerVideoTrackSource(
std::unique_ptr<test::FrameGeneratorCapturer> 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<VideoFrame>* source() override {
return video_capturer_.get();
@ -78,6 +82,7 @@ class FrameGeneratorCapturerVideoTrackSource : public VideoTrackSource {
private:
const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
std::unique_ptr<test::FrameGeneratorCapturer> video_capturer_;
const bool is_screencast_;
};
} // namespace webrtc

View File

@ -646,13 +646,17 @@ PeerConnectionE2EQualityTest::MaybeAddVideo(TestPeer* peer) {
capturer->Init();
rtc::scoped_refptr<FrameGeneratorCapturerVideoTrackSource> source =
new rtc::RefCountedObject<FrameGeneratorCapturerVideoTrackSource>(
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<VideoTrackInterface> 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;