summaryrefslogtreecommitdiff
path: root/src/codecs/include/ogg.hpp
blob: 2d6ea8c5afec3ebf808215f9ac2a435209efe5ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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