#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) { … }
enum class XDefineTagAttribute { … };
constexpr std::string_view GetAttributeName(XDefineTagAttribute attribute) { … }
enum class XMediaTagAttribute { … };
constexpr std::string_view GetAttributeName(XMediaTagAttribute attribute) { … }
enum class XStreamInfTagAttribute { … };
constexpr std::string_view GetAttributeName(XStreamInfTagAttribute attribute) { … }
enum class XSkipTagAttribute { … };
constexpr std::string_view GetAttributeName(XSkipTagAttribute attribute) { … }
enum class XRenditionReportTagAttribute { … };
constexpr std::string_view GetAttributeName(XRenditionReportTagAttribute attr) { … }
enum class XMapTagAttribute { … };
constexpr std::string_view GetAttributeName(XMapTagAttribute attribute) { … }
enum class XPartTagAttribute { … };
constexpr std::string_view GetAttributeName(XPartTagAttribute attribute) { … }
enum class XPartInfTagAttribute { … };
constexpr std::string_view GetAttributeName(XPartInfTagAttribute attribute) { … }
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...>) { … }
template <typename T, std::size_t... Indices>
constexpr std::array<types::AttributeMap::Item, sizeof...(Indices)>
MakeTypedAttributeMapStorage(std::index_sequence<Indices...> seq) { … }
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...>>;
template <typename Result,
typename AttrEnum,
typename ParseFn,
typename... ParseFnArgs>
ParseStatus::Or<Result> ParseField(AttrEnum field_name,
TypedAttributeMap<AttrEnum> map,
ParseFn parser,
ParseFnArgs&&... args) { … }
}
ParseStatus::Or<M3uTag> M3uTag::Parse(TagItem tag) { … }
XDefineTag XDefineTag::CreateDefinition(types::VariableName name,
std::string_view value) { … }
XDefineTag XDefineTag::CreateImport(types::VariableName name) { … }
ParseStatus::Or<XDefineTag> XDefineTag::Parse(TagItem tag) { … }
ParseStatus::Or<XIndependentSegmentsTag> XIndependentSegmentsTag::Parse(
TagItem tag) { … }
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;
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;
ParseStatus::Or<XStreamInfTag> XStreamInfTag::Parse(
TagItem tag,
const VariableDictionary& variable_dict,
VariableDictionary::SubstitutionBuffer& sub_buffer) { … }
ParseStatus::Or<InfTag> InfTag::Parse(TagItem tag) { … }
ParseStatus::Or<XBitrateTag> XBitrateTag::Parse(TagItem tag) { … }
ParseStatus::Or<XByteRangeTag> XByteRangeTag::Parse(TagItem tag) { … }
ParseStatus::Or<XDiscontinuityTag> XDiscontinuityTag::Parse(TagItem tag) { … }
ParseStatus::Or<XDiscontinuitySequenceTag> XDiscontinuitySequenceTag::Parse(
TagItem tag) { … }
ParseStatus::Or<XEndListTag> XEndListTag::Parse(TagItem tag) { … }
ParseStatus::Or<XGapTag> XGapTag::Parse(TagItem tag) { … }
ParseStatus::Or<XIFramesOnlyTag> XIFramesOnlyTag::Parse(TagItem tag) { … }
ParseStatus::Or<XMapTag> XMapTag::Parse(
TagItem tag,
const VariableDictionary& variable_dict,
VariableDictionary::SubstitutionBuffer& sub_buffer) { … }
ParseStatus::Or<XMediaSequenceTag> XMediaSequenceTag::Parse(TagItem tag) { … }
ParseStatus::Or<XPartTag> XPartTag::Parse(
TagItem tag,
const VariableDictionary& vars,
VariableDictionary::SubstitutionBuffer& subs) { … }
ParseStatus::Or<XPartInfTag> XPartInfTag::Parse(TagItem tag) { … }
ParseStatus::Or<XPlaylistTypeTag> XPlaylistTypeTag::Parse(TagItem tag) { … }
ParseStatus::Or<XServerControlTag> XServerControlTag::Parse(TagItem tag) { … }
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) { … }
}
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
}