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