wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 11 | #include "pc/sctp_utils.h" |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 12 | |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 13 | #include <stddef.h> |
Harald Alvestrand | c24a218 | 2022-02-23 13:44:59 | [diff] [blame] | 14 | |
| 15 | #include <cstdint> |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 16 | |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 | [diff] [blame] | 17 | #include "absl/types/optional.h" |
Harald Alvestrand | fd5ae7f | 2020-05-16 06:37:49 | [diff] [blame] | 18 | #include "api/priority.h" |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 19 | #include "media/sctp/sctp_transport_internal.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 20 | #include "rtc_base/byte_buffer.h" |
| 21 | #include "rtc_base/copy_on_write_buffer.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 22 | #include "rtc_base/logging.h" |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 23 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 24 | namespace webrtc { |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 25 | |
| 26 | // Format defined at |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 27 | // http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-01#section |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 28 | |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 29 | static const uint8_t DATA_CHANNEL_OPEN_MESSAGE_TYPE = 0x03; |
| 30 | static const uint8_t DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE = 0x02; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 31 | |
| 32 | enum DataChannelOpenMessageChannelType { |
| 33 | DCOMCT_ORDERED_RELIABLE = 0x00, |
| 34 | DCOMCT_ORDERED_PARTIAL_RTXS = 0x01, |
| 35 | DCOMCT_ORDERED_PARTIAL_TIME = 0x02, |
| 36 | DCOMCT_UNORDERED_RELIABLE = 0x80, |
| 37 | DCOMCT_UNORDERED_PARTIAL_RTXS = 0x81, |
| 38 | DCOMCT_UNORDERED_PARTIAL_TIME = 0x82, |
| 39 | }; |
| 40 | |
Harald Alvestrand | fd5ae7f | 2020-05-16 06:37:49 | [diff] [blame] | 41 | // Values of priority in the DC open protocol message. |
| 42 | // These are compared against an integer, so are enum, not enum class. |
| 43 | enum DataChannelPriority { |
| 44 | DCO_PRIORITY_VERY_LOW = 128, |
| 45 | DCO_PRIORITY_LOW = 256, |
| 46 | DCO_PRIORITY_MEDIUM = 512, |
| 47 | DCO_PRIORITY_HIGH = 1024, |
| 48 | }; |
| 49 | |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 50 | StreamId::StreamId() : id_(absl::nullopt) { |
| 51 | thread_checker_.Detach(); |
| 52 | } |
| 53 | |
| 54 | StreamId::StreamId(int id) |
| 55 | : id_(id >= cricket::kMinSctpSid && id <= cricket::kSpecMaxSctpSid |
| 56 | ? absl::optional<uint16_t>(static_cast<uint16_t>(id)) |
| 57 | : absl::nullopt) { |
| 58 | thread_checker_.Detach(); |
| 59 | } |
| 60 | |
| 61 | StreamId::StreamId(const StreamId& sid) : id_(sid.id_) {} |
| 62 | |
| 63 | bool StreamId::HasValue() const { |
| 64 | RTC_DCHECK_RUN_ON(&thread_checker_); |
| 65 | return id_.has_value(); |
| 66 | } |
| 67 | |
| 68 | int StreamId::stream_id_int() const { |
| 69 | RTC_DCHECK_RUN_ON(&thread_checker_); |
| 70 | return id_.has_value() ? static_cast<int>(id_.value().value()) : -1; |
| 71 | } |
| 72 | |
| 73 | void StreamId::reset() { |
| 74 | RTC_DCHECK_RUN_ON(&thread_checker_); |
| 75 | id_ = absl::nullopt; |
| 76 | } |
| 77 | |
| 78 | StreamId& StreamId::operator=(const StreamId& sid) { |
| 79 | RTC_DCHECK_RUN_ON(&thread_checker_); |
| 80 | RTC_DCHECK_RUN_ON(&sid.thread_checker_); |
| 81 | id_ = sid.id_; |
| 82 | return *this; |
| 83 | } |
| 84 | |
| 85 | bool StreamId::operator==(const StreamId& sid) const { |
| 86 | RTC_DCHECK_RUN_ON(&thread_checker_); |
| 87 | RTC_DCHECK_RUN_ON(&sid.thread_checker_); |
| 88 | return id_ == sid.id_; |
| 89 | } |
| 90 | |
| 91 | bool StreamId::operator<(const StreamId& sid) const { |
| 92 | RTC_DCHECK_RUN_ON(&thread_checker_); |
| 93 | RTC_DCHECK_RUN_ON(&sid.thread_checker_); |
| 94 | return id_ < sid.id_; |
| 95 | } |
| 96 | |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 97 | bool IsOpenMessage(const rtc::CopyOnWriteBuffer& payload) { |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 98 | // Format defined at |
Tommi | 5bbfb00 | 2023-03-04 15:47:53 | [diff] [blame] | 99 | // https://www.rfc-editor.org/rfc/rfc8832#section-5.1 |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 100 | if (payload.size() < 1) { |
Tommi | 5bbfb00 | 2023-03-04 15:47:53 | [diff] [blame] | 101 | RTC_DLOG(LS_WARNING) << "Could not read OPEN message type."; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 102 | return false; |
| 103 | } |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 104 | |
| 105 | uint8_t message_type = payload[0]; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 106 | return message_type == DATA_CHANNEL_OPEN_MESSAGE_TYPE; |
| 107 | } |
| 108 | |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 109 | bool ParseDataChannelOpenMessage(const rtc::CopyOnWriteBuffer& payload, |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 110 | std::string* label, |
| 111 | DataChannelInit* config) { |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 112 | // Format defined at |
| 113 | // http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04 |
| 114 | |
jbauch | f1f8720 | 2016-03-30 13:43:37 | [diff] [blame] | 115 | rtc::ByteBufferReader buffer(payload.data<char>(), payload.size()); |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 116 | uint8_t message_type; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 117 | if (!buffer.ReadUInt8(&message_type)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 118 | RTC_LOG(LS_WARNING) << "Could not read OPEN message type."; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 119 | return false; |
| 120 | } |
| 121 | if (message_type != DATA_CHANNEL_OPEN_MESSAGE_TYPE) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 122 | RTC_LOG(LS_WARNING) << "Data Channel OPEN message of unexpected type: " |
| 123 | << message_type; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 124 | return false; |
| 125 | } |
| 126 | |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 127 | uint8_t channel_type; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 128 | if (!buffer.ReadUInt8(&channel_type)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 129 | RTC_LOG(LS_WARNING) << "Could not read OPEN message channel type."; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 130 | return false; |
| 131 | } |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 | [diff] [blame] | 132 | |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 133 | uint16_t priority; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 134 | if (!buffer.ReadUInt16(&priority)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 135 | RTC_LOG(LS_WARNING) |
| 136 | << "Could not read OPEN message reliabilility prioirty."; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 137 | return false; |
| 138 | } |
Harald Alvestrand | fd5ae7f | 2020-05-16 06:37:49 | [diff] [blame] | 139 | // Parse priority as defined in |
| 140 | // https://w3c.github.io/webrtc-priority/#rtcdatachannel-processing-steps |
| 141 | if (priority <= DCO_PRIORITY_VERY_LOW) { |
| 142 | config->priority = Priority::kVeryLow; |
| 143 | } else if (priority <= DCO_PRIORITY_LOW) { |
| 144 | config->priority = Priority::kLow; |
| 145 | } else if (priority <= DCO_PRIORITY_MEDIUM) { |
| 146 | config->priority = Priority::kMedium; |
| 147 | } else { |
| 148 | config->priority = Priority::kHigh; |
| 149 | } |
| 150 | |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 151 | uint32_t reliability_param; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 | [diff] [blame] | 152 | if (!buffer.ReadUInt32(&reliability_param)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 153 | RTC_LOG(LS_WARNING) << "Could not read OPEN message reliabilility param."; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 | [diff] [blame] | 154 | return false; |
| 155 | } |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 156 | uint16_t label_length; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 157 | if (!buffer.ReadUInt16(&label_length)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 158 | RTC_LOG(LS_WARNING) << "Could not read OPEN message label length."; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 159 | return false; |
| 160 | } |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 161 | uint16_t protocol_length; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 162 | if (!buffer.ReadUInt16(&protocol_length)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 163 | RTC_LOG(LS_WARNING) << "Could not read OPEN message protocol length."; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 164 | return false; |
| 165 | } |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 166 | if (!buffer.ReadString(label, (size_t)label_length)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 167 | RTC_LOG(LS_WARNING) << "Could not read OPEN message label"; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 168 | return false; |
| 169 | } |
| 170 | if (!buffer.ReadString(&config->protocol, protocol_length)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 171 | RTC_LOG(LS_WARNING) << "Could not read OPEN message protocol."; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 172 | return false; |
| 173 | } |
| 174 | |
| 175 | config->ordered = true; |
| 176 | switch (channel_type) { |
| 177 | case DCOMCT_UNORDERED_RELIABLE: |
| 178 | case DCOMCT_UNORDERED_PARTIAL_RTXS: |
| 179 | case DCOMCT_UNORDERED_PARTIAL_TIME: |
| 180 | config->ordered = false; |
| 181 | } |
| 182 | |
Harald Alvestrand | f3736ed | 2019-04-08 11:09:30 | [diff] [blame] | 183 | config->maxRetransmits = absl::nullopt; |
| 184 | config->maxRetransmitTime = absl::nullopt; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 185 | switch (channel_type) { |
| 186 | case DCOMCT_ORDERED_PARTIAL_RTXS: |
| 187 | case DCOMCT_UNORDERED_PARTIAL_RTXS: |
| 188 | config->maxRetransmits = reliability_param; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 | [diff] [blame] | 189 | break; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 190 | case DCOMCT_ORDERED_PARTIAL_TIME: |
| 191 | case DCOMCT_UNORDERED_PARTIAL_TIME: |
| 192 | config->maxRetransmitTime = reliability_param; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 | [diff] [blame] | 193 | break; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 194 | } |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 195 | return true; |
| 196 | } |
| 197 | |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 198 | bool ParseDataChannelOpenAckMessage(const rtc::CopyOnWriteBuffer& payload) { |
| 199 | if (payload.size() < 1) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 200 | RTC_LOG(LS_WARNING) << "Could not read OPEN_ACK message type."; |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 201 | return false; |
| 202 | } |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 203 | |
| 204 | uint8_t message_type = payload[0]; |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 205 | if (message_type != DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 206 | RTC_LOG(LS_WARNING) << "Data Channel OPEN_ACK message of unexpected type: " |
| 207 | << message_type; |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 208 | return false; |
| 209 | } |
| 210 | return true; |
| 211 | } |
| 212 | |
| 213 | bool WriteDataChannelOpenMessage(const std::string& label, |
| 214 | const DataChannelInit& config, |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 215 | rtc::CopyOnWriteBuffer* payload) { |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 216 | return WriteDataChannelOpenMessage(label, config.protocol, config.priority, |
| 217 | config.ordered, config.maxRetransmits, |
| 218 | config.maxRetransmitTime, payload); |
| 219 | } |
| 220 | |
| 221 | bool WriteDataChannelOpenMessage(const std::string& label, |
| 222 | const std::string& protocol, |
| 223 | absl::optional<Priority> opt_priority, |
| 224 | bool ordered, |
| 225 | absl::optional<int> max_retransmits, |
| 226 | absl::optional<int> max_retransmit_time, |
| 227 | rtc::CopyOnWriteBuffer* payload) { |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 228 | // Format defined at |
Harald Alvestrand | f3736ed | 2019-04-08 11:09:30 | [diff] [blame] | 229 | // http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-09#section-5.1 |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 230 | uint8_t channel_type = 0; |
| 231 | uint32_t reliability_param = 0; |
| 232 | uint16_t priority = 0; |
Harald Alvestrand | fd5ae7f | 2020-05-16 06:37:49 | [diff] [blame] | 233 | // Set priority according to |
| 234 | // https://tools.ietf.org/html/draft-ietf-rtcweb-data-channel-12#section-6.4 |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 235 | if (opt_priority) { |
| 236 | switch (*opt_priority) { |
Harald Alvestrand | fd5ae7f | 2020-05-16 06:37:49 | [diff] [blame] | 237 | case Priority::kVeryLow: |
| 238 | priority = DCO_PRIORITY_VERY_LOW; |
| 239 | break; |
| 240 | case Priority::kLow: |
| 241 | priority = DCO_PRIORITY_LOW; |
| 242 | break; |
| 243 | case Priority::kMedium: |
| 244 | priority = DCO_PRIORITY_MEDIUM; |
| 245 | break; |
| 246 | case Priority::kHigh: |
| 247 | priority = DCO_PRIORITY_HIGH; |
| 248 | break; |
| 249 | } |
| 250 | } |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 251 | if (ordered) { |
| 252 | if (max_retransmits) { |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 253 | channel_type = DCOMCT_ORDERED_PARTIAL_RTXS; |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 254 | reliability_param = *max_retransmits; |
| 255 | } else if (max_retransmit_time) { |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 256 | channel_type = DCOMCT_ORDERED_PARTIAL_TIME; |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 257 | reliability_param = *max_retransmit_time; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 258 | } else { |
| 259 | channel_type = DCOMCT_ORDERED_RELIABLE; |
| 260 | } |
| 261 | } else { |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 262 | if (max_retransmits) { |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 263 | channel_type = DCOMCT_UNORDERED_PARTIAL_RTXS; |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 264 | reliability_param = *max_retransmits; |
| 265 | } else if (max_retransmit_time) { |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 266 | channel_type = DCOMCT_UNORDERED_PARTIAL_TIME; |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 267 | reliability_param = *max_retransmit_time; |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 268 | } else { |
| 269 | channel_type = DCOMCT_UNORDERED_RELIABLE; |
| 270 | } |
| 271 | } |
| 272 | |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 273 | rtc::ByteBufferWriter buffer(NULL, 20 + label.length() + protocol.length()); |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 274 | // TODO(tommi): Add error handling and check resulting length. |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 275 | buffer.WriteUInt8(DATA_CHANNEL_OPEN_MESSAGE_TYPE); |
| 276 | buffer.WriteUInt8(channel_type); |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 277 | buffer.WriteUInt16(priority); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 | [diff] [blame] | 278 | buffer.WriteUInt32(reliability_param); |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 279 | buffer.WriteUInt16(static_cast<uint16_t>(label.length())); |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 280 | buffer.WriteUInt16(static_cast<uint16_t>(protocol.length())); |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 281 | buffer.WriteString(label); |
Tommi | 492296c | 2023-03-12 15:59:25 | [diff] [blame^] | 282 | buffer.WriteString(protocol); |
wu@webrtc.org | 1d1ffc9 | 2013-10-16 18:12:02 | [diff] [blame] | 283 | payload->SetData(buffer.Data(), buffer.Length()); |
| 284 | return true; |
| 285 | } |
| 286 | |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 287 | void WriteDataChannelOpenAckMessage(rtc::CopyOnWriteBuffer* payload) { |
| 288 | uint8_t data = DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE; |
| 289 | payload->SetData(&data, sizeof(data)); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 290 | } |
jbauch | eec21bd | 2016-03-20 13:15:43 | [diff] [blame] | 291 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 292 | } // namespace webrtc |