From 67caeb6e3cda44205ba8fe783274b20dc7ea216e Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 9 Aug 2023 12:00:02 +1000 Subject: Use opusfile instead of working directly with ogg and opus --- src/codecs/include/ogg.hpp | 43 ------------------------------------------- src/codecs/include/opus.hpp | 16 +++++++--------- src/codecs/include/vorbis.hpp | 1 - 3 files changed, 7 insertions(+), 53 deletions(-) delete mode 100644 src/codecs/include/ogg.hpp (limited to 'src/codecs/include') diff --git a/src/codecs/include/ogg.hpp b/src/codecs/include/ogg.hpp deleted file mode 100644 index a27e961e..00000000 --- a/src/codecs/include/ogg.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2023 jacqueline - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include -#include -#include -#include - -#include "ogg/ogg.h" -#include "span.hpp" - -namespace codecs { - -class OggContainer { - public: - OggContainer(); - ~OggContainer(); - - auto AddBytes(cpp::span) -> bool; - - auto Next() -> bool; - auto Current() -> cpp::span; - auto HasPacket() -> bool; - - private: - auto AdvancePage() -> bool; - auto AdvancePacket() -> bool; - - ogg_sync_state sync_; - ogg_stream_state stream_; - ogg_page page_; - ogg_packet packet_; - - bool has_stream_; - bool has_packet_; -}; - -} // namespace codecs \ No newline at end of file diff --git a/src/codecs/include/opus.hpp b/src/codecs/include/opus.hpp index 50717b73..051cd0b9 100644 --- a/src/codecs/include/opus.hpp +++ b/src/codecs/include/opus.hpp @@ -13,9 +13,7 @@ #include #include -#include "ogg.hpp" -#include "ogg/ogg.h" -#include "opus.h" +#include "opusfile.h" #include "sample.hpp" #include "span.hpp" @@ -45,13 +43,13 @@ class XiphOpusDecoder : public ICodec { auto SeekStream(cpp::span input, std::size_t target_sample) -> Result override; - private: - OggContainer ogg_; - OpusDecoder* opus_; - cpp::span sample_buffer_; - int32_t pos_in_buffer_; - int32_t samples_in_buffer_; + auto ReadCallback() -> cpp::span; + auto AfterReadCallback(size_t bytes_read) -> void; + private: + OggOpusFile* opus_; + cpp::span input_; + size_t pos_in_input_; }; } // namespace codecs diff --git a/src/codecs/include/vorbis.hpp b/src/codecs/include/vorbis.hpp index 2804bb7c..ab15af19 100644 --- a/src/codecs/include/vorbis.hpp +++ b/src/codecs/include/vorbis.hpp @@ -14,7 +14,6 @@ #include #include "ivorbisfile.h" -#include "ogg.hpp" #include "ogg/ogg.h" #include "opus.h" #include "sample.hpp" -- cgit v1.2.3