Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
Gsm610Codec.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "VoiceChatPacket.hpp"
4
5#include <array>
6#include <cstdint>
7#include <expected>
8#include <memory>
9#include <span>
10#include <string>
11#include <vector>
12
14{
15 inline constexpr std::uint16_t FormatTag = 0x0031u;
16 inline constexpr std::uint32_t SampleRate = 11025u;
17 inline constexpr std::uint16_t SamplesPerFrame = 160u;
18 inline constexpr std::uint16_t SamplesPerBlock = 320u;
19 inline constexpr std::uint16_t BlockAlign = 65u;
20 inline constexpr std::uint32_t AverageBytesPerSecond = 2239u;
21
23 {
25 std::array<std::uint8_t, 2> extra{};
26 };
27
29 {
30 return {
31 {
33 1u,
37 0u,
38 2u,
39 },
40 {
41 static_cast<std::uint8_t>(SamplesPerBlock),
42 static_cast<std::uint8_t>(SamplesPerBlock >> 8u),
43 },
44 };
45 }
46
48 const packet::Event& event) noexcept;
49
51 {
52 public:
53 Encoder();
59
61 [[nodiscard]] std::expected<std::vector<std::uint8_t>, std::string>
62 encodeU8(std::span<const std::uint8_t> pcm);
63 void reset();
64
65 private:
67 std::unique_ptr<Impl> impl_;
68 std::vector<std::uint8_t> pending_;
69 };
70
72 {
73 public:
74 Decoder();
80
82 [[nodiscard]] std::expected<std::vector<std::uint8_t>, std::string>
83 decodeToU8(std::span<const std::uint8_t> encoded);
84 void reset();
85
86 private:
88 std::unique_ptr<Impl> impl_;
89 };
90}
unsigned index
std::expected< std::vector< std::uint8_t >, std::string > encodeU8(std::span< const std::uint8_t > pcm)
constexpr std::uint16_t SamplesPerBlock
constexpr std::uint32_t SampleRate
constexpr std::uint16_t FormatTag
constexpr std::uint16_t BlockAlign
constexpr std::uint32_t AverageBytesPerSecond
constexpr std::uint16_t SamplesPerFrame
bool matchesRetailWireFormat(const packet::Event &event) noexcept
constexpr WireFormat retailWireFormat() noexcept
std::array< std::uint8_t, 2 > extra