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
@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/copy_on_write_buffer.h"
|
||||
#include "rtc_base/ref_count.h"
|
||||
@ -35,15 +36,16 @@ struct DataChannelInit {
|
||||
bool ordered = true;
|
||||
|
||||
// The max period of time in milliseconds in which retransmissions will be
|
||||
// sent. After this time, no more retransmissions will be sent. -1 if unset.
|
||||
// sent. After this time, no more retransmissions will be sent.
|
||||
//
|
||||
// Cannot be set along with |maxRetransmits|.
|
||||
int maxRetransmitTime = -1;
|
||||
// This is called |maxPacketLifeTime| in the WebRTC JS API.
|
||||
absl::optional<int> maxRetransmitTime;
|
||||
|
||||
// The max number of retransmissions. -1 if unset.
|
||||
// The max number of retransmissions.
|
||||
//
|
||||
// Cannot be set along with |maxRetransmitTime|.
|
||||
int maxRetransmits = -1;
|
||||
absl::optional<int> maxRetransmits;
|
||||
|
||||
// This is set by the application and opaque to the WebRTC implementation.
|
||||
std::string protocol;
|
||||
@ -137,8 +139,11 @@ class DataChannelInterface : public rtc::RefCountInterface {
|
||||
// implemented these APIs. They should all just return the values the
|
||||
// DataChannel was created with.
|
||||
virtual bool ordered() const;
|
||||
// TODO(hta): Deprecate and remove the following two functions.
|
||||
virtual uint16_t maxRetransmitTime() const;
|
||||
virtual uint16_t maxRetransmits() const;
|
||||
virtual absl::optional<int> maxRetransmitsOpt() const;
|
||||
virtual absl::optional<int> maxPacketLifeTime() const;
|
||||
virtual std::string protocol() const;
|
||||
virtual bool negotiated() const;
|
||||
|
||||
|
Reference in New Issue
Block a user