summaryrefslogtreecommitdiff
path: root/src/audio/include/stream_info.hpp
blob: 45f10fc6a2706a69e655368b7967736b7739801e (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
37
38
39
40
41
42
43
44
#pragma once

#include <cstdint>
#include <optional>
#include <string>
#include <string_view>

#include "cbor.h"
#include "result.hpp"

namespace audio {

class StreamInfo {
 public:
  static auto Parse(CborValue& container) -> cpp::result<StreamInfo, CborError>;

  StreamInfo() = default;
  StreamInfo(const StreamInfo&) = default;

  ~StreamInfo() = default;

  auto Path() const -> const std::optional<std::string>& { return path_; }
  auto Path(const std::string_view& d) -> void { path_ = d; }

  auto Channels() const -> const std::optional<uint8_t>& { return channels_; }

  auto BitsPerSample() const -> const std::optional<uint8_t>& {
    return bits_per_sample_;
  }

  auto SampleRate() const -> const std::optional<uint16_t>& {
    return sample_rate_;
  }

  auto Encode(CborEncoder& enc) -> std::optional<CborError>;

 private:
  std::optional<std::string> path_;
  std::optional<uint8_t> channels_;
  std::optional<uint8_t> bits_per_sample_;
  std::optional<uint16_t> sample_rate_;
};

}  // namespace audio