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}
This commit is contained in:
Harald Alvestrand
2021-05-21 13:33:51 +00:00
committed by WebRTC LUCI CQ
parent 0d0ed76ac1
commit a9af50f151
12 changed files with 60 additions and 27 deletions

View File

@ -920,9 +920,24 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
// Also, calling CreateDataChannel is the only way to get a data "m=" section
// in SDP, so it should be done before CreateOffer is called, if the
// application plans to use data channels.
virtual RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>
CreateDataChannelOrError(const std::string& label,
const DataChannelInit* config) {
return RTCError(RTCErrorType::INTERNAL_ERROR, "dummy function called");
}
// TODO(crbug.com/788659): Remove "virtual" below and default implementation
// above once mock in Chrome is fixed.
ABSL_DEPRECATED("Use CreateDataChannelOrError")
virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
const std::string& label,
const DataChannelInit* config) = 0;
const DataChannelInit* config) {
auto result = CreateDataChannelOrError(label, config);
if (!result.ok()) {
return nullptr;
} else {
return result.MoveValue();
}
}
// NOTE: For the following 6 methods, it's only safe to dereference the
// SessionDescriptionInterface on signaling_thread() (for example, calling