Datachannel: Use absl::optional for maxRetransmits and maxRetransmitTime.
These parameters are nullable in the JS API. This allows cleaner handling of "unset" vs "set" in Chrome. Backwards compatibility note: Behavior should not change, even for users who set the values explicitly to -1 in the DataChannelInit struct. Those who try to read back the value will get a compile-time error. Bug: chromium:854385 Change-Id: Ib488ca5f70bc24ba8b4a3f71b506434c4d2c60b2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131381 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27507}
This commit is contained in:

committed by
Commit Bot

parent
8581877121
commit
f3736ed3d8
@ -108,8 +108,8 @@ bool ParseDataChannelOpenMessage(const rtc::CopyOnWriteBuffer& payload,
|
||||
config->ordered = false;
|
||||
}
|
||||
|
||||
config->maxRetransmits = -1;
|
||||
config->maxRetransmitTime = -1;
|
||||
config->maxRetransmits = absl::nullopt;
|
||||
config->maxRetransmitTime = absl::nullopt;
|
||||
switch (channel_type) {
|
||||
case DCOMCT_ORDERED_PARTIAL_RTXS:
|
||||
case DCOMCT_UNORDERED_PARTIAL_RTXS:
|
||||
@ -142,27 +142,27 @@ bool WriteDataChannelOpenMessage(const std::string& label,
|
||||
const DataChannelInit& config,
|
||||
rtc::CopyOnWriteBuffer* payload) {
|
||||
// Format defined at
|
||||
// http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-00#section-6.1
|
||||
// http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-09#section-5.1
|
||||
uint8_t channel_type = 0;
|
||||
uint32_t reliability_param = 0;
|
||||
uint16_t priority = 0;
|
||||
if (config.ordered) {
|
||||
if (config.maxRetransmits > -1) {
|
||||
if (config.maxRetransmits) {
|
||||
channel_type = DCOMCT_ORDERED_PARTIAL_RTXS;
|
||||
reliability_param = config.maxRetransmits;
|
||||
} else if (config.maxRetransmitTime > -1) {
|
||||
reliability_param = *config.maxRetransmits;
|
||||
} else if (config.maxRetransmitTime) {
|
||||
channel_type = DCOMCT_ORDERED_PARTIAL_TIME;
|
||||
reliability_param = config.maxRetransmitTime;
|
||||
reliability_param = *config.maxRetransmitTime;
|
||||
} else {
|
||||
channel_type = DCOMCT_ORDERED_RELIABLE;
|
||||
}
|
||||
} else {
|
||||
if (config.maxRetransmits > -1) {
|
||||
if (config.maxRetransmits) {
|
||||
channel_type = DCOMCT_UNORDERED_PARTIAL_RTXS;
|
||||
reliability_param = config.maxRetransmits;
|
||||
} else if (config.maxRetransmitTime > -1) {
|
||||
reliability_param = *config.maxRetransmits;
|
||||
} else if (config.maxRetransmitTime) {
|
||||
channel_type = DCOMCT_UNORDERED_PARTIAL_TIME;
|
||||
reliability_param = config.maxRetransmitTime;
|
||||
reliability_param = *config.maxRetransmitTime;
|
||||
} else {
|
||||
channel_type = DCOMCT_UNORDERED_RELIABLE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user