summaryrefslogtreecommitdiff
path: root/src/codecs/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/codecs/include')
-rw-r--r--src/codecs/include/ogg.hpp36
-rw-r--r--src/codecs/include/opus.hpp3
2 files changed, 39 insertions, 0 deletions
diff --git a/src/codecs/include/ogg.hpp b/src/codecs/include/ogg.hpp
new file mode 100644
index 00000000..2d6ea8c5
--- /dev/null
+++ b/src/codecs/include/ogg.hpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2023 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <sys/_stdint.h>
+#include <cstddef>
+#include <cstdint>
+#include <optional>
+
+#include "ogg/ogg.h"
+#include "span.hpp"
+
+namespace codecs {
+
+class OggContainer {
+ public:
+ OggContainer();
+ ~OggContainer();
+
+ auto AddBytes(cpp::span<const std::byte>) -> void;
+ auto HasNextPacket() -> bool;
+ auto NextPacket() -> cpp::span<uint8_t>;
+ auto PeekPacket() -> cpp::span<uint8_t>;
+
+ private:
+ ogg_sync_state sync_;
+ ogg_stream_state stream_;
+ ogg_page page_;
+ ogg_packet packet_;
+};
+
+} // namespace codecs \ No newline at end of file
diff --git a/src/codecs/include/opus.hpp b/src/codecs/include/opus.hpp
index f824a7cb..50717b73 100644
--- a/src/codecs/include/opus.hpp
+++ b/src/codecs/include/opus.hpp
@@ -13,6 +13,8 @@
#include <string>
#include <utility>
+#include "ogg.hpp"
+#include "ogg/ogg.h"
#include "opus.h"
#include "sample.hpp"
#include "span.hpp"
@@ -44,6 +46,7 @@ class XiphOpusDecoder : public ICodec {
-> Result<void> override;
private:
+ OggContainer ogg_;
OpusDecoder* opus_;
cpp::span<int16_t> sample_buffer_;
int32_t pos_in_buffer_;