Introduce CreateDataChannelOrError
Deprecate CreateDataChannel, and make it a simple wrapper function.
Bug: webrtc:12796
Change-Id: I053d75a264596ba87ca734a29df9241de93a80c3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219784
Reviewed-by: Xavier Lepaul <xalep@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34130}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index e2b3b61..0939f59 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -1279,9 +1279,9 @@
"trickle");
}
-rtc::scoped_refptr<DataChannelInterface> PeerConnection::CreateDataChannel(
- const std::string& label,
- const DataChannelInit* config) {
+RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>
+PeerConnection::CreateDataChannelOrError(const std::string& label,
+ const DataChannelInit* config) {
RTC_DCHECK_RUN_ON(signaling_thread());
TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel");
@@ -1291,11 +1291,13 @@
if (config) {
internal_config.reset(new InternalDataChannelInit(*config));
}
+ // TODO(bugs.webrtc.org/12796): Return a more specific error.
rtc::scoped_refptr<DataChannelInterface> channel(
data_channel_controller_.InternalCreateDataChannelWithProxy(
label, internal_config.get()));
if (!channel.get()) {
- return nullptr;
+ return RTCError(RTCErrorType::INTERNAL_ERROR,
+ "Data channel creation failed");
}
// Trigger the onRenegotiationNeeded event for