|
@@ -74,8 +74,13 @@ bool DataChannel::IsOpenMessage(message_ptr message) {
|
|
DataChannel::DataChannel(weak_ptr<PeerConnection> pc, string label, string protocol,
|
|
DataChannel::DataChannel(weak_ptr<PeerConnection> pc, string label, string protocol,
|
|
Reliability reliability)
|
|
Reliability reliability)
|
|
: mPeerConnection(pc), mLabel(std::move(label)), mProtocol(std::move(protocol)),
|
|
: mPeerConnection(pc), mLabel(std::move(label)), mProtocol(std::move(protocol)),
|
|
- mReliability(std::make_shared<Reliability>(std::move(reliability))),
|
|
|
|
- mRecvQueue(RECV_QUEUE_LIMIT, message_size_func) {}
|
|
|
|
|
|
+ mRecvQueue(RECV_QUEUE_LIMIT, message_size_func) {
|
|
|
|
+
|
|
|
|
+ if(reliability.maxPacketLifeTime && reliability.maxRetransmits)
|
|
|
|
+ throw std::invalid_argument("Both maxPacketLifeTime and maxRetransmits are set");
|
|
|
|
+
|
|
|
|
+ mReliability = std::make_shared<Reliability>(std::move(reliability));
|
|
|
|
+}
|
|
|
|
|
|
DataChannel::~DataChannel() {
|
|
DataChannel::~DataChannel() {
|
|
PLOG_VERBOSE << "Destroying DataChannel";
|
|
PLOG_VERBOSE << "Destroying DataChannel";
|
|
@@ -247,22 +252,35 @@ void OutgoingDataChannel::open(shared_ptr<SctpTransport> transport) {
|
|
|
|
|
|
uint8_t channelType;
|
|
uint8_t channelType;
|
|
uint32_t reliabilityParameter;
|
|
uint32_t reliabilityParameter;
|
|
- switch (mReliability->type) {
|
|
|
|
- case Reliability::Type::Rexmit:
|
|
|
|
|
|
+ if (mReliability->maxPacketLifeTime) {
|
|
|
|
+ channelType = CHANNEL_PARTIAL_RELIABLE_TIMED;
|
|
|
|
+ reliabilityParameter = uint32_t(mReliability->maxPacketLifeTime->count());
|
|
|
|
+ } else if (mReliability->maxRetransmits) {
|
|
channelType = CHANNEL_PARTIAL_RELIABLE_REXMIT;
|
|
channelType = CHANNEL_PARTIAL_RELIABLE_REXMIT;
|
|
- reliabilityParameter = uint32_t(std::max(std::get<int>(mReliability->rexmit), 0));
|
|
|
|
- break;
|
|
|
|
|
|
+ reliabilityParameter = uint32_t(*mReliability->maxRetransmits);
|
|
|
|
+ }
|
|
|
|
+ // else {
|
|
|
|
+ // channelType = CHANNEL_RELIABLE;
|
|
|
|
+ // reliabilityParameter = 0;
|
|
|
|
+ // }
|
|
|
|
+ // Deprecated
|
|
|
|
+ else
|
|
|
|
+ switch (mReliability->typeDeprecated) {
|
|
|
|
+ case Reliability::Type::Rexmit:
|
|
|
|
+ channelType = CHANNEL_PARTIAL_RELIABLE_REXMIT;
|
|
|
|
+ reliabilityParameter = uint32_t(std::max(std::get<int>(mReliability->rexmit), 0));
|
|
|
|
+ break;
|
|
|
|
|
|
- case Reliability::Type::Timed:
|
|
|
|
- channelType = CHANNEL_PARTIAL_RELIABLE_TIMED;
|
|
|
|
- reliabilityParameter = uint32_t(std::get<milliseconds>(mReliability->rexmit).count());
|
|
|
|
- break;
|
|
|
|
|
|
+ case Reliability::Type::Timed:
|
|
|
|
+ channelType = CHANNEL_PARTIAL_RELIABLE_TIMED;
|
|
|
|
+ reliabilityParameter = uint32_t(std::get<milliseconds>(mReliability->rexmit).count());
|
|
|
|
+ break;
|
|
|
|
|
|
- default:
|
|
|
|
- channelType = CHANNEL_RELIABLE;
|
|
|
|
- reliabilityParameter = 0;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ default:
|
|
|
|
+ channelType = CHANNEL_RELIABLE;
|
|
|
|
+ reliabilityParameter = 0;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
|
|
if (mReliability->unordered)
|
|
if (mReliability->unordered)
|
|
channelType |= 0x80;
|
|
channelType |= 0x80;
|
|
@@ -329,17 +347,31 @@ void IncomingDataChannel::processOpenMessage(message_ptr message) {
|
|
mProtocol.assign(end + open.labelLength, open.protocolLength);
|
|
mProtocol.assign(end + open.labelLength, open.protocolLength);
|
|
|
|
|
|
mReliability->unordered = (open.channelType & 0x80) != 0;
|
|
mReliability->unordered = (open.channelType & 0x80) != 0;
|
|
|
|
+ mReliability->maxPacketLifeTime.reset();
|
|
|
|
+ mReliability->maxRetransmits.reset();
|
|
|
|
+ switch (open.channelType & 0x7F) {
|
|
|
|
+ case CHANNEL_PARTIAL_RELIABLE_REXMIT:
|
|
|
|
+ mReliability->maxRetransmits.emplace(open.reliabilityParameter);
|
|
|
|
+ break;
|
|
|
|
+ case CHANNEL_PARTIAL_RELIABLE_TIMED:
|
|
|
|
+ mReliability->maxPacketLifeTime.emplace(milliseconds(open.reliabilityParameter));
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Deprecated
|
|
switch (open.channelType & 0x7F) {
|
|
switch (open.channelType & 0x7F) {
|
|
case CHANNEL_PARTIAL_RELIABLE_REXMIT:
|
|
case CHANNEL_PARTIAL_RELIABLE_REXMIT:
|
|
- mReliability->type = Reliability::Type::Rexmit;
|
|
|
|
|
|
+ mReliability->typeDeprecated = Reliability::Type::Rexmit;
|
|
mReliability->rexmit = int(open.reliabilityParameter);
|
|
mReliability->rexmit = int(open.reliabilityParameter);
|
|
break;
|
|
break;
|
|
case CHANNEL_PARTIAL_RELIABLE_TIMED:
|
|
case CHANNEL_PARTIAL_RELIABLE_TIMED:
|
|
- mReliability->type = Reliability::Type::Timed;
|
|
|
|
|
|
+ mReliability->typeDeprecated = Reliability::Type::Timed;
|
|
mReliability->rexmit = milliseconds(open.reliabilityParameter);
|
|
mReliability->rexmit = milliseconds(open.reliabilityParameter);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- mReliability->type = Reliability::Type::Reliable;
|
|
|
|
|
|
+ mReliability->typeDeprecated = Reliability::Type::Reliable;
|
|
mReliability->rexmit = int(0);
|
|
mReliability->rexmit = int(0);
|
|
}
|
|
}
|
|
|
|
|