Destroy PC properly to stop input video before closing video writer

Bug: None
Change-Id: Ib0683ee1d2313371240ca85f4984eec5311ef695
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/207281
Reviewed-by: Andrey Logvin <landrey@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33266}
This commit is contained in:
Artem Titov
2021-02-13 01:35:44 +01:00
committed by Commit Bot
parent 9aa9b8dbbe
commit 6e35ecec1b
3 changed files with 45 additions and 7 deletions

View File

@ -670,12 +670,12 @@ void PeerConnectionE2EQualityTest::TearDownCall() {
video_source->Stop();
}
alice_->pc()->Close();
bob_->pc()->Close();
alice_video_sources_.clear();
bob_video_sources_.clear();
alice_->Close();
bob_->Close();
media_helper_ = nullptr;
}

View File

@ -21,6 +21,7 @@ namespace webrtc_pc_e2e {
bool TestPeer::AddIceCandidates(
std::vector<std::unique_ptr<IceCandidateInterface>> candidates) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
bool success = true;
for (auto& candidate : candidates) {
if (!pc()->AddIceCandidate(candidate.get())) {
@ -37,6 +38,15 @@ bool TestPeer::AddIceCandidates(
return success;
}
void TestPeer::Close() {
wrapper_->pc()->Close();
remote_ice_candidates_.clear();
audio_processing_ = nullptr;
video_sources_.clear();
wrapper_ = nullptr;
worker_thread_ = nullptr;
}
TestPeer::TestPeer(
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,
rtc::scoped_refptr<PeerConnectionInterface> pc,

View File

@ -30,63 +30,87 @@ class TestPeer final {
public:
Params* params() const { return params_.get(); }
PeerConfigurerImpl::VideoSource ReleaseVideoSource(size_t i) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return std::move(video_sources_[i]);
}
PeerConnectionFactoryInterface* pc_factory() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->pc_factory();
}
PeerConnectionInterface* pc() { return wrapper_->pc(); }
MockPeerConnectionObserver* observer() { return wrapper_->observer(); }
PeerConnectionInterface* pc() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->pc();
}
MockPeerConnectionObserver* observer() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->observer();
}
std::unique_ptr<SessionDescriptionInterface> CreateOffer() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->CreateOffer();
}
std::unique_ptr<SessionDescriptionInterface> CreateAnswer() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->CreateAnswer();
}
bool SetLocalDescription(std::unique_ptr<SessionDescriptionInterface> desc,
std::string* error_out = nullptr) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->SetLocalDescription(std::move(desc), error_out);
}
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);
}
rtc::scoped_refptr<RtpTransceiverInterface> AddTransceiver(
cricket::MediaType media_type,
const RtpTransceiverInit& init) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->AddTransceiver(media_type, init);
}
rtc::scoped_refptr<RtpSenderInterface> AddTrack(
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids = {}) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->AddTrack(track, stream_ids);
}
rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
const std::string& label) {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->CreateDataChannel(label);
}
PeerConnectionInterface::SignalingState signaling_state() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->signaling_state();
}
bool IsIceGatheringDone() { return wrapper_->IsIceGatheringDone(); }
bool IsIceGatheringDone() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->IsIceGatheringDone();
}
bool IsIceConnected() { return wrapper_->IsIceConnected(); }
bool IsIceConnected() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->IsIceConnected();
}
rtc::scoped_refptr<const RTCStatsReport> GetStats() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
return wrapper_->GetStats();
}
void DetachAecDump() {
RTC_CHECK(wrapper_) << "TestPeer is already closed";
if (audio_processing_) {
audio_processing_->DetachAecDump();
}
@ -96,6 +120,10 @@ class TestPeer final {
bool AddIceCandidates(
std::vector<std::unique_ptr<IceCandidateInterface>> candidates);
// Closes underlying peer connection and destroys all related objects freeing
// up related resources.
void Close();
protected:
friend class TestPeerFactory;
TestPeer(rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,