OpenTera WebRTC API (C++) 1.2.5
DataChannelConfiguration.h
1 #ifndef OPENTERA_WEBRTC_NATIVE_CLIENT_CONFIGURATIONS_DATA_CHANNEL_CONFIGURATION_H
2 #define OPENTERA_WEBRTC_NATIVE_CLIENT_CONFIGURATIONS_DATA_CHANNEL_CONFIGURATION_H
3 
4 #include <api/data_channel_interface.h>
5 
6 #include <string>
7 
8 namespace opentera
9 {
14  {
15  bool m_ordered;
16  absl::optional<int> m_maxPacketLifeTime; // It cannot be set with m_maxRetransmits
17  absl::optional<int> m_maxRetransmits; // It cannot be set with m_maxPacketLifeTime
18  std::string m_protocol;
19 
21  bool ordered,
22  absl::optional<int> maxPacketLifeTime,
23  absl::optional<int> maxRetransmits,
24  std::string&& protocol);
25 
26  public:
27  DataChannelConfiguration(const DataChannelConfiguration& other) = default;
29  virtual ~DataChannelConfiguration() = default;
30 
34  static DataChannelConfiguration create(bool ordered, std::string protocol);
35 
41 
46 
47  [[nodiscard]] bool ordered() const;
48  [[nodiscard]] const absl::optional<int>& maxPacketLifeTime() const;
49  [[nodiscard]] const absl::optional<int>& maxRetransmits() const;
50  [[nodiscard]] const std::string& protocol() const;
51 
52  explicit operator webrtc::DataChannelInit() const;
53 
54  DataChannelConfiguration& operator=(const DataChannelConfiguration& other) = default;
55  DataChannelConfiguration& operator=(DataChannelConfiguration&& other) = default;
56  };
57 
63  {
64  return {true, absl::nullopt, absl::nullopt, ""};
65  }
66 
74  {
75  return {ordered, absl::nullopt, absl::nullopt, ""};
76  }
77 
85  {
86  return {true, absl::nullopt, absl::nullopt, std::move(protocol)};
87  }
88 
96  inline DataChannelConfiguration DataChannelConfiguration::create(bool ordered, std::string protocol)
97  {
98  return {ordered, absl::nullopt, absl::nullopt, std::move(protocol)};
99  }
100 
108  {
109  return {true, maxPacketLifeTime, absl::nullopt, ""};
110  }
111 
120  DataChannelConfiguration::createMaxPacketLifeTime(bool ordered, int maxPacketLifeTime)
121  {
122  return {ordered, maxPacketLifeTime, absl::nullopt, ""};
123  }
124 
133  DataChannelConfiguration::createMaxPacketLifeTime(int maxPacketLifeTime, std::string protocol)
134  {
135  return {true, maxPacketLifeTime, absl::nullopt, std::move(protocol)};
136  }
137 
147  DataChannelConfiguration::createMaxPacketLifeTime(bool ordered, int maxPacketLifeTime, std::string protocol)
148  {
149  return {ordered, maxPacketLifeTime, absl::nullopt, std::move(protocol)};
150  }
151 
159  {
160  return {true, absl::nullopt, maxRetransmits, ""};
161  }
162 
171  {
172  return {ordered, absl::nullopt, maxRetransmits, ""};
173  }
174 
183  DataChannelConfiguration::createMaxRetransmits(int maxRetransmits, std::string protocol)
184  {
185  return {true, absl::nullopt, maxRetransmits, std::move(protocol)};
186  }
187 
197  DataChannelConfiguration::createMaxRetransmits(bool ordered, int maxRetransmits, std::string protocol)
198  {
199  return {ordered, absl::nullopt, maxRetransmits, std::move(protocol)};
200  }
201 
206  inline bool DataChannelConfiguration::ordered() const { return m_ordered; }
207 
212  inline const absl::optional<int>& DataChannelConfiguration::maxPacketLifeTime() const
213  {
214  return m_maxPacketLifeTime;
215  }
216 
221  inline const absl::optional<int>& DataChannelConfiguration::maxRetransmits() const { return m_maxRetransmits; }
222 
227  inline const std::string& DataChannelConfiguration::protocol() const { return m_protocol; }
228 }
229 
230 #endif
Represents a data channel configuration.
Definition: DataChannelConfiguration.h:14
static DataChannelConfiguration createProtocol(std::string protocol)
Creates a data channel configuration with the specified value.
Definition: DataChannelConfiguration.h:84
static DataChannelConfiguration createMaxRetransmits(int maxRetransmits)
Creates a data channel configuration with the specified value.
Definition: DataChannelConfiguration.h:158
const std::string & protocol() const
Returns the data channel protocol.
Definition: DataChannelConfiguration.h:227
static DataChannelConfiguration createMaxPacketLifeTime(int maxPacketLifeTime)
Creates a data channel configuration with the specified value.
Definition: DataChannelConfiguration.h:107
const absl::optional< int > & maxRetransmits() const
Returns the maximum number of time a message can be retransmitted.
Definition: DataChannelConfiguration.h:221
bool ordered() const
Indicates if the message order must be preserved.
Definition: DataChannelConfiguration.h:206
static DataChannelConfiguration create()
Creates a data channel configuration with default values.
Definition: DataChannelConfiguration.h:62
const absl::optional< int > & maxPacketLifeTime() const
Returns the maximum number of time a message can be retransmitted.
Definition: DataChannelConfiguration.h:212