chromium/media/mojo/common/media_type_converters.h

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_MOJO_COMMON_MEDIA_TYPE_CONVERTERS_H_
#define MEDIA_MOJO_COMMON_MEDIA_TYPE_CONVERTERS_H_

#include <memory>
#include <optional>

#include "base/memory/scoped_refptr.h"
#include "media/mojo/mojom/content_decryption_module.mojom.h"
#include "media/mojo/mojom/media_types.mojom.h"
#include "mojo/public/cpp/bindings/type_converter.h"

namespace media {
class AudioBuffer;
class DecoderBuffer;
class DecryptConfig;
}  // namespace media

// These are specializations of mojo::TypeConverter and have to be in the mojo
// namespace.
namespace mojo {

template <>
struct TypeConverter<media::mojom::DecryptConfigPtr, media::DecryptConfig> {};
template <>
struct TypeConverter<std::unique_ptr<media::DecryptConfig>,
                     media::mojom::DecryptConfigPtr> {};

template <>
struct TypeConverter<media::mojom::DecoderBufferSideDataPtr,
                     std::optional<media::DecoderBufferSideData>> {};
template <>
struct TypeConverter<std::optional<media::DecoderBufferSideData>,
                     media::mojom::DecoderBufferSideDataPtr> {};

template <>
struct TypeConverter<media::mojom::DecoderBufferPtr, media::DecoderBuffer> {};
template <>
struct TypeConverter<scoped_refptr<media::DecoderBuffer>,
                     media::mojom::DecoderBufferPtr> {};

template <>
struct TypeConverter<media::mojom::AudioBufferPtr, media::AudioBuffer> {};
template <>
struct TypeConverter<scoped_refptr<media::AudioBuffer>,
                     media::mojom::AudioBufferPtr> {};

}  // namespace mojo

#endif  // MEDIA_MOJO_COMMON_MEDIA_TYPE_CONVERTERS_H_