New class FakePeriodicVideoTrackSource, simplifying shutdown logic.
Previous code had a FakePeriodicVideoSource and a
VideoTrackSource, where the latter is reference counted and
outlives the former. That results in potential races when
RemoveSink is called on the VideoTrackSource after the
FakePeriodicVideoSource is destroyed, with a complicated sequence
to do correct shutdown.
The new class, FakePeriodicVideoTrackSource, owns a
FakePeriodicVideoSource, and they get the same lifetime.
Bug: webrtc:6353
Change-Id: Ic33b393e00a31fa28893dce2018948d3f90e0a9e
Reviewed-on: https://webrtc-review.googlesource.com/76961
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23320}
diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc
index e697e3a..28b7d16 100644
--- a/pc/peerconnection_integrationtest.cc
+++ b/pc/peerconnection_integrationtest.cc
@@ -48,7 +48,7 @@
#include "pc/rtpmediautils.h"
#include "pc/sessiondescription.h"
#include "pc/test/fakeaudiocapturemodule.h"
-#include "pc/test/fakeperiodicvideosource.h"
+#include "pc/test/fakeperiodicvideotracksource.h"
#include "pc/test/fakertccertificategenerator.h"
#include "pc/test/fakevideotrackrenderer.h"
#include "pc/test/mockpeerconnectionobservers.h"
@@ -238,20 +238,6 @@
return client;
}
- ~PeerConnectionWrapper() {
- // Tear down video sources in the proper order.
- for (const auto& video_source : fake_video_sources_) {
- // No more calls to downstream OnFrame
- video_source->Stop();
- }
- for (const auto& track_source : video_track_sources_) {
- // No more calls to upstream AddOrUpdateSink
- track_source->OnSourceDestroyed();
- }
- fake_video_sources_.clear();
- video_track_sources_.clear();
- }
-
webrtc::PeerConnectionFactoryInterface* pc_factory() const {
return peer_connection_factory_.get();
}
@@ -655,12 +641,9 @@
// TODO(deadbeef): Do something more robust.
config.frame_interval_ms = 100;
- fake_video_sources_.emplace_back(
- rtc::MakeUnique<webrtc::FakePeriodicVideoSource>(config));
-
video_track_sources_.emplace_back(
- new rtc::RefCountedObject<webrtc::VideoTrackSource>(
- fake_video_sources_.back().get(), false /* remote */));
+ new rtc::RefCountedObject<webrtc::FakePeriodicVideoTrackSource>(
+ config, false /* remote */));
rtc::scoped_refptr<webrtc::VideoTrackInterface> track(
peer_connection_factory_->CreateVideoTrack(
rtc::CreateRandomUuid(), video_track_sources_.back()));
@@ -940,8 +923,6 @@
// Store references to the video sources we've created, so that we can stop
// them, if required.
- std::vector<std::unique_ptr<webrtc::FakePeriodicVideoSource>>
- fake_video_sources_;
std::vector<rtc::scoped_refptr<webrtc::VideoTrackSource>>
video_track_sources_;
// |local_video_renderer_| attached to the first created local video track.