0

Break out DecoderStatus from Status.

Moves all the status codes that media::Decoder used for ::Initialize()
and ::Decode() out into their own TypedStatus implementation.

This is the last major thing to remove from StatusCodeType - with just
Mojo and PipelineError left.

R=liberato

Change-Id: I6ba6af1151076cb5a67a2c5a2395ced53d98faef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3353823
Reviewed-by: Kenneth MacKay <kmackay@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Eugene Zemtsov <eugene@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Reviewed-by: Yusuke Sato <yusukes@chromium.org>
Commit-Queue: Ted (Chromium) Meyer <tmathmeyer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#957889}
This commit is contained in:
Ted Meyer
2022-01-12 02:37:27 +00:00
committed by Chromium LUCI CQ
parent f399d1ac08
commit a8afec221e
140 changed files with 1103 additions and 1075 deletions
ash/components/arc
chromecast/media/cma/decoder
content/renderer/pepper
media
base
cast
cdm
filters
gpu
mojo
renderers
test
video
third_party/blink/renderer

@ -325,12 +325,8 @@ mojom("media") {
cpp = "media::VideoPixelFormat"
},
{
mojom = "arc.mojom.DecodeStatus"
cpp = "media::DecodeStatus"
},
{
mojom = "arc.mojom.Status"
cpp = "media::Status"
mojom = "arc.mojom.DecoderStatus"
cpp = "media::DecoderStatus"
},
]
traits_headers = [ "video_accelerator_mojom_traits.h" ]

@ -228,85 +228,45 @@ bool StructTraits<arc::mojom::VideoFrameLayoutDataView,
}
// static
arc::mojom::DecodeStatus
EnumTraits<arc::mojom::DecodeStatus, media::DecodeStatus>::ToMojom(
media::DecodeStatus input) {
switch (input) {
case media::DecodeStatus::kOk:
return arc::mojom::DecodeStatus::OK;
case media::DecodeStatus::kAborted:
return arc::mojom::DecodeStatus::ABORTED;
case media::DecodeStatus::kDecoderFailedDecode:
return arc::mojom::DecodeStatus::DECODE_FAILED;
default:
NOTREACHED() << "unknown decode status: " << static_cast<int>(input);
return arc::mojom::DecodeStatus::DECODE_FAILED;
}
}
// static
bool EnumTraits<arc::mojom::DecodeStatus, media::DecodeStatus>::FromMojom(
arc::mojom::DecodeStatus input,
media::DecodeStatus* output) {
switch (input) {
case arc::mojom::DecodeStatus::OK:
*output = media::DecodeStatus::kOk;
return true;
case arc::mojom::DecodeStatus::ABORTED:
*output = media::DecodeStatus::kAborted;
return true;
case arc::mojom::DecodeStatus::DECODE_FAILED:
*output = media::DecodeStatus::kDecoderFailedDecode;
return true;
}
NOTREACHED() << "unknown decode status: " << static_cast<int>(input);
return false;
}
// static
arc::mojom::Status EnumTraits<arc::mojom::Status, media::Status>::ToMojom(
media::Status input) {
arc::mojom::DecoderStatus
EnumTraits<arc::mojom::DecoderStatus, media::DecoderStatus>::ToMojom(
media::DecoderStatus input) {
switch (input.code()) {
case media::StatusCode::kOk:
return arc::mojom::Status::OK;
case media::StatusCode::kAborted:
return arc::mojom::Status::ABORTED;
case media::StatusCode::kInvalidArgument:
return arc::mojom::Status::INVALID_ARGUMENT;
case media::StatusCode::kDecoderFailedDecode:
return arc::mojom::Status::DECODER_DECODE_FAILED;
case media::StatusCode::kDecoderInitializationFailed:
return arc::mojom::Status::DECODER_INITIALIZATION_FAILED;
case media::StatusCode::kDecoderCreationFailed:
return arc::mojom::Status::DECODER_CREATION_FAILED;
case media::DecoderStatus::Codes::kOk:
return arc::mojom::DecoderStatus::OK;
case media::DecoderStatus::Codes::kAborted:
return arc::mojom::DecoderStatus::ABORTED;
case media::DecoderStatus::Codes::kFailed:
return arc::mojom::DecoderStatus::FAILED;
case media::DecoderStatus::Codes::kFailedToCreateDecoder:
return arc::mojom::DecoderStatus::CREATION_FAILED;
case media::DecoderStatus::Codes::kInvalidArgument:
return arc::mojom::DecoderStatus::INVALID_ARGUMENT;
default:
NOTREACHED() << "unknown status: " << static_cast<int>(input.code());
return arc::mojom::Status::INVALID_ARGUMENT;
return arc::mojom::DecoderStatus::INVALID_ARGUMENT;
}
}
// static
bool EnumTraits<arc::mojom::Status, media::Status>::FromMojom(
arc::mojom::Status input,
media::Status* output) {
bool EnumTraits<arc::mojom::DecoderStatus, media::DecoderStatus>::FromMojom(
arc::mojom::DecoderStatus input,
media::DecoderStatus* output) {
switch (input) {
case arc::mojom::Status::OK:
*output = media::StatusCode::kOk;
case arc::mojom::DecoderStatus::OK:
*output = media::DecoderStatus::Codes::kOk;
return true;
case arc::mojom::Status::ABORTED:
*output = media::StatusCode::kAborted;
case arc::mojom::DecoderStatus::ABORTED:
*output = media::DecoderStatus::Codes::kAborted;
return true;
case arc::mojom::Status::INVALID_ARGUMENT:
*output = media::StatusCode::kInvalidArgument;
case arc::mojom::DecoderStatus::FAILED:
*output = media::DecoderStatus::Codes::kFailed;
return true;
case arc::mojom::Status::DECODER_DECODE_FAILED:
*output = media::StatusCode::kDecoderFailedDecode;
case arc::mojom::DecoderStatus::CREATION_FAILED:
*output = media::DecoderStatus::Codes::kFailedToCreateDecoder;
return true;
case arc::mojom::Status::DECODER_INITIALIZATION_FAILED:
*output = media::StatusCode::kDecoderInitializationFailed;
return true;
case arc::mojom::Status::DECODER_CREATION_FAILED:
*output = media::StatusCode::kDecoderCreationFailed;
case arc::mojom::DecoderStatus::INVALID_ARGUMENT:
*output = media::DecoderStatus::Codes::kInvalidArgument;
return true;
}
NOTREACHED() << "unknown status: " << static_cast<int>(input);

@ -11,7 +11,7 @@
#include "ash/components/arc/mojom/video_decoder.mojom-shared.h"
#include "ash/components/arc/video_accelerator/video_frame_plane.h"
#include "media/base/color_plane_layout.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/status.h"
#include "media/base/video_codecs.h"
#include "media/base/video_frame_layout.h"
@ -135,18 +135,11 @@ struct StructTraits<arc::mojom::VideoFrameLayoutDataView,
};
template <>
struct EnumTraits<arc::mojom::DecodeStatus, media::DecodeStatus> {
static arc::mojom::DecodeStatus ToMojom(media::DecodeStatus input);
struct EnumTraits<arc::mojom::DecoderStatus, media::DecoderStatus> {
static arc::mojom::DecoderStatus ToMojom(media::DecoderStatus input);
static bool FromMojom(arc::mojom::DecodeStatus input,
media::DecodeStatus* output);
};
template <>
struct EnumTraits<arc::mojom::Status, media::Status> {
static arc::mojom::Status ToMojom(media::Status input);
static bool FromMojom(arc::mojom::Status input, media::Status* output);
static bool FromMojom(arc::mojom::DecoderStatus input,
media::DecoderStatus* output);
};
} // namespace mojo

@ -9,24 +9,17 @@ import "ash/components/arc/mojom/video_common.mojom";
import "ash/components/arc/mojom/video_frame_pool.mojom";
import "sandbox/policy/mojom/sandbox.mojom";
// Based on media::Status, only a limited set of relevant status codes are
// currently added here.
// Based on media::DecoderStatus, only a limited set of relevant status codes
// are currently added here.
// TODO(b:189278506): ensure that the ARCVM side of the video decoder uses the
// new entries listed here.
[Extensible]
enum Status {
enum DecoderStatus {
OK = 0,
ABORTED = 1,
INVALID_ARGUMENT = 2,
DECODER_DECODE_FAILED = 3,
DECODER_INITIALIZATION_FAILED = 4,
DECODER_CREATION_FAILED = 5,
};
// Based on media::DecodeStatus
[Extensible]
enum DecodeStatus {
OK = 0,
ABORTED = 1,
DECODE_FAILED = 2,
FAILED = 2,
INVALID_ARGUMENT = 3,
CREATION_FAILED = 4,
};
// Based on media::DecoderBuffer
@ -72,10 +65,10 @@ interface VideoDecoder {
Initialize@0(VideoDecoderConfig config,
pending_remote<VideoDecoderClient> client,
pending_associated_receiver<VideoFramePool> video_frame_pool)
=> (Status status);
=> (DecoderStatus status);
// Decode the specified frame, flushes if an EOS buffer is passed
Decode@1(DecoderBuffer buffer) => (DecodeStatus status);
Decode@1(DecoderBuffer buffer) => (DecoderStatus status);
// Reset the decoder. All pending Decode requests will be finished or aborted
// before the callback is called.
@ -95,5 +88,5 @@ interface VideoDecoderClient {
int64 timestamp);
// Notify the client an error happened while decoding the stream.
OnError@1(Status status);
OnError@1(DecoderStatus status);
};

@ -421,8 +421,8 @@ void GpuArcVideoDecodeAccelerator::InitializeTask(
}
void GpuArcVideoDecodeAccelerator::NotifyInitializationComplete(
media::Status status) {
DVLOGF(4) << "status: " << status.code();
media::DecoderStatus status) {
DVLOGF(4) << "status: " << static_cast<int>(status.code());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
OnInitializeDone(

@ -51,7 +51,7 @@ class GpuArcVideoDecodeAccelerator
~GpuArcVideoDecodeAccelerator() override;
// Implementation of media::VideoDecodeAccelerator::Client interface.
void NotifyInitializationComplete(media::Status status) override;
void NotifyInitializationComplete(media::DecoderStatus status) override;
void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
media::VideoPixelFormat format,
uint32_t textures_per_buffer,

@ -17,7 +17,7 @@
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/media_util.h"
#include "media/base/video_codecs.h"
#include "media/base/video_frame.h"
@ -90,14 +90,13 @@ void GpuArcVideoDecoder::Initialize(
if (decoder_) {
VLOGF(1) << "Re-initialization is not allowed";
OnInitializeDone(
media::Status(media::StatusCode::kDecoderInitializationFailed));
OnInitializeDone(media::DecoderStatus::Codes::kFailed);
return;
}
if (num_instances_ >= kMaxConcurrentInstances) {
VLOGF(1) << "Maximum concurrent instances reached: " << num_instances_;
OnInitializeDone(media::Status(media::StatusCode::kDecoderCreationFailed));
OnInitializeDone(media::DecoderStatus::Codes::kFailedToCreateDecoder);
return;
}
@ -110,7 +109,7 @@ void GpuArcVideoDecoder::Initialize(
if (!decoder_) {
VLOGF(1) << "Failed to create video decoder";
OnInitializeDone(media::Status(media::StatusCode::kDecoderCreationFailed));
OnInitializeDone(media::DecoderStatus::Codes::kFailedToCreateDecoder);
return;
}
num_instances_++;
@ -161,7 +160,7 @@ void GpuArcVideoDecoder::Decode(arc::mojom::DecoderBufferPtr buffer,
mojom::BufferPtr& buffer_ptr = buffer->get_buffer();
base::ScopedFD fd = buffer_ptr->handle_fd.TakeFD();
if (!fd.is_valid()) {
OnError(FROM_HERE, media::Status(media::StatusCode::kInvalidArgument));
OnError(media::DecoderStatus::Codes::kInvalidArgument);
return;
}
DVLOGF(4) << "timestamp: " << buffer_ptr->timestamp << ", fd: " << fd.get();
@ -183,7 +182,7 @@ void GpuArcVideoDecoder::Decode(arc::mojom::DecoderBufferPtr buffer,
CreateDecoderBuffer(std::move(fd), buffer_ptr->offset, buffer_ptr->size);
if (!decoder_buffer) {
VLOGF(1) << "Failed to create decoder buffer from fd";
OnError(FROM_HERE, media::Status(media::StatusCode::kInvalidArgument));
OnError(media::DecoderStatus::Codes::kInvalidArgument);
return;
}
@ -234,28 +233,24 @@ void GpuArcVideoDecoder::Reset(ResetCallback callback) {
base::Unretained(this), std::move(callback)));
}
void GpuArcVideoDecoder::OnInitializeDone(media::Status status) {
DVLOGF(4) << "status: " << status.code();
void GpuArcVideoDecoder::OnInitializeDone(media::DecoderStatus status) {
DVLOGF(4) << "status: " << static_cast<int>(status.code());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Report initialization status to UMA.
base::UmaHistogramEnumeration("Media.GpuArcVideoDecoder.InitializeResult",
status.code());
std::move(init_callback_).Run(status);
}
void GpuArcVideoDecoder::OnDecodeDone(DecodeCallback callback,
media::Status status) {
DVLOGF(4) << "status: " << status.code();
media::DecoderStatus status) {
DVLOGF(4) << "status: " << static_cast<int>(status.code());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!status.is_ok() && (status.code() != media::StatusCode::kAborted)) {
if (!status.is_ok() && status != media::DecoderStatus::Codes::kAborted) {
std::move(callback).Run(status.code());
return;
}
std::move(callback).Run(media::DecodeStatus::OK);
std::move(callback).Run(media::DecoderStatus::Codes::kOk);
}
void GpuArcVideoDecoder::OnFrameReady(scoped_refptr<media::VideoFrame> frame) {
@ -267,7 +262,7 @@ void GpuArcVideoDecoder::OnFrameReady(scoped_refptr<media::VideoFrame> frame) {
video_frame_pool_->GetVideoFrameId(frame.get());
if (!video_frame_id) {
VLOGF(1) << "Failed to get video frame id.";
OnError(FROM_HERE, media::Status(media::StatusCode::kInvalidArgument));
OnError(media::DecoderStatus::Codes::kInvalidArgument);
return;
}
@ -295,7 +290,7 @@ void GpuArcVideoDecoder::OnResetDone() {
if (!reset_callback_) {
VLOGF(1) << "Unexpected OnResetDone() callback received from VD";
OnError(FROM_HERE, media::Status(media::StatusCode::kInvalidArgument));
OnError(media::DecoderStatus::Codes::kInvalidArgument);
return;
}
@ -312,8 +307,7 @@ void GpuArcVideoDecoder::OnRequestVideoFrames() {
client_video_frames_.clear();
}
void GpuArcVideoDecoder::OnError(base::Location location,
const media::Status& status) {
void GpuArcVideoDecoder::OnError(media::DecoderStatus status) {
VLOGF(1) << "error: " << static_cast<int>(status.code());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
@ -327,7 +321,7 @@ void GpuArcVideoDecoder::OnError(base::Location location,
error_state_ = true;
if (client_) {
client_->OnError(status);
client_->OnError(std::move(status));
}
// Abort all pending requests.
@ -364,7 +358,7 @@ void GpuArcVideoDecoder::HandleDecodeRequest(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (error_state_) {
std::move(callback).Run(media::DecodeStatus::DECODE_ERROR);
std::move(callback).Run(media::DecoderStatus::Codes::kFailed);
return;
}
if (!decoder_) {
@ -387,7 +381,7 @@ void GpuArcVideoDecoder::HandleResetRequest(ResetCallback callback) {
if (!decoder_) {
VLOGF(1) << "VD not initialized";
OnError(FROM_HERE, media::Status(media::StatusCode::kInvalidArgument));
OnError(media::DecoderStatus::Codes::kInvalidArgument);
return;
}

@ -56,9 +56,9 @@ class GpuArcVideoDecoder : public mojom::VideoDecoder {
using Request = base::OnceClosure;
// Called by the decoder when initialization is done.
void OnInitializeDone(media::Status status);
void OnInitializeDone(media::DecoderStatus status);
// Called by the decoder when the specified buffer has been decoded.
void OnDecodeDone(DecodeCallback callback, media::Status status);
void OnDecodeDone(DecodeCallback callback, media::DecoderStatus status);
// Called by the decoder when a decoded frame is ready.
void OnFrameReady(scoped_refptr<media::VideoFrame> frame);
// Called by the decoder when a reset has been completed.
@ -66,7 +66,7 @@ class GpuArcVideoDecoder : public mojom::VideoDecoder {
// Called by the video frame pool when new frames have been requested.
void OnRequestVideoFrames();
// Called when an error occurred.
void OnError(base::Location location, const media::Status& status);
void OnError(media::DecoderStatus status);
// Handle all requests that are currently in the |requests_| queue.
void HandleRequests();

@ -12,7 +12,7 @@
#include "base/posix/eintr_wrapper.h"
#include "build/build_config.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/format_utils.h"
#include "media/base/video_types.h"
#include "media/gpu/buffer_validation.h"

@ -157,7 +157,7 @@ class CastAudioDecoderImpl : public CastAudioDecoder {
weak_this_, timestamp));
}
void OnInitialized(::media::Status status) {
void OnInitialized(::media::DecoderStatus status) {
DCHECK(!initialized_);
initialized_ = true;
if (status.is_ok()) {
@ -185,7 +185,7 @@ class CastAudioDecoderImpl : public CastAudioDecoder {
}
void OnDecodeStatus(base::TimeDelta buffer_timestamp,
::media::Status status) {
::media::DecoderStatus status) {
DCHECK(pending_decode_callback_);
Status result_status = kDecodeOk;

@ -119,9 +119,9 @@ class VideoDecoderShim::DecoderImpl {
void Stop();
private:
void OnInitDone(media::Status status);
void OnInitDone(media::DecoderStatus status);
void DoDecode();
void OnDecodeComplete(media::Status status);
void OnDecodeComplete(media::DecoderStatus status);
void OnOutputComplete(scoped_refptr<media::VideoFrame> frame);
void OnResetComplete();
@ -182,7 +182,7 @@ void VideoDecoderShim::DecoderImpl::Initialize(
weak_ptr_factory_.GetWeakPtr()),
base::NullCallback());
#else
OnInitDone(media::StatusCode::kDecoderFailedInitialization);
OnInitDone(media::DecoderStatus::Codes::kUnsupportedCodec);
#endif // BUILDFLAG(ENABLE_LIBVPX) || BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
}
@ -227,7 +227,7 @@ void VideoDecoderShim::DecoderImpl::Stop() {
// This instance is deleted once we exit this scope.
}
void VideoDecoderShim::DecoderImpl::OnInitDone(media::Status status) {
void VideoDecoderShim::DecoderImpl::OnInitDone(media::DecoderStatus status) {
if (!status.is_ok()) {
main_task_runner_->PostTask(
FROM_HERE,
@ -253,14 +253,15 @@ void VideoDecoderShim::DecoderImpl::DoDecode() {
pending_decodes_.pop();
}
void VideoDecoderShim::DecoderImpl::OnDecodeComplete(media::Status status) {
void VideoDecoderShim::DecoderImpl::OnDecodeComplete(
media::DecoderStatus status) {
DCHECK(awaiting_decoder_);
awaiting_decoder_ = false;
int32_t result;
switch (status.code()) {
case media::StatusCode::kOk:
case media::StatusCode::kAborted:
case media::DecoderStatus::Codes::kOk:
case media::DecoderStatus::Codes::kAborted:
result = PP_OK;
break;
default:

@ -136,8 +136,6 @@ source_set("base") {
"data_buffer.h",
"data_source.cc",
"data_source.h",
"decode_status.cc",
"decode_status.h",
"decoder.cc",
"decoder.h",
"decoder_buffer.cc",
@ -146,6 +144,8 @@ source_set("base") {
"decoder_buffer_queue.h",
"decoder_factory.cc",
"decoder_factory.h",
"decoder_status.cc",
"decoder_status.h",
"decrypt_config.cc",
"decrypt_config.h",
"decryptor.cc",

@ -17,7 +17,7 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "media/base/android/media_codec_bridge.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/encryption_scheme.h"
#include "media/base/media_export.h"
#include "media/base/subsample_entry.h"

@ -9,12 +9,11 @@
#include "base/memory/ref_counted.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/channel_layout.h"
#include "media/base/decode_status.h"
#include "media/base/decoder.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decoder_status.h"
#include "media/base/media_export.h"
#include "media/base/pipeline_status.h"
#include "media/base/status.h"
#include "media/base/waiting.h"
namespace media {
@ -25,7 +24,7 @@ class CdmContext;
class MEDIA_EXPORT AudioDecoder : public Decoder {
public:
// Callback for Decoder initialization.
using InitCB = base::OnceCallback<void(Status)>;
using InitCB = base::OnceCallback<void(DecoderStatus)>;
// Callback for AudioDecoder to return a decoded frame whenever it becomes
// available. Only non-EOS frames should be returned via this callback.
@ -37,7 +36,7 @@ class MEDIA_EXPORT AudioDecoder : public Decoder {
// decode was aborted, which does not necessarily indicate an error. For
// example, a Reset() can trigger this. Any other status code indicates that
// the decoder encountered an error, and must be reset.
using DecodeCB = base::OnceCallback<void(Status)>;
using DecodeCB = base::OnceCallback<void(DecoderStatus)>;
AudioDecoder();

@ -1,71 +0,0 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/decode_status.h"
#include <ostream>
#include "base/trace_event/trace_event.h"
#include "media/base/status.h"
namespace media {
const char* GetDecodeStatusString(DecodeStatus status) {
switch (status) {
case DecodeStatus::OK:
return "DecodeStatus::OK";
case DecodeStatus::ABORTED:
return "DecodeStatus::ABORTED";
case DecodeStatus::DECODE_ERROR:
return "DecodeStatus::DECODE_ERROR";
default:
// TODO(liberato): Temporary while converting to media::Status. This
// fn should go away.
return "DecodeStatus::UNKNOWN_ERROR";
}
NOTREACHED();
return "";
}
// static
bool ScopedDecodeTrace::IsEnabled() {
bool enable_decode_traces = false;
TRACE_EVENT_CATEGORY_GROUP_ENABLED("media", &enable_decode_traces);
return enable_decode_traces;
}
ScopedDecodeTrace::ScopedDecodeTrace(const char* trace_name,
bool is_key_frame,
base::TimeDelta timestamp)
: trace_name_(trace_name) {
DCHECK(trace_name_);
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2("media", trace_name_, TRACE_ID_LOCAL(this),
"is_key_frame", is_key_frame,
"timestamp_us", timestamp.InMicroseconds());
}
ScopedDecodeTrace::ScopedDecodeTrace(const char* trace_name,
const DecoderBuffer& buffer)
: trace_name_(trace_name) {
DCHECK(trace_name_);
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
"media", trace_name_, TRACE_ID_LOCAL(this), "decoder_buffer",
buffer.AsHumanReadableString(/*verbose=*/true));
}
ScopedDecodeTrace::~ScopedDecodeTrace() {
if (!closed_)
EndTrace(DecodeStatus::ABORTED);
}
void ScopedDecodeTrace::EndTrace(const Status& status) {
DCHECK(!closed_);
closed_ = true;
TRACE_EVENT_NESTABLE_ASYNC_END1("media", trace_name_, TRACE_ID_LOCAL(this),
"status",
GetDecodeStatusString(status.code()));
}
} // namespace media

@ -0,0 +1,85 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/decoder_status.h"
#include <sstream>
#include "base/trace_event/trace_event.h"
#include "media/base/status.h"
namespace media {
namespace {
const std::string GetDecodeStatusString(const DecoderStatus& status) {
#define STRINGIFY(V) \
case V: \
return #V
switch (status.code()) {
STRINGIFY(DecoderStatus::Codes::kOk);
STRINGIFY(DecoderStatus::Codes::kFailed);
STRINGIFY(DecoderStatus::Codes::kAborted);
STRINGIFY(DecoderStatus::Codes::kInvalidArgument);
STRINGIFY(DecoderStatus::Codes::kInterrupted);
STRINGIFY(DecoderStatus::Codes::kNotInitialized);
STRINGIFY(DecoderStatus::Codes::kMissingCDM);
STRINGIFY(DecoderStatus::Codes::kFailedToGetVideoFrame);
STRINGIFY(DecoderStatus::Codes::kPlatformDecodeFailure);
STRINGIFY(DecoderStatus::Codes::kMalformedBitstream);
STRINGIFY(DecoderStatus::Codes::kFailedToGetDecoderBuffer);
STRINGIFY(DecoderStatus::Codes::kDecoderStreamInErrorState);
STRINGIFY(DecoderStatus::Codes::kDecoderStreamReinitFailed);
STRINGIFY(DecoderStatus::Codes::kDecoderStreamDemuxerError);
STRINGIFY(DecoderStatus::Codes::kUnsupportedProfile);
STRINGIFY(DecoderStatus::Codes::kUnsupportedCodec);
STRINGIFY(DecoderStatus::Codes::kUnsupportedConfig);
STRINGIFY(DecoderStatus::Codes::kUnsupportedEncryptionMode);
STRINGIFY(DecoderStatus::Codes::kCantChangeCodec);
STRINGIFY(DecoderStatus::Codes::kFailedToCreateDecoder);
STRINGIFY(DecoderStatus::Codes::kKeyFrameRequired);
}
#undef STRINGIFY
}
} // namespace
// static
bool ScopedDecodeTrace::IsEnabled() {
bool enable_decode_traces = false;
TRACE_EVENT_CATEGORY_GROUP_ENABLED("media", &enable_decode_traces);
return enable_decode_traces;
}
ScopedDecodeTrace::ScopedDecodeTrace(const char* trace_name,
bool is_key_frame,
base::TimeDelta timestamp)
: trace_name_(trace_name) {
DCHECK(trace_name_);
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2("media", trace_name_, TRACE_ID_LOCAL(this),
"is_key_frame", is_key_frame,
"timestamp_us", timestamp.InMicroseconds());
}
ScopedDecodeTrace::ScopedDecodeTrace(const char* trace_name,
const DecoderBuffer& buffer)
: trace_name_(trace_name) {
DCHECK(trace_name_);
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
"media", trace_name_, TRACE_ID_LOCAL(this), "decoder_buffer",
buffer.AsHumanReadableString(/*verbose=*/true));
}
ScopedDecodeTrace::~ScopedDecodeTrace() {
if (!closed_)
EndTrace(DecoderStatus::Codes::kAborted);
}
void ScopedDecodeTrace::EndTrace(const DecoderStatus& status) {
DCHECK(!closed_);
closed_ = true;
TRACE_EVENT_NESTABLE_ASYNC_END1("media", trace_name_, TRACE_ID_LOCAL(this),
"status", GetDecodeStatusString(status));
}
} // namespace media

@ -1,24 +1,49 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_DECODE_STATUS_H_
#define MEDIA_BASE_DECODE_STATUS_H_
#include <iosfwd>
#ifndef MEDIA_BASE_DECODER_STATUS_H_
#define MEDIA_BASE_DECODER_STATUS_H_
#include "media/base/decoder_buffer.h"
#include "media/base/media_export.h"
#include "media/base/status.h"
#include "media/base/status_codes.h"
namespace media {
// TODO(crbug.com/1129662): This is temporary, to allow DecodeStatus::OK to
// work, while we replace DecodeStatus with actual status codes.
using DecodeStatus = StatusCode;
struct DecoderStatusTraits {
enum class Codes : StatusCodeType {
// Shared & General errors
kOk = 0,
kFailed = 1,
kAborted = 2, // TODO(*) document _why_ aborted is a thing
kInvalidArgument = 3,
kInterrupted = 4,
MEDIA_EXPORT const char* GetDecodeStatusString(DecodeStatus status);
// Reasons for failing to decode
kNotInitialized = 100,
kMissingCDM = 101,
kFailedToGetVideoFrame = 102,
kPlatformDecodeFailure = 103,
kMalformedBitstream = 104,
kFailedToGetDecoderBuffer = 107,
kDecoderStreamInErrorState = 108,
kDecoderStreamReinitFailed = 109,
kDecoderStreamDemuxerError = 110,
kKeyFrameRequired = 111,
// Reasons for failing to initialize
kUnsupportedProfile = 200,
kUnsupportedCodec = 201,
kUnsupportedConfig = 202,
kUnsupportedEncryptionMode = 203,
kCantChangeCodec = 204,
kFailedToCreateDecoder = 205,
};
static constexpr StatusGroupType Group() { return "DecoderStatusCodes"; }
static constexpr Codes DefaultEnumValue() { return Codes::kOk; }
};
using DecoderStatus = TypedStatus<DecoderStatusTraits>;
// Helper class for ensuring that Decode() traces are properly unique and closed
// if the Decode is aborted via a WeakPtr invalidation. We use the |this|
@ -43,7 +68,7 @@ class MEDIA_EXPORT ScopedDecodeTrace {
~ScopedDecodeTrace();
// Completes the Decode() trace with the given status.
void EndTrace(const Status& status);
void EndTrace(const DecoderStatus& status);
private:
const char* trace_name_;
@ -52,4 +77,4 @@ class MEDIA_EXPORT ScopedDecodeTrace {
} // namespace media
#endif // MEDIA_BASE_DECODE_STATUS_H_
#endif // MEDIA_BASE_DECODER_STATUS_H_

@ -16,8 +16,8 @@
#include "media/base/channel_layout.h"
#include "media/base/container_names.h"
#include "media/base/content_decryption_module.h"
#include "media/base/decode_status.h"
#include "media/base/decoder.h"
#include "media/base/decoder_status.h"
#include "media/base/decrypt_config.h"
#include "media/base/decryptor.h"
#include "media/base/demuxer_stream.h"

@ -224,7 +224,7 @@ class MEDIA_EXPORT TypedStatus {
}
const std::string group() const {
return data_ ? data_->group : Traits::Group();
return data_ ? data_->group : std::string(Traits::Group());
}
const std::string& message() const {

@ -29,29 +29,9 @@ enum class StatusCode : StatusCodeType {
// General errors: 0x00
kAborted = 0x0001,
kInvalidArgument = 0x0002,
kKeyFrameRequired = 0x0003,
kWrappedError = 0x0004,
// Decoder Errors: 0x01
kDecoderInitializeNeverCompleted = 0x0101,
kDecoderFailedDecode = 0x0102,
kDecoderUnsupportedProfile = 0x0103,
kDecoderUnsupportedCodec = 0x0104,
kDecoderUnsupportedConfig = 0x0105,
kEncryptedContentUnsupported = 0x0106,
kClearContentUnsupported = 0x0107,
kDecoderMissingCdmForEncryptedContent = 0x0108,
kDecoderInitializationFailed = 0x0109, // Prefer this one.
kDecoderFailedInitialization = kDecoderInitializationFailed, // Do not use.
kDecoderCantChangeCodec = 0x010A,
kDecoderCreationFailed = 0x010B, // Prefer this one.
kDecoderFailedCreation = kDecoderCreationFailed, // Do not use.
kInitializationUnspecifiedFailure = 0x010C,
kDecoderVideoFrameConstructionFailed = 0x010D,
kMakeContextCurrentFailed = 0x010E,
// This is a temporary error for use only by existing code during the
// DecodeStatus => Status conversion.
kDecodeErrorDoNotUse = 0x010F,
// MojoDecoder Errors: 0x04
kMojoDecoderNoWrappedDecoder = 0x0401,
@ -110,19 +90,6 @@ enum class StatusCode : StatusCodeType {
// proper status.
kDecoderStreamDemuxerError = 0x0B02,
// DecodeStatus temporary codes. These names were chosen to match the
// DecodeStatus enum, so that un-converted code can DecodeStatus::OK/etc.
// Note that OK must result in Status::is_ok(), since converted code will
// check for it. These will be removed when the conversion is complete.
//
// DO NOT ADD NEW USES OF OK/ABORTED/DECODE_ERROR.
OK = kOk, // Everything went as planned.
// Read aborted due to Reset() during pending read.
ABORTED = kAborted, // Read aborted due to Reset() during pending read.
// Decoder returned decode error. Note: Prefixed by DECODE_
// since ERROR is a reserved name (special macro) on Windows.
DECODE_ERROR = kDecodeErrorDoNotUse,
// Special codes
kGenericErrorPleaseRemove = 0x7999,
kCodeOnlyForTesting = std::numeric_limits<StatusCodeType>::max(),

@ -15,6 +15,7 @@
#include "base/strings/stringprintf.h"
#include "media/base/audio_parameters.h"
#include "media/base/channel_layout.h"
#include "media/base/decoder_status.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_log.h"
#include "media/base/pipeline_status.h"
@ -261,7 +262,7 @@ MATCHER(IsOkStatus, "") {
// True if and only if the Status would be interpreted as an error from a decode
// callback (not okay, not aborted).
MATCHER(IsDecodeErrorStatus, "") {
return !arg.is_ok() && arg.code() != StatusCode::kAborted;
return !arg.is_ok() && arg.code() != DecoderStatus::Codes::kAborted;
}
// Compares two {Audio|Video}DecoderConfigs

@ -6,8 +6,8 @@
#define MEDIA_BASE_VIDEO_DECODER_H_
#include "base/memory/ref_counted.h"
#include "media/base/decode_status.h"
#include "media/base/decoder.h"
#include "media/base/decoder_status.h"
#include "media/base/media_export.h"
#include "media/base/pipeline_status.h"
#include "media/base/waiting.h"
@ -23,7 +23,7 @@ class VideoFrame;
class MEDIA_EXPORT VideoDecoder : public Decoder {
public:
// Callback for Decoder initialization.
using InitCB = base::OnceCallback<void(Status)>;
using InitCB = base::OnceCallback<void(DecoderStatus)>;
// Callback for VideoDecoder to return a decoded frame whenever it becomes
// available. Only non-EOS frames should be returned via this callback.
@ -35,7 +35,7 @@ class MEDIA_EXPORT VideoDecoder : public Decoder {
// decode was aborted, which does not necessarily indicate an error. For
// example, a Reset() can trigger this. Any other status code indicates that
// the decoder encountered an error, and must be reset.
using DecodeCB = base::OnceCallback<void(Status)>;
using DecodeCB = base::OnceCallback<void(DecoderStatus)>;
VideoDecoder();
VideoDecoder(const VideoDecoder&) = delete;

@ -36,7 +36,7 @@ void VideoThumbnailDecoder::Start(VideoFrameCallback video_frame_callback) {
base::DoNothing());
}
void VideoThumbnailDecoder::OnVideoDecoderInitialized(Status status) {
void VideoThumbnailDecoder::OnVideoDecoderInitialized(DecoderStatus status) {
if (!status.is_ok()) {
NotifyComplete(nullptr);
return;
@ -50,7 +50,7 @@ void VideoThumbnailDecoder::OnVideoDecoderInitialized(Status status) {
weak_factory_.GetWeakPtr()));
}
void VideoThumbnailDecoder::OnVideoBufferDecoded(Status status) {
void VideoThumbnailDecoder::OnVideoBufferDecoded(DecoderStatus status) {
if (!status.is_ok()) {
NotifyComplete(nullptr);
return;
@ -62,7 +62,7 @@ void VideoThumbnailDecoder::OnVideoBufferDecoded(Status status) {
weak_factory_.GetWeakPtr()));
}
void VideoThumbnailDecoder::OnEosBufferDecoded(Status status) {
void VideoThumbnailDecoder::OnEosBufferDecoded(DecoderStatus status) {
if (!status.is_ok())
NotifyComplete(nullptr);
}

@ -39,9 +39,9 @@ class MEDIA_EXPORT VideoThumbnailDecoder {
void Start(VideoFrameCallback video_frame_callback);
private:
void OnVideoDecoderInitialized(Status status);
void OnVideoBufferDecoded(Status status);
void OnEosBufferDecoded(Status status);
void OnVideoDecoderInitialized(DecoderStatus status);
void OnVideoBufferDecoded(DecoderStatus status);
void OnEosBufferDecoded(DecoderStatus status);
// Called when the output frame is generated.
void OnVideoFrameDecoded(scoped_refptr<VideoFrame> frame);

@ -88,11 +88,11 @@ class VideoThumbnailDecoderTest : public testing::Test {
TEST_F(VideoThumbnailDecoderTest, Success) {
auto expected_frame = CreateFrame();
EXPECT_CALL(*mock_video_decoder(), Initialize_(_, _, _, _, _, _))
.WillOnce(DoAll(RunOnceCallback<3>(OkStatus()),
.WillOnce(DoAll(RunOnceCallback<3>(DecoderStatus::Codes::kOk),
RunCallback<4>(expected_frame)));
EXPECT_CALL(*mock_video_decoder(), Decode_(_, _))
.Times(2)
.WillRepeatedly(RunOnceCallback<1>(DecodeStatus::OK));
.WillRepeatedly(RunOnceCallback<1>(DecoderStatus::Codes::kOk));
Start();
EXPECT_TRUE(frame());
@ -102,7 +102,7 @@ TEST_F(VideoThumbnailDecoderTest, Success) {
TEST_F(VideoThumbnailDecoderTest, InitializationFailed) {
auto expected_frame = CreateFrame();
EXPECT_CALL(*mock_video_decoder(), Initialize_(_, _, _, _, _, _))
.WillOnce(RunOnceCallback<3>(StatusCode::kCodeOnlyForTesting));
.WillOnce(RunOnceCallback<3>(DecoderStatus::Codes::kFailed));
Start();
EXPECT_FALSE(frame());
@ -112,9 +112,9 @@ TEST_F(VideoThumbnailDecoderTest, InitializationFailed) {
TEST_F(VideoThumbnailDecoderTest, DecodingFailed) {
auto expected_frame = CreateFrame();
EXPECT_CALL(*mock_video_decoder(), Initialize_(_, _, _, _, _, _))
.WillOnce(RunOnceCallback<3>(OkStatus()));
.WillOnce(RunOnceCallback<3>(DecoderStatus::Codes::kOk));
EXPECT_CALL(*mock_video_decoder(), Decode_(_, _))
.WillOnce(RunOnceCallback<1>(DecodeStatus::DECODE_ERROR));
.WillOnce(RunOnceCallback<1>(DecoderStatus::Codes::kFailed));
Start();
EXPECT_FALSE(frame());

@ -59,7 +59,7 @@ namespace cast {
// See comment in end2end_unittest.cc for details on this value.
const double kVideoAcceptedPSNR = 38.0;
void SaveDecoderInitResult(bool* out_result, ::media::Status in_result) {
void SaveDecoderInitResult(bool* out_result, DecoderStatus in_result) {
*out_result = in_result.is_ok();
}
@ -160,7 +160,7 @@ class EndToEndFrameChecker
++count_frames_checked_;
}
void DecodeDone(Status status) { EXPECT_TRUE(status.is_ok()); }
void DecodeDone(DecoderStatus status) { EXPECT_TRUE(status.is_ok()); }
int count_frames_checked() const { return count_frames_checked_; }

@ -23,7 +23,7 @@
#include "base/run_loop.h"
#include "base/task/single_thread_task_executor.h"
#include "base/threading/thread_task_runner_handle.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/media_switches.h"
#include "media/base/media_util.h"
#include "media/cdm/cdm_type_conversion.h"
@ -186,7 +186,7 @@ class VideoDecoderAdapter final : public CdmVideoDecoder {
~VideoDecoderAdapter() final = default;
// CdmVideoDecoder implementation.
Status Initialize(const cdm::VideoDecoderConfig_3& config) final {
DecoderStatus Initialize(const cdm::VideoDecoderConfig_3& config) final {
auto clear_config = ToClearMediaVideoDecoderConfig(config);
DVLOG(1) << __func__ << ": " << clear_config.AsHumanReadableString();
DCHECK(!last_init_result_.has_value());
@ -244,7 +244,7 @@ class VideoDecoderAdapter final : public CdmVideoDecoder {
// "kAborted" shouldn't happen during a sync decode, so treat it as an
// error.
DCHECK_NE(decode_status.code(), StatusCode::kAborted);
DCHECK_NE(decode_status.code(), DecoderStatus::Codes::kAborted);
if (!decode_status.is_ok())
return cdm::kDecodeError;
@ -261,7 +261,7 @@ class VideoDecoderAdapter final : public CdmVideoDecoder {
}
private:
void OnInitialized(base::OnceClosure quit_closure, Status status) {
void OnInitialized(base::OnceClosure quit_closure, DecoderStatus status) {
DVLOG(1) << __func__ << " success = " << status.is_ok();
DCHECK(!last_init_result_.has_value());
last_init_result_ = std::move(status);
@ -282,7 +282,7 @@ class VideoDecoderAdapter final : public CdmVideoDecoder {
std::move(quit_closure).Run();
}
void OnDecoded(base::OnceClosure quit_closure, Status decode_status) {
void OnDecoded(base::OnceClosure quit_closure, DecoderStatus decode_status) {
DCHECK(!last_decode_status_.has_value());
last_decode_status_ = std::move(decode_status);
std::move(quit_closure).Run();
@ -293,8 +293,8 @@ class VideoDecoderAdapter final : public CdmVideoDecoder {
// Results of |video_decoder_| operations. Set iff the callback of the
// operation has been called.
absl::optional<Status> last_init_result_;
absl::optional<Status> last_decode_status_;
absl::optional<DecoderStatus> last_init_result_;
absl::optional<DecoderStatus> last_decode_status_;
// Queue of decoded video frames.
using VideoFrameQueue = base::queue<scoped_refptr<VideoFrame>>;

@ -11,7 +11,7 @@
#include "base/memory/ref_counted.h"
#include "media/base/decoder_buffer.h"
#include "media/base/status.h"
#include "media/base/decoder_status.h"
#include "media/cdm/api/content_decryption_module.h"
namespace media {
@ -22,8 +22,8 @@ class CdmVideoDecoder {
public:
using CdmVideoFrame = cdm::VideoFrame_2;
virtual ~CdmVideoDecoder() {}
virtual Status Initialize(const cdm::VideoDecoderConfig_3& config) = 0;
virtual ~CdmVideoDecoder() = default;
virtual DecoderStatus Initialize(const cdm::VideoDecoderConfig_3& config) = 0;
virtual void Deinitialize() = 0;
virtual void Reset() = 0;
virtual cdm::Status Decode(scoped_refptr<DecoderBuffer> buffer,

@ -46,7 +46,7 @@ MediaCodecAudioDecoder::~MediaCodecAudioDecoder() {
if (media_crypto_context_)
media_crypto_context_->SetMediaCryptoReadyCB(base::NullCallback());
ClearInputQueue(DecodeStatus::ABORTED);
ClearInputQueue(DecoderStatus::Codes::kAborted);
}
AudioDecoderType MediaCodecAudioDecoder::GetDecoderType() const {
@ -66,7 +66,7 @@ void MediaCodecAudioDecoder::Initialize(const AudioDecoderConfig& config,
// Initialization and reinitialization should not be called during pending
// decode.
DCHECK(input_queue_.empty());
ClearInputQueue(DecodeStatus::ABORTED);
ClearInputQueue(DecoderStatus::Codes::kAborted);
is_passthrough_ = MediaCodecUtil::IsPassthroughAudioFormat(config.codec());
sample_format_ = kSampleFormatS16;
@ -80,8 +80,7 @@ void MediaCodecAudioDecoder::Initialize(const AudioDecoderConfig& config,
if (state_ == STATE_ERROR) {
DVLOG(1) << "Decoder is in error state.";
BindToCurrentLoop(std::move(init_cb))
.Run(StatusCode::kDecoderFailedInitialization);
BindToCurrentLoop(std::move(init_cb)).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -96,7 +95,7 @@ void MediaCodecAudioDecoder::Initialize(const AudioDecoderConfig& config,
if (!is_codec_supported) {
DVLOG(1) << "Unsuported codec " << GetCodecName(config.codec());
BindToCurrentLoop(std::move(init_cb))
.Run(StatusCode::kDecoderUnsupportedCodec);
.Run(DecoderStatus::Codes::kUnsupportedCodec);
return;
}
@ -114,7 +113,7 @@ void MediaCodecAudioDecoder::Initialize(const AudioDecoderConfig& config,
"MediaCryptoContext is not supported";
SetState(STATE_ERROR);
BindToCurrentLoop(std::move(init_cb))
.Run(StatusCode::kDecoderMissingCdmForEncryptedContent);
.Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -126,13 +125,12 @@ void MediaCodecAudioDecoder::Initialize(const AudioDecoderConfig& config,
}
if (!CreateMediaCodecLoop()) {
BindToCurrentLoop(std::move(init_cb))
.Run(StatusCode::kDecoderFailedInitialization);
BindToCurrentLoop(std::move(init_cb)).Run(DecoderStatus::Codes::kFailed);
return;
}
SetState(STATE_READY);
BindToCurrentLoop(std::move(init_cb)).Run(OkStatus());
BindToCurrentLoop(std::move(init_cb)).Run(DecoderStatus::Codes::kOk);
}
bool MediaCodecAudioDecoder::CreateMediaCodecLoop() {
@ -171,7 +169,7 @@ void MediaCodecAudioDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
if (!buffer->end_of_stream() && buffer->timestamp() == kNoTimestamp) {
DVLOG(2) << __func__ << " " << buffer->AsHumanReadableString()
<< ": no timestamp, skipping this buffer";
std::move(bound_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -180,8 +178,8 @@ void MediaCodecAudioDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
// We get here if an error happens in DequeueOutput() or Reset().
DVLOG(2) << __func__ << " " << buffer->AsHumanReadableString()
<< ": Error state, returning decode error for all buffers";
ClearInputQueue(DecodeStatus::DECODE_ERROR);
std::move(bound_decode_cb).Run(DecodeStatus::DECODE_ERROR);
ClearInputQueue(DecoderStatus::Codes::kFailed);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -204,7 +202,7 @@ void MediaCodecAudioDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
void MediaCodecAudioDecoder::Reset(base::OnceClosure closure) {
DVLOG(2) << __func__;
ClearInputQueue(DecodeStatus::ABORTED);
ClearInputQueue(DecoderStatus::Codes::kAborted);
// Flush if we can, otherwise completely recreate and reconfigure the codec.
bool success = codec_loop_->TryFlush();
@ -267,7 +265,7 @@ void MediaCodecAudioDecoder::OnMediaCryptoReady(
if (media_crypto->is_null()) {
LOG(ERROR) << "MediaCrypto is not available, can't play encrypted stream.";
SetState(STATE_UNINITIALIZED);
std::move(init_cb).Run(StatusCode::kDecoderMissingCdmForEncryptedContent);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -280,12 +278,12 @@ void MediaCodecAudioDecoder::OnMediaCryptoReady(
// After receiving |media_crypto_| we can configure MediaCodec.
if (!CreateMediaCodecLoop()) {
SetState(STATE_UNINITIALIZED);
std::move(init_cb).Run(StatusCode::kDecoderFailedInitialization);
std::move(init_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
SetState(STATE_READY);
std::move(init_cb).Run(OkStatus());
std::move(init_cb).Run(DecoderStatus::Codes::kOk);
}
bool MediaCodecAudioDecoder::IsAnyInputPending() const {
@ -332,11 +330,11 @@ void MediaCodecAudioDecoder::OnInputDataQueued(bool success) {
return;
std::move(input_queue_.front().second)
.Run(success ? DecodeStatus::OK : DecodeStatus::DECODE_ERROR);
.Run(success ? DecoderStatus::Codes::kOk : DecoderStatus::Codes::kFailed);
input_queue_.pop_front();
}
void MediaCodecAudioDecoder::ClearInputQueue(DecodeStatus decode_status) {
void MediaCodecAudioDecoder::ClearInputQueue(DecoderStatus decode_status) {
DVLOG(2) << __func__;
for (auto& entry : input_queue_)
@ -354,7 +352,7 @@ void MediaCodecAudioDecoder::SetState(State new_state) {
void MediaCodecAudioDecoder::OnCodecLoopError() {
// If the codec transitions into the error state, then so should we.
SetState(STATE_ERROR);
ClearInputQueue(DecodeStatus::DECODE_ERROR);
ClearInputQueue(DecoderStatus::Codes::kFailed);
}
bool MediaCodecAudioDecoder::OnDecodedEos(
@ -376,7 +374,7 @@ bool MediaCodecAudioDecoder::OnDecodedEos(
// So, we shouldn't be in that state. So, just DCHECK here.
DCHECK_NE(state_, STATE_ERROR);
std::move(input_queue_.front()).second.Run(DecodeStatus::OK);
std::move(input_queue_.front()).second.Run(DecoderStatus::Codes::kOk);
input_queue_.pop_front();
return true;

@ -142,7 +142,7 @@ class MEDIA_EXPORT MediaCodecAudioDecoder : public AudioDecoder,
// Calls DecodeCB with |decode_status| for every frame in |input_queue| and
// then clears it.
void ClearInputQueue(DecodeStatus decode_status);
void ClearInputQueue(DecoderStatus decode_status);
// Helper method to change the state.
void SetState(State new_state);

@ -98,7 +98,8 @@ class AudioDecoderStreamTest : public testing::Test {
config.channel_layout(), config.channels(),
config.samples_per_second(), 1221, last_timestamp_)));
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(decode_cb), DecodeStatus::OK));
FROM_HERE,
base::BindOnce(std::move(decode_cb), DecoderStatus::Codes::kOk));
}
void RunUntilIdle() { task_environment_.RunUntilIdle(); }
@ -109,7 +110,7 @@ class AudioDecoderStreamTest : public testing::Test {
EXPECT_CALL(*decoder, Initialize_(_, _, _, _, _))
.Times(AnyNumber())
.WillRepeatedly(DoAll(SaveArg<3>(&decoder_output_cb_),
RunOnceCallback<2>(OkStatus())));
RunOnceCallback<2>(DecoderStatus::Codes::kOk)));
decoder_ = decoder.get();
std::vector<std::unique_ptr<AudioDecoder>> result;

@ -124,7 +124,7 @@ class AudioDecoderTest
params_(std::get<1>(GetParam())),
pending_decode_(false),
pending_reset_(false),
last_decode_status_(DecodeStatus::DECODE_ERROR) {
last_decode_status_(DecoderStatus::Codes::kFailed) {
switch (decoder_type_) {
case FFMPEG:
decoder_ = std::make_unique<FFmpegAudioDecoder>(
@ -151,7 +151,7 @@ class AudioDecoderTest
void DecodeBuffer(scoped_refptr<DecoderBuffer> buffer) {
ASSERT_FALSE(pending_decode_);
pending_decode_ = true;
last_decode_status_ = DecodeStatus::DECODE_ERROR;
last_decode_status_ = DecoderStatus::Codes::kFailed;
base::RunLoop run_loop;
decoder_->Decode(
@ -227,7 +227,7 @@ class AudioDecoderTest
bool success) {
decoder_->Initialize(config, nullptr,
base::BindOnce(
[](bool success, Status status) {
[](bool success, DecoderStatus status) {
EXPECT_EQ(status.is_ok(), success);
},
success),
@ -280,7 +280,7 @@ class AudioDecoderTest
decoded_audio_.push_back(std::move(buffer));
}
void DecodeFinished(base::OnceClosure quit_closure, Status status) {
void DecodeFinished(base::OnceClosure quit_closure, DecoderStatus status) {
EXPECT_TRUE(pending_decode_);
EXPECT_FALSE(pending_reset_);
pending_decode_ = false;
@ -353,7 +353,9 @@ class AudioDecoderTest
const scoped_refptr<AudioBuffer>& decoded_audio(size_t i) {
return decoded_audio_[i];
}
const Status& last_decode_status() const { return last_decode_status_; }
const DecoderStatus& last_decode_status() const {
return last_decode_status_;
}
private:
const TestAudioDecoderType decoder_type_;
@ -373,7 +375,7 @@ class AudioDecoderTest
std::unique_ptr<AudioDecoder> decoder_;
bool pending_decode_;
bool pending_reset_;
Status last_decode_status_;
DecoderStatus last_decode_status_ = DecoderStatus::Codes::kOk;
base::circular_deque<scoped_refptr<AudioBuffer>> decoded_audio_;
base::TimeDelta start_timestamp_;

@ -169,13 +169,14 @@ void Dav1dVideoDecoder::Initialize(const VideoDecoderConfig& config,
InitCB bound_init_cb = bind_callbacks_ ? BindToCurrentLoop(std::move(init_cb))
: std::move(init_cb);
if (config.is_encrypted()) {
std::move(bound_init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(bound_init_cb)
.Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
if (config.codec() != VideoCodec::kAV1) {
std::move(bound_init_cb)
.Run(Status(StatusCode::kDecoderUnsupportedCodec)
.Run(DecoderStatus(DecoderStatus::Codes::kUnsupportedCodec)
.WithData("codec", config.codec()));
return;
}
@ -211,14 +212,14 @@ void Dav1dVideoDecoder::Initialize(const VideoDecoderConfig& config,
// TODO(tmathmeyer) write the dav1d error into the data for the media error.
if (dav1d_open(&dav1d_decoder_, &s) < 0) {
std::move(bound_init_cb).Run(StatusCode::kDecoderFailedInitialization);
std::move(bound_init_cb).Run(DecoderStatus::Codes::kFailedToCreateDecoder);
return;
}
config_ = config;
state_ = DecoderState::kNormal;
output_cb_ = output_cb;
std::move(bound_init_cb).Run(OkStatus());
std::move(bound_init_cb).Run(DecoderStatus::Codes::kOk);
}
void Dav1dVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
@ -234,18 +235,18 @@ void Dav1dVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
: std::move(decode_cb);
if (state_ == DecoderState::kError) {
std::move(bound_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
if (!DecodeBuffer(std::move(buffer))) {
state_ = DecoderState::kError;
std::move(bound_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
// VideoDecoderShim expects |decode_cb| call after |output_cb_|.
std::move(bound_decode_cb).Run(DecodeStatus::OK);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kOk);
}
void Dav1dVideoDecoder::Reset(base::OnceClosure reset_cb) {

@ -57,7 +57,7 @@ class Dav1dVideoDecoderTest : public testing::Test {
config, true, // Use low delay so we get 1 frame out for each frame in.
nullptr,
base::BindOnce(
[](bool success, Status status) {
[](bool success, DecoderStatus status) {
EXPECT_EQ(status.is_ok(), success);
},
success),
@ -105,14 +105,14 @@ class Dav1dVideoDecoderTest : public testing::Test {
// Decodes all buffers in |input_buffers| and push all successfully decoded
// output frames into |output_frames|. Returns the last decode status returned
// by the decoder.
Status DecodeMultipleFrames(const InputBuffers& input_buffers) {
DecoderStatus DecodeMultipleFrames(const InputBuffers& input_buffers) {
for (auto iter = input_buffers.begin(); iter != input_buffers.end();
++iter) {
Status status = Decode(*iter);
DecoderStatus status = Decode(*iter);
switch (status.code()) {
case StatusCode::kOk:
case DecoderStatus::Codes::kOk:
break;
case StatusCode::kAborted:
case DecoderStatus::Codes::kAborted:
NOTREACHED();
[[fallthrough]];
default:
@ -120,11 +120,11 @@ class Dav1dVideoDecoderTest : public testing::Test {
return status;
}
}
return StatusCode::kOk;
return DecoderStatus::Codes::kOk;
}
// Decodes the single compressed frame in |buffer|.
Status DecodeSingleFrame(scoped_refptr<DecoderBuffer> buffer) {
DecoderStatus DecodeSingleFrame(scoped_refptr<DecoderBuffer> buffer) {
InputBuffers input_buffers;
input_buffers.push_back(std::move(buffer));
return DecodeMultipleFrames(input_buffers);
@ -143,7 +143,7 @@ class Dav1dVideoDecoderTest : public testing::Test {
input_buffers.push_back(buffer);
input_buffers.push_back(DecoderBuffer::CreateEOSBuffer());
Status status = DecodeMultipleFrames(input_buffers);
DecoderStatus status = DecodeMultipleFrames(input_buffers);
EXPECT_TRUE(status.is_ok());
ASSERT_EQ(2U, output_frames_.size());
@ -159,8 +159,8 @@ class Dav1dVideoDecoderTest : public testing::Test {
output_frames_[1]->visible_rect().size().height());
}
Status Decode(scoped_refptr<DecoderBuffer> buffer) {
Status status;
DecoderStatus Decode(scoped_refptr<DecoderBuffer> buffer) {
DecoderStatus status;
EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status));
decoder_->Decode(std::move(buffer),
@ -185,7 +185,7 @@ class Dav1dVideoDecoderTest : public testing::Test {
return base::MD5DigestToBase16(digest);
}
MOCK_METHOD1(DecodeDone, void(Status));
MOCK_METHOD1(DecodeDone, void(DecoderStatus));
testing::StrictMock<MockMediaLog> media_log_;

@ -321,9 +321,10 @@ void DecoderSelector<StreamType>::InitializeDecoder() {
}
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::OnDecoderInitializeDone(Status status) {
void DecoderSelector<StreamType>::OnDecoderInitializeDone(
DecoderStatus status) {
DVLOG(2) << __func__ << ": " << decoder_->GetDecoderType()
<< " success=" << std::hex << status.code();
<< " success=" << static_cast<int>(status.code());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!status.is_ok()) {

@ -132,7 +132,7 @@ class MEDIA_EXPORT DecoderSelector {
private:
void CreateDecoders();
void InitializeDecoder();
void OnDecoderInitializeDone(Status status);
void OnDecoderInitializeDone(DecoderStatus status);
void ReturnNullDecoder();
void InitializeDecryptingDemuxerStream();
void OnDecryptingDemuxerStreamInitializeDone(PipelineStatus status);

@ -68,16 +68,19 @@ bool DecoderCapabilitySupportsDecryption(DecoderCapability capability) {
}
}
Status IsConfigSupported(DecoderCapability capability, bool is_encrypted) {
DecoderStatus IsConfigSupported(DecoderCapability capability,
bool is_encrypted) {
switch (capability) {
case kAlwaysFail:
return StatusCode::kCodeOnlyForTesting;
return DecoderStatus::Codes::kFailed;
case kClearOnly:
return is_encrypted ? StatusCode::kCodeOnlyForTesting : StatusCode::kOk;
return is_encrypted ? DecoderStatus::Codes::kUnsupportedEncryptionMode
: DecoderStatus::Codes::kOk;
case kEncryptedOnly:
return is_encrypted ? StatusCode::kOk : StatusCode::kCodeOnlyForTesting;
return is_encrypted ? DecoderStatus::Codes::kOk
: DecoderStatus::Codes::kUnsupportedEncryptionMode;
case kAlwaysSucceed:
return OkStatus();
return DecoderStatus::Codes::kOk;
}
}

@ -78,12 +78,12 @@ const char* GetPrepareTraceString<DemuxerStream::AUDIO>() {
return "AudioDecoderStream::PrepareOutput";
}
const char* GetStatusString(const Status& status) {
const char* GetStatusString(const DecoderStatus& status) {
// TODO(crbug.com/1129662): Replace this with generic Status-to-string.
switch (status.code()) {
case StatusCode::kOk:
case DecoderStatus::Codes::kOk:
return "okay";
case StatusCode::kAborted:
case DecoderStatus::Codes::kAborted:
return "aborted";
default:
return "decode_error";
@ -127,7 +127,7 @@ DecoderStream<StreamType>::~DecoderStream() {
}
if (read_cb_) {
read_cb_ = BindToCurrentLoop(std::move(read_cb_));
SatisfyRead(StatusCode::kAborted);
SatisfyRead(DecoderStatus::Codes::kAborted);
}
if (reset_cb_)
task_runner_->PostTask(FROM_HERE, std::move(reset_cb_));
@ -188,7 +188,7 @@ void DecoderStream<StreamType>::Read(ReadCB read_cb) {
read_cb_ = BindToCurrentLoop(std::move(read_cb));
// TODO(crbug.com/1129662): Consider attaching a caused-by of the original
// error as well.
SatisfyRead(StatusCode::kDecoderStreamInErrorState);
SatisfyRead(DecoderStatus::Codes::kDecoderStreamInErrorState);
return;
}
@ -223,7 +223,7 @@ void DecoderStream<StreamType>::Reset(base::OnceClosure closure) {
if (read_cb_) {
read_cb_ = BindToCurrentLoop(std::move(read_cb_));
SatisfyRead(StatusCode::kAborted);
SatisfyRead(DecoderStatus::Codes::kAborted);
}
ClearOutputs();
@ -519,8 +519,9 @@ void DecoderStream<StreamType>::OnDecodeDone(
int buffer_size,
bool end_of_stream,
std::unique_ptr<ScopedDecodeTrace> trace_event,
Status status) {
FUNCTION_DVLOG(status.is_ok() ? 3 : 1) << ": " << status.code();
DecoderStatus status) {
FUNCTION_DVLOG(status.is_ok() ? 3 : 1)
<< ": " << static_cast<int>(status.code());
DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER ||
state_ == STATE_ERROR)
<< state_;
@ -552,11 +553,11 @@ void DecoderStream<StreamType>::OnDecodeDone(
return;
switch (status.code()) {
case StatusCode::kAborted:
case DecoderStatus::Codes::kAborted:
// Decoder can return kAborted during Reset() or during destruction.
return;
case StatusCode::kOk:
case DecoderStatus::Codes::kOk:
// Any successful decode counts!
if (buffer_size > 0)
traits_->ReportStatistics(statistics_cb_, buffer_size);
@ -742,7 +743,7 @@ void DecoderStream<StreamType>::OnBufferReady(
pending_buffers_.clear();
ClearOutputs();
if (read_cb_)
SatisfyRead(StatusCode::kDecoderStreamDemuxerError);
SatisfyRead(DecoderStatus::Codes::kDecoderStreamDemuxerError);
}
// Decoding has been stopped.
@ -818,7 +819,7 @@ void DecoderStream<StreamType>::OnBufferReady(
if (status == DemuxerStream::kAborted) {
if (read_cb_)
SatisfyRead(StatusCode::kAborted);
SatisfyRead(DecoderStatus::Codes::kAborted);
return;
}
@ -870,7 +871,7 @@ void DecoderStream<StreamType>::CompleteDecoderReinitialization(bool success) {
if (state_ == STATE_ERROR) {
MEDIA_LOG(ERROR, media_log_)
<< GetStreamTypeString() << " decoder reinitialization failed";
SatisfyRead(StatusCode::kDecoderStreamReinitFailed);
SatisfyRead(DecoderStatus::Codes::kDecoderStreamReinitFailed);
return;
}

@ -18,6 +18,7 @@
#include "base/types/pass_key.h"
#include "media/base/audio_decoder.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/decoder_status.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_export.h"
#include "media/base/media_log.h"
@ -55,7 +56,7 @@ class MEDIA_EXPORT DecoderStream {
using InitCB = base::OnceCallback<void(bool success)>;
// Indicates completion of a DecoderStream read.
using ReadResult = StatusOr<scoped_refptr<Output>>;
using ReadResult = DecoderStatus::Or<scoped_refptr<Output>>;
using ReadCB = base::OnceCallback<void(ReadResult)>;
DecoderStream(std::unique_ptr<DecoderStreamTraits<StreamType>> traits,
@ -199,7 +200,7 @@ class MEDIA_EXPORT DecoderStream {
void OnDecodeDone(int buffer_size,
bool end_of_stream,
std::unique_ptr<ScopedDecodeTrace> trace_event,
media::Status status);
DecoderStatus status);
// Output callback passed to Decoder::Initialize().
void OnDecodeOutputReady(scoped_refptr<Output> output);

@ -102,7 +102,7 @@ void DecoderStreamTraits<DemuxerStream::AUDIO>::InitializeDecoder(
void DecoderStreamTraits<DemuxerStream::AUDIO>::OnDecoderInitialized(
DecoderType* decoder,
InitCB cb,
Status result) {
DecoderStatus result) {
if (result.is_ok())
stats_.audio_pipeline_info.decoder_type = decoder->GetDecoderType();
std::move(cb).Run(result);
@ -227,7 +227,7 @@ void DecoderStreamTraits<DemuxerStream::VIDEO>::InitializeDecoder(
void DecoderStreamTraits<DemuxerStream::VIDEO>::OnDecoderInitialized(
DecoderType* decoder,
InitCB cb,
Status result) {
DecoderStatus result) {
if (result.is_ok()) {
stats_.video_pipeline_info.decoder_type = decoder->GetDecoderType();
DVLOG(2) << stats_.video_pipeline_info.decoder_type;

@ -67,7 +67,9 @@ class MEDIA_EXPORT DecoderStreamTraits<DemuxerStream::AUDIO> {
InitCB init_cb,
const OutputCB& output_cb,
const WaitingCB& waiting_cb);
void OnDecoderInitialized(DecoderType* decoder, InitCB cb, Status status);
void OnDecoderInitialized(DecoderType* decoder,
InitCB cb,
DecoderStatus status);
DecoderConfigType GetDecoderConfig(DemuxerStream* stream);
void OnDecode(const DecoderBuffer& buffer);
PostDecodeAction OnDecodeDone(OutputType* buffer);
@ -126,7 +128,9 @@ class MEDIA_EXPORT DecoderStreamTraits<DemuxerStream::VIDEO> {
InitCB init_cb,
const OutputCB& output_cb,
const WaitingCB& waiting_cb);
void OnDecoderInitialized(DecoderType* decoder, InitCB cb, Status status);
void OnDecoderInitialized(DecoderType* decoder,
InitCB cb,
DecoderStatus status);
void OnDecode(const DecoderBuffer& buffer);
PostDecodeAction OnDecodeDone(OutputType* buffer);
void OnStreamReset(DemuxerStream* stream);

@ -61,12 +61,12 @@ void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
if (!cdm_context) {
// Once we have a CDM context, one should always be present.
DCHECK(!support_clear_content_);
std::move(init_cb_).Run(StatusCode::kDecoderMissingCdmForEncryptedContent);
std::move(init_cb_).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
if (!config.is_encrypted() && !support_clear_content_) {
std::move(init_cb_).Run(StatusCode::kClearContentUnsupported);
std::move(init_cb_).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -82,7 +82,7 @@ void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
// TODO(xhwang): We should be able to DCHECK config.IsValidConfig().
if (!config.IsValidConfig()) {
DLOG(ERROR) << "Invalid audio stream config.";
std::move(init_cb_).Run(StatusCode::kDecoderUnsupportedCodec);
std::move(init_cb_).Run(DecoderStatus::Codes::kUnsupportedCodec);
return;
}
@ -91,7 +91,7 @@ void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
if (state_ == kUninitialized) {
if (!cdm_context->GetDecryptor()) {
DVLOG(1) << __func__ << ": no decryptor";
std::move(init_cb_).Run(StatusCode::kDecoderFailedInitialization);
std::move(init_cb_).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -121,7 +121,7 @@ void DecryptingAudioDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
// Return empty (end-of-stream) frames if decoding has finished.
if (state_ == kDecodeFinished) {
output_cb_.Run(AudioBuffer::CreateEOSBuffer());
std::move(decode_cb_).Run(DecodeStatus::OK);
std::move(decode_cb_).Run(DecoderStatus::Codes::kOk);
return;
}
@ -162,7 +162,7 @@ void DecryptingAudioDecoder::Reset(base::OnceClosure closure) {
if (state_ == kWaitingForKey) {
DCHECK(decode_cb_);
pending_buffer_to_decode_.reset();
std::move(decode_cb_).Run(DecodeStatus::ABORTED);
std::move(decode_cb_).Run(DecoderStatus::Codes::kAborted);
}
DCHECK(!decode_cb_);
@ -182,9 +182,9 @@ DecryptingAudioDecoder::~DecryptingAudioDecoder() {
}
pending_buffer_to_decode_.reset();
if (init_cb_)
std::move(init_cb_).Run(StatusCode::kDecoderInitializeNeverCompleted);
std::move(init_cb_).Run(DecoderStatus::Codes::kInterrupted);
if (decode_cb_)
std::move(decode_cb_).Run(DecodeStatus::ABORTED);
std::move(decode_cb_).Run(DecoderStatus::Codes::kAborted);
if (reset_cb_)
std::move(reset_cb_).Run();
}
@ -207,7 +207,7 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) {
if (!success) {
DVLOG(1) << __func__ << ": failed to init audio decoder on decryptor";
std::move(init_cb_).Run(StatusCode::kDecoderInitializeNeverCompleted);
std::move(init_cb_).Run(DecoderStatus::Codes::kFailedToCreateDecoder);
decryptor_ = nullptr;
event_cb_registration_.reset();
state_ = kError;
@ -219,7 +219,7 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) {
std::make_unique<AudioTimestampHelper>(config_.samples_per_second());
state_ = kIdle;
std::move(init_cb_).Run(OkStatus());
std::move(init_cb_).Run(DecoderStatus::Codes::kOk);
}
void DecryptingAudioDecoder::DecodePendingBuffer() {
@ -254,7 +254,7 @@ void DecryptingAudioDecoder::DeliverFrame(
std::move(pending_buffer_to_decode_);
if (reset_cb_) {
std::move(decode_cb_).Run(DecodeStatus::ABORTED);
std::move(decode_cb_).Run(DecoderStatus::Codes::kAborted);
DoReset();
return;
}
@ -265,7 +265,7 @@ void DecryptingAudioDecoder::DeliverFrame(
DVLOG(2) << "DeliverFrame() - kError";
MEDIA_LOG(ERROR, media_log_) << GetDecoderType() << ": decode error";
state_ = kDecodeFinished; // TODO add kError state
std::move(decode_cb_).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb_).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -299,7 +299,7 @@ void DecryptingAudioDecoder::DeliverFrame(
DVLOG(2) << "DeliverFrame() - kNeedMoreData";
state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished
: kIdle;
std::move(decode_cb_).Run(DecodeStatus::OK);
std::move(decode_cb_).Run(DecoderStatus::Codes::kOk);
return;
}
@ -316,7 +316,7 @@ void DecryptingAudioDecoder::DeliverFrame(
}
state_ = kIdle;
std::move(decode_cb_).Run(DecodeStatus::OK);
std::move(decode_cb_).Run(DecoderStatus::Codes::kOk);
}
void DecryptingAudioDecoder::OnCdmContextEvent(CdmContext::Event event) {

@ -89,7 +89,7 @@ class DecryptingAudioDecoderTest : public testing::Test {
decoder_->Initialize(
config, cdm_context_.get(),
base::BindOnce(
[](bool success, Status status) {
[](bool success, DecoderStatus status) {
EXPECT_EQ(status.is_ok(), success);
},
success),
@ -132,7 +132,8 @@ class DecryptingAudioDecoderTest : public testing::Test {
.WillOnce(RunOnceCallback<1>(true));
decoder_->Initialize(
new_config, cdm_context_.get(),
base::BindOnce([](Status status) { EXPECT_TRUE(status.is_ok()); }),
base::BindOnce(
[](DecoderStatus status) { EXPECT_TRUE(status.is_ok()); }),
base::BindRepeating(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)),
base::BindRepeating(&DecryptingAudioDecoderTest::OnWaiting,
@ -140,7 +141,8 @@ class DecryptingAudioDecoderTest : public testing::Test {
}
// Decode |buffer| and expect DecodeDone to get called with |status|.
void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer, StatusCode status) {
void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer,
DecoderStatus status) {
EXPECT_CALL(*this, DecodeDone(HasStatusCode(status)));
decoder_->Decode(buffer,
base::BindOnce(&DecryptingAudioDecoderTest::DecodeDone,
@ -176,7 +178,7 @@ class DecryptingAudioDecoderTest : public testing::Test {
Invoke(this, &DecryptingAudioDecoderTest::DecryptAndDecodeAudio));
EXPECT_CALL(*this, FrameReady(decoded_frame_));
for (int i = 0; i < kDecodingDelay + 1; ++i)
DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK);
DecodeAndExpect(encrypted_buffer_, DecoderStatus::Codes::kOk);
}
// Sets up expectations and actions to put DecryptingAudioDecoder in an end
@ -185,7 +187,8 @@ class DecryptingAudioDecoderTest : public testing::Test {
void EnterEndOfStreamState() {
// The codec in the |decryptor_| will be flushed.
EXPECT_CALL(*this, FrameReady(decoded_frame_)).Times(kDecodingDelay);
DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), DecodeStatus::OK);
DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(),
DecoderStatus::Codes::kOk);
EXPECT_EQ(0, num_frames_in_decryptor_);
}
@ -252,7 +255,7 @@ class DecryptingAudioDecoderTest : public testing::Test {
}
MOCK_METHOD1(FrameReady, void(scoped_refptr<AudioBuffer>));
MOCK_METHOD1(DecodeDone, void(Status));
MOCK_METHOD1(DecodeDone, void(DecoderStatus));
MOCK_METHOD1(OnWaiting, void(WaitingReason));
@ -329,7 +332,7 @@ TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_DecodeError) {
.WillRepeatedly(
RunOnceCallback<1>(Decryptor::kError, Decryptor::AudioFrames()));
DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR);
DecodeAndExpect(encrypted_buffer_, DecoderStatus::Codes::kFailed);
}
// Test the case where the decryptor returns multiple decoded frames.
@ -353,7 +356,7 @@ TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_MultipleFrames) {
EXPECT_CALL(*this, FrameReady(decoded_frame_));
EXPECT_CALL(*this, FrameReady(frame_a));
EXPECT_CALL(*this, FrameReady(frame_b));
DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK);
DecodeAndExpect(encrypted_buffer_, DecoderStatus::Codes::kOk);
}
// Test the case where the decryptor receives end-of-stream buffer.
@ -461,7 +464,7 @@ TEST_F(DecryptingAudioDecoderTest, Reset_DuringPendingDecode) {
Initialize();
EnterPendingDecodeState();
EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(*this, DecodeDone(HasStatusCode(DecoderStatus::Codes::kAborted)));
Reset();
}
@ -471,7 +474,7 @@ TEST_F(DecryptingAudioDecoderTest, Reset_DuringWaitingForKey) {
Initialize();
EnterWaitingForKeyState();
EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(*this, DecodeDone(HasStatusCode(DecoderStatus::Codes::kAborted)));
Reset();
}

@ -53,12 +53,12 @@ void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config,
if (!cdm_context) {
// Once we have a CDM context, one should always be present.
DCHECK(!support_clear_content_);
std::move(init_cb_).Run(StatusCode::kDecoderMissingCdmForEncryptedContent);
std::move(init_cb_).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
if (!config.is_encrypted() && !support_clear_content_) {
std::move(init_cb_).Run(StatusCode::kClearContentUnsupported);
std::move(init_cb_).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -75,7 +75,7 @@ void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config,
if (state_ == kUninitialized) {
if (!cdm_context->GetDecryptor()) {
DVLOG(1) << __func__ << ": no decryptor";
std::move(init_cb_).Run(StatusCode::kDecoderFailedInitialization);
std::move(init_cb_).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -112,13 +112,13 @@ void DecryptingVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
decode_cb_ = BindToCurrentLoop(std::move(decode_cb));
if (state_ == kError) {
std::move(decode_cb_).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb_).Run(DecoderStatus::Codes::kPlatformDecodeFailure);
return;
}
// Return empty frames if decoding has finished.
if (state_ == kDecodeFinished) {
std::move(decode_cb_).Run(DecodeStatus::OK);
std::move(decode_cb_).Run(DecoderStatus::Codes::kOk);
return;
}
@ -154,7 +154,7 @@ void DecryptingVideoDecoder::Reset(base::OnceClosure closure) {
CompleteWaitingForDecryptionKey();
DCHECK(decode_cb_);
pending_buffer_to_decode_.reset();
std::move(decode_cb_).Run(DecodeStatus::ABORTED);
std::move(decode_cb_).Run(DecoderStatus::Codes::kAborted);
}
DCHECK(!decode_cb_);
@ -178,9 +178,9 @@ DecryptingVideoDecoder::~DecryptingVideoDecoder() {
}
pending_buffer_to_decode_.reset();
if (init_cb_)
std::move(init_cb_).Run(StatusCode::kDecoderInitializeNeverCompleted);
std::move(init_cb_).Run(DecoderStatus::Codes::kInterrupted);
if (decode_cb_)
std::move(decode_cb_).Run(DecodeStatus::ABORTED);
std::move(decode_cb_).Run(DecoderStatus::Codes::kAborted);
if (reset_cb_)
std::move(reset_cb_).Run();
}
@ -195,7 +195,9 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) {
if (!success) {
DVLOG(1) << __func__ << ": failed to init video decoder on decryptor";
std::move(init_cb_).Run(StatusCode::kDecoderInitializeNeverCompleted);
// TODO(*) Is there a better reason? Should this method itself take a
// status?
std::move(init_cb_).Run(DecoderStatus::Codes::kFailed);
decryptor_ = nullptr;
event_cb_registration_.reset();
state_ = kError;
@ -204,7 +206,7 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) {
// Success!
state_ = kIdle;
std::move(init_cb_).Run(OkStatus());
std::move(init_cb_).Run(DecoderStatus::Codes::kOk);
}
void DecryptingVideoDecoder::DecodePendingBuffer() {
@ -243,7 +245,7 @@ void DecryptingVideoDecoder::DeliverFrame(Decryptor::Status status,
std::move(pending_buffer_to_decode_);
if (reset_cb_) {
std::move(decode_cb_).Run(DecodeStatus::ABORTED);
std::move(decode_cb_).Run(DecoderStatus::Codes::kAborted);
DoReset();
return;
}
@ -254,7 +256,7 @@ void DecryptingVideoDecoder::DeliverFrame(Decryptor::Status status,
DVLOG(2) << "DeliverFrame() - kError";
MEDIA_LOG(ERROR, media_log_) << GetDecoderType() << ": decode error";
state_ = kError;
std::move(decode_cb_).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb_).Run(DecoderStatus::Codes::kPlatformDecodeFailure);
return;
}
@ -290,7 +292,7 @@ void DecryptingVideoDecoder::DeliverFrame(Decryptor::Status status,
DVLOG(2) << "DeliverFrame() - kNeedMoreData";
state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished
: kIdle;
std::move(decode_cb_).Run(DecodeStatus::OK);
std::move(decode_cb_).Run(DecoderStatus::Codes::kOk);
return;
}
@ -318,7 +320,7 @@ void DecryptingVideoDecoder::DeliverFrame(Decryptor::Status status,
}
state_ = kIdle;
std::move(decode_cb_).Run(DecodeStatus::OK);
std::move(decode_cb_).Run(DecoderStatus::Codes::kOk);
}
void DecryptingVideoDecoder::OnCdmContextEvent(CdmContext::Event event) {

@ -84,7 +84,7 @@ class DecryptingVideoDecoderTest : public testing::Test {
decoder_->Initialize(
config, false, cdm_context_.get(),
base::BindOnce(
[](bool success, Status status) {
[](bool success, DecoderStatus status) {
EXPECT_EQ(status.is_ok(), success);
},
success),
@ -118,7 +118,8 @@ class DecryptingVideoDecoderTest : public testing::Test {
}
// Decode |buffer| and expect DecodeDone to get called with |status|.
void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer, StatusCode status) {
void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer,
DecoderStatus::Codes status) {
EXPECT_CALL(*this, DecodeDone(HasStatusCode(status)));
decoder_->Decode(buffer,
base::BindOnce(&DecryptingVideoDecoderTest::DecodeDone,
@ -162,7 +163,7 @@ class DecryptingVideoDecoderTest : public testing::Test {
Invoke(this, &DecryptingVideoDecoderTest::DecryptAndDecodeVideo));
EXPECT_CALL(*this, FrameReady(decoded_video_frame_));
for (int i = 0; i < kDecodingDelay + 1; ++i)
DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK);
DecodeAndExpect(encrypted_buffer_, DecoderStatus::Codes::kOk);
}
// Sets up expectations and actions to put DecryptingVideoDecoder in an end
@ -171,7 +172,8 @@ class DecryptingVideoDecoderTest : public testing::Test {
void EnterEndOfStreamState() {
// The codec in the |decryptor_| will be flushed.
EXPECT_CALL(*this, FrameReady(decoded_video_frame_)).Times(kDecodingDelay);
DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), DecodeStatus::OK);
DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(),
DecoderStatus::Codes::kOk);
EXPECT_EQ(0, num_frames_in_decryptor_);
}
@ -237,7 +239,7 @@ class DecryptingVideoDecoderTest : public testing::Test {
}
MOCK_METHOD1(FrameReady, void(scoped_refptr<VideoFrame>));
MOCK_METHOD1(DecodeDone, void(Status));
MOCK_METHOD1(DecodeDone, void(DecoderStatus));
MOCK_METHOD1(OnWaiting, void(WaitingReason));
@ -389,7 +391,7 @@ TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDecode) {
Initialize();
EnterPendingDecodeState();
EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(*this, DecodeDone(HasStatusCode(DecoderStatus::Codes::kAborted)));
Reset();
}
@ -399,7 +401,7 @@ TEST_F(DecryptingVideoDecoderTest, Reset_DuringWaitingForKey) {
Initialize();
EnterWaitingForKeyState();
EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(*this, DecodeDone(HasStatusCode(DecoderStatus::Codes::kAborted)));
Reset();
}
@ -459,7 +461,7 @@ TEST_F(DecryptingVideoDecoderTest, Destroy_DuringPendingDecode) {
Initialize();
EnterPendingDecodeState();
EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(*this, DecodeDone(HasStatusCode(DecoderStatus::Codes::kAborted)));
Destroy();
}
@ -469,7 +471,7 @@ TEST_F(DecryptingVideoDecoderTest, Destroy_DuringWaitingForKey) {
Initialize();
EnterWaitingForKeyState();
EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(*this, DecodeDone(HasStatusCode(DecoderStatus::Codes::kAborted)));
Destroy();
}
@ -491,7 +493,7 @@ TEST_F(DecryptingVideoDecoderTest, Destroy_DuringPendingReset) {
EnterPendingDecodeState();
EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo));
EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(*this, DecodeDone(HasStatusCode(DecoderStatus::Codes::kAborted)));
decoder_->Reset(NewExpectedClosure());
Destroy();

@ -96,18 +96,18 @@ void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config,
if (config.is_encrypted() && (!supports_encrypted_config_ || !cdm_context)) {
DVLOG(1) << "Encrypted config not supported.";
state_ = STATE_NORMAL;
init_cb_.RunOrHold(StatusCode::kEncryptedContentUnsupported);
init_cb_.RunOrHold(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
if (fail_to_initialize_) {
DVLOG(1) << decoder_id_ << ": Initialization failed.";
state_ = STATE_ERROR;
init_cb_.RunOrHold(StatusCode::kDecoderInitializeNeverCompleted);
init_cb_.RunOrHold(DecoderStatus::Codes::kFailed);
} else {
DVLOG(1) << decoder_id_ << ": Initialization succeeded.";
state_ = STATE_NORMAL;
init_cb_.RunOrHold(OkStatus());
init_cb_.RunOrHold(DecoderStatus::Codes::kOk);
}
}
@ -127,7 +127,7 @@ void FakeVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
buffer_size, BindToCurrentLoop(std::move(decode_cb)));
if (state_ == STATE_ERROR) {
std::move(wrapped_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(wrapped_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -218,7 +218,8 @@ void FakeVideoDecoder::SimulateError() {
state_ = STATE_ERROR;
while (!held_decode_callbacks_.empty()) {
std::move(held_decode_callbacks_.front()).Run(DecodeStatus::DECODE_ERROR);
std::move(held_decode_callbacks_.front())
.Run(DecoderStatus::Codes::kFailed);
held_decode_callbacks_.pop_front();
}
decoded_frames_.clear();
@ -234,7 +235,7 @@ int FakeVideoDecoder::GetMaxDecodeRequests() const {
void FakeVideoDecoder::OnFrameDecoded(int buffer_size,
DecodeCB decode_cb,
Status status) {
DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (status.is_ok()) {
@ -261,7 +262,7 @@ void FakeVideoDecoder::RunDecodeCallback(DecodeCB decode_cb) {
if (!reset_cb_.IsNull()) {
DCHECK(decoded_frames_.empty());
std::move(decode_cb).Run(DecodeStatus::ABORTED);
std::move(decode_cb).Run(DecoderStatus::Codes::kAborted);
return;
}
@ -286,7 +287,7 @@ void FakeVideoDecoder::RunDecodeCallback(DecodeCB decode_cb) {
}
}
std::move(decode_cb).Run(DecodeStatus::OK);
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
}
void FakeVideoDecoder::DoReset() {

@ -101,7 +101,9 @@ class FakeVideoDecoder : public VideoDecoder {
virtual scoped_refptr<VideoFrame> MakeVideoFrame(const DecoderBuffer& buffer);
// Callback for updating |total_bytes_decoded_|.
void OnFrameDecoded(int buffer_size, DecodeCB decode_cb, Status status);
void OnFrameDecoded(int buffer_size,
DecodeCB decode_cb,
DecoderStatus status);
// Runs |decode_cb| or puts it to |held_decode_callbacks_| depending on
// current value of |hold_decode_|.

@ -45,7 +45,7 @@ class FakeVideoDecoderTest
num_decoded_frames_(0),
num_bytes_decoded_(0),
total_bytes_in_buffers_(0),
last_decode_status_(DecodeStatus::OK),
last_decode_status_(DecoderStatus::Codes::kOk),
pending_decode_requests_(0),
is_reset_pending_(false) {}
@ -60,7 +60,7 @@ class FakeVideoDecoderTest
bool success) {
decoder_->Initialize(config, false, nullptr,
base::BindOnce(
[](bool success, Status status) {
[](bool success, DecoderStatus status) {
EXPECT_EQ(status.is_ok(), success);
},
success),
@ -86,7 +86,7 @@ class FakeVideoDecoderTest
}
// Callback for VideoDecoder::Decode().
void DecodeDone(Status status) {
void DecodeDone(DecoderStatus status) {
DCHECK_GT(pending_decode_requests_, 0);
--pending_decode_requests_;
last_decode_status_ = std::move(status);
@ -126,7 +126,7 @@ class FakeVideoDecoderTest
break;
case ABORTED:
EXPECT_EQ(0, pending_decode_requests_);
ASSERT_EQ(StatusCode::kAborted, last_decode_status_.code());
ASSERT_EQ(DecoderStatus::Codes::kAborted, last_decode_status_.code());
EXPECT_FALSE(last_decoded_frame_.get());
break;
}
@ -241,7 +241,7 @@ class FakeVideoDecoderTest
int total_bytes_in_buffers_;
// Callback result/status.
Status last_decode_status_;
DecoderStatus last_decode_status_;
scoped_refptr<VideoFrame> last_decoded_frame_;
int pending_decode_requests_;
bool is_reset_pending_;

@ -82,15 +82,16 @@ void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config,
if (config.is_encrypted()) {
std::move(bound_init_cb)
.Run(Status(StatusCode::kEncryptedContentUnsupported,
"FFmpegAudioDecoder does not support encrypted content"));
.Run(DecoderStatus(
DecoderStatus::Codes::kUnsupportedEncryptionMode,
"FFmpegAudioDecoder does not support encrypted content"));
return;
}
// TODO(dalecurtis): Remove this if ffmpeg ever gets xHE-AAC support.
if (config.profile() == AudioCodecProfile::kXHE_AAC) {
std::move(bound_init_cb)
.Run(Status(StatusCode::kDecoderUnsupportedProfile)
.Run(DecoderStatus(DecoderStatus::Codes::kUnsupportedProfile)
.WithData("decoder", "FFmpegAudioDecoder")
.WithData("profile", config.profile()));
return;
@ -98,7 +99,7 @@ void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config,
if (!ConfigureDecoder(config)) {
av_sample_format_ = 0;
std::move(bound_init_cb).Run(StatusCode::kDecoderFailedInitialization);
std::move(bound_init_cb).Run(DecoderStatus::Codes::kUnsupportedConfig);
return;
}
@ -106,7 +107,7 @@ void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config,
config_ = config;
output_cb_ = BindToCurrentLoop(output_cb);
state_ = DecoderState::kNormal;
std::move(bound_init_cb).Run(OkStatus());
std::move(bound_init_cb).Run(DecoderStatus::Codes::kOk);
}
void FFmpegAudioDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
@ -117,13 +118,13 @@ void FFmpegAudioDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
DecodeCB decode_cb_bound = BindToCurrentLoop(std::move(decode_cb));
if (state_ == DecoderState::kError) {
std::move(decode_cb_bound).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kFailed);
return;
}
// Do nothing if decoding has finished.
if (state_ == DecoderState::kDecodeFinished) {
std::move(decode_cb_bound).Run(DecodeStatus::OK);
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kOk);
return;
}
@ -150,20 +151,20 @@ void FFmpegAudioDecoder::DecodeBuffer(const DecoderBuffer& buffer,
// occurs with some damaged files.
if (!buffer.end_of_stream() && buffer.timestamp() == kNoTimestamp) {
DVLOG(1) << "Received a buffer without timestamps!";
std::move(decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
if (!FFmpegDecode(buffer)) {
state_ = DecoderState::kError;
std::move(decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
if (buffer.end_of_stream())
state_ = DecoderState::kDecodeFinished;
std::move(decode_cb).Run(DecodeStatus::OK);
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
}
bool FFmpegAudioDecoder::FFmpegDecode(const DecoderBuffer& buffer) {

@ -248,12 +248,13 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config,
InitCB bound_init_cb = BindToCurrentLoop(std::move(init_cb));
if (config.is_encrypted()) {
std::move(bound_init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(bound_init_cb)
.Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
if (!ConfigureDecoder(config, low_delay)) {
std::move(bound_init_cb).Run(StatusCode::kDecoderFailedInitialization);
std::move(bound_init_cb).Run(DecoderStatus::Codes::kUnsupportedConfig);
return;
}
@ -261,7 +262,7 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config,
config_ = config;
output_cb_ = output_cb;
state_ = DecoderState::kNormal;
std::move(bound_init_cb).Run(OkStatus());
std::move(bound_init_cb).Run(DecoderStatus::Codes::kOk);
}
void FFmpegVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
@ -275,12 +276,12 @@ void FFmpegVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
DecodeCB decode_cb_bound = BindToCurrentLoop(std::move(decode_cb));
if (state_ == DecoderState::kError) {
std::move(decode_cb_bound).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kFailed);
return;
}
if (state_ == DecoderState::kDecodeFinished) {
std::move(decode_cb_bound).Run(DecodeStatus::OK);
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kOk);
return;
}
@ -306,7 +307,7 @@ void FFmpegVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
if (!FFmpegDecode(*buffer)) {
state_ = DecoderState::kError;
std::move(decode_cb_bound).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -315,7 +316,7 @@ void FFmpegVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
// VideoDecoderShim expects that |decode_cb| is called only after
// |output_cb_|.
std::move(decode_cb_bound).Run(DecodeStatus::OK);
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kOk);
}
void FFmpegVideoDecoder::Reset(base::OnceClosure closure) {

@ -78,7 +78,7 @@ class FFmpegVideoDecoderTest : public testing::Test {
decoder_->Initialize(
config, false, nullptr,
base::BindOnce(
[](bool success, Status status) {
[](bool success, DecoderStatus status) {
EXPECT_EQ(status.is_ok(), success);
},
success),
@ -126,14 +126,14 @@ class FFmpegVideoDecoderTest : public testing::Test {
// Decodes all buffers in |input_buffers| and push all successfully decoded
// output frames into |output_frames|.
// Returns the last decode status returned by the decoder.
Status DecodeMultipleFrames(const InputBuffers& input_buffers) {
DecoderStatus DecodeMultipleFrames(const InputBuffers& input_buffers) {
for (auto iter = input_buffers.begin(); iter != input_buffers.end();
++iter) {
Status status = Decode(*iter);
DecoderStatus status = Decode(*iter);
switch (status.code()) {
case StatusCode::kOk:
case DecoderStatus::Codes::kOk:
break;
case StatusCode::kAborted:
case DecoderStatus::Codes::kAborted:
NOTREACHED();
[[fallthrough]];
default:
@ -141,14 +141,14 @@ class FFmpegVideoDecoderTest : public testing::Test {
return status;
}
}
return StatusCode::kOk;
return DecoderStatus::Codes::kOk;
}
// Decodes the single compressed frame in |buffer| and writes the
// uncompressed output to |video_frame|. This method works with single
// and multithreaded decoders. End of stream buffers are used to trigger
// the frame to be returned in the multithreaded decoder case.
Status DecodeSingleFrame(scoped_refptr<DecoderBuffer> buffer) {
DecoderStatus DecodeSingleFrame(scoped_refptr<DecoderBuffer> buffer) {
InputBuffers input_buffers;
input_buffers.push_back(buffer);
input_buffers.push_back(end_of_stream_buffer_);
@ -170,7 +170,7 @@ class FFmpegVideoDecoderTest : public testing::Test {
input_buffers.push_back(buffer);
input_buffers.push_back(end_of_stream_buffer_);
Status status = DecodeMultipleFrames(input_buffers);
DecoderStatus status = DecodeMultipleFrames(input_buffers);
EXPECT_TRUE(status.is_ok());
ASSERT_EQ(2U, output_frames_.size());
@ -186,8 +186,8 @@ class FFmpegVideoDecoderTest : public testing::Test {
output_frames_[1]->visible_rect().size().height());
}
Status Decode(scoped_refptr<DecoderBuffer> buffer) {
Status status;
DecoderStatus Decode(scoped_refptr<DecoderBuffer> buffer) {
DecoderStatus status;
EXPECT_CALL(*this, DecodeDone(_)).WillOnce(SaveArg<0>(&status));
decoder_->Decode(buffer, base::BindOnce(&FFmpegVideoDecoderTest::DecodeDone,
@ -203,7 +203,7 @@ class FFmpegVideoDecoderTest : public testing::Test {
output_frames_.push_back(std::move(frame));
}
MOCK_METHOD1(DecodeDone, void(Status));
MOCK_METHOD1(DecodeDone, void(DecoderStatus));
StrictMock<MockMediaLog> media_log_;
@ -281,7 +281,7 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeError) {
EXPECT_TRUE(output_frames_.empty());
// After a decode error occurred, all following decodes will return
// DecodeStatus::DECODE_ERROR.
// DecoderStatus::Codes::kFailed.
EXPECT_THAT(Decode(i_frame_buffer_), IsDecodeErrorStatus());
EXPECT_TRUE(output_frames_.empty());
}

@ -242,7 +242,7 @@ void FuchsiaVideoDecoder::Initialize(const VideoDecoderConfig& config,
// There should be no pending decode request, so DropInputQueue() is not
// expected to fail.
bool result = DropInputQueue(DecodeStatus::ABORTED);
bool result = DropInputQueue(DecoderStatus::Codes::kAborted);
DCHECK(result);
output_cb_ = output_cb;
@ -252,7 +252,7 @@ void FuchsiaVideoDecoder::Initialize(const VideoDecoderConfig& config,
// Keep decoder and decryptor if the configuration hasn't changed.
if (decoder_ && current_config_.codec() == config.codec() &&
current_config_.is_encrypted() == config.is_encrypted()) {
std::move(done_callback).Run(OkStatus());
std::move(done_callback).Run(DecoderStatus::Codes::kOk);
return;
}
@ -261,10 +261,10 @@ void FuchsiaVideoDecoder::Initialize(const VideoDecoderConfig& config,
// Initialize the stream.
bool secure_mode = false;
StatusCode status = InitializeSysmemBufferStream(config.is_encrypted(),
cdm_context, &secure_mode);
if (status != StatusCode::kOk) {
std::move(done_callback).Run(StatusCode::kOk);
DecoderStatus status = InitializeSysmemBufferStream(
config.is_encrypted(), cdm_context, &secure_mode);
if (!status.is_ok()) {
std::move(done_callback).Run(status);
return;
}
@ -292,7 +292,7 @@ void FuchsiaVideoDecoder::Initialize(const VideoDecoderConfig& config,
break;
default:
std::move(done_callback).Run(StatusCode::kDecoderUnsupportedCodec);
std::move(done_callback).Run(DecoderStatus::Codes::kUnsupportedCodec);
return;
}
@ -320,7 +320,7 @@ void FuchsiaVideoDecoder::Initialize(const VideoDecoderConfig& config,
current_config_ = config;
std::move(done_callback).Run(OkStatus());
std::move(done_callback).Run(DecoderStatus::Codes::kOk);
}
void FuchsiaVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
@ -330,7 +330,7 @@ void FuchsiaVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
// Decode() to complete synchronously.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(decode_cb), DecodeStatus::DECODE_ERROR));
base::BindOnce(std::move(decode_cb), DecoderStatus::Codes::kFailed));
return;
}
@ -340,7 +340,7 @@ void FuchsiaVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
}
void FuchsiaVideoDecoder::Reset(base::OnceClosure closure) {
DropInputQueue(DecodeStatus::ABORTED);
DropInputQueue(DecoderStatus::Codes::kAborted);
base::SequencedTaskRunnerHandle::Get()->PostTask(FROM_HERE,
std::move(closure));
}
@ -357,7 +357,7 @@ int FuchsiaVideoDecoder::GetMaxDecodeRequests() const {
return max_decoder_requests_;
}
StatusCode FuchsiaVideoDecoder::InitializeSysmemBufferStream(
DecoderStatus FuchsiaVideoDecoder::InitializeSysmemBufferStream(
bool is_encrypted,
CdmContext* cdm_context,
bool* out_secure_mode) {
@ -373,7 +373,7 @@ StatusCode FuchsiaVideoDecoder::InitializeSysmemBufferStream(
// Caller makes sure |cdm_context| is available if the stream is encrypted.
if (!cdm_context) {
DLOG(ERROR) << "No cdm context for encrypted stream.";
return StatusCode::kDecoderMissingCdmForEncryptedContent;
return DecoderStatus::Codes::kUnsupportedEncryptionMode;
}
// Use FuchsiaStreamDecryptor with FuchsiaCdm (it doesn't support
@ -400,7 +400,7 @@ StatusCode FuchsiaVideoDecoder::InitializeSysmemBufferStream(
sysmem_buffer_stream_->Initialize(this, kInputBufferSize, kNumInputBuffers);
return StatusCode::kOk;
return DecoderStatus::Codes::kOk;
}
void FuchsiaVideoDecoder::OnSysmemBufferStreamBufferCollectionToken(
@ -597,10 +597,10 @@ void FuchsiaVideoDecoder::CallNextDecodeCallback() {
auto cb = std::move(decode_callbacks_.front());
decode_callbacks_.pop_front();
std::move(cb).Run(DecodeStatus::OK);
std::move(cb).Run(DecoderStatus::Codes::kOk);
}
bool FuchsiaVideoDecoder::DropInputQueue(DecodeStatus status) {
bool FuchsiaVideoDecoder::DropInputQueue(DecoderStatus status) {
// Invalidate callbacks for CallNextDecodeCallback(), so the callbacks are not
// called when the |decoder_| is dropped below. The callbacks are called
// explicitly later.
@ -617,7 +617,7 @@ bool FuchsiaVideoDecoder::DropInputQueue(DecodeStatus status) {
auto weak_this = weak_this_;
for (auto& cb : decode_callbacks_) {
std::move(cb).Run(status);
std::move(cb).Run(std::move(status));
// DecodeCB may destroy |this|.
if (!weak_this)
@ -634,7 +634,7 @@ void FuchsiaVideoDecoder::OnError() {
ReleaseOutputBuffers();
DropInputQueue(DecodeStatus::DECODE_ERROR);
DropInputQueue(DecoderStatus::Codes::kFailed);
}
void FuchsiaVideoDecoder::SetBufferCollectionTokenForGpu(

@ -74,9 +74,9 @@ class MEDIA_EXPORT FuchsiaVideoDecoder : public VideoDecoder,
private:
class OutputMailbox;
StatusCode InitializeSysmemBufferStream(bool is_encrypted,
CdmContext* cdm_context,
bool* secure_mode);
DecoderStatus InitializeSysmemBufferStream(bool is_encrypted,
CdmContext* cdm_context,
bool* secure_mode);
// SysmemBufferStream::Sink implementation.
void OnSysmemBufferStreamBufferCollectionToken(
@ -104,7 +104,7 @@ class MEDIA_EXPORT FuchsiaVideoDecoder : public VideoDecoder,
// Drops all pending input buffers and then calls all pending DecodeCB with
// |status|. Returns true if the decoder still exists.
bool DropInputQueue(DecodeStatus status);
bool DropInputQueue(DecoderStatus status);
// Called on errors to shutdown the decoder and notify the client.
void OnError();

@ -308,7 +308,8 @@ class FuchsiaVideoDecoderTest : public testing::Test {
decoder_->Initialize(
config, true, /*cdm_context=*/nullptr,
base::BindRepeating(
[](bool* init_cb_result, base::RunLoop* run_loop, Status status) {
[](bool* init_cb_result, base::RunLoop* run_loop,
DecoderStatus status) {
*init_cb_result = status.is_ok();
run_loop->Quit();
},
@ -351,7 +352,7 @@ class FuchsiaVideoDecoderTest : public testing::Test {
DecodeBuffer(ReadTestDataFile(name));
}
void OnFrameDecoded(size_t frame_pos, Status status) {
void OnFrameDecoded(size_t frame_pos, DecoderStatus status) {
EXPECT_EQ(frame_pos, num_decoded_buffers_);
num_decoded_buffers_ += 1;
last_decode_status_ = std::move(status);
@ -388,7 +389,7 @@ class FuchsiaVideoDecoderTest : public testing::Test {
std::list<scoped_refptr<VideoFrame>> output_frames_;
size_t num_output_frames_ = 0;
Status last_decode_status_;
DecoderStatus last_decode_status_;
base::RunLoop* run_loop_ = nullptr;
// Number of frames that OnVideoFrame() should keep in |output_frames_|.

@ -269,7 +269,8 @@ void Gav1VideoDecoder::Initialize(const VideoDecoderConfig& config,
InitCB bound_init_cb = bind_callbacks_ ? BindToCurrentLoop(std::move(init_cb))
: std::move(init_cb);
if (config.is_encrypted() || config.codec() != VideoCodec::kAV1) {
std::move(bound_init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(bound_init_cb)
.Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -295,7 +296,7 @@ void Gav1VideoDecoder::Initialize(const VideoDecoderConfig& config,
if (status != kLibgav1StatusOk) {
MEDIA_LOG(ERROR, media_log_) << "libgav1::Decoder::Init() failed, "
<< "status=" << status;
std::move(bound_init_cb).Run(StatusCode::kDecoderFailedInitialization);
std::move(bound_init_cb).Run(DecoderStatus::Codes::kFailedToCreateDecoder);
return;
}
@ -303,7 +304,7 @@ void Gav1VideoDecoder::Initialize(const VideoDecoderConfig& config,
state_ = DecoderState::kDecoding;
color_space_ = config.color_space_info();
aspect_ratio_ = config.aspect_ratio();
std::move(bound_init_cb).Run(OkStatus());
std::move(bound_init_cb).Run(DecoderStatus::Codes::kOk);
}
void Gav1VideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
@ -320,18 +321,18 @@ void Gav1VideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
: std::move(decode_cb);
if (state_ == DecoderState::kError) {
std::move(bound_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
if (!DecodeBuffer(std::move(buffer))) {
state_ = DecoderState::kError;
std::move(bound_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
// VideoDecoderShim expects |decode_cb| call after |output_cb_|.
std::move(bound_decode_cb).Run(DecodeStatus::OK);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kOk);
}
bool Gav1VideoDecoder::DecodeBuffer(scoped_refptr<DecoderBuffer> buffer) {

@ -82,7 +82,7 @@ class Gav1VideoDecoderTest : public testing::Test {
bool success) {
decoder_->Initialize(config, false, nullptr,
base::BindOnce(
[](bool success, Status status) {
[](bool success, DecoderStatus status) {
EXPECT_EQ(status.is_ok(), success);
},
success),
@ -130,14 +130,14 @@ class Gav1VideoDecoderTest : public testing::Test {
// Decodes all buffers in |input_buffers| and push all successfully decoded
// output frames into |output_frames|. Returns the last decode status returned
// by the decoder.
Status DecodeMultipleFrames(const InputBuffers& input_buffers) {
DecoderStatus DecodeMultipleFrames(const InputBuffers& input_buffers) {
for (auto iter = input_buffers.begin(); iter != input_buffers.end();
++iter) {
Status status = Decode(*iter);
DecoderStatus status = Decode(*iter);
switch (status.code()) {
case StatusCode::kOk:
case DecoderStatus::Codes::kOk:
break;
case StatusCode::kAborted:
case DecoderStatus::Codes::kAborted:
NOTREACHED();
[[fallthrough]];
default:
@ -145,11 +145,11 @@ class Gav1VideoDecoderTest : public testing::Test {
return status;
}
}
return StatusCode::kOk;
return DecoderStatus::Codes::kOk;
}
// Decodes the single compressed frame in |buffer|.
Status DecodeSingleFrame(scoped_refptr<DecoderBuffer> buffer) {
DecoderStatus DecodeSingleFrame(scoped_refptr<DecoderBuffer> buffer) {
InputBuffers input_buffers;
input_buffers.push_back(std::move(buffer));
return DecodeMultipleFrames(input_buffers);
@ -168,9 +168,7 @@ class Gav1VideoDecoderTest : public testing::Test {
input_buffers.push_back(buffer);
input_buffers.push_back(DecoderBuffer::CreateEOSBuffer());
Status status = DecodeMultipleFrames(input_buffers);
EXPECT_TRUE(status.is_ok());
EXPECT_TRUE(DecodeMultipleFrames(input_buffers).is_ok());
ASSERT_EQ(2U, output_frames_.size());
gfx::Size original_size = TestVideoConfig::NormalCodedSize();
@ -184,8 +182,8 @@ class Gav1VideoDecoderTest : public testing::Test {
output_frames_[1]->visible_rect().size().height());
}
Status Decode(scoped_refptr<DecoderBuffer> buffer) {
Status status;
DecoderStatus Decode(scoped_refptr<DecoderBuffer> buffer) {
DecoderStatus status;
EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status));
decoder_->Decode(std::move(buffer),
@ -210,7 +208,7 @@ class Gav1VideoDecoderTest : public testing::Test {
return base::MD5DigestToBase16(digest);
}
MOCK_METHOD1(DecodeDone, void(Status));
MOCK_METHOD1(DecodeDone, void(DecoderStatus));
testing::StrictMock<MockMediaLog> media_log_;

@ -35,7 +35,7 @@ class CancellationHelper {
void Decode(scoped_refptr<DecoderBuffer> buffer,
VideoDecoder::DecodeCB decode_cb) {
if (cancellation_flag_->IsSet()) {
std::move(decode_cb).Run(DecodeStatus::ABORTED);
std::move(decode_cb).Run(DecoderStatus::Codes::kAborted);
return;
}

@ -87,7 +87,7 @@ class OffloadingVideoDecoderTest : public testing::Test {
EXPECT_CALL(*this, InitDone(success))
.WillOnce(VerifyOn(task_env_.GetMainThreadTaskRunner()));
return base::BindOnce(
[](base::OnceCallback<void(bool)> cb, Status status) {
[](base::OnceCallback<void(bool)> cb, DecoderStatus status) {
std::move(cb).Run(status.is_ok());
},
base::BindOnce(&OffloadingVideoDecoderTest::InitDone,
@ -101,7 +101,7 @@ class OffloadingVideoDecoderTest : public testing::Test {
base::Unretained(this));
}
VideoDecoder::DecodeCB ExpectDecodeCB(StatusCode status) {
VideoDecoder::DecodeCB ExpectDecodeCB(DecoderStatus status) {
EXPECT_CALL(*this, DecodeDone(HasStatusCode(status)))
.WillOnce(VerifyOn(task_env_.GetMainThreadTaskRunner()));
return base::BindOnce(&OffloadingVideoDecoderTest::DecodeDone,
@ -128,7 +128,7 @@ class OffloadingVideoDecoderTest : public testing::Test {
VideoDecoder::OutputCB output_cb;
EXPECT_CALL(*decoder_, Initialize_(_, false, nullptr, _, _, _))
.WillOnce(DoAll(VerifyOn(task_env_.GetMainThreadTaskRunner()),
RunOnceCallback<3>(OkStatus()),
RunOnceCallback<3>(DecoderStatus::Codes::kOk),
SaveArg<4>(&output_cb)));
offloading_decoder_->Initialize(config, false, nullptr, ExpectInitCB(true),
ExpectOutputCB(), base::NullCallback());
@ -138,9 +138,9 @@ class OffloadingVideoDecoderTest : public testing::Test {
EXPECT_CALL(*decoder_, Decode_(_, _))
.WillOnce(DoAll(VerifyOn(task_env_.GetMainThreadTaskRunner()),
RunOnceClosure(base::BindOnce(output_cb, nullptr)),
RunOnceCallback<1>(DecodeStatus::OK)));
RunOnceCallback<1>(DecoderStatus::Codes::kOk)));
offloading_decoder_->Decode(DecoderBuffer::CreateEOSBuffer(),
ExpectDecodeCB(DecodeStatus::OK));
ExpectDecodeCB(DecoderStatus::Codes::kOk));
task_env_.RunUntilIdle();
// Reset so we can call Initialize() again.
@ -170,7 +170,7 @@ class OffloadingVideoDecoderTest : public testing::Test {
ExpectOutputCB(), base::NullCallback());
EXPECT_CALL(*decoder_, Initialize_(_, false, nullptr, _, _, _))
.WillOnce(DoAll(VerifyNotOn(task_env_.GetMainThreadTaskRunner()),
RunOnceCallback<3>(OkStatus()),
RunOnceCallback<3>(DecoderStatus::Codes::kOk),
SaveArg<4>(&output_cb)));
task_env_.RunUntilIdle();
@ -179,11 +179,11 @@ class OffloadingVideoDecoderTest : public testing::Test {
// Verify decode works and is called on the right thread.
offloading_decoder_->Decode(DecoderBuffer::CreateEOSBuffer(),
ExpectDecodeCB(DecodeStatus::OK));
ExpectDecodeCB(DecoderStatus::Codes::kOk));
EXPECT_CALL(*decoder_, Decode_(_, _))
.WillOnce(DoAll(VerifyNotOn(task_env_.GetMainThreadTaskRunner()),
RunOnceClosure(base::BindOnce(output_cb, nullptr)),
RunOnceCallback<1>(DecodeStatus::OK)));
RunOnceCallback<1>(DecoderStatus::Codes::kOk)));
task_env_.RunUntilIdle();
// Reset so we can call Initialize() again.
@ -196,7 +196,7 @@ class OffloadingVideoDecoderTest : public testing::Test {
MOCK_METHOD1(InitDone, void(bool));
MOCK_METHOD1(OutputDone, void(scoped_refptr<VideoFrame>));
MOCK_METHOD1(DecodeDone, void(Status));
MOCK_METHOD1(DecodeDone, void(DecoderStatus));
MOCK_METHOD0(ResetDone, void(void));
base::test::TaskEnvironment task_env_;
@ -253,7 +253,8 @@ TEST_F(OffloadingVideoDecoderTest, OffloadingAfterNoOffloading) {
.WillOnce(VerifyNotOn(task_env_.GetMainThreadTaskRunner()));
EXPECT_CALL(*decoder_, Initialize_(_, false, nullptr, _, _, _))
.WillOnce(DoAll(VerifyOn(task_env_.GetMainThreadTaskRunner()),
RunOnceCallback<3>(OkStatus()), SaveArg<4>(&output_cb)));
RunOnceCallback<3>(DecoderStatus::Codes::kOk),
SaveArg<4>(&output_cb)));
task_env_.RunUntilIdle();
}
@ -280,7 +281,8 @@ TEST_F(OffloadingVideoDecoderTest, ParallelizedOffloading) {
base::NullCallback());
EXPECT_CALL(*decoder_, Initialize_(_, false, nullptr, _, _, _))
.WillOnce(DoAll(VerifyNotOn(task_env_.GetMainThreadTaskRunner()),
RunOnceCallback<3>(OkStatus()), SaveArg<4>(&output_cb)));
RunOnceCallback<3>(DecoderStatus::Codes::kOk),
SaveArg<4>(&output_cb)));
task_env_.RunUntilIdle();
// When offloading decodes should be parallelized.
@ -300,7 +302,7 @@ TEST_F(OffloadingVideoDecoderTest, ParallelizedOffloading) {
.Times(2)
.WillRepeatedly(DoAll(VerifyNotOn(task_env_.GetMainThreadTaskRunner()),
RunClosure(base::BindRepeating(output_cb, nullptr)),
RunOnceCallback<1>(DecodeStatus::OK)));
RunOnceCallback<1>(DecoderStatus::Codes::kOk)));
EXPECT_CALL(*this, DecodeDone(IsOkStatus()))
.Times(2)
.WillRepeatedly(VerifyOn(task_env_.GetMainThreadTaskRunner()));
@ -331,7 +333,8 @@ TEST_F(OffloadingVideoDecoderTest, ParallelizedOffloadingResetAbortsDecodes) {
base::NullCallback());
EXPECT_CALL(*decoder_, Initialize_(_, false, nullptr, _, _, _))
.WillOnce(DoAll(VerifyNotOn(task_env_.GetMainThreadTaskRunner()),
RunOnceCallback<3>(OkStatus()), SaveArg<4>(&output_cb)));
RunOnceCallback<3>(DecoderStatus::Codes::kOk),
SaveArg<4>(&output_cb)));
task_env_.RunUntilIdle();
// When offloading decodes should be parallelized.
@ -348,7 +351,7 @@ TEST_F(OffloadingVideoDecoderTest, ParallelizedOffloadingResetAbortsDecodes) {
base::Unretained(this)));
EXPECT_CALL(*decoder_, Decode_(_, _)).Times(0);
EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)))
EXPECT_CALL(*this, DecodeDone(HasStatusCode(DecoderStatus::Codes::kAborted)))
.Times(2)
.WillRepeatedly(VerifyOn(task_env_.GetMainThreadTaskRunner()));
offloading_decoder_->Reset(ExpectResetCB());

@ -369,9 +369,10 @@ class VideoDecoderStreamTest
void FrameReady(VideoDecoderStream::ReadResult result) {
DCHECK(pending_read_);
last_read_status_code_ = result.code();
scoped_refptr<VideoFrame> frame = last_read_status_code_ == StatusCode::kOk
? std::move(result).value()
: nullptr;
scoped_refptr<VideoFrame> frame =
last_read_status_code_ == DecoderStatus::Codes::kOk
? std::move(result).value()
: nullptr;
frame_read_ = frame;
if (frame && !frame->metadata().end_of_stream) {
EXPECT_EQ(*frame->metadata().frame_duration, demuxer_stream_->duration());
@ -555,7 +556,7 @@ class VideoDecoderStreamTest
bool pending_stop_;
int num_decoded_bytes_unreported_;
scoped_refptr<VideoFrame> frame_read_;
StatusCode last_read_status_code_;
DecoderStatus::Codes last_read_status_code_;
// Decryptor has no key to decrypt a frame.
bool has_no_key_;
@ -824,7 +825,7 @@ TEST_P(VideoDecoderStreamTest, Read_DuringEndOfStreamDecode) {
decoder_->SatisfySingleDecode();
base::RunLoop().RunUntilIdle();
ASSERT_FALSE(pending_read_);
EXPECT_EQ(last_read_status_code_, StatusCode::kOk);
EXPECT_EQ(last_read_status_code_, DecoderStatus::Codes::kOk);
// The read output should indicate end of stream.
ASSERT_TRUE(frame_read_.get());
@ -847,8 +848,8 @@ TEST_P(VideoDecoderStreamTest, Read_DemuxerStreamReadError) {
base::RunLoop().RunUntilIdle();
ASSERT_FALSE(pending_read_);
EXPECT_NE(last_read_status_code_, StatusCode::kOk);
EXPECT_NE(last_read_status_code_, StatusCode::kAborted);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kOk);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kAborted);
}
// No Reset() before initialization is successfully completed.
@ -1037,7 +1038,7 @@ TEST_P(VideoDecoderStreamTest, FallbackDecoder_DecodeError) {
ASSERT_EQ(GetDecoderId(1), decoder_->GetDecoderId());
ASSERT_FALSE(pending_read_);
ASSERT_EQ(last_read_status_code_, StatusCode::kOk);
ASSERT_EQ(last_read_status_code_, DecoderStatus::Codes::kOk);
// Check that we fell back to Decoder2.
ASSERT_GT(decoder_->total_bytes_decoded(), 0);
@ -1077,7 +1078,7 @@ TEST_P(VideoDecoderStreamTest,
// A frame should have been emitted.
EXPECT_FALSE(pending_read_);
EXPECT_EQ(last_read_status_code_, StatusCode::kOk);
EXPECT_EQ(last_read_status_code_, DecoderStatus::Codes::kOk);
EXPECT_FALSE(frame_read_->metadata().end_of_stream);
EXPECT_GT(decoder_->total_bytes_decoded(), 0);
@ -1151,8 +1152,8 @@ TEST_P(VideoDecoderStreamTest, FallbackDecoder_DecodeErrorRepeated) {
// No decoders left, expect failure.
EXPECT_EQ(decoder_, nullptr);
EXPECT_FALSE(pending_read_);
EXPECT_NE(last_read_status_code_, StatusCode::kOk);
EXPECT_NE(last_read_status_code_, StatusCode::kAborted);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kOk);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kAborted);
}
// This tests verifies that we properly fallback to a new decoder if the first
@ -1173,7 +1174,7 @@ TEST_P(VideoDecoderStreamTest,
// Verify that the first frame was decoded successfully.
EXPECT_FALSE(pending_read_);
EXPECT_GT(decoder_->total_bytes_decoded(), 0);
EXPECT_EQ(last_read_status_code_, StatusCode::kOk);
EXPECT_EQ(last_read_status_code_, DecoderStatus::Codes::kOk);
// Continue up to the point of reinitialization.
EnterPendingState(DEMUXER_READ_CONFIG_CHANGE);
@ -1197,7 +1198,7 @@ TEST_P(VideoDecoderStreamTest,
// Verify that fallback happened.
EXPECT_EQ(GetDecoderId(0), decoder_->GetDecoderId());
EXPECT_FALSE(pending_read_);
EXPECT_EQ(last_read_status_code_, StatusCode::kOk);
EXPECT_EQ(last_read_status_code_, DecoderStatus::Codes::kOk);
EXPECT_GT(decoder_->total_bytes_decoded(), 0);
}
@ -1234,8 +1235,8 @@ TEST_P(VideoDecoderStreamTest,
// No decoders left.
EXPECT_EQ(decoder_, nullptr);
EXPECT_FALSE(pending_read_);
EXPECT_NE(last_read_status_code_, StatusCode::kOk);
EXPECT_NE(last_read_status_code_, StatusCode::kAborted);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kOk);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kAborted);
}
TEST_P(VideoDecoderStreamTest,
@ -1388,7 +1389,7 @@ TEST_P(VideoDecoderStreamTest, FallbackDecoder_SelectedOnDecodeThenInitErrors) {
ASSERT_EQ(GetDecoderId(2), decoder_->GetDecoderId());
ASSERT_FALSE(pending_read_);
ASSERT_EQ(last_read_status_code_, StatusCode::kOk);
ASSERT_EQ(last_read_status_code_, DecoderStatus::Codes::kOk);
// Can't check previously selected decoder(s) right now, they might have been
// destroyed already.
@ -1413,7 +1414,7 @@ TEST_P(VideoDecoderStreamTest, FallbackDecoder_SelectedOnInitThenDecodeErrors) {
ASSERT_EQ(GetDecoderId(2), decoder_->GetDecoderId());
ASSERT_FALSE(pending_read_);
ASSERT_EQ(last_read_status_code_, StatusCode::kOk);
ASSERT_EQ(last_read_status_code_, DecoderStatus::Codes::kOk);
// Can't check previously selected decoder(s) right now, they might have been
// destroyed already.
@ -1435,7 +1436,7 @@ TEST_P(VideoDecoderStreamTest,
decoder_->SimulateError();
// The error must surface from Read() as DECODE_ERROR.
while (last_read_status_code_ == StatusCode::kOk) {
while (last_read_status_code_ == DecoderStatus::Codes::kOk) {
ReadOneFrame();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(pending_read_);
@ -1444,8 +1445,8 @@ TEST_P(VideoDecoderStreamTest,
// Verify the error was surfaced, rather than falling back to other decoders.
ASSERT_EQ(GetDecoderId(0), decoder_->GetDecoderId());
EXPECT_FALSE(pending_read_);
EXPECT_NE(last_read_status_code_, StatusCode::kOk);
EXPECT_NE(last_read_status_code_, StatusCode::kAborted);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kOk);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kAborted);
}
TEST_P(VideoDecoderStreamTest, DecoderErrorWhenNotReading) {
@ -1464,13 +1465,13 @@ TEST_P(VideoDecoderStreamTest, DecoderErrorWhenNotReading) {
decoder_->SimulateError();
// The error must surface from Read() as DECODE_ERROR.
while (last_read_status_code_ == StatusCode::kOk) {
while (last_read_status_code_ == DecoderStatus::Codes::kOk) {
ReadOneFrame();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(pending_read_);
}
EXPECT_NE(last_read_status_code_, StatusCode::kOk);
EXPECT_NE(last_read_status_code_, StatusCode::kAborted);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kOk);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kAborted);
}
TEST_P(VideoDecoderStreamTest, ReinitializeFailure_Once) {
@ -1531,13 +1532,13 @@ TEST_P(VideoDecoderStreamTest, ReinitializeFailure_NoSupportedDecoder) {
ReadUntilDecoderReinitialized();
// The error will surface from Read() as DECODE_ERROR.
while (last_read_status_code_ == StatusCode::kOk) {
while (last_read_status_code_ == DecoderStatus::Codes::kOk) {
ReadOneFrame();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(pending_read_);
}
EXPECT_NE(last_read_status_code_, StatusCode::kOk);
EXPECT_NE(last_read_status_code_, StatusCode::kAborted);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kOk);
EXPECT_NE(last_read_status_code_, DecoderStatus::Codes::kAborted);
}
TEST_P(VideoDecoderStreamTest, Destroy_DuringFallbackDecoderSelection) {

@ -146,12 +146,13 @@ void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config,
InitCB bound_init_cb = bind_callbacks_ ? BindToCurrentLoop(std::move(init_cb))
: std::move(init_cb);
if (config.is_encrypted()) {
std::move(bound_init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(bound_init_cb)
.Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
if (!ConfigureDecoder(config)) {
std::move(bound_init_cb).Run(StatusCode::kDecoderFailedInitialization);
std::move(bound_init_cb).Run(DecoderStatus::Codes::kUnsupportedConfig);
return;
}
@ -159,7 +160,7 @@ void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config,
config_ = config;
state_ = DecoderState::kNormal;
output_cb_ = output_cb;
std::move(bound_init_cb).Run(OkStatus());
std::move(bound_init_cb).Run(DecoderStatus::Codes::kOk);
}
void VpxVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
@ -176,25 +177,25 @@ void VpxVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
: std::move(decode_cb);
if (state_ == DecoderState::kError) {
std::move(bound_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
if (state_ == DecoderState::kDecodeFinished) {
std::move(bound_decode_cb).Run(DecodeStatus::OK);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kOk);
return;
}
if (state_ == DecoderState::kNormal && buffer->end_of_stream()) {
state_ = DecoderState::kDecodeFinished;
std::move(bound_decode_cb).Run(DecodeStatus::OK);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kOk);
return;
}
scoped_refptr<VideoFrame> video_frame;
if (!VpxDecode(buffer.get(), &video_frame)) {
state_ = DecoderState::kError;
std::move(bound_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -206,7 +207,7 @@ void VpxVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
}
// VideoDecoderShim expects |decode_cb| call after |output_cb_|.
std::move(bound_decode_cb).Run(DecodeStatus::OK);
std::move(bound_decode_cb).Run(DecoderStatus::Codes::kOk);
}
void VpxVideoDecoder::Reset(base::OnceClosure reset_cb) {

@ -30,13 +30,14 @@ struct Env {
base::test::SingleThreadTaskEnvironment task_environment;
};
void OnDecodeComplete(base::OnceClosure quit_closure, media::Status status) {
void OnDecodeComplete(base::OnceClosure quit_closure,
media::DecoderStatus status) {
std::move(quit_closure).Run();
}
void OnInitDone(base::OnceClosure quit_closure,
bool* success_dest,
media::Status status) {
media::DecoderStatus status) {
*success_dest = status.is_ok();
std::move(quit_closure).Run();
}

@ -44,7 +44,7 @@ class VpxVideoDecoderTest : public testing::Test {
bool success) {
decoder_->Initialize(config, false, nullptr,
base::BindOnce(
[](bool success, Status status) {
[](bool success, DecoderStatus status) {
EXPECT_EQ(status.is_ok(), success);
},
success),
@ -92,14 +92,14 @@ class VpxVideoDecoderTest : public testing::Test {
// Decodes all buffers in |input_buffers| and push all successfully decoded
// output frames into |output_frames|.
// Returns the last decode status returned by the decoder.
Status DecodeMultipleFrames(const InputBuffers& input_buffers) {
DecoderStatus DecodeMultipleFrames(const InputBuffers& input_buffers) {
for (auto iter = input_buffers.begin(); iter != input_buffers.end();
++iter) {
Status status = Decode(*iter);
DecoderStatus status = Decode(*iter);
switch (status.code()) {
case StatusCode::kOk:
case DecoderStatus::Codes::kOk:
break;
case StatusCode::kAborted:
case DecoderStatus::Codes::kAborted:
NOTREACHED();
[[fallthrough]];
default:
@ -107,14 +107,14 @@ class VpxVideoDecoderTest : public testing::Test {
return status;
}
}
return OkStatus();
return DecoderStatus::Codes::kOk;
}
// Decodes the single compressed frame in |buffer| and writes the
// uncompressed output to |video_frame|. This method works with single
// and multithreaded decoders. End of stream buffers are used to trigger
// the frame to be returned in the multithreaded decoder case.
Status DecodeSingleFrame(scoped_refptr<DecoderBuffer> buffer) {
DecoderStatus DecodeSingleFrame(scoped_refptr<DecoderBuffer> buffer) {
InputBuffers input_buffers;
input_buffers.push_back(std::move(buffer));
input_buffers.push_back(DecoderBuffer::CreateEOSBuffer());
@ -135,7 +135,7 @@ class VpxVideoDecoderTest : public testing::Test {
input_buffers.push_back(buffer);
input_buffers.push_back(DecoderBuffer::CreateEOSBuffer());
Status status = DecodeMultipleFrames(input_buffers);
DecoderStatus status = DecodeMultipleFrames(input_buffers);
EXPECT_TRUE(status.is_ok());
ASSERT_EQ(2U, output_frames_.size());
@ -151,8 +151,8 @@ class VpxVideoDecoderTest : public testing::Test {
output_frames_[1]->visible_rect().size().height());
}
Status Decode(scoped_refptr<DecoderBuffer> buffer) {
Status status;
DecoderStatus Decode(scoped_refptr<DecoderBuffer> buffer) {
DecoderStatus status;
EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status));
decoder_->Decode(std::move(buffer),
@ -168,7 +168,7 @@ class VpxVideoDecoderTest : public testing::Test {
output_frames_.push_back(std::move(frame));
}
MOCK_METHOD1(DecodeDone, void(Status));
MOCK_METHOD1(DecodeDone, void(DecoderStatus));
base::test::TaskEnvironment task_env_;
std::unique_ptr<VideoDecoder> decoder_;
@ -326,7 +326,7 @@ TEST_F(VpxVideoDecoderTest, MemoryPoolAllowsMultipleDisplay) {
AVPacket packet = {};
while (av_read_frame(glue.format_context(), &packet) >= 0) {
Status decode_status =
DecoderStatus decode_status =
Decode(DecoderBuffer::CopyFrom(packet.data, packet.size));
av_packet_unref(&packet);
if (!decode_status.is_ok())

@ -309,7 +309,7 @@ void MediaCodecVideoDecoder::DestroyAsync(
// Cancel callbacks we no longer want.
self->codec_allocator_weak_factory_.InvalidateWeakPtrs();
self->CancelPendingDecodes(DecodeStatus::ABORTED);
self->CancelPendingDecodes(DecoderStatus::Codes::kAborted);
self->StartDrainingCodec(DrainType::kForDestroy);
// Per the WARNING above. Validate that no draining work remains.
@ -336,7 +336,7 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
<< config.AsHumanReadableString();
DVLOG(1) << "Invalid configuration.";
BindToCurrentLoop(std::move(init_cb))
.Run(StatusCode::kDecoderUnsupportedConfig);
.Run(DecoderStatus::Codes::kUnsupportedConfig);
return;
}
@ -351,7 +351,7 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
MEDIA_LOG(INFO, media_log_) << "Video configuration is not valid: "
<< config.AsHumanReadableString();
BindToCurrentLoop(std::move(init_cb))
.Run(StatusCode::kDecoderUnsupportedConfig);
.Run(DecoderStatus::Codes::kUnsupportedConfig);
return;
}
@ -362,7 +362,7 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
<< decoder_config_.AsHumanReadableString()
<< " -> " << config.AsHumanReadableString();
BindToCurrentLoop(std::move(init_cb))
.Run(StatusCode::kDecoderCantChangeCodec);
.Run(DecoderStatus::Codes::kCantChangeCodec);
return;
}
decoder_config_ = config;
@ -391,12 +391,12 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
DVLOG(1) << "No MediaCrypto to handle encrypted config";
MEDIA_LOG(INFO, media_log_) << "No MediaCrypto to handle encrypted config";
BindToCurrentLoop(std::move(init_cb))
.Run(StatusCode::kDecoderMissingCdmForEncryptedContent);
.Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
// Do the rest of the initialization lazily on the first decode.
BindToCurrentLoop(std::move(init_cb)).Run(OkStatus());
BindToCurrentLoop(std::move(init_cb)).Run(DecoderStatus::Codes::kOk);
const int width = decoder_config_.coded_size().width();
// On re-init, reallocate the codec if the size has changed too much.
@ -451,14 +451,14 @@ void MediaCodecVideoDecoder::OnMediaCryptoReady(
if (decoder_config_.is_encrypted()) {
LOG(ERROR) << "MediaCrypto is not available";
EnterTerminalState(State::kError, "MediaCrypto is not available");
std::move(init_cb).Run(StatusCode::kDecoderMissingCdmForEncryptedContent);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
// MediaCrypto is not available, but the stream is clear. So we can still
// play the current stream. But if we switch to an encrypted stream playback
// will fail.
std::move(init_cb).Run(OkStatus());
std::move(init_cb).Run(DecoderStatus::Codes::kOk);
return;
}
@ -473,7 +473,7 @@ void MediaCodecVideoDecoder::OnMediaCryptoReady(
: SurfaceChooserHelper::SecureSurfaceMode::kRequested);
// Signal success, and create the codec lazily on the first decode.
std::move(init_cb).Run(OkStatus());
std::move(init_cb).Run(DecoderStatus::Codes::kOk);
}
void MediaCodecVideoDecoder::OnCdmContextEvent(CdmContext::Event event) {
@ -736,7 +736,7 @@ void MediaCodecVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
DecodeCB decode_cb) {
DVLOG(3) << __func__ << ": " << buffer->AsHumanReadableString();
if (state_ == State::kError) {
std::move(decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
pending_decodes_.emplace_back(std::move(buffer), std::move(decode_cb));
@ -932,7 +932,7 @@ bool MediaCodecVideoDecoder::QueueInput() {
DCHECK(!eos_decode_cb_);
eos_decode_cb_ = std::move(pending_decode.decode_cb);
} else {
std::move(pending_decode.decode_cb).Run(DecodeStatus::OK);
std::move(pending_decode.decode_cb).Run(DecoderStatus::Codes::kOk);
}
pending_decodes_.pop_front();
return true;
@ -1039,7 +1039,7 @@ void MediaCodecVideoDecoder::RunEosDecodeCb(int reset_generation) {
// * After a Reset(), the reset generations won't match, but we might already
// have a new |eos_decode_cb_| for the new generation.
if (reset_generation == reset_generation_ && eos_decode_cb_)
std::move(eos_decode_cb_).Run(DecodeStatus::OK);
std::move(eos_decode_cb_).Run(DecoderStatus::Codes::kOk);
}
void MediaCodecVideoDecoder::ForwardVideoFrame(
@ -1080,7 +1080,7 @@ void MediaCodecVideoDecoder::Reset(base::OnceClosure closure) {
DCHECK(!reset_cb_);
reset_generation_++;
reset_cb_ = std::move(closure);
CancelPendingDecodes(DecodeStatus::ABORTED);
CancelPendingDecodes(DecoderStatus::Codes::kAborted);
StartDrainingCodec(DrainType::kForReset);
}
@ -1163,7 +1163,7 @@ void MediaCodecVideoDecoder::EnterTerminalState(State state,
target_surface_bundle_ = nullptr;
texture_owner_bundle_ = nullptr;
if (state == State::kError)
CancelPendingDecodes(DecodeStatus::DECODE_ERROR);
CancelPendingDecodes(DecoderStatus::Codes::kFailed);
if (drain_type_)
OnCodecDrained();
}
@ -1172,7 +1172,7 @@ bool MediaCodecVideoDecoder::InTerminalState() {
return state_ == State::kSurfaceDestroyed || state_ == State::kError;
}
void MediaCodecVideoDecoder::CancelPendingDecodes(DecodeStatus status) {
void MediaCodecVideoDecoder::CancelPendingDecodes(DecoderStatus status) {
for (auto& pending_decode : pending_decodes_)
std::move(pending_decode.decode_cb).Run(status);
pending_decodes_.clear();

@ -211,7 +211,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder final
// if possible.
void StartDrainingCodec(DrainType drain_type);
void OnCodecDrained();
void CancelPendingDecodes(DecodeStatus status);
void CancelPendingDecodes(DecoderStatus status);
// Sets |state_| and does common teardown for the terminal states. |state_|
// must be either kSurfaceDestroyed or kError. |reason| will be logged to

@ -185,7 +185,7 @@ class MediaCodecVideoDecoderTest : public testing::TestWithParam<VideoCodec> {
if (!mcvd_)
CreateMcvd();
bool result = false;
auto init_cb = [](bool* result_out, Status result) {
auto init_cb = [](bool* result_out, DecoderStatus result) {
*result_out = result.is_ok();
};
mcvd_->Initialize(
@ -602,7 +602,7 @@ TEST_P(MediaCodecVideoDecoderTest,
TEST_P(MediaCodecVideoDecoderTest, ResetAbortsPendingDecodes) {
InitializeWithTextureOwner_OneDecodePending(TestVideoConfig::Large(codec_));
EXPECT_CALL(decode_cb_, Run(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(decode_cb_, Run(HasStatusCode(DecoderStatus::Codes::kAborted)));
DoReset();
testing::Mock::VerifyAndClearExpectations(&decode_cb_);
}
@ -620,7 +620,8 @@ TEST_P(MediaCodecVideoDecoderTest, ResetAbortsPendingEosDecode) {
codec->AcceptOneInput(MockMediaCodecBridge::kEos);
PumpCodec();
EXPECT_CALL(eos_decode_cb, Run(HasStatusCode(StatusCode::kAborted)));
EXPECT_CALL(eos_decode_cb,
Run(HasStatusCode(DecoderStatus::Codes::kAborted)));
DoReset();
// Should be run before |mcvd_| is destroyed.
testing::Mock::VerifyAndClearExpectations(&eos_decode_cb);

@ -36,7 +36,7 @@ DecoderBufferTranscryptor::DecoderBufferTranscryptor(
DecoderBufferTranscryptor::~DecoderBufferTranscryptor() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
Reset(DecodeStatus::ABORTED);
Reset(DecoderStatus::Codes::kAborted);
}
void DecoderBufferTranscryptor::EnqueueBuffer(
@ -47,7 +47,7 @@ void DecoderBufferTranscryptor::EnqueueBuffer(
DecryptPendingBuffer();
}
void DecoderBufferTranscryptor::Reset(DecodeStatus status) {
void DecoderBufferTranscryptor::Reset(DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (current_transcrypt_task_) {
std::move(current_transcrypt_task_->decode_done_cb).Run(status);
@ -150,4 +150,4 @@ void DecoderBufferTranscryptor::OnBufferTranscrypted(
DecryptPendingBuffer();
}
} // namespace media
} // namespace media

@ -13,8 +13,8 @@
#include "base/sequence_checker.h"
#include "media/base/callback_registry.h"
#include "media/base/cdm_context.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decoder_status.h"
#include "media/base/decryptor.h"
#include "media/base/video_decoder.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
@ -48,7 +48,7 @@ class DecoderBufferTranscryptor {
// Removes all pending tasks and invokes all pending VideoDecoder::DecodeCB
// callbacks with the passed in |status|.
void Reset(DecodeStatus status);
void Reset(DecoderStatus status);
private:
// Transcrypt task holding single transcrypt request.

@ -270,7 +270,7 @@ bool VdVideoDecodeAccelerator::Initialize(const Config& config,
return true;
}
void VdVideoDecodeAccelerator::OnInitializeDone(Status status) {
void VdVideoDecodeAccelerator::OnInitializeDone(DecoderStatus status) {
DVLOGF(3) << "success: " << status.is_ok();
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);
DCHECK(client_);
@ -313,12 +313,13 @@ void VdVideoDecodeAccelerator::Decode(scoped_refptr<DecoderBuffer> buffer,
}
void VdVideoDecodeAccelerator::OnDecodeDone(int32_t bitstream_buffer_id,
Status status) {
DVLOGF(4) << "status: " << status.code();
DecoderStatus status) {
DVLOGF(4) << "status: " << status.group() << ":"
<< static_cast<int>(status.code());
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);
DCHECK(client_);
if (!status.is_ok() && status.code() != StatusCode::kAborted) {
if (!status.is_ok() && status.code() != DecoderStatus::Codes::kAborted) {
OnError(FROM_HERE, PLATFORM_FAILURE);
return;
}
@ -364,16 +365,16 @@ void VdVideoDecodeAccelerator::Flush() {
base::BindOnce(&VdVideoDecodeAccelerator::OnFlushDone, weak_this_));
}
void VdVideoDecodeAccelerator::OnFlushDone(Status status) {
DVLOGF(3) << "status: " << status.code();
void VdVideoDecodeAccelerator::OnFlushDone(DecoderStatus status) {
DVLOGF(3) << "status: " << static_cast<int>(status.code());
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);
DCHECK(client_);
switch (status.code()) {
case StatusCode::kOk:
case DecoderStatus::Codes::kOk:
client_->NotifyFlushDone();
break;
case StatusCode::kAborted:
case DecoderStatus::Codes::kAborted:
// Do nothing.
break;
default:

@ -93,10 +93,10 @@ class MEDIA_GPU_EXPORT VdVideoDecodeAccelerator
scoped_refptr<base::SequencedTaskRunner> task_runner);
// Callback methods of |vd_|.
void OnInitializeDone(Status status);
void OnDecodeDone(int32_t bitstream_buffer_id, Status status);
void OnInitializeDone(DecoderStatus status);
void OnDecodeDone(int32_t bitstream_buffer_id, DecoderStatus status);
void OnFrameReady(scoped_refptr<VideoFrame> frame);
void OnFlushDone(Status status);
void OnFlushDone(DecoderStatus status);
void OnResetDone();
// Get Picture instance that represents the same buffer as |frame|. Return

@ -265,24 +265,24 @@ void VideoDecoderPipeline::Initialize(const VideoDecoderConfig& config,
if (!config.IsValidConfig()) {
VLOGF(1) << "config is not valid";
std::move(init_cb).Run(StatusCode::kDecoderUnsupportedConfig);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedConfig);
return;
}
#if BUILDFLAG(USE_CHROMEOS_PROTECTED_MEDIA)
if (config.is_encrypted() && !cdm_context) {
VLOGF(1) << "Encrypted streams require a CdmContext";
std::move(init_cb).Run(StatusCode::kDecoderUnsupportedConfig);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedConfig);
return;
}
#else // BUILDFLAG(USE_CHROMEOS_PROTECTED_MEDIA)
if (config.is_encrypted() && !allow_encrypted_content_for_testing_) {
VLOGF(1) << "Encrypted streams are not supported for this VD";
std::move(init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
if (cdm_context && !allow_encrypted_content_for_testing_) {
VLOGF(1) << "cdm_context is not supported.";
std::move(init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
#endif // !BUILDFLAG(USE_CHROMEOS_PROTECTED_MEDIA)
@ -320,7 +320,8 @@ void VideoDecoderPipeline::InitializeTask(const VideoDecoderConfig& config,
OnError("|decoder_| creation failed.");
client_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(std::move(init_cb), StatusCode::kDecoderFailedCreation));
base::BindOnce(std::move(init_cb),
DecoderStatus::Codes::kFailedToCreateDecoder));
return;
}
@ -336,14 +337,14 @@ void VideoDecoderPipeline::InitializeTask(const VideoDecoderConfig& config,
void VideoDecoderPipeline::OnInitializeDone(InitCB init_cb,
CdmContext* cdm_context,
Status status) {
DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_sequence_checker_);
DVLOGF(4) << "Initialization status = " << status.code();
DVLOGF(4) << "Initialization status = " << static_cast<int>(status.code());
if (!status.is_ok()) {
MEDIA_LOG(ERROR, media_log_)
<< "VideoDecoderPipeline |decoder_| Initialize() failed, status: "
<< status.code();
<< static_cast<int>(status.code());
decoder_ = nullptr;
}
MEDIA_LOG(INFO, media_log_)
@ -354,7 +355,7 @@ void VideoDecoderPipeline::OnInitializeDone(InitCB init_cb,
if (!cdm_context) {
VLOGF(1) << "CdmContext required for transcryption";
decoder_ = nullptr;
status = Status(StatusCode::kDecoderMissingCdmForEncryptedContent);
status = DecoderStatus::Codes::kUnsupportedEncryptionMode;
} else {
// We need to enable transcryption for protected content.
buffer_transcryptor_ = std::make_unique<DecoderBufferTranscryptor>(
@ -402,10 +403,10 @@ void VideoDecoderPipeline::OnResetDone(base::OnceClosure reset_cb) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (buffer_transcryptor_)
buffer_transcryptor_->Reset(DecodeStatus::ABORTED);
buffer_transcryptor_->Reset(DecoderStatus::Codes::kAborted);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
CallFlushCbIfNeeded(DecodeStatus::ABORTED);
CallFlushCbIfNeeded(DecoderStatus::Codes::kAborted);
if (need_frame_pool_rebuild_) {
need_frame_pool_rebuild_ = false;
@ -437,8 +438,8 @@ void VideoDecoderPipeline::DecodeTask(scoped_refptr<DecoderBuffer> buffer,
if (has_error_) {
client_task_runner_->PostTask(
FROM_HERE, base::BindOnce(std::move(decode_cb),
Status(DecodeStatus::DECODE_ERROR)));
FROM_HERE,
base::BindOnce(std::move(decode_cb), DecoderStatus::Codes::kFailed));
return;
}
@ -461,16 +462,17 @@ void VideoDecoderPipeline::DecodeTask(scoped_refptr<DecoderBuffer> buffer,
void VideoDecoderPipeline::OnDecodeDone(bool is_flush,
DecodeCB decode_cb,
Status status) {
DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_sequence_checker_);
DVLOGF(4) << "is_flush: " << is_flush << ", status: " << status.code();
DVLOGF(4) << "is_flush: " << is_flush
<< ", status: " << static_cast<int>(status.code());
if (has_error_)
status = Status(DecodeStatus::DECODE_ERROR);
status = DecoderStatus::Codes::kFailed;
if (is_flush && status.is_ok()) {
client_flush_cb_ = std::move(decode_cb);
CallFlushCbIfNeeded(DecodeStatus::OK);
CallFlushCbIfNeeded(DecoderStatus::Codes::kOk);
return;
}
@ -526,7 +528,7 @@ void VideoDecoderPipeline::OnFrameConverted(scoped_refptr<VideoFrame> frame) {
FROM_HERE, base::BindOnce(client_output_cb_, std::move(frame)));
// After outputting a frame, flush might be completed.
CallFlushCbIfNeeded(DecodeStatus::OK);
CallFlushCbIfNeeded(DecoderStatus::Codes::kOk);
CallApplyResolutionChangeIfNeeded();
}
@ -555,20 +557,20 @@ void VideoDecoderPipeline::OnError(const std::string& msg) {
has_error_ = true;
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (buffer_transcryptor_)
buffer_transcryptor_->Reset(DecodeStatus::DECODE_ERROR);
buffer_transcryptor_->Reset(DecoderStatus::Codes::kFailed);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
CallFlushCbIfNeeded(DecodeStatus::DECODE_ERROR);
CallFlushCbIfNeeded(DecoderStatus::Codes::kFailed);
}
void VideoDecoderPipeline::CallFlushCbIfNeeded(DecodeStatus status) {
void VideoDecoderPipeline::CallFlushCbIfNeeded(DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_sequence_checker_);
DVLOGF(3) << "status: " << status;
DVLOGF(3) << "status: " << static_cast<int>(status.code());
if (!client_flush_cb_)
return;
// Flush is not completed yet.
if (status == DecodeStatus::OK && HasPendingFrames())
if (status == DecoderStatus::Codes::kOk && HasPendingFrames())
return;
client_task_runner_->PostTask(
@ -782,7 +784,7 @@ void VideoDecoderPipeline::OnBufferTranscrypted(
DCHECK(!has_error_);
if (!transcrypted_buffer) {
OnError("Error in buffer transcryption");
std::move(decode_callback).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_callback).Run(DecoderStatus::Codes::kFailed);
return;
}

@ -198,9 +198,11 @@ class MEDIA_GPU_EXPORT VideoDecoderPipeline : public VideoDecoder,
void ResetTask(base::OnceClosure reset_cb);
void DecodeTask(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb);
void OnInitializeDone(InitCB init_cb, CdmContext* cdm_context, Status status);
void OnInitializeDone(InitCB init_cb,
CdmContext* cdm_context,
DecoderStatus status);
void OnDecodeDone(bool eos_buffer, DecodeCB decode_cb, Status status);
void OnDecodeDone(bool eos_buffer, DecodeCB decode_cb, DecoderStatus status);
void OnResetDone(base::OnceClosure reset_cb);
void OnError(const std::string& msg);
@ -222,7 +224,7 @@ class MEDIA_GPU_EXPORT VideoDecoderPipeline : public VideoDecoder,
void CallApplyResolutionChangeIfNeeded();
// Call |client_flush_cb_| with |status|.
void CallFlushCbIfNeeded(DecodeStatus status);
void CallFlushCbIfNeeded(DecoderStatus status);
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Callback for when transcryption of a buffer completes.

@ -144,7 +144,7 @@ struct DecoderPipelineTestParams {
using RepeatingCreateDecoderFunctionCB = base::RepeatingCallback<
VideoDecoderPipeline::CreateDecoderFunctionCB::RunType>;
RepeatingCreateDecoderFunctionCB create_decoder_function_cb;
StatusCode status_code;
DecoderStatus::Codes status_code;
};
class VideoDecoderPipelineTest
@ -176,10 +176,10 @@ class VideoDecoderPipelineTest
VideoDecoderPipeline::DestroyAsync(std::move(decoder_));
task_environment_.RunUntilIdle();
}
MOCK_METHOD1(OnInit, void(Status));
MOCK_METHOD1(OnInit, void(DecoderStatus));
MOCK_METHOD1(OnOutput, void(scoped_refptr<VideoFrame>));
MOCK_METHOD0(OnResetDone, void());
MOCK_METHOD1(OnDecodeDone, void(Status));
MOCK_METHOD1(OnDecodeDone, void(DecoderStatus));
MOCK_METHOD1(OnWaiting, void(WaitingReason));
void SetCreateDecoderFunctionCB(VideoDecoderPipeline::CreateDecoderFunctionCB
@ -197,7 +197,7 @@ class VideoDecoderPipelineTest
// verifying |status_code| is received back in OnInit().
void InitializeDecoder(
VideoDecoderPipeline::CreateDecoderFunctionCB create_decoder_function_cb,
StatusCode status_code,
DecoderStatus::Codes status_code,
CdmContext* cdm_context = nullptr) {
SetCreateDecoderFunctionCB(std::move(create_decoder_function_cb));
@ -234,7 +234,7 @@ class VideoDecoderPipelineTest
InitializeDecoder(
base::BindOnce(
&VideoDecoderPipelineTest::CreateGoodMockTranscryptDecoder),
StatusCode::kOk, &cdm_context_);
DecoderStatus::Codes::kOk, &cdm_context_);
testing::Mock::VerifyAndClearExpectations(&chromeos_cdm_context_);
testing::Mock::VerifyAndClearExpectations(&cdm_context_);
// GetDecryptor() will be called again, so set that expectation.
@ -262,7 +262,7 @@ class VideoDecoderPipelineTest
std::unique_ptr<MockDecoder> decoder(new MockDecoder());
EXPECT_CALL(*decoder, Initialize(_, _, _, _, _, _))
.WillOnce(::testing::WithArgs<3>([](VideoDecoder::InitCB init_cb) {
std::move(init_cb).Run(OkStatus());
std::move(init_cb).Run(DecoderStatus::Codes::kOk);
}));
EXPECT_CALL(*decoder, NeedsTranscryption()).WillRepeatedly(Return(false));
return std::move(decoder);
@ -277,7 +277,7 @@ class VideoDecoderPipelineTest
std::unique_ptr<MockDecoder> decoder(new MockDecoder());
EXPECT_CALL(*decoder, Initialize(_, _, _, _, _, _))
.WillOnce(::testing::WithArgs<3>([](VideoDecoder::InitCB init_cb) {
std::move(init_cb).Run(OkStatus());
std::move(init_cb).Run(DecoderStatus::Codes::kOk);
}));
EXPECT_CALL(*decoder, NeedsTranscryption()).WillRepeatedly(Return(true));
return std::move(decoder);
@ -291,7 +291,7 @@ class VideoDecoderPipelineTest
std::unique_ptr<MockDecoder> decoder(new MockDecoder());
EXPECT_CALL(*decoder, Initialize(_, _, _, _, _, _))
.WillOnce(::testing::WithArgs<3>([](VideoDecoder::InitCB init_cb) {
std::move(init_cb).Run(StatusCode::kDecoderInitializationFailed);
std::move(init_cb).Run(DecoderStatus::Codes::kFailed);
}));
EXPECT_CALL(*decoder, NeedsTranscryption()).WillRepeatedly(Return(false));
return std::move(decoder);
@ -355,7 +355,7 @@ TEST_P(VideoDecoderPipelineTest, Initialize) {
InitializeDecoder(base::BindOnce(GetParam().create_decoder_function_cb),
GetParam().status_code);
EXPECT_EQ(GetParam().status_code == StatusCode::kOk,
EXPECT_EQ(GetParam().status_code == DecoderStatus::Codes::kOk,
!!GetUnderlyingDecoder());
}
@ -363,12 +363,12 @@ const struct DecoderPipelineTestParams kDecoderPipelineTestParams[] = {
// A CreateDecoderFunctionCB that fails to Create() (i.e. returns a
// null Decoder)
{base::BindRepeating(&VideoDecoderPipelineTest::CreateNullMockDecoder),
StatusCode::kDecoderFailedCreation},
DecoderStatus::Codes::kFailedToCreateDecoder},
// A CreateDecoderFunctionCB that works fine, i.e. Create()s and
// Initialize()s correctly.
{base::BindRepeating(&VideoDecoderPipelineTest::CreateGoodMockDecoder),
StatusCode::kOk},
DecoderStatus::Codes::kOk},
// A CreateDecoderFunctionCB for transcryption, where Create() is ok, and
// the decoder will Initialize OK, but then the pipeline will not create the
@ -376,12 +376,12 @@ const struct DecoderPipelineTestParams kDecoderPipelineTestParams[] = {
// through InitializeForTranscrypt where a CdmContext is set.
{base::BindRepeating(
&VideoDecoderPipelineTest::CreateGoodMockTranscryptDecoder),
StatusCode::kDecoderMissingCdmForEncryptedContent},
DecoderStatus::Codes::kUnsupportedEncryptionMode},
// A CreateDecoderFunctionCB that Create()s ok but fails to Initialize()
// correctly.
{base::BindRepeating(&VideoDecoderPipelineTest::CreateBadMockDecoder),
StatusCode::kDecoderInitializationFailed},
DecoderStatus::Codes::kFailed},
};
INSTANTIATE_TEST_SUITE_P(All,
@ -392,7 +392,7 @@ INSTANTIATE_TEST_SUITE_P(All,
TEST_F(VideoDecoderPipelineTest, Reset) {
InitializeDecoder(
base::BindOnce(&VideoDecoderPipelineTest::CreateGoodMockDecoder),
StatusCode::kOk);
DecoderStatus::Codes::kOk);
// When we call Reset(), we expect GetUnderlyingDecoder()'s Reset() method to
// be called, and when that method Run()s its argument closure, then
@ -427,9 +427,10 @@ TEST_F(VideoDecoderPipelineTest, TranscryptThenEos) {
Decode(transcrypted_buffer_, _))
.WillOnce([](scoped_refptr<DecoderBuffer> transcrypted,
VideoDecoderMixin::DecodeCB decode_cb) {
std::move(decode_cb).Run(OkStatus());
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
});
EXPECT_CALL(*this, OnDecodeDone(MatchesStatusCode(StatusCode::kOk)));
EXPECT_CALL(*this,
OnDecodeDone(MatchesStatusCode(DecoderStatus::Codes::kOk)));
}
decoder_->Decode(encrypted_buffer_,
base::BindOnce(&VideoDecoderPipelineTest::OnDecodeDone,
@ -449,9 +450,10 @@ TEST_F(VideoDecoderPipelineTest, TranscryptThenEos) {
Decode(eos_buffer, _))
.WillOnce([](scoped_refptr<DecoderBuffer> transcrypted,
VideoDecoderMixin::DecodeCB decode_cb) {
std::move(decode_cb).Run(OkStatus());
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
});
EXPECT_CALL(*this, OnDecodeDone(MatchesStatusCode(StatusCode::kOk)));
EXPECT_CALL(*this,
OnDecodeDone(MatchesStatusCode(DecoderStatus::Codes::kOk)));
}
decoder_->Decode(eos_buffer,
base::BindOnce(&VideoDecoderPipelineTest::OnDecodeDone,
@ -486,7 +488,8 @@ TEST_F(VideoDecoderPipelineTest, TranscryptReset) {
EXPECT_CALL(*reinterpret_cast<MockDecoder*>(GetUnderlyingDecoder()),
Reset(_))
.WillOnce([](base::OnceClosure closure) { std::move(closure).Run(); });
EXPECT_CALL(*this, OnDecodeDone(MatchesStatusCode(DecodeStatus::ABORTED)))
EXPECT_CALL(*this,
OnDecodeDone(MatchesStatusCode(DecoderStatus::Codes::kAborted)))
.Times(3);
EXPECT_CALL(*this, OnResetDone()).Times(1);
}
@ -533,9 +536,10 @@ TEST_F(VideoDecoderPipelineTest, TranscryptKeyAddedDuringTranscrypt) {
Decode(transcrypted_buffer_, _))
.WillOnce([](scoped_refptr<DecoderBuffer> transcrypted,
VideoDecoderMixin::DecodeCB decode_cb) {
std::move(decode_cb).Run(OkStatus());
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
});
EXPECT_CALL(*this, OnDecodeDone(MatchesStatusCode(StatusCode::kOk)));
EXPECT_CALL(*this,
OnDecodeDone(MatchesStatusCode(DecoderStatus::Codes::kOk)));
}
EXPECT_CALL(*this, OnWaiting(_)).Times(0);
std::move(saved_decrypt_cb).Run(Decryptor::kNoKey, nullptr);
@ -580,9 +584,10 @@ TEST_F(VideoDecoderPipelineTest, TranscryptNoKeyWaitRetry) {
Decode(transcrypted_buffer_, _))
.WillOnce([](scoped_refptr<DecoderBuffer> transcrypted,
VideoDecoderMixin::DecodeCB decode_cb) {
std::move(decode_cb).Run(OkStatus());
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
});
EXPECT_CALL(*this, OnDecodeDone(MatchesStatusCode(StatusCode::kOk)));
EXPECT_CALL(*this,
OnDecodeDone(MatchesStatusCode(DecoderStatus::Codes::kOk)));
}
event_callbacks_.Notify(CdmContext::Event::kHasAdditionalUsableKey);
task_environment_.RunUntilIdle();
@ -599,7 +604,7 @@ TEST_F(VideoDecoderPipelineTest, TranscryptError) {
std::move(decrypt_cb).Run(Decryptor::kError, nullptr);
});
EXPECT_CALL(*this,
OnDecodeDone(MatchesStatusCode(StatusCode::DECODE_ERROR)));
OnDecodeDone(MatchesStatusCode(DecoderStatus::Codes::kFailed)));
}
decoder_->Decode(encrypted_buffer_,
base::BindOnce(&VideoDecoderPipelineTest::OnDecodeDone,
@ -771,7 +776,7 @@ TEST_F(VideoDecoderPipelineTest, PickDecoderOutputFormatUnsupportedModifier) {
TEST_F(VideoDecoderPipelineTest, RebuildFramePoolsOnStateLost) {
InitializeDecoder(
base::BindOnce(&VideoDecoderPipelineTest::CreateGoodMockDecoder),
StatusCode::kOk);
DecoderStatus::Codes::kOk);
// Simulate the waiting callback from the decoder for kDecoderStateLost.
EXPECT_CALL(*this, OnWaiting(media::WaitingReason::kDecoderStateLost));

@ -172,7 +172,7 @@ void GpuVideoDecodeAcceleratorHost::OnInitializationComplete(bool success) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (client_) {
client_->NotifyInitializationComplete(
success ? OkStatus() : StatusCode::kInitializationUnspecifiedFailure);
success ? DecoderStatus::Codes::kOk : DecoderStatus::Codes::kFailed);
}
}

@ -312,7 +312,8 @@ GpuVideoDecodeAccelerator::GetCapabilities(
gpu_preferences, workarounds);
}
void GpuVideoDecodeAccelerator::NotifyInitializationComplete(Status status) {
void GpuVideoDecodeAccelerator::NotifyInitializationComplete(
DecoderStatus status) {
decoder_client_->OnInitializationComplete(status.is_ok());
}

@ -60,7 +60,7 @@ class GpuVideoDecodeAccelerator
const gpu::GpuDriverBugWorkarounds& workarounds);
// VideoDecodeAccelerator::Client implementation.
void NotifyInitializationComplete(Status status) override;
void NotifyInitializationComplete(DecoderStatus status) override;
void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
VideoPixelFormat format,
uint32_t textures_per_buffer,

@ -232,10 +232,9 @@ void VdaVideoDecoder::Initialize(const VideoDecoderConfig& config,
DCHECK(decode_cbs_.empty());
if (has_error_) {
// TODO(tmathmeyer) generic error, please remove.
parent_task_runner_->PostTask(
FROM_HERE, base::BindOnce(std::move(init_cb),
StatusCode::kGenericErrorPleaseRemove));
FROM_HERE,
base::BindOnce(std::move(init_cb), DecoderStatus::Codes::kFailed));
return;
}
@ -306,8 +305,9 @@ void VdaVideoDecoder::Initialize(const VideoDecoderConfig& config,
gpu_weak_this_));
} else {
parent_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&VdaVideoDecoder::InitializeDone,
parent_weak_this_, OkStatus()));
FROM_HERE,
base::BindOnce(&VdaVideoDecoder::InitializeDone, parent_weak_this_,
DecoderStatus::Codes::kOk));
}
return;
}
@ -344,7 +344,7 @@ void VdaVideoDecoder::InitializeOnGpuThread() {
parent_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&VdaVideoDecoder::InitializeDone, parent_weak_this_,
StatusCode::kDecoderInitializeNeverCompleted));
DecoderStatus::Codes::kFailed));
return;
}
@ -375,7 +375,7 @@ void VdaVideoDecoder::InitializeOnGpuThread() {
parent_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&VdaVideoDecoder::InitializeDone, parent_weak_this_,
StatusCode::kDecoderInitializeNeverCompleted));
DecoderStatus::Codes::kFailedToCreateDecoder));
return;
}
@ -388,13 +388,14 @@ void VdaVideoDecoder::InitializeOnGpuThread() {
decode_on_parent_thread_ = vda_->TryToSetupDecodeOnSeparateThread(
parent_weak_this_, parent_task_runner_);
parent_task_runner_->PostTask(FROM_HERE,
base::BindOnce(&VdaVideoDecoder::InitializeDone,
parent_weak_this_, OkStatus()));
parent_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&VdaVideoDecoder::InitializeDone,
parent_weak_this_, DecoderStatus::Codes::kOk));
}
void VdaVideoDecoder::InitializeDone(Status status) {
DVLOG(1) << __func__ << " success = (" << status.code() << ")";
void VdaVideoDecoder::InitializeDone(DecoderStatus status) {
DVLOG(1) << __func__ << " success = (" << static_cast<int>(status.code())
<< ")";
DCHECK(parent_task_runner_->BelongsToCurrentThread());
if (has_error_)
@ -422,7 +423,7 @@ void VdaVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
if (has_error_) {
parent_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(std::move(decode_cb), DecodeStatus::DECODE_ERROR));
base::BindOnce(std::move(decode_cb), DecoderStatus::Codes::kFailed));
return;
}
@ -504,8 +505,8 @@ int VdaVideoDecoder::GetMaxDecodeRequests() const {
return 4;
}
void VdaVideoDecoder::NotifyInitializationComplete(Status status) {
DVLOG(2) << __func__ << "(" << status.code() << ")";
void VdaVideoDecoder::NotifyInitializationComplete(DecoderStatus status) {
DVLOG(2) << __func__ << "(" << static_cast<int>(status.code()) << ")";
DCHECK(gpu_task_runner_->BelongsToCurrentThread());
DCHECK(vda_initialized_);
@ -686,7 +687,7 @@ void VdaVideoDecoder::NotifyEndOfBitstreamBufferOnParentThread(
// Run a local copy in case the decode callback modifies |decode_cbs_|.
DecodeCB decode_cb = std::move(decode_cb_it->second);
decode_cbs_.erase(decode_cb_it);
std::move(decode_cb).Run(DecodeStatus::OK);
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
}
void VdaVideoDecoder::NotifyFlushDone() {
@ -711,7 +712,7 @@ void VdaVideoDecoder::NotifyFlushDoneOnParentThread() {
return;
DCHECK(decode_cbs_.empty());
std::move(flush_cb_).Run(DecodeStatus::OK);
std::move(flush_cb_).Run(DecoderStatus::Codes::kOk);
}
void VdaVideoDecoder::NotifyResetDone() {
@ -744,13 +745,13 @@ void VdaVideoDecoder::NotifyResetDoneOnParentThread() {
std::map<int32_t, DecodeCB> local_decode_cbs = std::move(decode_cbs_);
decode_cbs_.clear();
for (auto& it : local_decode_cbs) {
std::move(it.second).Run(DecodeStatus::ABORTED);
std::move(it.second).Run(DecoderStatus::Codes::kAborted);
if (!weak_this)
return;
}
if (weak_this && flush_cb_)
std::move(flush_cb_).Run(DecodeStatus::ABORTED);
std::move(flush_cb_).Run(DecoderStatus::Codes::kAborted);
if (weak_this)
std::move(reset_cb_).Run();
@ -828,13 +829,13 @@ void VdaVideoDecoder::DestroyCallbacks() {
std::map<int32_t, DecodeCB> local_decode_cbs = std::move(decode_cbs_);
decode_cbs_.clear();
for (auto& it : local_decode_cbs) {
std::move(it.second).Run(DecodeStatus::DECODE_ERROR);
std::move(it.second).Run(DecoderStatus::Codes::kFailed);
if (!weak_this)
return;
}
if (weak_this && flush_cb_)
std::move(flush_cb_).Run(DecodeStatus::DECODE_ERROR);
std::move(flush_cb_).Run(DecoderStatus::Codes::kFailed);
// Note: |reset_cb_| cannot return failure, so the client won't actually find
// out about the error until another operation is attempted.
@ -842,7 +843,7 @@ void VdaVideoDecoder::DestroyCallbacks() {
std::move(reset_cb_).Run();
if (weak_this && init_cb_)
std::move(init_cb_).Run(StatusCode::kDecoderInitializeNeverCompleted);
std::move(init_cb_).Run(DecoderStatus::Codes::kFailed);
}
} // namespace media

@ -117,7 +117,7 @@ class VdaVideoDecoder : public VideoDecoder,
const VideoDecodeAccelerator::Capabilities& vda_capabilities);
// media::VideoDecodeAccelerator::Client implementation.
void NotifyInitializationComplete(Status status) override;
void NotifyInitializationComplete(DecoderStatus status) override;
void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
VideoPixelFormat format,
uint32_t textures_per_buffer,
@ -136,7 +136,7 @@ class VdaVideoDecoder : public VideoDecoder,
static void CleanupOnGpuThread(std::unique_ptr<VdaVideoDecoder>);
void InitializeOnGpuThread();
void ReinitializeOnGpuThread();
void InitializeDone(Status status);
void InitializeDone(DecoderStatus status);
void DecodeOnGpuThread(scoped_refptr<DecoderBuffer> buffer,
int32_t bitstream_id);
void DismissPictureBufferOnParentThread(int32_t picture_buffer_id);

@ -18,8 +18,8 @@
#include "base/time/time.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "media/base/async_destroy_video_decoder.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decoder_status.h"
#include "media/base/media_util.h"
#include "media/base/mock_media_log.h"
#include "media/base/simple_sync_token_client.h"
@ -179,7 +179,7 @@ class VdaVideoDecoderTest : public testing::TestWithParam<bool> {
}
void NotifyEndOfBitstreamBuffer(int32_t bitstream_id) {
EXPECT_CALL(decode_cb_, Run(HasStatusCode(DecodeStatus::OK)));
EXPECT_CALL(decode_cb_, Run(HasStatusCode(DecoderStatus::Codes::kOk)));
if (GetParam()) {
// TODO(sandersd): The VDA could notify on either thread. Test both.
client_->NotifyEndOfBitstreamBuffer(bitstream_id);
@ -328,8 +328,7 @@ TEST_P(VdaVideoDecoderTest, Initialize_UnsupportedSize) {
VideoDecoderConfig::AlphaMode::kIsOpaque, VideoColorSpace::REC601(),
kNoTransformation, gfx::Size(320, 240), gfx::Rect(320, 240),
gfx::Size(320, 240), EmptyExtraData(), EncryptionScheme::kUnencrypted));
EXPECT_CALL(init_cb_,
Run(HasStatusCode(StatusCode::kDecoderInitializeNeverCompleted)));
EXPECT_CALL(init_cb_, Run(HasStatusCode(DecoderStatus::Codes::kFailed)));
RunUntilIdle();
}
@ -339,8 +338,7 @@ TEST_P(VdaVideoDecoderTest, Initialize_UnsupportedCodec) {
VideoDecoderConfig::AlphaMode::kIsOpaque, VideoColorSpace::REC709(),
kNoTransformation, gfx::Size(1920, 1088), gfx::Rect(1920, 1080),
gfx::Size(1920, 1080), EmptyExtraData(), EncryptionScheme::kUnencrypted));
EXPECT_CALL(init_cb_,
Run(HasStatusCode(StatusCode::kDecoderInitializeNeverCompleted)));
EXPECT_CALL(init_cb_, Run(HasStatusCode(DecoderStatus::Codes::kFailed)));
RunUntilIdle();
}
@ -351,8 +349,7 @@ TEST_P(VdaVideoDecoderTest, Initialize_RejectedByVda) {
VideoDecoderConfig::AlphaMode::kIsOpaque, VideoColorSpace::REC709(),
kNoTransformation, gfx::Size(1920, 1088), gfx::Rect(1920, 1080),
gfx::Size(1920, 1080), EmptyExtraData(), EncryptionScheme::kUnencrypted));
EXPECT_CALL(init_cb_,
Run(HasStatusCode(StatusCode::kDecoderInitializeNeverCompleted)));
EXPECT_CALL(init_cb_, Run(HasStatusCode(DecoderStatus::Codes::kFailed)));
RunUntilIdle();
}
@ -376,7 +373,7 @@ TEST_P(VdaVideoDecoderTest, Decode_Reset) {
vdavd_->Reset(reset_cb_.Get());
RunUntilIdle();
EXPECT_CALL(decode_cb_, Run(HasStatusCode(DecodeStatus::ABORTED)));
EXPECT_CALL(decode_cb_, Run(HasStatusCode(DecoderStatus::Codes::kAborted)));
EXPECT_CALL(reset_cb_, Run());
NotifyResetDone();
}

@ -553,12 +553,12 @@ void Video::DecodeTask(const std::vector<uint8_t> data,
}
// Setup the VP9 decoder.
media::Status init_result;
DecoderStatus init_result;
VpxVideoDecoder decoder(
media::OffloadableVideoDecoder::OffloadState::kOffloaded);
media::VideoDecoder::InitCB init_cb =
base::BindOnce([](media::Status* save_to,
media::Status save_from) { *save_to = save_from; },
base::BindOnce([](DecoderStatus* save_to,
DecoderStatus save_from) { *save_to = save_from; },
&init_result);
decoder.Initialize(config, false, nullptr, std::move(init_cb),
base::BindRepeating(&Video::OnFrameDecoded, resolution,
@ -576,7 +576,7 @@ void Video::DecodeTask(const std::vector<uint8_t> data,
num_decoded_frames < num_frames) {
if (packet.stream_index == stream_index) {
media::VideoDecoder::DecodeCB decode_cb = base::BindOnce(
[](bool* success, media::Status status) {
[](bool* success, DecoderStatus status) {
*success = (status.is_ok());
},
success);

@ -87,7 +87,7 @@ bool BitstreamValidator::Initialize(const VideoDecoderConfig& decoder_config) {
bool success = false;
base::WaitableEvent initialized;
VideoDecoder::InitCB init_done = base::BindOnce(
[](bool* result, base::WaitableEvent* initialized, Status status) {
[](bool* result, base::WaitableEvent* initialized, DecoderStatus status) {
*result = true;
if (!status.is_ok()) {
LOG(ERROR) << "Failed decoder initialization ("
@ -264,14 +264,14 @@ void BitstreamValidator::ProcessBitstreamTask(
}
}
void BitstreamValidator::DecodeDone(int64_t timestamp, Status status) {
void BitstreamValidator::DecodeDone(int64_t timestamp, DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(validator_thread_sequence_checker_);
if (!status.is_ok()) {
base::AutoLock lock(validator_lock_);
if (!decode_error_) {
decode_error_ = true;
LOG(ERROR) << "DecodeStatus is not OK, status="
<< GetDecodeStatusString(status.code());
<< static_cast<int>(status.code());
}
}
if (timestamp == kEOSTimeStamp) {

@ -17,6 +17,7 @@
#include "base/thread_annotations.h"
#include "base/threading/thread.h"
#include "media/base/bitstream_buffer.h"
#include "media/base/decoder_status.h"
#include "media/base/video_decoder.h"
#include "media/gpu/test/bitstream_helpers.h"
#include "media/gpu/test/video_frame_helpers.h"
@ -77,7 +78,7 @@ class BitstreamValidator : public BitstreamProcessor {
void OutputFrameProcessed();
// Functions for media::VideoDecoder.
void DecodeDone(int64_t timestamp, Status status);
void DecodeDone(int64_t timestamp, DecoderStatus status);
void VerifyOutputFrame(scoped_refptr<VideoFrame> frame);
// Construct the spatial index conversion table |original_spatial_indices_|

@ -110,7 +110,7 @@ void TestVDAVideoDecoder::Initialize(const VideoDecoderConfig& config,
if (!decoder_factory) {
ASSERT_TRUE(decoder_) << "Failed to create VideoDecodeAccelerator factory";
std::move(init_cb).Run(StatusCode::kCodeOnlyForTesting);
std::move(init_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -142,17 +142,17 @@ void TestVDAVideoDecoder::Initialize(const VideoDecoderConfig& config,
if (!decoder_) {
ASSERT_TRUE(decoder_) << "Failed to create VideoDecodeAccelerator factory";
std::move(init_cb).Run(StatusCode::kCodeOnlyForTesting);
std::move(init_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
if (!vda_config.is_deferred_initialization_allowed)
std::move(init_cb).Run(OkStatus());
std::move(init_cb).Run(DecoderStatus::Codes::kOk);
else
init_cb_ = std::move(init_cb);
}
void TestVDAVideoDecoder::NotifyInitializationComplete(Status status) {
void TestVDAVideoDecoder::NotifyInitializationComplete(DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(vda_wrapper_sequence_checker_);
DCHECK(init_cb_);
@ -373,7 +373,7 @@ void TestVDAVideoDecoder::NotifyEndOfBitstreamBuffer(
<< "Couldn't find decode callback for picture buffer with id "
<< bitstream_buffer_id;
std::move(it->second).Run(DecodeStatus::OK);
std::move(it->second).Run(DecoderStatus::Codes::kOk);
decode_cbs_.erase(it);
}
@ -381,7 +381,7 @@ void TestVDAVideoDecoder::NotifyFlushDone() {
DCHECK_CALLED_ON_VALID_SEQUENCE(vda_wrapper_sequence_checker_);
DCHECK(flush_cb_);
std::move(flush_cb_).Run(DecodeStatus::OK);
std::move(flush_cb_).Run(DecoderStatus::Codes::kOk);
}
void TestVDAVideoDecoder::NotifyResetDone() {

@ -62,7 +62,7 @@ class TestVDAVideoDecoder : public media::VideoDecoder,
private:
// media::VideoDecodeAccelerator::Client implementation
void NotifyInitializationComplete(Status status) override;
void NotifyInitializationComplete(DecoderStatus status) override;
void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
VideoPixelFormat format,
uint32_t textures_per_buffer,

@ -234,7 +234,7 @@ void VideoDecoderClient::InitializeDecoderTask(const Video* video,
VideoDecoder::InitCB init_cb = base::BindOnce(
CallbackThunk<decltype(&VideoDecoderClient::DecoderInitializedTask),
Status>,
DecoderStatus>,
weak_this_, decoder_client_thread_.task_runner(),
&VideoDecoderClient::DecoderInitializedTask);
VideoDecoder::OutputCB output_cb = base::BindRepeating(
@ -320,7 +320,7 @@ void VideoDecoderClient::DecodeNextFragmentTask() {
VideoDecoder::DecodeCB decode_cb = base::BindOnce(
CallbackThunk<decltype(&VideoDecoderClient::DecodeDoneTask),
media::Status>,
DecoderStatus>,
weak_this_, decoder_client_thread_.task_runner(),
&VideoDecoderClient::DecodeDoneTask);
decoder_->Decode(std::move(bitstream_buffer), std::move(decode_cb));
@ -341,7 +341,7 @@ void VideoDecoderClient::FlushTask() {
VideoDecoder::DecodeCB flush_done_cb =
base::BindOnce(CallbackThunk<decltype(&VideoDecoderClient::FlushDoneTask),
media::Status>,
DecoderStatus>,
weak_this_, decoder_client_thread_.task_runner(),
&VideoDecoderClient::FlushDoneTask);
decoder_->Decode(DecoderBuffer::CreateEOSBuffer(), std::move(flush_done_cb));
@ -365,7 +365,7 @@ void VideoDecoderClient::ResetTask() {
FireEvent(VideoPlayerEvent::kResetting);
}
void VideoDecoderClient::DecoderInitializedTask(Status status) {
void VideoDecoderClient::DecoderInitializedTask(DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_client_sequence_checker_);
DCHECK(decoder_client_state_ == VideoDecoderClientState::kUninitialized ||
decoder_client_state_ == VideoDecoderClientState::kIdle);
@ -375,10 +375,10 @@ void VideoDecoderClient::DecoderInitializedTask(Status status) {
FireEvent(VideoPlayerEvent::kInitialized);
}
void VideoDecoderClient::DecodeDoneTask(media::Status status) {
void VideoDecoderClient::DecodeDoneTask(DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_client_sequence_checker_);
DCHECK_NE(VideoDecoderClientState::kIdle, decoder_client_state_);
ASSERT_TRUE(status.code() != media::StatusCode::kAborted ||
ASSERT_TRUE(status != DecoderStatus::Codes::kAborted ||
decoder_client_state_ == VideoDecoderClientState::kResetting);
DVLOGF(4);
@ -407,7 +407,7 @@ void VideoDecoderClient::FrameReadyTask(scoped_refptr<VideoFrame> video_frame) {
current_frame_index_++;
}
void VideoDecoderClient::FlushDoneTask(media::Status status) {
void VideoDecoderClient::FlushDoneTask(DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_client_sequence_checker_);
DCHECK_EQ(0u, num_outstanding_decode_requests_);

@ -14,7 +14,7 @@
#include "base/sequence_checker.h"
#include "base/threading/thread.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/video_decoder.h"
#include "media/base/video_decoder_config.h"
#include "media/gpu/test/video_player/video_player.h"
@ -142,13 +142,13 @@ class VideoDecoderClient {
// The below functions are callbacks provided to the video decoder. They are
// all executed on the |decoder_client_thread_|.
// Called by the decoder when initialization has completed.
void DecoderInitializedTask(Status status);
void DecoderInitializedTask(DecoderStatus status);
// Called by the decoder when a fragment has been decoded.
void DecodeDoneTask(media::Status status);
void DecodeDoneTask(DecoderStatus status);
// Called by the decoder when a video frame is ready.
void FrameReadyTask(scoped_refptr<VideoFrame> video_frame);
// Called by the decoder when flushing has completed.
void FlushDoneTask(media::Status status);
void FlushDoneTask(DecoderStatus status);
// Called by the decoder when resetting has completed.
void ResetDoneTask();
// Called by the decoder when a resolution change was requested, returns

@ -115,7 +115,7 @@ V4L2VideoDecoder::~V4L2VideoDecoder() {
// Call all pending decode callback.
if (backend_) {
backend_->ClearPendingRequests(DecodeStatus::ABORTED);
backend_->ClearPendingRequests(DecoderStatus::Codes::kAborted);
backend_ = nullptr;
}
@ -156,14 +156,13 @@ void V4L2VideoDecoder::Initialize(const VideoDecoderConfig& config,
case State::kError:
VLOGF(1) << "V4L2 decoder should not be initialized at state: "
<< static_cast<int>(state_);
std::move(init_cb).Run(
Status(Status::Codes::kDecoderInitializationFailed));
std::move(init_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
if (cdm_context || config.is_encrypted()) {
VLOGF(1) << "V4L2 decoder does not support encrypted stream";
std::move(init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -176,7 +175,7 @@ void V4L2VideoDecoder::Initialize(const VideoDecoderConfig& config,
// TODO(crbug/1103510): Make StopStreamV4L2Queue return a StatusOr, and
// pipe that back instead.
std::move(init_cb).Run(
Status(Status::Codes::kDecoderInitializeNeverCompleted)
DecoderStatus(DecoderStatus::Codes::kNotInitialized)
.AddCause(
V4L2Status(V4L2Status::Codes::kFailedToStopStreamQueue)));
return;
@ -199,7 +198,7 @@ void V4L2VideoDecoder::Initialize(const VideoDecoderConfig& config,
// TODO(crbug/1103510): Make V4L2Device::Create return a StatusOr, and
// pipe that back instead.
std::move(init_cb).Run(
Status(Status::Codes::kDecoderInitializeNeverCompleted)
DecoderStatus(DecoderStatus::Codes::kNotInitialized)
.AddCause(V4L2Status(V4L2Status::Codes::kNoDevice)));
return;
}
@ -219,7 +218,7 @@ void V4L2VideoDecoder::Initialize(const VideoDecoderConfig& config,
VLOGF(1) << "Unknown profile.";
SetState(State::kError);
std::move(init_cb).Run(
Status(Status::Codes::kDecoderInitializeNeverCompleted)
DecoderStatus(DecoderStatus::Codes::kNotInitialized)
.AddCause(V4L2Status(V4L2Status::Codes::kNoProfile)));
return;
}
@ -227,7 +226,7 @@ void V4L2VideoDecoder::Initialize(const VideoDecoderConfig& config,
// Call init_cb
output_cb_ = std::move(output_cb);
SetState(State::kInitialized);
std::move(init_cb).Run(::media::OkStatus());
std::move(init_cb).Run(DecoderStatus::Codes::kOk);
}
bool V4L2VideoDecoder::NeedsBitstreamConversion() const {
@ -524,7 +523,7 @@ void V4L2VideoDecoder::Reset(base::OnceClosure closure) {
}
// Call all pending decode callback.
backend_->ClearPendingRequests(DecodeStatus::ABORTED);
backend_->ClearPendingRequests(DecoderStatus::Codes::kAborted);
// Streamoff V4L2 queues to drop input and output buffers.
// If the queues are streaming before reset, then we need to start streaming
@ -554,14 +553,14 @@ void V4L2VideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
// VideoDecoder interface: |decode_cb| can't be called from within Decode().
auto trampoline_decode_cb = base::BindOnce(
[](const scoped_refptr<base::SequencedTaskRunner>& this_sequence_runner,
DecodeCB decode_cb, Status status) {
DecodeCB decode_cb, DecoderStatus status) {
this_sequence_runner->PostTask(
FROM_HERE, base::BindOnce(std::move(decode_cb), status));
},
base::SequencedTaskRunnerHandle::Get(), std::move(decode_cb));
if (state_ == State::kError) {
std::move(trampoline_decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(trampoline_decode_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -570,7 +569,7 @@ void V4L2VideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
if (status != V4L2Status::Codes::kOk) {
SetState(State::kError);
std::move(trampoline_decode_cb)
.Run(Status(Status::Codes::kDecoderFailedDecode)
.Run(DecoderStatus(DecoderStatus::Codes::kFailed)
.AddCause(std::move(status)));
return;
}
@ -890,7 +889,7 @@ void V4L2VideoDecoder::SetState(State new_state) {
VLOGF(1) << "Error occurred, stopping queues.";
StopStreamV4L2Queue(true);
if (backend_)
backend_->ClearPendingRequests(DecodeStatus::DECODE_ERROR);
backend_->ClearPendingRequests(DecoderStatus::Codes::kFailed);
return;
}
state_ = new_state;

@ -6,7 +6,7 @@
#define MEDIA_GPU_V4L2_V4L2_VIDEO_DECODER_BACKEND_H_
#include "base/memory/scoped_refptr.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/video_decoder.h"
#include "media/gpu/chromeos/chromeos_status.h"
#include "media/gpu/chromeos/dmabuf_video_frame_pool.h"
@ -94,7 +94,7 @@ class V4L2VideoDecoderBackend {
virtual void OnChangeResolutionDone(CroStatus status) = 0;
// Clear all pending decoding tasks and call all pending decode callbacks
// with |status| as argument.
virtual void ClearPendingRequests(DecodeStatus status) = 0;
virtual void ClearPendingRequests(DecoderStatus status) = 0;
// Whether we should stop the input queue when changing resolution. Stateless
// decoders require this, but stateful ones need the input queue to keep

@ -199,7 +199,7 @@ void V4L2StatefulVideoDecoderBackend::DoDecodeWork() {
if (!frame_splitter_->AdvanceFrameFragment(data, data_size, &bytes_to_copy)) {
VLOGF(1) << "Invalid H.264 stream detected.";
std::move(current_decode_request_->decode_cb)
.Run(DecodeStatus::DECODE_ERROR);
.Run(DecoderStatus::Codes::kFailed);
current_decode_request_.reset();
current_input_buffer_.reset();
client_->OnBackendError();
@ -210,7 +210,7 @@ void V4L2StatefulVideoDecoderBackend::DoDecodeWork() {
if (bytes_used + bytes_to_copy > current_input_buffer_->GetPlaneSize(0)) {
VLOGF(1) << "V4L2 buffer size is too small to contain a whole frame.";
std::move(current_decode_request_->decode_cb)
.Run(DecodeStatus::DECODE_ERROR);
.Run(DecoderStatus::Codes::kFailed);
current_decode_request_.reset();
current_input_buffer_.reset();
client_->OnBackendError();
@ -226,7 +226,8 @@ void V4L2StatefulVideoDecoderBackend::DoDecodeWork() {
// Release current_input_request_ if we reached its end.
if (current_decode_request_->IsCompleted()) {
std::move(current_decode_request_->decode_cb).Run(DecodeStatus::OK);
std::move(current_decode_request_->decode_cb)
.Run(DecoderStatus::Codes::kOk);
current_decode_request_.reset();
}
@ -520,7 +521,7 @@ bool V4L2StatefulVideoDecoderBackend::CompleteFlush() {
DCHECK(flush_cb_);
// Signal that flush has properly been completed.
std::move(flush_cb_).Run(DecodeStatus::OK);
std::move(flush_cb_).Run(DecoderStatus::Codes::kOk);
// If CAPTURE queue is streaming, send the START command to the V4L2 device
// to signal that we are resuming decoding with the same state.
@ -530,7 +531,7 @@ bool V4L2StatefulVideoDecoderBackend::CompleteFlush() {
cmd.cmd = V4L2_DEC_CMD_START;
if (device_->Ioctl(VIDIOC_DECODER_CMD, &cmd) != 0) {
LOG(ERROR) << "Failed to issue START command";
std::move(flush_cb_).Run(DecodeStatus::DECODE_ERROR);
std::move(flush_cb_).Run(DecoderStatus::Codes::kFailed);
client_->OnBackendError();
return false;
}
@ -661,7 +662,7 @@ void V4L2StatefulVideoDecoderBackend::OnChangeResolutionDone(CroStatus status) {
}
void V4L2StatefulVideoDecoderBackend::ClearPendingRequests(
DecodeStatus status) {
DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOGF(3);

@ -49,7 +49,7 @@ class V4L2StatefulVideoDecoderBackend : public V4L2VideoDecoderBackend {
const gfx::Rect& visible_rect,
const size_t num_output_frames) override;
void OnChangeResolutionDone(CroStatus status) override;
void ClearPendingRequests(DecodeStatus status) override;
void ClearPendingRequests(DecoderStatus status) override;
bool StopInputQueueOnResChange() const override;
private:

@ -18,7 +18,7 @@
#include "base/posix/eintr_wrapper.h"
#include "base/task/sequenced_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/video_codecs.h"
#include "media/base/video_frame.h"
#include "media/gpu/accelerated_video_decoder.h"
@ -422,7 +422,8 @@ bool V4L2StatelessVideoDecoderBackend::PumpDecodeTask() {
enqueuing_timestamps_[current_decode_request_->buffer->timestamp()
.InMilliseconds()] = base::TimeTicks::Now();
std::move(current_decode_request_->decode_cb).Run(DecodeStatus::OK);
std::move(current_decode_request_->decode_cb)
.Run(DecoderStatus::Codes::kOk);
current_decode_request_ = absl::nullopt;
}
@ -498,7 +499,7 @@ void V4L2StatelessVideoDecoderBackend::PumpOutputSurfaces() {
case OutputRequest::kFlushFence:
DCHECK(output_request_queue_.empty());
DVLOGF(2) << "Flush finished.";
std::move(flush_cb_).Run(DecodeStatus::OK);
std::move(flush_cb_).Run(DecoderStatus::Codes::kOk);
resume_decode = true;
client_->CompleteFlush();
break;
@ -617,7 +618,7 @@ void V4L2StatelessVideoDecoderBackend::OnStreamStopped(bool stop_input_queue) {
}
void V4L2StatelessVideoDecoderBackend::ClearPendingRequests(
DecodeStatus status) {
DecoderStatus status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOGF(3);

@ -11,7 +11,7 @@
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "base/task/sequenced_task_runner.h"
#include "media/base/decode_status.h"
#include "media/base/decoder_status.h"
#include "media/base/video_decoder.h"
#include "media/gpu/chromeos/dmabuf_video_frame_pool.h"
#include "media/gpu/v4l2/v4l2_decode_surface_handler.h"
@ -54,7 +54,7 @@ class V4L2StatelessVideoDecoderBackend : public V4L2VideoDecoderBackend,
const gfx::Rect& visible_rect,
const size_t num_output_frames) override;
void OnChangeResolutionDone(CroStatus status) override;
void ClearPendingRequests(DecodeStatus status) override;
void ClearPendingRequests(DecoderStatus status) override;
bool StopInputQueueOnResChange() const override;
// V4L2DecodeSurfaceHandler implementation.

@ -380,7 +380,7 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
}
// VideoDecodeAccelerator::Client methods.
MOCK_METHOD1(NotifyInitializationComplete, void(Status));
MOCK_METHOD1(NotifyInitializationComplete, void(DecoderStatus));
MOCK_METHOD5(
ProvidePictureBuffers,
void(uint32_t, VideoPixelFormat, uint32_t, const gfx::Size&, uint32_t));

@ -152,7 +152,7 @@ VaapiVideoDecoder::~VaapiVideoDecoder() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Abort all currently scheduled decode tasks.
ClearDecodeTaskQueue(DecodeStatus::ABORTED);
ClearDecodeTaskQueue(DecoderStatus::Codes::kAborted);
weak_this_factory_.InvalidateWeakPtrs();
@ -192,7 +192,7 @@ void VaapiVideoDecoder::Initialize(const VideoDecoderConfig& config,
state_ == State::kExpectingReset) {
LOG(ERROR)
<< "Don't call Initialize() while there are pending decode tasks";
std::move(init_cb).Run(StatusCode::kDecoderInitializationFailed);
std::move(init_cb).Run(DecoderStatus::Codes::kFailed);
return;
}
@ -239,12 +239,12 @@ void VaapiVideoDecoder::Initialize(const VideoDecoderConfig& config,
if (config.is_encrypted()) {
#if !BUILDFLAG(IS_CHROMEOS_ASH)
SetErrorState("encrypted content is not supported");
std::move(init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
#else
if (!cdm_context || !cdm_context->GetChromeOsCdmContext()) {
SetErrorState("cannot support encrypted stream w/out ChromeOsCdmContext");
std::move(init_cb).Run(StatusCode::kDecoderMissingCdmForEncryptedContent);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
bool encrypted_av1_support = false;
@ -261,7 +261,7 @@ void VaapiVideoDecoder::Initialize(const VideoDecoderConfig& config,
SetErrorState(
base::StringPrintf("%s is not supported for encrypted content",
GetCodecName(config.codec()).c_str()));
std::move(init_cb).Run(StatusCode::kEncryptedContentUnsupported);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
cdm_event_cb_registration_ = cdm_context->RegisterEventCB(
@ -278,7 +278,7 @@ void VaapiVideoDecoder::Initialize(const VideoDecoderConfig& config,
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableClearHevcForTesting)) {
SetErrorState("clear HEVC content is not supported");
std::move(init_cb).Run(StatusCode::kClearContentUnsupported);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
#endif
}
@ -303,7 +303,7 @@ void VaapiVideoDecoder::Initialize(const VideoDecoderConfig& config,
SetErrorState(
base::StringPrintf("failed initializing VaapiWrapper for profile %s, ",
GetProfileName(profile).c_str()));
std::move(init_cb).Run(StatusCode::kDecoderUnsupportedProfile);
std::move(init_cb).Run(DecoderStatus::Codes::kUnsupportedProfile);
return;
}
@ -315,7 +315,7 @@ void VaapiVideoDecoder::Initialize(const VideoDecoderConfig& config,
auto accel_status = CreateAcceleratedVideoDecoder();
if (!accel_status.is_ok()) {
SetErrorState("failed to create decoder delegate");
std::move(init_cb).Run(Status(Status::Codes::kDecoderInitializationFailed)
std::move(init_cb).Run(DecoderStatus(DecoderStatus::Codes::kFailed)
.AddCause(std::move(accel_status)));
return;
}
@ -327,7 +327,7 @@ void VaapiVideoDecoder::Initialize(const VideoDecoderConfig& config,
SetState(State::kWaitingForInput);
// Notify client initialization was successful.
std::move(init_cb).Run(OkStatus());
std::move(init_cb).Run(DecoderStatus::Codes::kOk);
}
void VaapiVideoDecoder::OnCdmContextEvent(CdmContext::Event event) {
@ -352,7 +352,7 @@ void VaapiVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
// VideoDecoder interface: |decode_cb| can't be called from within Decode().
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(decode_cb), DecodeStatus::DECODE_ERROR));
base::BindOnce(std::move(decode_cb), DecoderStatus::Codes::kFailed));
return;
}
@ -417,7 +417,8 @@ void VaapiVideoDecoder::HandleDecodeTask() {
case AcceleratedVideoDecoder::kRanOutOfStreamData:
// Decoding was successful, notify client and try to schedule the next
// task. Switch to the idle state if we ran out of buffers to decode.
std::move(current_decode_task_->decode_done_cb_).Run(DecodeStatus::OK);
std::move(current_decode_task_->decode_done_cb_)
.Run(DecoderStatus::Codes::kOk);
current_decode_task_ = absl::nullopt;
if (!decode_task_queue_.empty()) {
ScheduleNextDecodeTask();
@ -458,7 +459,7 @@ void VaapiVideoDecoder::HandleDecodeTask() {
}
}
void VaapiVideoDecoder::ClearDecodeTaskQueue(DecodeStatus status) {
void VaapiVideoDecoder::ClearDecodeTaskQueue(DecoderStatus status) {
DVLOGF(4);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
@ -1033,7 +1034,8 @@ void VaapiVideoDecoder::Flush() {
DCHECK(output_frames_.empty());
// Notify the client flushing is done.
std::move(current_decode_task_->decode_done_cb_).Run(DecodeStatus::OK);
std::move(current_decode_task_->decode_done_cb_)
.Run(DecoderStatus::Codes::kOk);
current_decode_task_ = absl::nullopt;
// Wait for new decodes, no decode tasks should be queued while flushing.
@ -1192,7 +1194,7 @@ void VaapiVideoDecoder::SetState(State state) {
state_ == State::kWaitingForProtected ||
state_ == State::kChangingResolution ||
state_ == State::kExpectingReset);
ClearDecodeTaskQueue(DecodeStatus::ABORTED);
ClearDecodeTaskQueue(DecoderStatus::Codes::kAborted);
break;
case State::kChangingResolution:
DCHECK_EQ(state_, State::kDecoding);
@ -1201,7 +1203,7 @@ void VaapiVideoDecoder::SetState(State state) {
DCHECK_EQ(state_, State::kChangingResolution);
break;
case State::kError:
ClearDecodeTaskQueue(DecodeStatus::DECODE_ERROR);
ClearDecodeTaskQueue(DecoderStatus::Codes::kFailed);
break;
}

@ -134,7 +134,7 @@ class VaapiVideoDecoder : public VideoDecoderMixin,
void HandleDecodeTask();
// Clear the decode task queue. This is done when resetting or destroying the
// decoder, or encountering an error.
void ClearDecodeTaskQueue(DecodeStatus status);
void ClearDecodeTaskQueue(DecoderStatus status);
// Releases the local reference to the VideoFrame associated with the
// specified |surface_id| on the decoder thread. This is called when

@ -214,7 +214,7 @@ class VideoDecoderTest : public ::testing::Test {
bool init_success = false;
VideoDecoder::InitCB init_cb = base::BindOnce(
[](bool* init_success, media::Status result) {
[](bool* init_success, DecoderStatus result) {
*init_success = result.is_ok();
},
&init_success);
@ -231,7 +231,7 @@ class VideoDecoderTest : public ::testing::Test {
while (!encoded_data_helper->ReachEndOfStream()) {
bool decode_success = false;
media::VideoDecoder::DecodeCB decode_cb = base::BindOnce(
[](bool* decode_success, media::Status status) {
[](bool* decode_success, DecoderStatus status) {
*decode_success = status.is_ok();
},
&decode_success);
@ -247,7 +247,7 @@ class VideoDecoderTest : public ::testing::Test {
}
bool flush_success = false;
media::VideoDecoder::DecodeCB flush_cb = base::BindOnce(
[](bool* flush_success, media::Status status) {
[](bool* flush_success, DecoderStatus status) {
*flush_success = status.is_ok();
},
&flush_success);

@ -497,7 +497,7 @@ void D3D11VideoDecoder::OnGpuInitComplete(
release_mailbox_cb_ = std::move(release_mailbox_cb);
state_ = State::kRunning;
std::move(init_cb_).Run(OkStatus());
std::move(init_cb_).Run(DecoderStatus::Codes::kOk);
}
void D3D11VideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
@ -512,7 +512,7 @@ void D3D11VideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
if (state_ == State::kError) {
// TODO(liberato): consider posting, though it likely doesn't matter.
std::move(decode_cb).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb).Run(DecoderStatus::Codes::kInterrupted);
return;
}
@ -558,7 +558,7 @@ void D3D11VideoDecoder::DoDecode() {
}
// Pictures out output synchronously during Flush. Signal the decode
// cb now.
std::move(current_decode_cb_).Run(DecodeStatus::OK);
std::move(current_decode_cb_).Run(DecoderStatus::Codes::kOk);
return;
}
// This must be after checking for EOS because there is no timestamp for an
@ -601,7 +601,7 @@ void D3D11VideoDecoder::DoDecode() {
// TODO(liberato): switch + class enum.
if (result == media::AcceleratedVideoDecoder::kRanOutOfStreamData) {
current_buffer_ = nullptr;
std::move(current_decode_cb_).Run(DecodeStatus::OK);
std::move(current_decode_cb_).Run(DecoderStatus::Codes::kOk);
break;
} else if (result == media::AcceleratedVideoDecoder::kRanOutOfSurfaces) {
// At this point, we know the picture size.
@ -673,10 +673,10 @@ void D3D11VideoDecoder::Reset(base::OnceClosure closure) {
current_buffer_ = nullptr;
if (current_decode_cb_)
std::move(current_decode_cb_).Run(DecodeStatus::ABORTED);
std::move(current_decode_cb_).Run(DecoderStatus::Codes::kAborted);
for (auto& queue_pair : input_buffer_queue_)
std::move(queue_pair.second).Run(DecodeStatus::ABORTED);
std::move(queue_pair.second).Run(DecoderStatus::Codes::kAborted);
input_buffer_queue_.clear();
// TODO(liberato): how do we signal an error?
@ -908,9 +908,8 @@ void D3D11VideoDecoder::NotifyError(D3D11Status reason) {
// TODO(liberato): VideoDecoder::InitCB should have either its own status
// codes, or should use a common one that has "succeeded / didn't succeed"
// as its only options.
std::move(init_cb_).Run(
Status(Status::Codes::kDecoderInitializeNeverCompleted)
.AddCause(std::move(reason)));
std::move(init_cb_).Run(DecoderStatus(DecoderStatus::Codes::kFailed)
.AddCause(std::move(reason)));
} else {
// TODO(tmathmeyer) - Remove this after plumbing Status through the
// decode_cb and input_buffer_queue cb's.
@ -922,10 +921,10 @@ void D3D11VideoDecoder::NotifyError(D3D11Status reason) {
current_buffer_ = nullptr;
if (current_decode_cb_)
std::move(current_decode_cb_).Run(DecodeStatus::DECODE_ERROR);
std::move(current_decode_cb_).Run(DecoderStatus::Codes::kFailed);
for (auto& queue_pair : input_buffer_queue_)
std::move(queue_pair.second).Run(DecodeStatus::DECODE_ERROR);
std::move(queue_pair.second).Run(DecoderStatus::Codes::kFailed);
input_buffer_queue_.clear();
}

@ -224,12 +224,12 @@ class D3D11VideoDecoderTest : public ::testing::Test {
base::RunLoop().RunUntilIdle();
}
void CheckStatus(bool expectSuccess, Status actual) {
void CheckStatus(bool expectSuccess, DecoderStatus actual) {
ASSERT_EQ(expectSuccess, actual.is_ok());
MockInitCB(actual);
}
MOCK_METHOD1(MockInitCB, void(Status));
MOCK_METHOD1(MockInitCB, void(DecoderStatus));
base::test::TaskEnvironment task_environment_;

@ -51,7 +51,7 @@ AudioDecoderType MojoAudioDecoder::GetDecoderType() const {
return decoder_type_;
}
void MojoAudioDecoder::FailInit(InitCB init_cb, Status err) {
void MojoAudioDecoder::FailInit(InitCB init_cb, DecoderStatus err) {
task_runner_->PostTask(FROM_HERE,
base::BindOnce(std::move(init_cb), std::move(err)));
}
@ -70,7 +70,7 @@ void MojoAudioDecoder::Initialize(const AudioDecoderConfig& config,
// This could happen during reinitialization.
if (!remote_decoder_.is_connected()) {
DVLOG(1) << __func__ << ": Connection error happened.";
FailInit(std::move(init_cb), StatusCode::kMojoDecoderNoConnection);
FailInit(std::move(init_cb), DecoderStatus::Codes::kFailedToCreateDecoder);
return;
}
@ -82,7 +82,7 @@ void MojoAudioDecoder::Initialize(const AudioDecoderConfig& config,
if (config.is_encrypted() && !cdm_id) {
DVLOG(1) << __func__ << ": Invalid CdmContext.";
FailInit(std::move(init_cb),
StatusCode::kDecoderMissingCdmForEncryptedContent);
DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
@ -105,7 +105,7 @@ void MojoAudioDecoder::Decode(scoped_refptr<DecoderBuffer> media_buffer,
if (!remote_decoder_.is_connected()) {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(std::move(decode_cb), DecodeStatus::DECODE_ERROR));
base::BindOnce(std::move(decode_cb), DecoderStatus::Codes::kFailed));
return;
}
@ -114,7 +114,7 @@ void MojoAudioDecoder::Decode(scoped_refptr<DecoderBuffer> media_buffer,
if (!buffer) {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(std::move(decode_cb), DecodeStatus::DECODE_ERROR));
base::BindOnce(std::move(decode_cb), DecoderStatus::Codes::kFailed));
return;
}
@ -134,7 +134,7 @@ void MojoAudioDecoder::Reset(base::OnceClosure closure) {
if (decode_cb_) {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(std::move(decode_cb_), DecodeStatus::DECODE_ERROR));
base::BindOnce(std::move(decode_cb_), DecoderStatus::Codes::kFailed));
}
task_runner_->PostTask(FROM_HERE, std::move(closure));
@ -188,17 +188,17 @@ void MojoAudioDecoder::OnConnectionError() {
DCHECK(!remote_decoder_.is_connected());
if (init_cb_) {
FailInit(std::move(init_cb_), StatusCode::kMojoDecoderNoConnection);
FailInit(std::move(init_cb_), DecoderStatus::Codes::kFailedToCreateDecoder);
return;
}
if (decode_cb_)
std::move(decode_cb_).Run(DecodeStatus::DECODE_ERROR);
std::move(decode_cb_).Run(DecoderStatus::Codes::kFailed);
if (reset_cb_)
std::move(reset_cb_).Run();
}
void MojoAudioDecoder::OnInitialized(const Status& status,
void MojoAudioDecoder::OnInitialized(const DecoderStatus& status,
bool needs_bitstream_conversion,
AudioDecoderType decoder_type) {
DVLOG(1) << __func__ << ": success:" << status.is_ok();
@ -219,8 +219,8 @@ void MojoAudioDecoder::OnInitialized(const Status& status,
std::move(init_cb_).Run(std::move(status));
}
void MojoAudioDecoder::OnDecodeStatus(const Status& status) {
DVLOG(1) << __func__ << ": status:" << status.code();
void MojoAudioDecoder::OnDecodeStatus(const DecoderStatus& status) {
DVLOG(1) << __func__ << ": status:" << static_cast<int>(status.code());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(decode_cb_);

@ -66,15 +66,15 @@ class MojoAudioDecoder final : public AudioDecoder,
void OnConnectionError();
// Fail an initialization with a Status.
void FailInit(InitCB init_cb, Status err);
void FailInit(InitCB init_cb, DecoderStatus err);
// Called when |remote_decoder_| finished initialization.
void OnInitialized(const Status& status,
void OnInitialized(const DecoderStatus& status,
bool needs_bitstream_conversion,
AudioDecoderType decoder_type);
// Called when |remote_decoder_| accepted or rejected DecoderBuffer.
void OnDecodeStatus(const Status& decode_status);
void OnDecodeStatus(const DecoderStatus& decode_status);
// called when |remote_decoder_| finished Reset() sequence.
void OnResetDone();

@ -83,10 +83,10 @@ class MojoAudioDecoderTest : public ::testing::Test {
}
// Completion callbacks.
MOCK_METHOD1(OnInitialized, void(Status));
MOCK_METHOD1(OnInitialized, void(DecoderStatus));
MOCK_METHOD1(OnOutput, void(scoped_refptr<AudioBuffer>));
MOCK_METHOD1(OnWaiting, void(WaitingReason));
MOCK_METHOD1(OnDecoded, void(Status));
MOCK_METHOD1(OnDecoded, void(DecoderStatus));
MOCK_METHOD0(OnReset, void());
// Always create a new RunLoop (and destroy the old loop if it exists) before
@ -118,12 +118,12 @@ class MojoAudioDecoderTest : public ::testing::Test {
EXPECT_CALL(*mock_audio_decoder_, Initialize_(_, _, _, _, _))
.WillRepeatedly(DoAll(SaveArg<3>(&output_cb_), SaveArg<4>(&waiting_cb_),
RunOnceCallback<2>(OkStatus())));
RunOnceCallback<2>(DecoderStatus::Codes::kOk)));
EXPECT_CALL(*mock_audio_decoder_, Decode(_, _))
.WillRepeatedly([&](scoped_refptr<DecoderBuffer> buffer,
AudioDecoder::DecodeCB decode_cb) {
ReturnOutput();
std::move(decode_cb).Run(DecodeStatus::OK);
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
});
EXPECT_CALL(*mock_audio_decoder_, Reset_(_))
.WillRepeatedly(RunOnceCallback<0>());
@ -138,8 +138,8 @@ class MojoAudioDecoderTest : public ::testing::Test {
mojo_audio_decoder_->set_writer_capacity_for_testing(capacity);
}
void InitializeAndExpect(Status status) {
DVLOG(1) << __func__ << ": success=" << status.code();
void InitializeAndExpect(DecoderStatus status) {
DVLOG(1) << __func__ << ": success=" << static_cast<int>(status.code());
EXPECT_CALL(*this, OnInitialized(SameStatusCode(status)))
.WillOnce(InvokeWithoutArgs(this, &MojoAudioDecoderTest::QuitLoop));
@ -159,7 +159,7 @@ class MojoAudioDecoderTest : public ::testing::Test {
RunLoop();
}
void Initialize() { InitializeAndExpect(OkStatus()); }
void Initialize() { InitializeAndExpect(DecoderStatus::Codes::kOk); }
void Decode() {
scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(100));
@ -294,7 +294,7 @@ TEST_F(MojoAudioDecoderTest, WaitingForKey) {
.WillOnce([&](scoped_refptr<DecoderBuffer> buffer,
AudioDecoder::DecodeCB decode_cb) {
WaitForKey();
std::move(decode_cb).Run(DecodeStatus::OK);
std::move(decode_cb).Run(DecoderStatus::Codes::kOk);
});
EXPECT_CALL(*this, OnWaiting(WaitingReason::kNoDecryptionKey)).Times(1);
EXPECT_CALL(*this, OnDecoded(IsOkStatus()))

Some files were not shown because too many files have changed in this diff Show More