Commit 61ce5837 authored by liberato@chromium.org's avatar liberato@chromium.org Committed by Commit Bot

Use MediaLog in MediaCodecVideoDecoder

Send in MediaLog to MCVD, and use it to log errors during init
and decoding.

Change-Id: Ia4e0b4689475e5b7fc0cb3bdc1a0ff3a25f6dcf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816133
Commit-Queue: Frank Liberato <liberato@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699516}
parent 905c1bfc
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "media/base/bind_to_current_loop.h" #include "media/base/bind_to_current_loop.h"
#include "media/base/cdm_context.h" #include "media/base/cdm_context.h"
#include "media/base/decoder_buffer.h" #include "media/base/decoder_buffer.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "media/base/scoped_async_trace.h" #include "media/base/scoped_async_trace.h"
#include "media/base/video_codecs.h" #include "media/base/video_codecs.h"
...@@ -204,13 +205,15 @@ MediaCodecVideoDecoder::GetSupportedConfigs() { ...@@ -204,13 +205,15 @@ MediaCodecVideoDecoder::GetSupportedConfigs() {
MediaCodecVideoDecoder::MediaCodecVideoDecoder( MediaCodecVideoDecoder::MediaCodecVideoDecoder(
const gpu::GpuPreferences& gpu_preferences, const gpu::GpuPreferences& gpu_preferences,
const gpu::GpuFeatureInfo& gpu_feature_info, const gpu::GpuFeatureInfo& gpu_feature_info,
std::unique_ptr<MediaLog> media_log,
DeviceInfo* device_info, DeviceInfo* device_info,
CodecAllocator* codec_allocator, CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser, std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
AndroidOverlayMojoFactoryCB overlay_factory_cb, AndroidOverlayMojoFactoryCB overlay_factory_cb,
RequestOverlayInfoCB request_overlay_info_cb, RequestOverlayInfoCB request_overlay_info_cb,
std::unique_ptr<VideoFrameFactory> video_frame_factory) std::unique_ptr<VideoFrameFactory> video_frame_factory)
: codec_allocator_(codec_allocator), : media_log_(std::move(media_log)),
codec_allocator_(codec_allocator),
request_overlay_info_cb_(std::move(request_overlay_info_cb)), request_overlay_info_cb_(std::move(request_overlay_info_cb)),
is_surface_control_enabled_(IsSurfaceControlEnabled(gpu_feature_info)), is_surface_control_enabled_(IsSurfaceControlEnabled(gpu_feature_info)),
surface_chooser_helper_( surface_chooser_helper_(
...@@ -279,6 +282,12 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config, ...@@ -279,6 +282,12 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
<< ", cdm_context = " << cdm_context; << ", cdm_context = " << cdm_context;
if (!config.IsValidConfig()) { if (!config.IsValidConfig()) {
media_log_->AddEvent(media_log_->CreateStringEvent(
MediaLogEvent::MEDIA_INFO_LOG_ENTRY, "info",
"Video configuration is not valid"));
media_log_->AddEvent(
media_log_->CreateStringEvent(MediaLogEvent::MEDIA_INFO_LOG_ENTRY,
"info", config.AsHumanReadableString()));
DVLOG(1) << "Invalid configuration."; DVLOG(1) << "Invalid configuration.";
BindToCurrentLoop(std::move(init_cb)).Run(false); BindToCurrentLoop(std::move(init_cb)).Run(false);
return; return;
...@@ -292,6 +301,12 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config, ...@@ -292,6 +301,12 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
: GetSupportedConfigsInternal(device_info_); : GetSupportedConfigsInternal(device_info_);
if (!IsVideoDecoderConfigSupported(configs, config)) { if (!IsVideoDecoderConfigSupported(configs, config)) {
DVLOG(1) << "Unsupported configuration."; DVLOG(1) << "Unsupported configuration.";
media_log_->AddEvent(media_log_->CreateStringEvent(
MediaLogEvent::MEDIA_INFO_LOG_ENTRY, "info",
"Video configuration is not supported"));
media_log_->AddEvent(
media_log_->CreateStringEvent(MediaLogEvent::MEDIA_INFO_LOG_ENTRY,
"info", config.AsHumanReadableString()));
BindToCurrentLoop(std::move(init_cb)).Run(false); BindToCurrentLoop(std::move(init_cb)).Run(false);
return; return;
} }
...@@ -299,6 +314,15 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config, ...@@ -299,6 +314,15 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
// Disallow codec changes when reinitializing. // Disallow codec changes when reinitializing.
if (!first_init && decoder_config_.codec() != config.codec()) { if (!first_init && decoder_config_.codec() != config.codec()) {
DVLOG(1) << "Codec changed: cannot reinitialize"; DVLOG(1) << "Codec changed: cannot reinitialize";
media_log_->AddEvent(media_log_->CreateStringEvent(
MediaLogEvent::MEDIA_INFO_LOG_ENTRY, "info",
"Cannot change codec during re-init"));
media_log_->AddEvent(
media_log_->CreateStringEvent(MediaLogEvent::MEDIA_INFO_LOG_ENTRY,
"info", config.AsHumanReadableString()));
media_log_->AddEvent(media_log_->CreateStringEvent(
MediaLogEvent::MEDIA_INFO_LOG_ENTRY, "info",
decoder_config_.AsHumanReadableString()));
BindToCurrentLoop(std::move(init_cb)).Run(false); BindToCurrentLoop(std::move(init_cb)).Run(false);
return; return;
} }
...@@ -326,6 +350,9 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config, ...@@ -326,6 +350,9 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
if (config.is_encrypted() && media_crypto_.is_null()) { if (config.is_encrypted() && media_crypto_.is_null()) {
DVLOG(1) << "No MediaCrypto to handle encrypted config"; DVLOG(1) << "No MediaCrypto to handle encrypted config";
media_log_->AddEvent(media_log_->CreateStringEvent(
MediaLogEvent::MEDIA_INFO_LOG_ENTRY, "info",
"No MediaCrypto to handle encrypted config"));
BindToCurrentLoop(std::move(init_cb)).Run(false); BindToCurrentLoop(std::move(init_cb)).Run(false);
return; return;
} }
...@@ -383,7 +410,7 @@ void MediaCodecVideoDecoder::OnMediaCryptoReady( ...@@ -383,7 +410,7 @@ void MediaCodecVideoDecoder::OnMediaCryptoReady(
if (decoder_config_.is_encrypted()) { if (decoder_config_.is_encrypted()) {
LOG(ERROR) << "MediaCrypto is not available"; LOG(ERROR) << "MediaCrypto is not available";
EnterTerminalState(State::kError); EnterTerminalState(State::kError, "MediaCrypto is not available");
std::move(init_cb).Run(false); std::move(init_cb).Run(false);
return; return;
} }
...@@ -460,7 +487,7 @@ void MediaCodecVideoDecoder::OnVideoFrameFactoryInitialized( ...@@ -460,7 +487,7 @@ void MediaCodecVideoDecoder::OnVideoFrameFactoryInitialized(
TRACE_EVENT0("media", TRACE_EVENT0("media",
"MediaCodecVideoDecoder::OnVideoFrameFactoryInitialized"); "MediaCodecVideoDecoder::OnVideoFrameFactoryInitialized");
if (!texture_owner) { if (!texture_owner) {
EnterTerminalState(State::kError); EnterTerminalState(State::kError, "Could not allocated TextureOwner");
return; return;
} }
texture_owner_bundle_ = new CodecSurfaceBundle(std::move(texture_owner)); texture_owner_bundle_ = new CodecSurfaceBundle(std::move(texture_owner));
...@@ -536,7 +563,7 @@ void MediaCodecVideoDecoder::OnSurfaceDestroyed(AndroidOverlay* overlay) { ...@@ -536,7 +563,7 @@ void MediaCodecVideoDecoder::OnSurfaceDestroyed(AndroidOverlay* overlay) {
// no idea that this has happened. We should unback the frames here. This // no idea that this has happened. We should unback the frames here. This
// might work now that we have CodecImageGroup -- verify this. // might work now that we have CodecImageGroup -- verify this.
if (!device_info_->IsSetOutputSurfaceSupported()) { if (!device_info_->IsSetOutputSurfaceSupported()) {
EnterTerminalState(State::kSurfaceDestroyed); EnterTerminalState(State::kSurfaceDestroyed, "Surface destroyed");
return; return;
} }
...@@ -560,7 +587,7 @@ void MediaCodecVideoDecoder::TransitionToTargetSurface() { ...@@ -560,7 +587,7 @@ void MediaCodecVideoDecoder::TransitionToTargetSurface() {
if (!codec_->SetSurface(target_surface_bundle_)) { if (!codec_->SetSurface(target_surface_bundle_)) {
video_frame_factory_->SetSurfaceBundle(nullptr); video_frame_factory_->SetSurfaceBundle(nullptr);
EnterTerminalState(State::kError); EnterTerminalState(State::kError, "Could not switch codec output surface");
return; return;
} }
...@@ -630,7 +657,7 @@ void MediaCodecVideoDecoder::OnCodecConfigured( ...@@ -630,7 +657,7 @@ void MediaCodecVideoDecoder::OnCodecConfigured(
DCHECK_EQ(state_, State::kRunning); DCHECK_EQ(state_, State::kRunning);
if (!codec) { if (!codec) {
EnterTerminalState(State::kError); EnterTerminalState(State::kError, "Unable to allocate codec");
return; return;
} }
...@@ -707,7 +734,7 @@ void MediaCodecVideoDecoder::FlushCodec() { ...@@ -707,7 +734,7 @@ void MediaCodecVideoDecoder::FlushCodec() {
if (codec_->SupportsFlush(device_info_)) { if (codec_->SupportsFlush(device_info_)) {
DVLOG(2) << "Flushing codec"; DVLOG(2) << "Flushing codec";
if (!codec_->Flush()) if (!codec_->Flush())
EnterTerminalState(State::kError); EnterTerminalState(State::kError, "Codec flush failed");
} else { } else {
DVLOG(2) << "flush() workaround: creating a new codec"; DVLOG(2) << "flush() workaround: creating a new codec";
// Release the codec and create a new one. // Release the codec and create a new one.
...@@ -824,7 +851,7 @@ bool MediaCodecVideoDecoder::QueueInput() { ...@@ -824,7 +851,7 @@ bool MediaCodecVideoDecoder::QueueInput() {
waiting_cb_.Run(WaitingReason::kNoDecryptionKey); waiting_cb_.Run(WaitingReason::kNoDecryptionKey);
return false; return false;
case CodecWrapper::QueueStatus::kError: case CodecWrapper::QueueStatus::kError:
EnterTerminalState(State::kError); EnterTerminalState(State::kError, "QueueInputBuffer failed");
return false; return false;
} }
...@@ -871,7 +898,7 @@ bool MediaCodecVideoDecoder::DequeueOutput() { ...@@ -871,7 +898,7 @@ bool MediaCodecVideoDecoder::DequeueOutput() {
return false; return false;
case CodecWrapper::DequeueStatus::kError: case CodecWrapper::DequeueStatus::kError:
DVLOG(1) << "DequeueOutputBuffer() error"; DVLOG(1) << "DequeueOutputBuffer() error";
EnterTerminalState(State::kError); EnterTerminalState(State::kError, "DequeueOutputBuffer failed");
return false; return false;
} }
DVLOG(3) << "DequeueOutputBuffer(): pts=" DVLOG(3) << "DequeueOutputBuffer(): pts="
...@@ -946,7 +973,7 @@ void MediaCodecVideoDecoder::ForwardVideoFrame( ...@@ -946,7 +973,7 @@ void MediaCodecVideoDecoder::ForwardVideoFrame(
// No |frame| indicates an error creating it. // No |frame| indicates an error creating it.
if (!frame) { if (!frame) {
DLOG(ERROR) << __func__ << " |frame| is null"; DLOG(ERROR) << __func__ << " |frame| is null";
EnterTerminalState(State::kError); EnterTerminalState(State::kError, "Could not create VideoFrame");
return; return;
} }
...@@ -1035,8 +1062,12 @@ void MediaCodecVideoDecoder::OnCodecDrained() { ...@@ -1035,8 +1062,12 @@ void MediaCodecVideoDecoder::OnCodecDrained() {
} }
} }
void MediaCodecVideoDecoder::EnterTerminalState(State state) { void MediaCodecVideoDecoder::EnterTerminalState(State state,
DVLOG(2) << __func__ << " " << static_cast<int>(state); const char* reason) {
DVLOG(2) << __func__ << " " << static_cast<int>(state) << " " << reason;
media_log_->AddEvent(media_log_->CreateStringEvent(
MediaLogEvent::MEDIA_INFO_LOG_ENTRY, "info", reason));
state_ = state; state_ = state;
DCHECK(InTerminalState()); DCHECK(InTerminalState());
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
namespace media { namespace media {
class MediaLog;
class ScopedAsyncTrace; class ScopedAsyncTrace;
struct SupportedVideoDecoderConfig; struct SupportedVideoDecoderConfig;
...@@ -64,6 +65,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder : public VideoDecoder { ...@@ -64,6 +65,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder : public VideoDecoder {
MediaCodecVideoDecoder( MediaCodecVideoDecoder(
const gpu::GpuPreferences& gpu_preferences, const gpu::GpuPreferences& gpu_preferences,
const gpu::GpuFeatureInfo& gpu_feature_info, const gpu::GpuFeatureInfo& gpu_feature_info,
std::unique_ptr<MediaLog> media_log,
DeviceInfo* device_info, DeviceInfo* device_info,
CodecAllocator* codec_allocator, CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser, std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
...@@ -193,8 +195,10 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder : public VideoDecoder { ...@@ -193,8 +195,10 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder : public VideoDecoder {
void CancelPendingDecodes(DecodeStatus status); void CancelPendingDecodes(DecodeStatus status);
// Sets |state_| and does common teardown for the terminal states. |state_| // Sets |state_| and does common teardown for the terminal states. |state_|
// must be either kSurfaceDestroyed or kError. // must be either kSurfaceDestroyed or kError. |reason| will be logged to
void EnterTerminalState(State state); // |media_log_| as an info event ("error" indicates that playback will stop,
// but we don't know that the renderer will do that).
void EnterTerminalState(State state, const char* reason);
bool InTerminalState(); bool InTerminalState();
// Releases |codec_| if it's not null. // Releases |codec_| if it's not null.
...@@ -216,6 +220,8 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder : public VideoDecoder { ...@@ -216,6 +220,8 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder : public VideoDecoder {
// position if required. // position if required.
PromotionHintAggregator::NotifyPromotionHintCB CreatePromotionHintCB(); PromotionHintAggregator::NotifyPromotionHintCB CreatePromotionHintCB();
std::unique_ptr<MediaLog> media_log_;
State state_ = State::kInitializing; State state_ = State::kInitializing;
// Whether initialization still needs to be done on the first decode call. // Whether initialization still needs to be done on the first decode call.
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "media/base/android/mock_android_overlay.h" #include "media/base/android/mock_android_overlay.h"
#include "media/base/android/mock_media_crypto_context.h" #include "media/base/android/mock_media_crypto_context.h"
#include "media/base/decoder_buffer.h" #include "media/base/decoder_buffer.h"
#include "media/base/media_util.h"
#include "media/base/test_helpers.h" #include "media/base/test_helpers.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "media/gpu/android/android_video_surface_chooser_impl.h" #include "media/gpu/android/android_video_surface_chooser_impl.h"
...@@ -149,8 +150,8 @@ class MediaCodecVideoDecoderTest : public testing::TestWithParam<VideoCodec> { ...@@ -149,8 +150,8 @@ class MediaCodecVideoDecoderTest : public testing::TestWithParam<VideoCodec> {
.WillByDefault(RunCallback<1>(texture_owner)); .WillByDefault(RunCallback<1>(texture_owner));
auto* observable_mcvd = new DestructionObservableMCVD( auto* observable_mcvd = new DestructionObservableMCVD(
gpu_preferences_, gpu_feature_info_, device_info_.get(), gpu_preferences_, gpu_feature_info_, std::make_unique<NullMediaLog>(),
codec_allocator_.get(), std::move(surface_chooser), device_info_.get(), codec_allocator_.get(), std::move(surface_chooser),
base::BindRepeating(&CreateAndroidOverlayCb), base::BindRepeating(&CreateAndroidOverlayCb),
base::Bind(&MediaCodecVideoDecoderTest::RequestOverlayInfoCb, base::Bind(&MediaCodecVideoDecoderTest::RequestOverlayInfoCb,
base::Unretained(this)), base::Unretained(this)),
......
...@@ -224,7 +224,8 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder( ...@@ -224,7 +224,8 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
auto ycbcr_helper = auto ycbcr_helper =
YCbCrHelper::Create(gpu_task_runner_, std::move(get_stub_cb)); YCbCrHelper::Create(gpu_task_runner_, std::move(get_stub_cb));
video_decoder = std::make_unique<MediaCodecVideoDecoder>( video_decoder = std::make_unique<MediaCodecVideoDecoder>(
gpu_preferences_, gpu_feature_info_, DeviceInfo::GetInstance(), gpu_preferences_, gpu_feature_info_, media_log->Clone(),
DeviceInfo::GetInstance(),
CodecAllocator::GetInstance(gpu_task_runner_), CodecAllocator::GetInstance(gpu_task_runner_),
std::make_unique<AndroidVideoSurfaceChooserImpl>( std::make_unique<AndroidVideoSurfaceChooserImpl>(
DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()), DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()),
......
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