chromium/media/formats/hls/tag_name.h

// Copyright 2022 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_FORMATS_HLS_TAG_NAME_H_
#define MEDIA_FORMATS_HLS_TAG_NAME_H_

#include <cstdint>
#include <optional>
#include <string_view>

#include "media/base/media_export.h"

namespace media::hls {

enum class TagKind {};

// Underlying type for all `k*TagName` constants. Each name constant must be
// unique across all kinds, and the full set of constants must be contiguous.
TagName;

// Tags common to multivariant and media playlists.
// For organization, this list is in alphabetical order.
enum class CommonTagName : TagName {};

// Tags exclusive to multivariant playlists.
// For organization, this list is in alphabetical order.
enum class MultivariantPlaylistTagName : TagName {};

// Tags exclusive to media playlists.
// For organization, this list is in alphabetical order.
enum class MediaPlaylistTagName : TagName {};

constexpr TagKind GetTagKind(CommonTagName) {}

constexpr TagName ToTagName(CommonTagName name) {}

constexpr TagKind GetTagKind(MultivariantPlaylistTagName) {}

constexpr TagName ToTagName(MultivariantPlaylistTagName name) {}

constexpr TagKind GetTagKind(MediaPlaylistTagName) {}

constexpr TagName ToTagName(MediaPlaylistTagName name) {}

MEDIA_EXPORT TagKind GetTagKind(TagName name);

// No-op conversion function for generic code.
constexpr TagName ToTagName(TagName name) {}

// Parses the tag name, converting it to one of the `*TagName` enum values.
// If the tag is not recognized, returns `std::nullopt`.
MEDIA_EXPORT std::optional<TagName> ParseTagName(std::string_view name);

// Prints the corresponding string representation of the given `TagName`.
MEDIA_EXPORT std::string_view TagNameToString(TagName name);

constexpr TagName kMinTagName =;
constexpr TagName kMaxTagName =;

}  // namespace media::hls

#endif  // MEDIA_FORMATS_HLS_TAG_NAME_H_