group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
VoiceCodec.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
7
8#include <cstdint>
9#include <memory>
10#include <span>
11#include <vector>
12
13struct OpusEncoder;
14struct OpusDecoder;
15
17{
18public:
19 VoiceEncoder() = default;
21 VoiceEncoder(const VoiceEncoder&) = delete;
23 VoiceEncoder(VoiceEncoder&& other) noexcept;
24 VoiceEncoder& operator=(VoiceEncoder&& other) noexcept;
25
26 [[nodiscard]] bool init();
27 [[nodiscard]] bool ready() const noexcept { return encoder_ != nullptr; }
28 [[nodiscard]] std::vector<std::uint8_t> encode(std::span<const float> monoPcm);
29 void reset();
30
31private:
32 OpusEncoder* encoder_ = nullptr;
33};
34
36{
37public:
38 VoiceDecoder() = default;
40 VoiceDecoder(const VoiceDecoder&) = delete;
42 VoiceDecoder(VoiceDecoder&& other) noexcept;
43 VoiceDecoder& operator=(VoiceDecoder&& other) noexcept;
44
45 [[nodiscard]] bool init();
46 [[nodiscard]] bool ready() const noexcept { return decoder_ != nullptr; }
47 [[nodiscard]] std::vector<float> decode(std::span<const std::uint8_t> opus, std::uint8_t frameMs);
48 [[nodiscard]] std::vector<float> conceal(std::uint8_t frameMs);
49 void reset();
50
51private:
52 OpusDecoder* decoder_ = nullptr;
53};
Bounded Opus voice-frame packet helpers.
bool ready() const noexcept
Definition VoiceCodec.hpp:46
~VoiceDecoder()
Definition VoiceCodec.cpp:83
VoiceDecoder(const VoiceDecoder &)=delete
std::vector< float > conceal(std::uint8_t frameMs)
Definition VoiceCodec.cpp:134
bool init()
Definition VoiceCodec.cpp:103
VoiceDecoder()=default
std::vector< float > decode(std::span< const std::uint8_t > opus, std::uint8_t frameMs)
Definition VoiceCodec.cpp:116
OpusDecoder * decoder_
Definition VoiceCodec.hpp:52
void reset()
Definition VoiceCodec.cpp:150
VoiceDecoder & operator=(const VoiceDecoder &)=delete
std::vector< std::uint8_t > encode(std::span< const float > monoPcm)
Definition VoiceCodec.cpp:56
VoiceEncoder(const VoiceEncoder &)=delete
OpusEncoder * encoder_
Definition VoiceCodec.hpp:32
VoiceEncoder()=default
bool init()
Definition VoiceCodec.cpp:39
void reset()
Definition VoiceCodec.cpp:75
bool ready() const noexcept
Definition VoiceCodec.hpp:27
VoiceEncoder & operator=(const VoiceEncoder &)=delete
~VoiceEncoder()
Definition VoiceCodec.cpp:19