Commit a0af7542 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Use FuchsiaVideoDecoder on Fuchsia

Now renderer will try to use FuchsiaVideoDecoder on Fuchsia before
falling back to SW decoders.
Also moved FuchsiaVideoDecoder implementation from //media/gpu to
//media/filters since it will be used in the renderer process.

Bug: 876519
Change-Id: Iad682c2dbcf4b100406891d722e818435d04bfda
Reviewed-on: https://chromium-review.googlesource.com/c/1300686Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605125}
parent 8a11a6d0
......@@ -468,6 +468,7 @@ source_set("common") {
deps += [
"//third_party/fuchsia-sdk/sdk:fdio",
"//third_party/fuchsia-sdk/sdk:fonts",
"//third_party/fuchsia-sdk/sdk:mediacodec",
"//third_party/fuchsia-sdk/sdk:scenic",
]
}
......
......@@ -9,6 +9,7 @@
#include <zircon/processargs.h>
#include <fuchsia/fonts/cpp/fidl.h>
#include <fuchsia/mediacodec/cpp/fidl.h>
#include <fuchsia/ui/scenic/cpp/fidl.h>
#include <memory>
#include <utility>
......@@ -30,7 +31,7 @@ namespace content {
namespace {
constexpr const char* const kRendererServices[] = {
fuchsia::fonts::Provider::Name_};
fuchsia::fonts::Provider::Name_, fuchsia::mediacodec::CodecFactory::Name_};
constexpr const char* const kGpuServices[] = {
fuchsia::ui::scenic::Scenic::Name_};
......
......@@ -2258,7 +2258,12 @@ RenderThreadImpl::GetMediaThreadTaskRunner() {
DCHECK(main_thread_runner()->BelongsToCurrentThread());
if (!media_thread_) {
media_thread_.reset(new base::Thread("Media"));
media_thread_->Start();
base::Thread::Options options;
#if defined(OS_FUCHSIA)
// Start IO thread on Fuchsia to make that thread usable for FIDL.
options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0);
#endif
media_thread_->StartWithOptions(options);
}
return media_thread_->task_runner();
}
......
......@@ -206,6 +206,14 @@ jumbo_source_set("filters") {
"h264_bitstream_buffer.h",
]
}
if (is_fuchsia) {
sources += [
"fuchsia/fuchsia_video_decoder.cc",
"fuchsia/fuchsia_video_decoder.h",
]
deps += [ "//third_party/fuchsia-sdk/sdk:mediacodec" ]
}
}
source_set("perftests") {
......@@ -281,10 +289,6 @@ source_set("unit_tests") {
"vp9_raw_bits_reader_unittest.cc",
]
if (is_android) {
sources += [ "android/video_frame_extractor_unittest.cc" ]
}
deps = [
"//base/test:test_support",
"//media:test_support",
......@@ -299,6 +303,7 @@ source_set("unit_tests") {
]
if (is_android) {
sources += [ "android/video_frame_extractor_unittest.cc" ]
sources -= [
"decrypting_audio_decoder_unittest.cc",
"decrypting_video_decoder_unittest.cc",
......@@ -307,6 +312,10 @@ source_set("unit_tests") {
deps += [ "//ui/gl" ]
}
if (is_fuchsia) {
sources += [ "fuchsia/fuchsia_video_decoder_unittest.cc" ]
}
# libvpx for running vpx test on chromecast doesn't support high bit depth.
# This may cause some unit tests failure.
if (is_chromecast) {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/gpu/fuchsia/fuchsia_video_decoder.h"
#include "media/filters/fuchsia/fuchsia_video_decoder.h"
#include <fuchsia/mediacodec/cpp/fidl.h>
#include <zircon/rights.h>
......@@ -643,8 +643,9 @@ void FuchsiaVideoDecoder::OnError() {
auto weak_this = weak_this_;
// Call decode callback with DECODE_ERROR before clearing input_buffers_.
// Otherwise InputBuffer destructor would call it with ABORTED.
// Call all decode callback with DECODE_ERROR before clearing input_buffers_
// and pending_decodes_. Otherwise PendingDecode and InputBuffer destructors
// would the callbacks with ABORTED.
for (auto& buffer : input_buffers_) {
if (buffer.is_used()) {
buffer.OnDoneDecoding(DecodeStatus::DECODE_ERROR);
......@@ -656,7 +657,13 @@ void FuchsiaVideoDecoder::OnError() {
}
}
// Will call DecodeCB(ABORTED) for all pending decode requests.
for (auto& pending_decode : pending_decodes_) {
pending_decode.TakeDecodeCallback().Run(DecodeStatus::DECODE_ERROR);
if (!weak_this) {
return;
}
}
pending_decodes_.clear();
num_used_input_buffers_ = 0;
......
......@@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_GPU_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
#define MEDIA_GPU_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
#ifndef MEDIA_FILTERS_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
#define MEDIA_FILTERS_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
#include <memory>
#include "media/gpu/media_gpu_export.h"
#include "media/base/media_export.h"
namespace media {
class VideoDecoder;
// Creates VideoDecoder that uses fuchsia.mediacodec API.
MEDIA_GPU_EXPORT std::unique_ptr<VideoDecoder> CreateFuchsiaVideoDecoder();
MEDIA_EXPORT std::unique_ptr<VideoDecoder> CreateFuchsiaVideoDecoder();
} // namespace media
#endif // MEDIA_GPU_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
#endif // MEDIA_FILTERS_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/gpu/fuchsia/fuchsia_video_decoder.h"
#include "media/filters/fuchsia/fuchsia_video_decoder.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
......
......@@ -214,14 +214,6 @@ component("gpu") {
}
}
if (is_fuchsia) {
sources += [
"fuchsia/fuchsia_video_decoder.cc",
"fuchsia/fuchsia_video_decoder.h",
]
deps += [ "//third_party/fuchsia-sdk/sdk:mediacodec" ]
}
if (use_v4lplugin) {
sources += get_target_outputs(":libv4l2_generate_stubs")
deps += [ ":libv4l2_generate_stubs" ]
......@@ -649,9 +641,6 @@ source_set("unit_tests") {
if (use_v4l2_codec || use_vaapi) {
sources += [ "vp8_decoder_unittest.cc" ]
}
if (is_fuchsia) {
sources += [ "fuchsia/fuchsia_video_decoder_unittest.cc" ]
}
if (is_win && enable_library_cdms) {
sources += [
"windows/d3d11_cdm_proxy_unittest.cc",
......
......@@ -23,6 +23,10 @@
#include "media/filters/decrypting_video_decoder.h"
#endif
#if defined(OS_FUCHSIA)
#include "media/filters/fuchsia/fuchsia_video_decoder.h"
#endif
#if BUILDFLAG(ENABLE_AV1_DECODER)
#include "media/filters/aom_video_decoder.h"
#endif
......@@ -107,6 +111,10 @@ void DefaultDecoderFactory::CreateVideoDecoders(
}
}
#if defined(OS_FUCHSIA)
video_decoders->push_back(CreateFuchsiaVideoDecoder());
#endif
#if BUILDFLAG(ENABLE_LIBVPX)
video_decoders->push_back(std::make_unique<OffloadingVpxVideoDecoder>());
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment