Skip to content

Truly independent web browser

1.1 KB
Raw Blame
/*
 * Copyright (c) 2025, Gregory Bertilson <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Format.h>
#include <AK/StringView.h>
#include <AK/Types.h>

namespace Media {

enum class SeekMode : u8 {
    Accurate,
    ApproximateForSpeed,
    FastBefore,
    FastAfter,
};

enum class SeekDecision : u8 {
    Seek,
    // Nothing is seekable, so the playback position stays where it is.
    Skip,
};

constexpr StringView seek_mode_to_string(SeekMode seek_mode)
{
    switch (seek_mode) {
    case SeekMode::Accurate:
        return "Accurate"sv;
    case SeekMode::ApproximateForSpeed:
        return "ApproximateForSpeed"sv;
    case SeekMode::FastBefore:
        return "FastBefore"sv;
    case SeekMode::FastAfter:
        return "FastAfter"sv;
    }
    VERIFY_NOT_REACHED();
}

}

namespace AK {

template<>
struct Formatter<Media::SeekMode> : Formatter<StringView> {
    ErrorOr<void> format(FormatBuilder& builder, Media::SeekMode color_primaries)
    {
        return Formatter<StringView>::format(builder, Media::seek_mode_to_string(color_primaries));
    }
};

}