Commit 2661955a authored by Philipp Hancke's avatar Philipp Hancke Committed by Commit Bot

webrtc: make RTCIceCandidate tcpType optional

for spec compliance the field can/shall be null instead of an empty string
for udp candidates.

BUG=chromium:1125168

Change-Id: I201e6a700ba7c4bcba45f0af6ccf809971d1df0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390659Reviewed-by: default avatarHarald Alvestrand <hta@chromium.org>
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Cr-Commit-Position: refs/heads/master@{#804670}
parent 42031375
......@@ -127,7 +127,7 @@ String RTCIceCandidate::type() const {
return platform_candidate_->Type();
}
String RTCIceCandidate::tcpType() const {
base::Optional<String> RTCIceCandidate::tcpType() const {
return platform_candidate_->TcpType();
}
......
......@@ -65,7 +65,7 @@ class MODULES_EXPORT RTCIceCandidate final : public ScriptWrappable {
String protocol() const;
base::Optional<uint16_t> port() const;
String type() const;
String tcpType() const;
base::Optional<String> tcpType() const;
String relatedAddress() const;
base::Optional<uint16_t> relatedPort() const;
String usernameFragment() const;
......
......@@ -76,7 +76,9 @@ void RTCIceCandidatePlatform::PopulateFields(bool use_username_from_candidate) {
port_ = c.address().port();
}
type_ = CandidateTypeToString(c.type());
tcp_type_ = String::FromUTF8(c.tcptype().data());
if (!c.tcptype().empty()) {
tcp_type_ = String::FromUTF8(c.tcptype().data());
}
if (!c.related_address().IsNil()) {
related_address_ =
String::FromUTF8(c.related_address().HostAsURIString().data());
......
......@@ -68,7 +68,7 @@ class PLATFORM_EXPORT RTCIceCandidatePlatform final
const String Protocol() const { return protocol_; }
const base::Optional<uint16_t>& Port() const { return port_; }
const String& Type() const { return type_; }
const String& TcpType() const { return tcp_type_; }
const base::Optional<String>& TcpType() const { return tcp_type_; }
const String& RelatedAddress() const { return related_address_; }
const base::Optional<uint16_t>& RelatedPort() const { return related_port_; }
const String& UsernameFragment() const { return username_fragment_; }
......@@ -88,7 +88,7 @@ class PLATFORM_EXPORT RTCIceCandidatePlatform final
String protocol_;
base::Optional<uint16_t> port_;
String type_;
String tcp_type_;
base::Optional<String> tcp_type_;
String related_address_;
base::Optional<uint16_t> related_port_;
String username_fragment_;
......
This is a testharness.js-based test.
PASS new RTCIceCandidate()
PASS new RTCIceCandidate({})
PASS new RTCIceCandidate({ ... }) with manually filled default values
PASS new RTCIceCandidate({ sdpMid: null, sdpMLineIndex: null })
PASS new RTCIceCandidate({ candidate: '' })
PASS new RTCIceCandidate({ candidate: null })
PASS new RTCIceCandidate({ ... }) with valid candidate string only
PASS new RTCIceCandidate({ sdpMid: 'audio' })
PASS new RTCIceCandidate({ sdpMLineIndex: 0 })
PASS new RTCIceCandidate({ sdpMid: 'audio', sdpMLineIndex: 0 })
PASS new RTCIceCandidate({ candidate: '', sdpMid: 'audio' }
PASS new RTCIceCandidate({ candidate: '', sdpMLineIndex: 0 }
PASS new RTCIceCandidate({ ... }) with valid candidate string and sdpMid
PASS new RTCIceCandidate({ ... }) with invalid candidate string and sdpMid
FAIL new RTCIceCandidate({ ... }) with nondefault values for all fields assert_equals: tcpType expected (object) null but got (string) ""
PASS new RTCIceCandidate({ ... }) with nondefault values for all fields, tcp candidate
PASS new RTCIceCandidate({ ... }) with invalid sdpMid
PASS new RTCIceCandidate({ ... }) with invalid sdpMLineIndex
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment