Commit 95dd8011 authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

DLP: Send black frame when screen capture is paused.

When confidential content appears in the capture area and
screen capture is being paused, a black frame should be sent
to override the last sent capture frame.

Bug: 1134566
Change-Id: I20c2859cefcc0166ae86b08cde02e5b1b8835dbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521737Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825296}
parent f4eca45b
......@@ -102,7 +102,8 @@ class BLINK_MODULES_EXPORT MediaStreamVideoSource
// verified by checking that the IsRunning() method returns true.
// Any attempt to invoke StopForRestart() before the source has started
// results in no action and |callback| invoked with INVALID_STATE.
void StopForRestart(RestartCallback callback);
// If |send_black_frame| is set, an additional black frame will be sent.
void StopForRestart(RestartCallback callback, bool send_black_frame = false);
// Tries to restart a source that was previously temporarily stopped using the
// supplied |new_format|. This method can be invoked only after a successful
......
......@@ -198,7 +198,8 @@ void MediaStreamVideoSource::ReconfigureTrack(
UpdateTrackSettings(track, adapter_settings);
}
void MediaStreamVideoSource::StopForRestart(RestartCallback callback) {
void MediaStreamVideoSource::StopForRestart(RestartCallback callback,
bool send_black_frame) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (state_ != STARTED) {
Thread::Current()->GetTaskRunner()->PostTask(
......@@ -211,6 +212,21 @@ void MediaStreamVideoSource::StopForRestart(RestartCallback callback) {
track_adapter_->StopFrameMonitoring();
state_ = STOPPING_FOR_RESTART;
restart_callback_ = std::move(callback);
if (send_black_frame) {
const base::Optional<gfx::Size> source_size =
track_adapter_->source_frame_size();
scoped_refptr<media::VideoFrame> black_frame =
media::VideoFrame::CreateBlackFrame(
source_size.has_value() ? *source_size
: gfx::Size(kDefaultWidth, kDefaultHeight));
PostCrossThreadTask(
*io_task_runner(), FROM_HERE,
CrossThreadBindOnce(&VideoTrackAdapter::DeliverFrameOnIO,
track_adapter_, black_frame,
base::TimeTicks::Now()));
}
StopSourceForRestartImpl();
}
......
......@@ -1228,7 +1228,8 @@ void UserMediaProcessor::OnDeviceRequestStateChange(
}
if (new_state == mojom::blink::MediaStreamStateChange::PAUSE) {
if (video_source->IsRunning()) {
video_source->StopForRestart(base::DoNothing());
video_source->StopForRestart(base::DoNothing(),
/*send_black_frame=*/true);
}
} else if (new_state == mojom::blink::MediaStreamStateChange::PLAY) {
if (video_source->IsStoppedForRestart()) {
......
......@@ -413,6 +413,7 @@ bool VideoTrackAdapter::VideoFrameResolutionAdapter::MaybeDropFrame(
if (settings_.max_frame_rate() == 0.0f ||
(source_frame_rate > 0 &&
source_frame_rate <= settings_.max_frame_rate())) {
last_time_stamp_ = frame.timestamp();
return false;
}
......
......@@ -95,6 +95,10 @@ class MODULES_EXPORT VideoTrackAdapter
const VideoTrackAdapterSettings& settings,
gfx::Size* desired_size);
base::Optional<gfx::Size> source_frame_size() const {
return source_frame_size_;
}
private:
virtual ~VideoTrackAdapter();
friend class WTF::ThreadSafeRefCounted<VideoTrackAdapter>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment