diff --git a/api/dtmfsenderinterface.h b/api/dtmfsenderinterface.h index ce848a7c96..217f9d206b 100644 --- a/api/dtmfsenderinterface.h +++ b/api/dtmfsenderinterface.h @@ -71,12 +71,6 @@ class DtmfSenderInterface : public rtc::RefCountInterface { int duration, int inter_tone_gap) = 0; - // Returns the track given as argument to the constructor. Only exists for - // backwards compatibilty; now that DtmfSenders are tied to RtpSenders, it's - // no longer relevant. - // TODO(bugs.webrtc.org/9426): Remove this method. - virtual const AudioTrackInterface* track() const { return nullptr; } - // Returns the tones remaining to be played out. virtual std::string tones() const = 0; diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index cb6b572420..683a5977cd 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -740,17 +740,6 @@ class PeerConnectionInterface : public rtc::RefCountInterface { return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented"); } - // Returns pointer to a DtmfSender on success. Otherwise returns null. - // - // This API is no longer part of the standard; instead DtmfSenders are - // obtained from RtpSenders. Which is what the implementation does; it finds - // an RtpSender for |track| and just returns its DtmfSender. - // TODO(bugs.webrtc.org/9426): Remove this method. - virtual rtc::scoped_refptr CreateDtmfSender( - AudioTrackInterface* track) { - return nullptr; - } - // TODO(deadbeef): Make these pure virtual once all subclasses implement them. // Creates a sender without a track. Can be used for "early media"/"warmup" diff --git a/api/peerconnectionproxy.h b/api/peerconnectionproxy.h index 1e16ecf124..ab3b735828 100644 --- a/api/peerconnectionproxy.h +++ b/api/peerconnectionproxy.h @@ -51,9 +51,6 @@ PROXY_METHOD2(RTCErrorOr>, AddTransceiver, cricket::MediaType, const RtpTransceiverInit&) -PROXY_METHOD1(rtc::scoped_refptr, - CreateDtmfSender, - AudioTrackInterface*) PROXY_METHOD2(rtc::scoped_refptr, CreateSender, const std::string&, diff --git a/pc/dtmfsender.cc b/pc/dtmfsender.cc index 64876ee80f..709612095e 100644 --- a/pc/dtmfsender.cc +++ b/pc/dtmfsender.cc @@ -62,31 +62,28 @@ bool GetDtmfCode(char tone, int* code) { } rtc::scoped_refptr DtmfSender::Create( - AudioTrackInterface* track, rtc::Thread* signaling_thread, DtmfProviderInterface* provider) { if (!signaling_thread) { return nullptr; } rtc::scoped_refptr dtmf_sender( - new rtc::RefCountedObject(track, signaling_thread, provider)); + new rtc::RefCountedObject(signaling_thread, provider)); return dtmf_sender; } -DtmfSender::DtmfSender(AudioTrackInterface* track, - rtc::Thread* signaling_thread, +DtmfSender::DtmfSender(rtc::Thread* signaling_thread, DtmfProviderInterface* provider) - : track_(track), - observer_(NULL), + : observer_(nullptr), signaling_thread_(signaling_thread), provider_(provider), duration_(kDtmfDefaultDurationMs), inter_tone_gap_(kDtmfDefaultGapMs) { - RTC_DCHECK(signaling_thread_ != NULL); + RTC_DCHECK(signaling_thread_); // TODO(deadbeef): Once we can use shared_ptr and weak_ptr, // do that instead of relying on a "destroyed" signal. if (provider_) { - RTC_DCHECK(provider_->GetOnDestroyedSignal() != NULL); + RTC_DCHECK(provider_->GetOnDestroyedSignal()); provider_->GetOnDestroyedSignal()->connect( this, &DtmfSender::OnProviderDestroyed); } @@ -101,7 +98,7 @@ void DtmfSender::RegisterObserver(DtmfSenderObserverInterface* observer) { } void DtmfSender::UnregisterObserver() { - observer_ = NULL; + observer_ = nullptr; } bool DtmfSender::CanInsertDtmf() { @@ -144,10 +141,6 @@ bool DtmfSender::InsertDtmf(const std::string& tones, return true; } -const AudioTrackInterface* DtmfSender::track() const { - return track_; -} - std::string DtmfSender::tones() const { return tones_; } @@ -232,7 +225,7 @@ void DtmfSender::DoInsertDtmf() { void DtmfSender::OnProviderDestroyed() { RTC_LOG(LS_INFO) << "The Dtmf provider is deleted. Clear the sending queue."; StopSending(); - provider_ = NULL; + provider_ = nullptr; } void DtmfSender::StopSending() { diff --git a/pc/dtmfsender.h b/pc/dtmfsender.h index f72778bac1..7b45a1f722 100644 --- a/pc/dtmfsender.h +++ b/pc/dtmfsender.h @@ -14,20 +14,16 @@ #include #include "api/dtmfsenderinterface.h" -#include "api/mediastreaminterface.h" #include "api/proxy.h" #include "rtc_base/constructormagic.h" #include "rtc_base/messagehandler.h" #include "rtc_base/refcount.h" +#include "rtc_base/thread.h" // DtmfSender is the native implementation of the RTCDTMFSender defined by // the WebRTC W3C Editor's Draft. // http://dev.w3.org/2011/webrtc/editor/webrtc.html -namespace rtc { -class Thread; -} - namespace webrtc { // This interface is called by DtmfSender to talk to the actual audio channel @@ -53,10 +49,7 @@ class DtmfSender : public DtmfSenderInterface, public sigslot::has_slots<>, public rtc::MessageHandler { public: - // |track| is only there for backwards compatibility, since there's a track - // accessor method. - static rtc::scoped_refptr Create(AudioTrackInterface* track, - rtc::Thread* signaling_thread, + static rtc::scoped_refptr Create(rtc::Thread* signaling_thread, DtmfProviderInterface* provider); // Implements DtmfSenderInterface. @@ -66,15 +59,12 @@ class DtmfSender : public DtmfSenderInterface, bool InsertDtmf(const std::string& tones, int duration, int inter_tone_gap) override; - const AudioTrackInterface* track() const override; std::string tones() const override; int duration() const override; int inter_tone_gap() const override; protected: - DtmfSender(AudioTrackInterface* track, - rtc::Thread* signaling_thread, - DtmfProviderInterface* provider); + DtmfSender(rtc::Thread* signaling_thread, DtmfProviderInterface* provider); virtual ~DtmfSender(); private: @@ -90,7 +80,6 @@ class DtmfSender : public DtmfSenderInterface, void StopSending(); - rtc::scoped_refptr track_; DtmfSenderObserverInterface* observer_; rtc::Thread* signaling_thread_; DtmfProviderInterface* provider_; @@ -108,7 +97,6 @@ PROXY_METHOD1(void, RegisterObserver, DtmfSenderObserverInterface*) PROXY_METHOD0(void, UnregisterObserver) PROXY_METHOD0(bool, CanInsertDtmf) PROXY_METHOD3(bool, InsertDtmf, const std::string&, int, int) -PROXY_CONSTMETHOD0(const AudioTrackInterface*, track) PROXY_CONSTMETHOD0(std::string, tones) PROXY_CONSTMETHOD0(int, duration) PROXY_CONSTMETHOD0(int, inter_tone_gap) diff --git a/pc/dtmfsender_unittest.cc b/pc/dtmfsender_unittest.cc index c901763911..dc8cc115b8 100644 --- a/pc/dtmfsender_unittest.cc +++ b/pc/dtmfsender_unittest.cc @@ -15,18 +15,14 @@ #include #include -#include "pc/audiotrack.h" #include "rtc_base/fakeclock.h" #include "rtc_base/gunit.h" #include "rtc_base/timeutils.h" -using webrtc::AudioTrackInterface; -using webrtc::AudioTrack; using webrtc::DtmfProviderInterface; using webrtc::DtmfSender; using webrtc::DtmfSenderObserverInterface; -static const char kTestAudioLabel[] = "test_audio_track"; // TODO(deadbeef): Even though this test now uses a fake clock, it has a // generous 3-second timeout for every test case. The timeout could be tuned // to each test based on the tones sent, instead. @@ -105,11 +101,10 @@ class FakeDtmfProvider : public DtmfProviderInterface { class DtmfSenderTest : public testing::Test { protected: DtmfSenderTest() - : track_(AudioTrack::Create(kTestAudioLabel, NULL)), - observer_(new rtc::RefCountedObject()), + : observer_(new rtc::RefCountedObject()), provider_(new FakeDtmfProvider()) { provider_->SetCanInsertDtmf(true); - dtmf_ = DtmfSender::Create(track_, rtc::Thread::Current(), provider_.get()); + dtmf_ = DtmfSender::Create(rtc::Thread::Current(), provider_.get()); dtmf_->RegisterObserver(observer_.get()); } @@ -144,11 +139,9 @@ class DtmfSenderTest : public testing::Test { } } - void VerifyExpectedState(AudioTrackInterface* track, - const std::string& tones, + void VerifyExpectedState(const std::string& tones, int duration, int inter_tone_gap) { - EXPECT_EQ(track, dtmf_->track()); EXPECT_EQ(tones, dtmf_->tones()); EXPECT_EQ(duration, dtmf_->duration()); EXPECT_EQ(inter_tone_gap, dtmf_->inter_tone_gap()); @@ -198,7 +191,6 @@ class DtmfSenderTest : public testing::Test { } } - rtc::scoped_refptr track_; std::unique_ptr observer_; std::unique_ptr provider_; rtc::scoped_refptr dtmf_; @@ -230,14 +222,14 @@ TEST_F(DtmfSenderTest, InsertDtmfTwice) { int duration = 100; int inter_tone_gap = 50; EXPECT_TRUE(dtmf_->InsertDtmf(tones1, duration, inter_tone_gap)); - VerifyExpectedState(track_, tones1, duration, inter_tone_gap); + VerifyExpectedState(tones1, duration, inter_tone_gap); // Wait until the first tone got sent. EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs, fake_clock_); - VerifyExpectedState(track_, "2", duration, inter_tone_gap); + VerifyExpectedState("2", duration, inter_tone_gap); // Insert with another tone buffer. EXPECT_TRUE(dtmf_->InsertDtmf(tones2, duration, inter_tone_gap)); - VerifyExpectedState(track_, tones2, duration, inter_tone_gap); + VerifyExpectedState(tones2, duration, inter_tone_gap); // Wait until it's completed. EXPECT_TRUE_SIMULATED_WAIT(observer_->completed(), kMaxWaitMs, fake_clock_); @@ -334,9 +326,9 @@ TEST_F(DtmfSenderTest, InsertDtmfSendsAfterWait) { int duration = 100; int inter_tone_gap = 50; EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap)); - VerifyExpectedState(track_, "ABC", duration, inter_tone_gap); + VerifyExpectedState("ABC", duration, inter_tone_gap); // Wait until the first tone got sent. EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs, fake_clock_); - VerifyExpectedState(track_, "BC", duration, inter_tone_gap); + VerifyExpectedState("BC", duration, inter_tone_gap); } diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index d99e97f2c9..5526d7266a 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -1471,25 +1471,6 @@ void PeerConnection::OnNegotiationNeeded() { observer_->OnRenegotiationNeeded(); } -rtc::scoped_refptr PeerConnection::CreateDtmfSender( - AudioTrackInterface* track) { - TRACE_EVENT0("webrtc", "PeerConnection::CreateDtmfSender"); - if (IsClosed()) { - return nullptr; - } - if (!track) { - RTC_LOG(LS_ERROR) << "CreateDtmfSender - track is NULL."; - return nullptr; - } - auto track_sender = FindSenderForTrack(track); - if (!track_sender) { - RTC_LOG(LS_ERROR) << "CreateDtmfSender called with a non-added track."; - return nullptr; - } - - return track_sender->GetDtmfSender(); -} - rtc::scoped_refptr PeerConnection::CreateSender( const std::string& kind, const std::string& stream_id) { diff --git a/pc/peerconnection.h b/pc/peerconnection.h index 41137464a6..0e8b71d449 100644 --- a/pc/peerconnection.h +++ b/pc/peerconnection.h @@ -113,9 +113,6 @@ class PeerConnection : public PeerConnectionInternal, // Version of the above method that returns the full certificate chain. std::unique_ptr GetRemoteAudioSSLCertChain(); - rtc::scoped_refptr CreateDtmfSender( - AudioTrackInterface* track) override; - rtc::scoped_refptr CreateSender( const std::string& kind, const std::string& stream_id) override; diff --git a/pc/peerconnectioninterface_unittest.cc b/pc/peerconnectioninterface_unittest.cc index 938e5b2dec..26cf6a5303 100644 --- a/pc/peerconnectioninterface_unittest.cc +++ b/pc/peerconnectioninterface_unittest.cc @@ -1861,18 +1861,6 @@ TEST_F(PeerConnectionInterfaceTestPlanB, RemoveTrackAfterAddStream) { EXPECT_TRUE(video_desc == nullptr); } -// Verify that CreateDtmfSender only succeeds if called with a valid local -// track. Other aspects of DtmfSenders are tested in -// peerconnection_integrationtest.cc. -TEST_P(PeerConnectionInterfaceTest, CreateDtmfSenderWithInvalidParams) { - CreatePeerConnection(); - AddAudioTrack(kAudioTracks[0]); - EXPECT_EQ(nullptr, pc_->CreateDtmfSender(nullptr)); - rtc::scoped_refptr non_localtrack( - pc_factory_->CreateAudioTrack("dummy_track", nullptr)); - EXPECT_EQ(nullptr, pc_->CreateDtmfSender(non_localtrack)); -} - // Test creating a sender with a stream ID, and ensure the ID is populated // in the offer. // Don't run under Unified Plan since the stream API is not available. @@ -2728,11 +2716,6 @@ TEST_F(PeerConnectionInterfaceTestPlanB, CloseAndTestMethods) { pc_->RemoveStream(local_stream); EXPECT_FALSE(pc_->AddStream(local_stream)); - ASSERT_FALSE(local_stream->GetAudioTracks().empty()); - rtc::scoped_refptr dtmf_sender( - pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0])); - EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed. - EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL); EXPECT_TRUE(pc_->local_description() != NULL); diff --git a/pc/rtpsender.cc b/pc/rtpsender.cc index e8105a835c..f3bf970fa9 100644 --- a/pc/rtpsender.cc +++ b/pc/rtpsender.cc @@ -129,7 +129,7 @@ AudioRtpSender::AudioRtpSender(rtc::Thread* worker_thread, track_(track), dtmf_sender_proxy_(DtmfSenderProxy::Create( rtc::Thread::Current(), - DtmfSender::Create(track_, rtc::Thread::Current(), this))), + DtmfSender::Create(rtc::Thread::Current(), this))), cached_track_enabled_(track ? track->enabled() : false), sink_adapter_(new LocalAudioSinkAdapter()), attachment_id_(track ? GenerateUniqueId() : 0) { diff --git a/pc/test/fakepeerconnectionbase.h b/pc/test/fakepeerconnectionbase.h index d6b61188b9..3db2d4b8e0 100644 --- a/pc/test/fakepeerconnectionbase.h +++ b/pc/test/fakepeerconnectionbase.h @@ -77,11 +77,6 @@ class FakePeerConnectionBase : public PeerConnectionInternal { return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented"); } - rtc::scoped_refptr CreateDtmfSender( - AudioTrackInterface* track) override { - return nullptr; - } - rtc::scoped_refptr CreateSender( const std::string& kind, const std::string& stream_id) override {