Enable the use of CreateDataChannel with a DataChannelInit config.

Change-Id: Ie9b783464c7b4f6c2d5624a96221f266531acbe9
Bug: b/267359410
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/292861
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#39293}
This commit is contained in:
Jeremy Leconte 2023-02-10 09:26:50 +01:00 committed by WebRTC LUCI CQ
parent 05873dcaa6
commit eccd93e892
5 changed files with 15 additions and 5 deletions

View File

@ -2269,6 +2269,7 @@ if (rtc_include_tests && !build_with_chromium) {
"../rtc_base:logging",
"../test:test_support",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
rtc_test("slow_peer_connection_unittests") {

View File

@ -15,6 +15,7 @@
#include <utility>
#include <vector>
#include "absl/types/optional.h"
#include "api/function_view.h"
#include "api/set_remote_description_observer_interface.h"
#include "pc/sdp_utils.h"
@ -312,8 +313,11 @@ rtc::scoped_refptr<RtpSenderInterface> PeerConnectionWrapper::AddVideoTrack(
}
rtc::scoped_refptr<DataChannelInterface>
PeerConnectionWrapper::CreateDataChannel(const std::string& label) {
auto result = pc()->CreateDataChannelOrError(label, nullptr);
PeerConnectionWrapper::CreateDataChannel(
const std::string& label,
const absl::optional<DataChannelInit>& config) {
const DataChannelInit* config_ptr = config.has_value() ? &(*config) : nullptr;
auto result = pc()->CreateDataChannelOrError(label, config_ptr);
if (!result.ok()) {
RTC_LOG(LS_ERROR) << "CreateDataChannel failed: "
<< ToString(result.error().type()) << " "

View File

@ -15,6 +15,7 @@
#include <string>
#include <vector>
#include "absl/types/optional.h"
#include "api/data_channel_interface.h"
#include "api/function_view.h"
#include "api/jsep.h"
@ -169,7 +170,8 @@ class PeerConnectionWrapper {
// Calls the underlying PeerConnection's CreateDataChannel method with default
// initialization parameters.
rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
const std::string& label);
const std::string& label,
const absl::optional<DataChannelInit>& config = absl::nullopt);
// Returns the signaling state of the underlying PeerConnection.
PeerConnectionInterface::SignalingState signaling_state();

View File

@ -80,6 +80,7 @@ if (!build_with_chromium) {
absl_deps = [
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
"//third_party/abseil-cpp/absl/types:variant",
]
}

View File

@ -16,6 +16,7 @@
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/function_view.h"
#include "api/scoped_refptr.h"
#include "api/sequence_checker.h"
@ -109,9 +110,10 @@ class TestPeer final : public StatsProvider {
}
rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
const std::string& label) {
const std::string& label,
const absl::optional<DataChannelInit>& config = absl::nullopt) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->CreateDataChannel(label);
return wrapper_->CreateDataChannel(label, config);
}
PeerConnectionInterface::SignalingState signaling_state() {