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") { ...@@ -468,6 +468,7 @@ source_set("common") {
deps += [ deps += [
"//third_party/fuchsia-sdk/sdk:fdio", "//third_party/fuchsia-sdk/sdk:fdio",
"//third_party/fuchsia-sdk/sdk:fonts", "//third_party/fuchsia-sdk/sdk:fonts",
"//third_party/fuchsia-sdk/sdk:mediacodec",
"//third_party/fuchsia-sdk/sdk:scenic", "//third_party/fuchsia-sdk/sdk:scenic",
] ]
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <zircon/processargs.h> #include <zircon/processargs.h>
#include <fuchsia/fonts/cpp/fidl.h> #include <fuchsia/fonts/cpp/fidl.h>
#include <fuchsia/mediacodec/cpp/fidl.h>
#include <fuchsia/ui/scenic/cpp/fidl.h> #include <fuchsia/ui/scenic/cpp/fidl.h>
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -30,7 +31,7 @@ namespace content { ...@@ -30,7 +31,7 @@ namespace content {
namespace { namespace {
constexpr const char* const kRendererServices[] = { constexpr const char* const kRendererServices[] = {
fuchsia::fonts::Provider::Name_}; fuchsia::fonts::Provider::Name_, fuchsia::mediacodec::CodecFactory::Name_};
constexpr const char* const kGpuServices[] = { constexpr const char* const kGpuServices[] = {
fuchsia::ui::scenic::Scenic::Name_}; fuchsia::ui::scenic::Scenic::Name_};
......
...@@ -2258,7 +2258,12 @@ RenderThreadImpl::GetMediaThreadTaskRunner() { ...@@ -2258,7 +2258,12 @@ RenderThreadImpl::GetMediaThreadTaskRunner() {
DCHECK(main_thread_runner()->BelongsToCurrentThread()); DCHECK(main_thread_runner()->BelongsToCurrentThread());
if (!media_thread_) { if (!media_thread_) {
media_thread_.reset(new base::Thread("Media")); 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(); return media_thread_->task_runner();
} }
......
...@@ -206,6 +206,14 @@ jumbo_source_set("filters") { ...@@ -206,6 +206,14 @@ jumbo_source_set("filters") {
"h264_bitstream_buffer.h", "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") { source_set("perftests") {
...@@ -281,10 +289,6 @@ source_set("unit_tests") { ...@@ -281,10 +289,6 @@ source_set("unit_tests") {
"vp9_raw_bits_reader_unittest.cc", "vp9_raw_bits_reader_unittest.cc",
] ]
if (is_android) {
sources += [ "android/video_frame_extractor_unittest.cc" ]
}
deps = [ deps = [
"//base/test:test_support", "//base/test:test_support",
"//media:test_support", "//media:test_support",
...@@ -299,6 +303,7 @@ source_set("unit_tests") { ...@@ -299,6 +303,7 @@ source_set("unit_tests") {
] ]
if (is_android) { if (is_android) {
sources += [ "android/video_frame_extractor_unittest.cc" ]
sources -= [ sources -= [
"decrypting_audio_decoder_unittest.cc", "decrypting_audio_decoder_unittest.cc",
"decrypting_video_decoder_unittest.cc", "decrypting_video_decoder_unittest.cc",
...@@ -307,6 +312,10 @@ source_set("unit_tests") { ...@@ -307,6 +312,10 @@ source_set("unit_tests") {
deps += [ "//ui/gl" ] 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. # libvpx for running vpx test on chromecast doesn't support high bit depth.
# This may cause some unit tests failure. # This may cause some unit tests failure.
if (is_chromecast) { if (is_chromecast) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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 <fuchsia/mediacodec/cpp/fidl.h>
#include <zircon/rights.h> #include <zircon/rights.h>
...@@ -643,8 +643,9 @@ void FuchsiaVideoDecoder::OnError() { ...@@ -643,8 +643,9 @@ void FuchsiaVideoDecoder::OnError() {
auto weak_this = weak_this_; auto weak_this = weak_this_;
// Call decode callback with DECODE_ERROR before clearing input_buffers_. // Call all decode callback with DECODE_ERROR before clearing input_buffers_
// Otherwise InputBuffer destructor would call it with ABORTED. // and pending_decodes_. Otherwise PendingDecode and InputBuffer destructors
// would the callbacks with ABORTED.
for (auto& buffer : input_buffers_) { for (auto& buffer : input_buffers_) {
if (buffer.is_used()) { if (buffer.is_used()) {
buffer.OnDoneDecoding(DecodeStatus::DECODE_ERROR); buffer.OnDoneDecoding(DecodeStatus::DECODE_ERROR);
...@@ -656,7 +657,13 @@ void FuchsiaVideoDecoder::OnError() { ...@@ -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(); pending_decodes_.clear();
num_used_input_buffers_ = 0; num_used_input_buffers_ = 0;
......
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef MEDIA_GPU_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_ #ifndef MEDIA_FILTERS_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
#define MEDIA_GPU_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_ #define MEDIA_FILTERS_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
#include <memory> #include <memory>
#include "media/gpu/media_gpu_export.h" #include "media/base/media_export.h"
namespace media { namespace media {
class VideoDecoder; class VideoDecoder;
// Creates VideoDecoder that uses fuchsia.mediacodec API. // Creates VideoDecoder that uses fuchsia.mediacodec API.
MEDIA_GPU_EXPORT std::unique_ptr<VideoDecoder> CreateFuchsiaVideoDecoder(); MEDIA_EXPORT std::unique_ptr<VideoDecoder> CreateFuchsiaVideoDecoder();
} // namespace media } // namespace media
#endif // MEDIA_GPU_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_ #endif // MEDIA_FILTERS_FUCHSIA_FUCHSIA_VIDEO_DECODER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/bind.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
......
...@@ -214,14 +214,6 @@ component("gpu") { ...@@ -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) { if (use_v4lplugin) {
sources += get_target_outputs(":libv4l2_generate_stubs") sources += get_target_outputs(":libv4l2_generate_stubs")
deps += [ ":libv4l2_generate_stubs" ] deps += [ ":libv4l2_generate_stubs" ]
...@@ -649,9 +641,6 @@ source_set("unit_tests") { ...@@ -649,9 +641,6 @@ source_set("unit_tests") {
if (use_v4l2_codec || use_vaapi) { if (use_v4l2_codec || use_vaapi) {
sources += [ "vp8_decoder_unittest.cc" ] sources += [ "vp8_decoder_unittest.cc" ]
} }
if (is_fuchsia) {
sources += [ "fuchsia/fuchsia_video_decoder_unittest.cc" ]
}
if (is_win && enable_library_cdms) { if (is_win && enable_library_cdms) {
sources += [ sources += [
"windows/d3d11_cdm_proxy_unittest.cc", "windows/d3d11_cdm_proxy_unittest.cc",
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "media/filters/decrypting_video_decoder.h" #include "media/filters/decrypting_video_decoder.h"
#endif #endif
#if defined(OS_FUCHSIA)
#include "media/filters/fuchsia/fuchsia_video_decoder.h"
#endif
#if BUILDFLAG(ENABLE_AV1_DECODER) #if BUILDFLAG(ENABLE_AV1_DECODER)
#include "media/filters/aom_video_decoder.h" #include "media/filters/aom_video_decoder.h"
#endif #endif
...@@ -107,6 +111,10 @@ void DefaultDecoderFactory::CreateVideoDecoders( ...@@ -107,6 +111,10 @@ void DefaultDecoderFactory::CreateVideoDecoders(
} }
} }
#if defined(OS_FUCHSIA)
video_decoders->push_back(CreateFuchsiaVideoDecoder());
#endif
#if BUILDFLAG(ENABLE_LIBVPX) #if BUILDFLAG(ENABLE_LIBVPX)
video_decoders->push_back(std::make_unique<OffloadingVpxVideoDecoder>()); video_decoders->push_back(std::make_unique<OffloadingVpxVideoDecoder>());
#endif #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