Skip to content

Commit

Permalink
[Fuchsia] Mark protected video frames
Browse files Browse the repository at this point in the history
Previously FuchsiaVideoDecoder wasn't setting hw_protected flag in the
video frames produced on the output. Without that flag the compositor
may try to present them without overlays, which is not supported. As
result the video content is not rendered correctly on the screen.
Now the decoder sets hw_protected and protected_video flags when
necessary.
Also moved handling of the --force-protected-video-output-buffers
command line argument to the renderer process.

Bug: 1401245
Change-Id: I2c34c0b5055bf2c19a50d18fb47a6c8673e3d987
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4116013
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Peter McNeeley <petermcneeley@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1090463}
  • Loading branch information
SergeyUlanov authored and Chromium LUCI CQ committed Jan 9, 2023
1 parent e9b2901 commit f592db4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,9 @@ void FuchsiaMediaCodecProviderImpl::CreateVideoDecoder(
fuchsia::mediacodec::SecureMemoryMode::ON);
break;

case media::mojom::VideoDecoderSecureMemoryMode::CLEAR_INPUT:
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kForceProtectedVideoOutputBuffers)) {
decoder_params.set_secure_output_mode(
fuchsia::mediacodec::SecureMemoryMode::ON);
}
case media::mojom::VideoDecoderSecureMemoryMode::SECURE_OUTPUT:
decoder_params.set_secure_output_mode(
fuchsia::mediacodec::SecureMemoryMode::ON);
break;
}

Expand Down
5 changes: 2 additions & 3 deletions media/fuchsia/mojom/fuchsia_media.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ enum VideoDecoderSecureMemoryMode {
// Input and output buffers must be allocated in protected memory.
SECURE,

// Input buffers are not protected. Output buffers may be allocated in
// protected memory.
CLEAR_INPUT,
// Input buffers are not protected. Output buffers are protected.
SECURE_OUTPUT,
};

// Interface used by the renderer to connect to CDM and mediacodec resources.
Expand Down
17 changes: 12 additions & 5 deletions media/fuchsia/video/fuchsia_video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void FuchsiaVideoDecoder::Initialize(const VideoDecoderConfig& config,
}

media::mojom::VideoDecoderSecureMemoryMode secure_mode =
media::mojom::VideoDecoderSecureMemoryMode::CLEAR_INPUT;
media::mojom::VideoDecoderSecureMemoryMode::CLEAR;
if (secure_input) {
if (!use_overlays_for_video_) {
DLOG(ERROR) << "Protected content can be rendered only using overlays.";
Expand All @@ -312,11 +312,13 @@ void FuchsiaVideoDecoder::Initialize(const VideoDecoderConfig& config,
return;
}
secure_mode = media::mojom::VideoDecoderSecureMemoryMode::SECURE;
} else if (!use_overlays_for_video_) {
// Protected output buffers can be rendered only using overlays. If overlays
// are not allowed then the output buffers cannot be protected.
secure_mode = media::mojom::VideoDecoderSecureMemoryMode::CLEAR;
} else if (use_overlays_for_video_ &&
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kForceProtectedVideoOutputBuffers)) {
secure_mode = media::mojom::VideoDecoderSecureMemoryMode::SECURE_OUTPUT;
}
protected_output_ =
secure_mode != media::mojom::VideoDecoderSecureMemoryMode::CLEAR;

// Reset output buffers since we won't be able to re-use them.
ReleaseOutputBuffers();
Expand Down Expand Up @@ -668,6 +670,11 @@ void FuchsiaVideoDecoder::OnStreamProcessorOutputPacket(
// registered with an ImagePipe.
frame->metadata().allow_overlay = use_overlays_for_video_;

if (protected_output_) {
frame->metadata().protected_video = true;
frame->metadata().hw_protected = true;
}

output_cb_.Run(std::move(frame));
}

Expand Down
3 changes: 3 additions & 0 deletions media/fuchsia/video/fuchsia_video_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ class MEDIA_EXPORT FuchsiaVideoDecoder : public VideoDecoder,
zx::eventpair output_buffer_collection_handle_;
std::vector<OutputMailbox*> output_mailboxes_;

// Set to true when the output buffers are protected.
bool protected_output_ = false;

size_t num_used_output_buffers_ = 0;

SEQUENCE_CHECKER(sequence_checker_);
Expand Down

0 comments on commit f592db4

Please sign in to comment.