chromium/media/formats/hls/tags.cc

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

#include "media/formats/hls/tags.h"

#include <cstddef>
#include <type_traits>
#include <utility>

#include "base/logging.h"
#include "base/notreached.h"
#include "base/time/time.h"
#include "media/base/mime_util.h"
#include "media/formats/hls/items.h"
#include "media/formats/hls/parse_status.h"
#include "media/formats/hls/variable_dictionary.h"

namespace media::hls {

namespace {

template <typename T>
ParseStatus::Or<T> ParseEmptyTag(TagItem tag) {}

template <typename T>
ParseStatus::Or<T> ParseDecimalIntegerTag(TagItem tag,
                                          types::DecimalInteger T::*field) {}

template <typename T>
ParseStatus::Or<T> ParseISO8601DateTimeTag(TagItem tag, base::Time T::*field) {}

// Attributes expected in `EXT-X-DEFINE` tag contents.
// These must remain sorted alphabetically.
enum class XDefineTagAttribute {};

constexpr std::string_view GetAttributeName(XDefineTagAttribute attribute) {}

// Attributes expected in `EXT-X-MEDIA` tag contents.
// These must remain sorted alphabetically.
enum class XMediaTagAttribute {};

constexpr std::string_view GetAttributeName(XMediaTagAttribute attribute) {}

// Attributes expected in `EXT-X-STREAM-INF` tag contents.
// These must remain sorted alphabetically.
enum class XStreamInfTagAttribute {};

constexpr std::string_view GetAttributeName(XStreamInfTagAttribute attribute) {}

// Attributes expected in `EXT-X-SKIP` tag contents.
// These must remain sorted alphabetically.
enum class XSkipTagAttribute {};

constexpr std::string_view GetAttributeName(XSkipTagAttribute attribute) {}

enum class XRenditionReportTagAttribute {};

constexpr std::string_view GetAttributeName(XRenditionReportTagAttribute attr) {}

// Attributes expected in `EXT-X-MAP` tag contents.
// These must remain sorted alphabetically.
enum class XMapTagAttribute {};

constexpr std::string_view GetAttributeName(XMapTagAttribute attribute) {}

// Attributes expected in `EXT-X-PART` tag contents.
// These must remain sorted alphabetically.
enum class XPartTagAttribute {};

constexpr std::string_view GetAttributeName(XPartTagAttribute attribute) {}

// Attributes expected in `EXT-X-PART-INF` tag contents.
// These must remain sorted alphabetically.
enum class XPartInfTagAttribute {};

constexpr std::string_view GetAttributeName(XPartInfTagAttribute attribute) {}

// Attributes expected in `EXT-X-SERVER-CONTROL` tag contents.
// These must remain sorted alphabetically.
enum class XServerControlTagAttribute {};

constexpr std::string_view GetAttributeName(
    XServerControlTagAttribute attribute) {}

enum class XKeyTagAttribute {};

constexpr std::string_view GetAttributeName(XKeyTagAttribute attribute) {}

template <typename T, size_t kLast>
constexpr bool IsAttributeEnumSorted(std::index_sequence<kLast>) {}

template <typename T, size_t kLHS, size_t kRHS, size_t... kRest>
constexpr bool IsAttributeEnumSorted(
    std::index_sequence<kLHS, kRHS, kRest...>) {}

// Wraps `AttributeMap::MakeStorage` by mapping the (compile-time) sequence
// of size_t's to a sequence of the corresponding attribute enum names.
template <typename T, std::size_t... Indices>
constexpr std::array<types::AttributeMap::Item, sizeof...(Indices)>
MakeTypedAttributeMapStorage(std::index_sequence<Indices...> seq) {}

// Helper for using AttributeMap with an enum of keys.
// The result of running `GetAttributeName` across `0..T::kMaxValue` (inclusive)
// must produced an ordered set of strings.
template <typename T>
struct TypedAttributeMap {};

#define RETURN_IF_ERROR

template <template <typename...> typename SpecifiedContainer, typename Type>
struct is_specialization_of : std::false_type {};

is_specialization_of<SpecifiedContainer, SpecifiedContainer<Types...>>;

// ParseField exists to help with the pattern where we need to parse some field
// from a dictionary of tag attributes where some of those fields are optional.
// It is designed to provide support for either optional or required fields,
// depending on the return-type specialization:
// When Result=std::optional<X>, ParseField will return a nullopt rather than
// an error if the `field_name` field can't be found in `map`.
// When Result=T (where T is not std::optional<X>), ParseField will fail with
// a ParseStatus if `field_name` is not found in map.
// A function pointer must also be provided which does the parsing from
// SourceString => Result, provided that the `field_name` key is present.
template <typename Result,
          typename AttrEnum,
          typename ParseFn,
          typename... ParseFnArgs>
ParseStatus::Or<Result> ParseField(AttrEnum field_name,
                                   TypedAttributeMap<AttrEnum> map,
                                   ParseFn parser,
                                   ParseFnArgs&&... args) {}

}  // namespace

// static
ParseStatus::Or<M3uTag> M3uTag::Parse(TagItem tag) {}

// static
XDefineTag XDefineTag::CreateDefinition(types::VariableName name,
                                        std::string_view value) {}

// static
XDefineTag XDefineTag::CreateImport(types::VariableName name) {}

// static
ParseStatus::Or<XDefineTag> XDefineTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XIndependentSegmentsTag> XIndependentSegmentsTag::Parse(
    TagItem tag) {}

// static
ParseStatus::Or<XVersionTag> XVersionTag::Parse(TagItem tag) {}

struct XMediaTag::CtorArgs {};

XMediaTag::XMediaTag(CtorArgs args)
    :{}

XMediaTag::~XMediaTag() = default;

XMediaTag::XMediaTag(const XMediaTag&) = default;

XMediaTag::XMediaTag(XMediaTag&&) = default;

XMediaTag& XMediaTag::operator=(const XMediaTag&) = default;

XMediaTag& XMediaTag::operator=(XMediaTag&&) = default;

// static
ParseStatus::Or<XMediaTag> XMediaTag::Parse(
    TagItem tag,
    const VariableDictionary& variable_dict,
    VariableDictionary::SubstitutionBuffer& sub_buffer) {}

XStreamInfTag::XStreamInfTag() = default;

XStreamInfTag::~XStreamInfTag() = default;

XStreamInfTag::XStreamInfTag(const XStreamInfTag&) = default;

XStreamInfTag::XStreamInfTag(XStreamInfTag&&) = default;

XStreamInfTag& XStreamInfTag::operator=(const XStreamInfTag&) = default;

XStreamInfTag& XStreamInfTag::operator=(XStreamInfTag&&) = default;

// static
ParseStatus::Or<XStreamInfTag> XStreamInfTag::Parse(
    TagItem tag,
    const VariableDictionary& variable_dict,
    VariableDictionary::SubstitutionBuffer& sub_buffer) {}

// static
ParseStatus::Or<InfTag> InfTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XBitrateTag> XBitrateTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XByteRangeTag> XByteRangeTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XDiscontinuityTag> XDiscontinuityTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XDiscontinuitySequenceTag> XDiscontinuitySequenceTag::Parse(
    TagItem tag) {}

// static
ParseStatus::Or<XEndListTag> XEndListTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XGapTag> XGapTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XIFramesOnlyTag> XIFramesOnlyTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XMapTag> XMapTag::Parse(
    TagItem tag,
    const VariableDictionary& variable_dict,
    VariableDictionary::SubstitutionBuffer& sub_buffer) {}

// static
ParseStatus::Or<XMediaSequenceTag> XMediaSequenceTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XPartTag> XPartTag::Parse(
    TagItem tag,
    const VariableDictionary& vars,
    VariableDictionary::SubstitutionBuffer& subs) {}

// static
ParseStatus::Or<XPartInfTag> XPartInfTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XPlaylistTypeTag> XPlaylistTypeTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XServerControlTag> XServerControlTag::Parse(TagItem tag) {}

// static
ParseStatus::Or<XTargetDurationTag> XTargetDurationTag::Parse(TagItem tag) {}

XSkipTag::XSkipTag() = default;
XSkipTag::~XSkipTag() = default;
XSkipTag::XSkipTag(const XSkipTag&) = default;
XSkipTag::XSkipTag(XSkipTag&&) = default;

ParseStatus::Or<XSkipTag> XSkipTag::Parse(
    TagItem tag,
    const VariableDictionary& variable_dict,
    VariableDictionary::SubstitutionBuffer& sub_buffer) {}

ParseStatus::Or<XRenditionReportTag> XRenditionReportTag::Parse(
    TagItem tag,
    const VariableDictionary& variable_dict,
    VariableDictionary::SubstitutionBuffer& sub_buffer) {}

ParseStatus::Or<XProgramDateTimeTag> XProgramDateTimeTag::Parse(TagItem tag) {}

template <typename Attrs>
ParseStatus::Or<TypedAttributeMap<Attrs>> RequireNonEmptyMap(
    std::optional<SourceString> content) {}

namespace {

constexpr char const* kMethodNone =;
constexpr char const* kMethodAES128 =;
constexpr char const* kMethodAES256 =;
constexpr char const* kMethodSampleAES =;
constexpr char const* kMethodSampleAESCTR =;
constexpr char const* kMethodSampleAESCENC =;
constexpr char const* kMethodISO230017 =;

constexpr char const* kFmtClearkey =;
constexpr char const* kFmtWidevine =;
constexpr char const* kFmtIdentity =;

ParseStatus::Or<XKeyTagMethod> RecognizeMethod(SourceString content) {}

ParseStatus::Or<XKeyTagKeyFormat> RecognizeFormat(
    std::optional<ResolvedSourceString> content) {}

template <typename T>
ParseStatus::Or<T> ValidateKeyTag(
    XKeyTagMethod method,
    ResolvedSourceString uri,
    std::optional<XKeyTag::IVHex::Container> iv,
    XKeyTagKeyFormat keyformat,
    std::optional<ResolvedSourceString> keyformat_versions) {}

template <typename T>
ParseStatus::Or<T> ParseKeyTag(TagItem tag,
                               const VariableDictionary& vars,
                               VariableDictionary::SubstitutionBuffer& subs) {}

}  // namespace

ParseStatus::Or<XKeyTag> XKeyTag::Parse(
    TagItem tag,
    const VariableDictionary& vars,
    VariableDictionary::SubstitutionBuffer& subs) {}

ParseStatus::Or<XSessionKeyTag> XSessionKeyTag::Parse(
    TagItem tag,
    const VariableDictionary& vars,
    VariableDictionary::SubstitutionBuffer& subs) {}

#undef RETURN_IF_ERROR

}  // namespace media::hls