Commit c1dab74f authored by Ted Meyer's avatar Ted Meyer Committed by Commit Bot

Adds NotifyError for Status types

And, as a use case, logs failure reason for decoders when they
can't be initialized.

This currently just dumps the status as JSON into the media log. I've
not implemented a frontend for this in devtools yet.

Change-Id: I3aea5f027078e3f2979eaeeebc08549aa8a393a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2141622Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Commit-Queue: Ted Meyer <tmathmeyer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757508}
parent 5f40a877
......@@ -65,6 +65,13 @@ void MediaLog::NotifyError(PipelineStatus status) {
AddLogRecord(std::move(record));
}
void MediaLog::NotifyError(Status status) {
DCHECK(!status.is_ok());
std::string output_str;
base::JSONWriter::Write(MediaSerialize(status), &output_str);
AddMessage(MediaLogMessageLevel::kERROR, output_str);
}
void MediaLog::OnWebMediaPlayerDestroyedLocked() {}
void MediaLog::OnWebMediaPlayerDestroyed() {
AddEvent<MediaLogEvent::kWebMediaPlayerDestroyed>();
......
......@@ -81,6 +81,9 @@ class MEDIA_EXPORT MediaLog {
// TODO(tmathmeyer) replace with Status when that's ready.
void NotifyError(PipelineStatus status);
// Notify a non-ok Status. This method Should _not_ be given an OK status.
void NotifyError(Status status);
// Notify the media log that the player is destroyed. Some implementations
// will want to change event handling based on this.
void OnWebMediaPlayerDestroyed();
......
......@@ -165,6 +165,14 @@ void DecoderSelector<StreamType>::OnDecoderInitializeDone(Status status) {
DCHECK(task_runner_->BelongsToCurrentThread());
if (!status.is_ok()) {
// TODO(tmathmeyer) this might be noisy in media log. Consider batching
// all failures as causes to a single Status object and only surfacing it if
// decoder selection fails entirely.
media_log_->NotifyError(
Status(StatusCode::kDecoderFailedInitialization)
.WithData("Decoder name", decoder_->GetDisplayName())
.AddCause(std::move(status)));
// Try the next decoder on the list.
decoder_.reset();
InitializeDecoder();
......
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