Make PeerConnection::StartSctpTransport return an RTCError
follow-up to https://webrtc-review.googlesource.com/c/src/+/380580
which changes the signature to return an RTCError.
BUG=webrtc:402429107
Change-Id: Ie437db74f9f7908c7b2398a72f0ecb0f6bf67c8a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/381320
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Cr-Commit-Position: refs/heads/main@{#44149}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index 9f11940..9518170 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -2942,10 +2942,9 @@
return observer_;
}
-void PeerConnection::StartSctpTransport(const SctpOptions& options) {
+RTCError PeerConnection::StartSctpTransport(const SctpOptions& options) {
RTC_DCHECK_RUN_ON(signaling_thread());
- if (!sctp_mid_s_)
- return;
+ RTC_DCHECK(sctp_mid_s_);
network_thread()->PostTask(
SafeTask(network_thread_safety_, [this, mid = *sctp_mid_s_, options] {
@@ -2954,6 +2953,7 @@
if (sctp_transport)
sctp_transport->Start(options);
}));
+ return RTCError::OK();
}
CryptoOptions PeerConnection::GetCryptoOptions() {
diff --git a/pc/peer_connection.h b/pc/peer_connection.h
index 39d7b2c..2f1f0bf 100644
--- a/pc/peer_connection.h
+++ b/pc/peer_connection.h
@@ -412,7 +412,7 @@
// Asynchronously calls SctpTransport::Start() on the network thread for
// `sctp_mid()` if set. Called as part of setting the local description.
- void StartSctpTransport(const SctpOptions& options) override;
+ RTCError StartSctpTransport(const SctpOptions& options) override;
// Returns the CryptoOptions for this PeerConnection. This will always
// return the RTCConfiguration.crypto_options if set and will only default
diff --git a/pc/peer_connection_internal.h b/pc/peer_connection_internal.h
index ce69fbd..1f9e8a2 100644
--- a/pc/peer_connection_internal.h
+++ b/pc/peer_connection_internal.h
@@ -125,14 +125,14 @@
bool fire_callback = true) = 0;
// Asynchronously calls SctpTransport::Start() on the network thread for
// `sctp_mid()` if set. Called as part of setting the local description.
- virtual void StartSctpTransport(const SctpOptions& options) = 0;
+ virtual RTCError StartSctpTransport(const SctpOptions& options) = 0;
[[deprecated("Call with SctpOptions")]]
virtual void StartSctpTransport(int local_port,
int remote_port,
int max_message_size) {
- return StartSctpTransport({.local_port = local_port,
- .remote_port = remote_port,
- .max_message_size = max_message_size});
+ StartSctpTransport({.local_port = local_port,
+ .remote_port = remote_port,
+ .max_message_size = max_message_size});
}
// Asynchronously adds a remote candidate on the network thread.
diff --git a/pc/test/fake_peer_connection_base.h b/pc/test/fake_peer_connection_base.h
index 0138dca..5fcc894 100644
--- a/pc/test/fake_peer_connection_base.h
+++ b/pc/test/fake_peer_connection_base.h
@@ -389,7 +389,9 @@
bool fire_callback = true) override {
return RTCError(RTCErrorType::INTERNAL_ERROR, "");
}
- void StartSctpTransport(const SctpOptions& options) override {}
+ RTCError StartSctpTransport(const SctpOptions& options) override {
+ return RTCError::OK();
+ }
void AddRemoteCandidate(absl::string_view mid,
const cricket::Candidate& candidate) override {}
diff --git a/pc/test/mock_peer_connection_internal.h b/pc/test/mock_peer_connection_internal.h
index 25d9d82..3fcea19 100644
--- a/pc/test/mock_peer_connection_internal.h
+++ b/pc/test/mock_peer_connection_internal.h
@@ -309,7 +309,7 @@
const RtpTransceiverInit&,
bool),
(override));
- MOCK_METHOD(void, StartSctpTransport, (const SctpOptions&), (override));
+ MOCK_METHOD(RTCError, StartSctpTransport, (const SctpOptions&), (override));
MOCK_METHOD(void,
AddRemoteCandidate,
(absl::string_view, const cricket::Candidate&),