blob: 5820d60f6414561affc63b6fa18952dab9ee4fea [file] [log] [blame]
// Copyright 2017 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_CHROMEOS_CAMERA_COMMON_MJPEG_DECODE_ACCELERATOR_MOJOM_TRAITS_H_
#define COMPONENTS_CHROMEOS_CAMERA_COMMON_MJPEG_DECODE_ACCELERATOR_MOJOM_TRAITS_H_
#include "base/numerics/safe_conversions.h"
#include "components/chromeos_camera/common/mjpeg_decode_accelerator.mojom.h"
#include "media/base/bitstream_buffer.h"
#include "media/video/mjpeg_decode_accelerator.h"
namespace mojo {
template <>
struct EnumTraits<chromeos_camera::mojom::DecodeError,
media::MjpegDecodeAccelerator::Error> {
static chromeos_camera::mojom::DecodeError ToMojom(
media::MjpegDecodeAccelerator::Error error);
static bool FromMojom(chromeos_camera::mojom::DecodeError input,
media::MjpegDecodeAccelerator::Error* out);
};
template <>
struct StructTraits<chromeos_camera::mojom::BitstreamBufferDataView,
media::BitstreamBuffer> {
static int32_t id(const media::BitstreamBuffer& input) { return input.id(); }
static mojo::ScopedSharedBufferHandle memory_handle(
const media::BitstreamBuffer& input);
static uint32_t size(const media::BitstreamBuffer& input) {
return base::checked_cast<uint32_t>(input.size());
}
static int64_t offset(const media::BitstreamBuffer& input) {
return base::checked_cast<int64_t>(input.offset());
}
static base::TimeDelta timestamp(const media::BitstreamBuffer& input) {
return input.presentation_timestamp();
}
static const std::string& key_id(const media::BitstreamBuffer& input) {
return input.key_id();
}
static const std::string& iv(const media::BitstreamBuffer& input) {
return input.iv();
}
static const std::vector<media::SubsampleEntry>& subsamples(
const media::BitstreamBuffer& input) {
return input.subsamples();
}
static bool Read(chromeos_camera::mojom::BitstreamBufferDataView input,
media::BitstreamBuffer* output);
};
} // namespace mojo
#endif // COMPONENTS_CHROMEOS_CAMERA_COMMON_MJPEG_DECODE_ACCELERATOR_MOJOM_TRAITS_H_