[PCLF] Continue to migrate out from PeerConnectionWrapper

Pair: mbonadei@webrtc.org
Bug: b/213863770
Change-Id: Ibdbd3c4b1b449660bc2677775108d690da7fa848
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257040
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36369}
This commit is contained in:
Artem Titov
2022-03-29 14:26:36 +02:00
committed by WebRTC LUCI CQ
parent b7c15706de
commit 17481fd031
3 changed files with 60 additions and 5 deletions

View File

@ -226,10 +226,15 @@ if (!build_with_chromium) {
":peer_configurer",
":peer_connection_quality_test_params",
"../../../api:frame_generator_api",
"../../../api:function_view",
"../../../api:libjingle_peerconnection_api",
"../../../api:peer_connection_quality_test_fixture_api",
"../../../api:scoped_refptr",
"../../../api:sequence_checker",
"../../../modules/audio_processing:api",
"../../../pc:peerconnection_wrapper",
"../../../rtc_base:logging",
"../../../rtc_base:refcount",
]
absl_deps = [
"//third_party/abseil-cpp/absl/memory",

View File

@ -18,6 +18,45 @@
namespace webrtc {
namespace webrtc_pc_e2e {
namespace {
class SetRemoteDescriptionCallback
: public webrtc::SetRemoteDescriptionObserverInterface {
public:
void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override {
is_called_ = true;
error_ = error;
}
bool is_called() const { return is_called_; }
webrtc::RTCError error() const { return error_; }
private:
bool is_called_ = false;
webrtc::RTCError error_;
};
} // namespace
bool TestPeer::SetRemoteDescription(
std::unique_ptr<SessionDescriptionInterface> desc,
std::string* error_out) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
auto observer = rtc::make_ref_counted<SetRemoteDescriptionCallback>();
// We're assuming (and asserting) that the PeerConnection implementation of
// SetRemoteDescription is synchronous when called on the signaling thread.
pc()->SetRemoteDescription(std::move(desc), observer);
RTC_CHECK(observer->is_called());
if (!observer->error().ok()) {
RTC_LOG(LS_ERROR) << *params_->name
<< ": Failed to set remote description: "
<< observer->error().message();
*error_out = observer->error().message();
}
return observer->error().ok();
}
bool TestPeer::AddIceCandidates(
std::vector<std::unique_ptr<IceCandidateInterface>> candidates) {

View File

@ -15,10 +15,15 @@
#include <vector>
#include "absl/memory/memory.h"
#include "absl/types/variant.h"
#include "api/function_view.h"
#include "api/scoped_refptr.h"
#include "api/sequence_checker.h"
#include "api/set_remote_description_observer_interface.h"
#include "api/test/frame_generator_interface.h"
#include "api/test/peerconnection_quality_test_fixture.h"
#include "pc/peer_connection_wrapper.h"
#include "rtc_base/logging.h"
#include "rtc_base/ref_counted_object.h"
#include "test/pc/e2e/peer_configurer.h"
#include "test/pc/e2e/peer_connection_quality_test_params.h"
@ -47,6 +52,14 @@ class TestPeer final {
return wrapper_->observer();
}
// Tell underlying `PeerConnection` to create an Offer.
// `observer` will be invoked on the signaling thread when offer is created.
void CreateOffer(
rtc::scoped_refptr<CreateSessionDescriptionObserver> observer) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
pc()->CreateOffer(observer.release(),
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
}
std::unique_ptr<SessionDescriptionInterface> CreateOffer() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->CreateOffer();
@ -63,11 +76,9 @@ class TestPeer final {
return wrapper_->SetLocalDescription(std::move(desc), error_out);
}
// `error_out` will be set only if returned value is false.
bool SetRemoteDescription(std::unique_ptr<SessionDescriptionInterface> desc,
std::string* error_out = nullptr) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->SetRemoteDescription(std::move(desc), error_out);
}
std::string* error_out = nullptr);
rtc::scoped_refptr<RtpTransceiverInterface> AddTransceiver(
cricket::MediaType media_type,