avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
channellayout.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <string_view>
5 #include <bitset>
6 
7 #include "avutils.h"
8 
9 #if API_NEW_CHANNEL_LAYOUT
10 extern "C" {
11 #include <libavutil/channel_layout.h>
12 }
13 
14 namespace av {
15 
16 std::string channel_name(AVChannel channel);
17 std::string channel_description(AVChannel channel);
18 AVChannel channel_from_string(const std::string &name);
19 AVChannel channel_from_string(const char *name);
20 
21 class ChannelLayout;
22 
23 class ChannelLayoutView
24 {
25 public:
26  ChannelLayoutView() noexcept;
27  // implicit by design
28  ChannelLayoutView(const AVChannelLayout &layout) noexcept;
29 
30  // ???
31  //+ const AVChannelLayout *av_channel_layout_standard(void **opaque);
32  template<typename Callable>
33  static void iterate(Callable callable) {
34  void *iter = nullptr;
35  const AVChannelLayout *playout;
36  while ((playout = av_channel_layout_standard(&iter))) {
37  if (callable(ChannelLayoutView(*playout)))
38  break;
39  }
40  }
41 
42  static void dumpLayouts();
43 
44  //+ int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size);
45  //+ int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel);
46  //+ int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout, const char *name);
47  //+ enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx);
48  //+ enum AVChannel av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout, const char *name);
49  //+ uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout, uint64_t mask);
50  //+ int av_channel_layout_check(const AVChannelLayout *channel_layout);
51  //+ int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1);
52 
53  AVChannelLayout *raw();
54  const AVChannelLayout *raw() const;
55 
56  int channels() const noexcept;
57  uint64_t layout() const noexcept;
58  uint64_t subset(uint64_t mask) const noexcept;
59  bool isValid() const noexcept;
60  std::string describe() const;
61  void describe(std::string &desc) const;
62 
63  int index(AVChannel channel) const;
64  int index(const char *name) const;
65 
66  AVChannel channel(unsigned int index) const;
67  AVChannel channel(const char *name) const;
68 
69  bool operator==(const ChannelLayoutView &other) const noexcept;
70 
71  ChannelLayout clone() const;
72 
73 protected:
74  AVChannelLayout m_layout{};
75 };
76 
77 
78 
79 class ChannelLayout : public ChannelLayoutView
80 {
81 public:
82  ChannelLayout() = default;
83  //explicit ChannelLayout(ChannelLayoutView &&view);
84  explicit ChannelLayout(const ChannelLayoutView &view);
85 
86  using ChannelLayoutView::ChannelLayoutView;
87 
88  ChannelLayout(const ChannelLayout& other);
89  ChannelLayout& operator=(const ChannelLayout& other);
90 
91  ChannelLayout(ChannelLayout&& other);
92  ChannelLayout& operator=(ChannelLayout&& other);
93 
94  ~ChannelLayout();
95 
96  //+ void av_channel_layout_uninit(AVChannelLayout *channel_layout);
97  //
98  //+ int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask);
99  //+ int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str);
100  //+ void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels);
101  //+ int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src);
102 
103  //explicit ChannelLayout(uint64_t mask);
104  explicit ChannelLayout(std::bitset<64> mask);
105  explicit ChannelLayout(const char *str);
106  explicit ChannelLayout(int channels);
107 
108  // Stop control AVChannelLayout
109  void release();
110 
111 private:
112  void swap(ChannelLayout &other);
113 
114 };
115 
116 } // namespace av
117 
118 #endif
avutils.h
av
Definition: audioresampler.cpp:8
std
Definition: averror.h:228