Commit 12ac60a8 authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

Revert "components/arc: Create mojo struct for media::DecoderBuffer."

This reverts commit a1921808.

We postpone the VD migration at ARC++, so the mojo struct for
media::DecoderBuffer is not used now.

BUG=b:136716638
TEST=ninja chrome
TEST=./testing/xvfb.py ./out/Debug/components_unittests
     --gtest_filter=VideoAcceleratorStructTraitsTest.*

Change-Id: I783480520c82793bd41af3b904011969c37d4adb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377261Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802111}
parent 89bd4d98
......@@ -418,7 +418,7 @@ source_set("unit_tests") {
"//chromeos/network:test_support",
"//chromeos/system:system",
"//components/account_id",
"//components/arc/video_accelerator",
"//components/arc/video_accelerator:common",
"//components/keyed_service/content",
"//components/prefs:test_support",
"//components/session_manager/core:core",
......
......@@ -4,9 +4,6 @@
#include "components/arc/mojom/video_accelerator_mojom_traits.h"
#include "base/files/platform_file.h"
#include "mojo/public/cpp/system/platform_handle.h"
namespace mojo {
// Make sure values in arc::mojom::VideoCodecProfile match to the values in
......@@ -299,22 +296,4 @@ bool StructTraits<arc::mojom::VideoFrameDataView,
return true;
}
// static
bool StructTraits<arc::mojom::DecoderBufferDataView, arc::DecoderBuffer>::Read(
arc::mojom::DecoderBufferDataView data,
arc::DecoderBuffer* out) {
base::PlatformFile platform_file = base::kInvalidPlatformFile;
if (mojo::UnwrapPlatformFile(data.TakeHandleFd(), &platform_file) !=
MOJO_RESULT_OK) {
return false;
}
out->handle_fd = base::ScopedFD(platform_file);
out->offset = data.offset();
out->payload_size = data.payload_size();
out->end_of_stream = data.end_of_stream();
out->timestamp = base::TimeDelta::FromMilliseconds(data.timestamp());
return true;
}
} // namespace mojo
......@@ -11,7 +11,6 @@
#include "components/arc/mojom/arc_gfx_mojom_traits.h"
#include "components/arc/mojom/video_common.mojom.h"
#include "components/arc/video_accelerator/decoder_buffer.h"
#include "components/arc/video_accelerator/video_frame_plane.h"
#include "media/base/color_plane_layout.h"
#include "media/base/decode_status.h"
......@@ -19,8 +18,6 @@
#include "media/base/video_frame.h"
#include "media/base/video_frame_layout.h"
#include "media/base/video_types.h"
#include "mojo/public/cpp/platform/platform_handle.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "ui/gfx/geometry/size.h"
namespace mojo {
......@@ -187,33 +184,6 @@ struct StructTraits<arc::mojom::VideoFrameDataView,
scoped_refptr<media::VideoFrame>* out);
};
template <>
struct StructTraits<arc::mojom::DecoderBufferDataView, arc::DecoderBuffer> {
static mojo::ScopedHandle handle_fd(arc::DecoderBuffer& input) {
return mojo::WrapPlatformHandle(
mojo::PlatformHandle(std::move(input.handle_fd)));
}
static uint32_t offset(const arc::DecoderBuffer& input) {
return input.offset;
}
static uint32_t payload_size(const arc::DecoderBuffer& input) {
return input.payload_size;
}
static bool end_of_stream(const arc::DecoderBuffer& input) {
return input.end_of_stream;
}
static int64_t timestamp(const arc::DecoderBuffer& input) {
return input.timestamp.InMilliseconds();
}
static bool Read(arc::mojom::DecoderBufferDataView data,
arc::DecoderBuffer* out);
};
} // namespace mojo
#endif // COMPONENTS_ARC_MOJOM_VIDEO_ACCELERATOR_MOJOM_TRAITS_H_
......@@ -6,11 +6,7 @@
#include <vector>
#include "base/files/file_util.h"
#include "base/stl_util.h"
#include "components/arc/mojom/video_common.mojom.h"
#include "components/arc/video_accelerator/arc_video_accelerator_util.h"
#include "components/arc/video_accelerator/decoder_buffer.h"
#include "media/base/video_frame_layout.h"
#include "media/base/video_types.h"
#include "mojo/public/cpp/test_support/test_utils.h"
......@@ -100,27 +96,4 @@ TEST(VideoAcceleratorStructTraitsTest, ConvertNullVideoFrame) {
EXPECT_FALSE(output);
}
TEST(VideoAcceleratorStructTraitsTest, ConvertDecoderBuffer) {
const std::string kData = "TESTING_STRING";
const uint32_t kOffset = 3;
const uint32_t kDataSize = kData.size() - kOffset;
constexpr bool kEndOfStream = false;
arc::DecoderBuffer input(arc::CreateTempFileForTesting(kData), kOffset,
kDataSize, kEndOfStream,
base::TimeDelta::FromMilliseconds(kTimestamp));
arc::DecoderBuffer output;
mojo::test::SerializeAndDeserialize<arc::mojom::DecoderBuffer>(&input,
&output);
EXPECT_EQ(output.end_of_stream, input.end_of_stream);
EXPECT_EQ(output.timestamp, input.timestamp);
EXPECT_EQ(output.offset, input.offset);
EXPECT_EQ(output.payload_size, input.payload_size);
scoped_refptr<media::DecoderBuffer> buf =
std::move(output).ToMediaDecoderBuffer();
EXPECT_EQ(memcmp(kData.c_str() + kOffset, buf->data(), kDataSize), 0);
}
} // namespace mojo
......@@ -130,21 +130,3 @@ struct VideoFrame {
// timestamp in milliseconds.
int64 timestamp;
};
// Struct for storing bitstream buffer.
struct DecoderBuffer {
// Field for a physical buffer. This buffer is passed over an interface from
// ARC++ to Chrome, with a callback method that will be run when the buffer is
// used and the file descriptor is closed.
handle handle_fd;
// Distance in bytes between the beginning of the buffer pointed by
// |handle_fd| and the beginning of bitstream buffer.
uint32 offset;
// Bitstream buffer size in bytes. The buffer length referred by |handle_fd|
// can be more than |offset| + |payload_size|.
uint32 payload_size;
// Whether the buffer is an end-of-stream (EOS) buffer.
bool end_of_stream;
// Timestamp in microseconds.
int64 timestamp;
};
......@@ -4,7 +4,6 @@
mojom = "//components/arc/mojom/video_common.mojom"
public_headers = [
"//components/arc/video_accelerator/decoder_buffer.h",
"//components/arc/video_accelerator/video_frame_plane.h",
"//media/base/color_plane_layout.h",
"//media/base/decode_status.h",
......@@ -15,7 +14,6 @@ public_headers = [
]
public_deps = [
"//components/arc/video_accelerator:common",
"//media",
]
......@@ -27,11 +25,11 @@ sources = [
]
deps = [
"//components/arc/video_accelerator:common",
"//ui/gfx/geometry",
]
type_mappings = [
"arc.mojom.DecoderBuffer=arc::DecoderBuffer[move_only]",
"arc.mojom.DecodeStatus=media::DecodeStatus",
"arc.mojom.ColorPlaneLayout=media::ColorPlaneLayout",
"arc.mojom.Size=gfx::Size",
......
......@@ -29,8 +29,6 @@ source_set("common") {
sources = [
"arc_video_accelerator_util.cc",
"arc_video_accelerator_util.h",
"decoder_buffer.cc",
"decoder_buffer.h",
"video_frame_plane.h",
]
......
// Copyright 2019 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 "components/arc/video_accelerator/decoder_buffer.h"
#include "base/logging.h"
#include "base/memory/platform_shared_memory_region.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/numerics/checked_math.h"
#include "base/unguessable_token.h"
#include "components/arc/video_accelerator/arc_video_accelerator_util.h"
#include "media/base/decoder_buffer.h"
#include "media/gpu/buffer_validation.h"
namespace arc {
DecoderBuffer::DecoderBuffer() = default;
DecoderBuffer::DecoderBuffer(base::ScopedFD handle_fd,
uint32_t offset,
uint32_t payload_size,
bool end_of_stream,
base::TimeDelta timestamp)
: handle_fd(std::move(handle_fd)),
offset(offset),
payload_size(payload_size),
end_of_stream(end_of_stream),
timestamp(timestamp) {}
DecoderBuffer::DecoderBuffer(DecoderBuffer&& buf) = default;
DecoderBuffer& DecoderBuffer::operator=(DecoderBuffer&& buf) = default;
DecoderBuffer::~DecoderBuffer() = default;
scoped_refptr<media::DecoderBuffer> DecoderBuffer::ToMediaDecoderBuffer() && {
if (end_of_stream)
return media::DecoderBuffer::CreateEOSBuffer();
base::CheckedNumeric<off_t> checked_offset(offset);
base::CheckedNumeric<size_t> checked_payload_size(payload_size);
if (!checked_offset.IsValid() || !checked_payload_size.IsValid()) {
VLOG(1) << "Overflow when convert offset and payload size to size_t.";
return nullptr;
}
size_t required_size;
if (!base::CheckAdd<size_t>(offset, payload_size)
.AssignIfValid(&required_size)) {
VLOG(1) << "Overflow when adding offset and payload size.";
return nullptr;
}
size_t file_size = 0;
if (!media::GetFileSize(handle_fd.get(), &file_size) ||
file_size < required_size) {
VLOG(1) << "File size(" << file_size << ") is smaller than required size("
<< required_size << ").";
return nullptr;
}
DCHECK(handle_fd.is_valid());
auto readonly_region = base::ReadOnlySharedMemoryRegion::Deserialize(
base::subtle::PlatformSharedMemoryRegion::Take(
std::move(handle_fd),
base::subtle::PlatformSharedMemoryRegion::Mode::kReadOnly, file_size,
base::UnguessableToken::Create()));
scoped_refptr<media::DecoderBuffer> output =
media::DecoderBuffer::FromSharedMemoryRegion(
std::move(readonly_region), checked_offset.ValueOrDie(),
checked_payload_size.ValueOrDie());
output->set_timestamp(timestamp);
return output;
}
} // namespace arc
// Copyright 2019 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 COMPONENTS_ARC_VIDEO_ACCELERATOR_DECODER_BUFFER_H_
#define COMPONENTS_ARC_VIDEO_ACCELERATOR_DECODER_BUFFER_H_
#include "base/files/scoped_file.h"
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
namespace media {
class DecoderBuffer;
} // namespace media
namespace arc {
// Intermediate class in converting from a mojom::DecoderBuffer to
// media::DecoderBuffer. Because media::DecoderBuffer doesn't have a public
// constructor, we cannot convert to media::DecoderBuffer directly by
// StructTraits::Read().
struct DecoderBuffer {
DecoderBuffer();
DecoderBuffer(base::ScopedFD handle_fd,
uint32_t offset,
uint32_t payload_size,
bool end_of_stream,
base::TimeDelta timestamp);
~DecoderBuffer();
DecoderBuffer(DecoderBuffer&& buf);
DecoderBuffer& operator=(DecoderBuffer&& buf);
// Convert to media::DecoderBuffer.
scoped_refptr<media::DecoderBuffer> ToMediaDecoderBuffer() &&;
// See components/arc/mojom/video_common.mojom for descriptions of each field.
base::ScopedFD handle_fd;
uint32_t offset;
uint32_t payload_size;
bool end_of_stream;
base::TimeDelta timestamp;
};
} // namespace arc
#endif // COMPONENTS_ARC_VIDEO_ACCELERATOR_DECODER_BUFFER_H_
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