diff --git a/api/peer_connection_interface.cc b/api/peer_connection_interface.cc index 78e3fc06fb..0c25405784 100644 --- a/api/peer_connection_interface.cc +++ b/api/peer_connection_interface.cc @@ -42,103 +42,17 @@ PeerConnectionInterface::RTCConfiguration::RTCConfiguration( PeerConnectionInterface::RTCConfiguration::~RTCConfiguration() = default; -RTCErrorOr> -PeerConnectionInterface::AddTrack( - rtc::scoped_refptr track, - const std::vector& stream_ids) { - return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented"); -} - -bool PeerConnectionInterface::RemoveTrack(RtpSenderInterface* sender) { - return RemoveTrackNew(sender).ok(); -} - RTCError PeerConnectionInterface::RemoveTrackNew( rtc::scoped_refptr sender) { return RTCError(RemoveTrack(sender) ? RTCErrorType::NONE : RTCErrorType::INTERNAL_ERROR); } -RTCErrorOr> -PeerConnectionInterface::AddTransceiver( - rtc::scoped_refptr track) { - return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented"); -} - -RTCErrorOr> -PeerConnectionInterface::AddTransceiver( - rtc::scoped_refptr track, - const RtpTransceiverInit& init) { - return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented"); -} - -RTCErrorOr> -PeerConnectionInterface::AddTransceiver(cricket::MediaType media_type) { - return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented"); -} - -RTCErrorOr> -PeerConnectionInterface::AddTransceiver(cricket::MediaType media_type, - const RtpTransceiverInit& init) { - return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented"); -} - -rtc::scoped_refptr PeerConnectionInterface::CreateSender( - const std::string& kind, - const std::string& stream_id) { - return rtc::scoped_refptr(); -} - -std::vector> -PeerConnectionInterface::GetSenders() const { - return std::vector>(); -} - -std::vector> -PeerConnectionInterface::GetReceivers() const { - return std::vector>(); -} - -std::vector> -PeerConnectionInterface::GetTransceivers() const { - return std::vector>(); -} - -const SessionDescriptionInterface* -PeerConnectionInterface::current_local_description() const { - return nullptr; -} - -const SessionDescriptionInterface* -PeerConnectionInterface::current_remote_description() const { - return nullptr; -} - -const SessionDescriptionInterface* -PeerConnectionInterface::pending_local_description() const { - return nullptr; -} - -const SessionDescriptionInterface* -PeerConnectionInterface::pending_remote_description() const { - return nullptr; -} - -PeerConnectionInterface::RTCConfiguration -PeerConnectionInterface::GetConfiguration() { - return PeerConnectionInterface::RTCConfiguration(); -} - RTCError PeerConnectionInterface::SetConfiguration( const PeerConnectionInterface::RTCConfiguration& config) { return RTCError(); } -bool PeerConnectionInterface::RemoveIceCandidates( - const std::vector& candidates) { - return false; -} - RTCError PeerConnectionInterface::SetBitrate(const BitrateSettings& bitrate) { BitrateParameters bitrate_parameters; bitrate_parameters.min_bitrate_bps = bitrate.min_bitrate_bps; @@ -156,39 +70,6 @@ RTCError PeerConnectionInterface::SetBitrate( return SetBitrate(bitrate); } -PeerConnectionInterface::IceConnectionState -PeerConnectionInterface::standardized_ice_connection_state() { - return PeerConnectionInterface::IceConnectionState::kIceConnectionFailed; -} - -PeerConnectionInterface::PeerConnectionState -PeerConnectionInterface::peer_connection_state() { - return PeerConnectionInterface::PeerConnectionState::kFailed; -} - -bool PeerConnectionInterface::StartRtcEventLog( - std::unique_ptr output, - int64_t output_period_ms) { - return false; -} - -bool PeerConnectionInterface::StartRtcEventLog( - std::unique_ptr output) { - return false; -} - -rtc::scoped_refptr -PeerConnectionInterface::LookupDtlsTransportByMid(const std::string& mid) { - RTC_NOTREACHED(); - return nullptr; -} - -rtc::scoped_refptr -PeerConnectionInterface::GetSctpTransport() const { - RTC_NOTREACHED(); - return nullptr; -} - PeerConnectionInterface::BitrateParameters::BitrateParameters() = default; PeerConnectionInterface::BitrateParameters::~BitrateParameters() = default; diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h index 4c6f6a12ec..82f687c755 100644 --- a/api/peer_connection_interface.h +++ b/api/peer_connection_interface.h @@ -760,12 +760,12 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // - INVALID_STATE: The PeerConnection is closed. virtual RTCErrorOr> AddTrack( rtc::scoped_refptr track, - const std::vector& stream_ids); + const std::vector& stream_ids) = 0; // Remove an RtpSender from this PeerConnection. // Returns true on success. // TODO(steveanton): Replace with signature that returns RTCError. - virtual bool RemoveTrack(RtpSenderInterface* sender); + virtual bool RemoveTrack(RtpSenderInterface* sender) = 0; // Plan B semantics: Removes the RtpSender from this PeerConnection. // Unified Plan semantics: Stop sending on the RtpSender and mark the @@ -798,8 +798,6 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // // Common errors: // - INTERNAL_ERROR: The configuration does not have Unified Plan enabled. - // TODO(steveanton): Make these pure virtual once downstream projects have - // updated. // Adds a transceiver with a sender set to transmit the given track. The kind // of the transceiver (and sender/receiver) will be derived from the kind of @@ -807,10 +805,10 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // Errors: // - INVALID_PARAMETER: |track| is null. virtual RTCErrorOr> - AddTransceiver(rtc::scoped_refptr track); + AddTransceiver(rtc::scoped_refptr track) = 0; virtual RTCErrorOr> AddTransceiver(rtc::scoped_refptr track, - const RtpTransceiverInit& init); + const RtpTransceiverInit& init) = 0; // Adds a transceiver with the given kind. Can either be MEDIA_TYPE_AUDIO or // MEDIA_TYPE_VIDEO. @@ -818,11 +816,10 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // - INVALID_PARAMETER: |media_type| is not MEDIA_TYPE_AUDIO or // MEDIA_TYPE_VIDEO. virtual RTCErrorOr> - AddTransceiver(cricket::MediaType media_type); + AddTransceiver(cricket::MediaType media_type) = 0; virtual RTCErrorOr> - AddTransceiver(cricket::MediaType media_type, const RtpTransceiverInit& init); - - // TODO(deadbeef): Make these pure virtual once all subclasses implement them. + AddTransceiver(cricket::MediaType media_type, + const RtpTransceiverInit& init) = 0; // Creates a sender without a track. Can be used for "early media"/"warmup" // use cases, where the application may want to negotiate video attributes @@ -840,7 +837,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // AddTransceiver instead. virtual rtc::scoped_refptr CreateSender( const std::string& kind, - const std::string& stream_id); + const std::string& stream_id) = 0; // If Plan B semantics are specified, gets all RtpSenders, created either // through AddStream, AddTrack, or CreateSender. All senders of a specific @@ -849,7 +846,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // If Unified Plan semantics are specified, gets the RtpSender for each // RtpTransceiver. virtual std::vector> GetSenders() - const; + const = 0; // If Plan B semantics are specified, gets all RtpReceivers created when a // remote description is applied. All receivers of a specific media type share @@ -860,7 +857,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // If Unified Plan semantics are specified, gets the RtpReceiver for each // RtpTransceiver. virtual std::vector> GetReceivers() - const; + const = 0; // Get all RtpTransceivers, created either through AddTransceiver, AddTrack or // by a remote description applied with SetRemoteDescription. @@ -868,7 +865,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // Note: This method is only available when Unified Plan is enabled (see // RTCConfiguration). virtual std::vector> - GetTransceivers() const; + GetTransceivers() const = 0; // The legacy non-compliant GetStats() API. This correspond to the // callback-based version of getStats() in JavaScript. The returned metrics @@ -897,19 +894,17 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // requires stop overriding the current version in third party or making third // party calls explicit to avoid ambiguity during switch. Make the future // version abstract as soon as third party projects implement it. - virtual void GetStats(RTCStatsCollectorCallback* callback) {} + virtual void GetStats(RTCStatsCollectorCallback* callback) = 0; // Spec-compliant getStats() performing the stats selection algorithm with the // sender. https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-getstats - // TODO(hbos): Make abstract as soon as third party projects implement it. virtual void GetStats( rtc::scoped_refptr selector, - rtc::scoped_refptr callback) {} + rtc::scoped_refptr callback) = 0; // Spec-compliant getStats() performing the stats selection algorithm with the // receiver. https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-getstats - // TODO(hbos): Make abstract as soon as third party projects implement it. virtual void GetStats( rtc::scoped_refptr selector, - rtc::scoped_refptr callback) {} + rtc::scoped_refptr callback) = 0; // Clear cached stats in the RTCStatsCollector. // Exposed for testing while waiting for automatic cache clear to work. // https://bugs.webrtc.org/8693 @@ -933,14 +928,18 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // A "current" description the one currently negotiated from a complete // offer/answer exchange. - virtual const SessionDescriptionInterface* current_local_description() const; - virtual const SessionDescriptionInterface* current_remote_description() const; + virtual const SessionDescriptionInterface* current_local_description() + const = 0; + virtual const SessionDescriptionInterface* current_remote_description() + const = 0; // A "pending" description is one that's part of an incomplete offer/answer // exchange (thus, either an offer or a pranswer). Once the offer/answer // exchange is finished, the "pending" description will become "current". - virtual const SessionDescriptionInterface* pending_local_description() const; - virtual const SessionDescriptionInterface* pending_remote_description() const; + virtual const SessionDescriptionInterface* pending_local_description() + const = 0; + virtual const SessionDescriptionInterface* pending_remote_description() + const = 0; // Tells the PeerConnection that ICE should be restarted. This triggers a need // for negotiation and subsequent CreateOffer() calls will act as if @@ -948,7 +947,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-restartice // TODO(hbos): Remove default implementation when downstream projects // implement this. - virtual void RestartIce() {} + virtual void RestartIce() = 0; // Create a new offer. // The CreateSessionDescriptionObserver callback will be called when done. @@ -973,14 +972,11 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // TODO(hbos): Remove when Chrome implements the new signature. virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer, SessionDescriptionInterface* desc) {} - // TODO(hbos): Make pure virtual when Chrome has updated its signature. virtual void SetRemoteDescription( std::unique_ptr desc, - rtc::scoped_refptr observer) {} + rtc::scoped_refptr observer) = 0; - // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of - // PeerConnectionInterface implement it. - virtual PeerConnectionInterface::RTCConfiguration GetConfiguration(); + virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() = 0; // Sets the PeerConnection's global configuration to |config|. // @@ -1018,7 +1014,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // continual gathering, to avoid an ever-growing list of candidates as // networks come and go. virtual bool RemoveIceCandidates( - const std::vector& candidates); + const std::vector& candidates) = 0; // 0 <= min <= current <= max should hold for set parameters. struct BitrateParameters { @@ -1062,13 +1058,12 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // In the Javascript API, DtlsTransport is a property of a sender, but // because the PeerConnection owns the DtlsTransport in this implementation, // it is better to look them up on the PeerConnection. - // TODO(hta): Remove default implementation after updating Chrome. virtual rtc::scoped_refptr LookupDtlsTransportByMid( - const std::string& mid); + const std::string& mid) = 0; // Returns the SCTP transport, if any. - // TODO(hta): Remove default implementation after updating Chrome. - virtual rtc::scoped_refptr GetSctpTransport() const; + virtual rtc::scoped_refptr GetSctpTransport() + const = 0; // Returns the current SignalingState. virtual SignalingState signaling_state() = 0; @@ -1080,10 +1075,10 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { virtual IceConnectionState ice_connection_state() = 0; // Returns an aggregated state of all ICE transports. - virtual IceConnectionState standardized_ice_connection_state(); + virtual IceConnectionState standardized_ice_connection_state() = 0; // Returns an aggregated state of all ICE and DTLS transports. - virtual PeerConnectionState peer_connection_state(); + virtual PeerConnectionState peer_connection_state() = 0; virtual IceGatheringState ice_gathering_state() = 0; @@ -1097,12 +1092,11 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { // lost in case the application crashes. If the |output_period_ms| argument is // omitted, webrtc selects a default deemed to be workable in most cases. virtual bool StartRtcEventLog(std::unique_ptr output, - int64_t output_period_ms); - virtual bool StartRtcEventLog(std::unique_ptr output); + int64_t output_period_ms) = 0; + virtual bool StartRtcEventLog(std::unique_ptr output) = 0; // Stops logging the RtcEventLog. - // TODO(ivoc): Make this pure virtual when Chrome is updat ed. - virtual void StopRtcEventLog() {} + virtual void StopRtcEventLog() = 0; // Terminates all media, closes the transports, and in general releases any // resources used by the PeerConnection. This is an irreversible operation. diff --git a/api/peer_connection_proxy.h b/api/peer_connection_proxy.h index e88190647e..551af4823e 100644 --- a/api/peer_connection_proxy.h +++ b/api/peer_connection_proxy.h @@ -72,6 +72,7 @@ PROXY_METHOD2(void, GetStats, rtc::scoped_refptr, rtc::scoped_refptr) +PROXY_METHOD0(void, ClearStatsCache) PROXY_METHOD2(rtc::scoped_refptr, CreateDataChannel, const std::string&, diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h index 80a5baa474..aacaaf6cab 100644 --- a/api/test/mock_peerconnectioninterface.h +++ b/api/test/mock_peerconnectioninterface.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -39,6 +40,8 @@ class MockPeerConnectionInterface MediaStreamTrackInterface*, std::vector)); MOCK_METHOD1(RemoveTrack, bool(RtpSenderInterface*)); + MOCK_METHOD1(RemoveTrackNew, + RTCError(rtc::scoped_refptr)); MOCK_METHOD1(AddTransceiver, RTCErrorOr>( rtc::scoped_refptr)); @@ -91,6 +94,7 @@ class MockPeerConnectionInterface const SessionDescriptionInterface*()); MOCK_CONST_METHOD0(pending_remote_description, const SessionDescriptionInterface*()); + MOCK_METHOD0(RestartIce, void()); MOCK_METHOD2(CreateOffer, void(CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&)); @@ -116,15 +120,22 @@ class MockPeerConnectionInterface MOCK_METHOD1(SetBitrate, RTCError(const BitrateParameters&)); MOCK_METHOD1(SetAudioPlayout, void(bool)); MOCK_METHOD1(SetAudioRecording, void(bool)); + MOCK_METHOD1(LookupDtlsTransportByMid, + rtc::scoped_refptr(const std::string&)); MOCK_METHOD0(signaling_state, SignalingState()); MOCK_METHOD0(ice_connection_state, IceConnectionState()); + MOCK_METHOD0(standardized_ice_connection_state, IceConnectionState()); + MOCK_METHOD0(peer_connection_state, PeerConnectionState()); MOCK_METHOD0(ice_gathering_state, IceGatheringState()); MOCK_METHOD2(StartRtcEventLog, bool(std::unique_ptr, int64_t)); + MOCK_METHOD1(StartRtcEventLog, bool(std::unique_ptr)); MOCK_METHOD0(StopRtcEventLog, void()); MOCK_METHOD0(Close, void()); }; +static_assert(!std::is_abstract::value, ""); + } // namespace webrtc #endif // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_ diff --git a/pc/test/fake_peer_connection_base.h b/pc/test/fake_peer_connection_base.h index 1f0e924298..9f82c0a1b3 100644 --- a/pc/test/fake_peer_connection_base.h +++ b/pc/test/fake_peer_connection_base.h @@ -52,6 +52,11 @@ class FakePeerConnectionBase : public PeerConnectionInternal { bool RemoveTrack(RtpSenderInterface* sender) override { return false; } + RTCError RemoveTrackNew( + rtc::scoped_refptr sender) override { + return RTCError(RTCErrorType::UNSUPPORTED_OPERATION); + } + RTCErrorOr> AddTransceiver( rtc::scoped_refptr track) override { return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented"); @@ -200,6 +205,14 @@ class FakePeerConnectionBase : public PeerConnectionInternal { return IceConnectionState::kIceConnectionNew; } + IceConnectionState standardized_ice_connection_state() override { + return IceConnectionState::kIceConnectionNew; + } + + PeerConnectionState peer_connection_state() override { + return PeerConnectionState::kNew; + } + IceGatheringState ice_gathering_state() override { return IceGatheringState::kIceGatheringNew; } @@ -209,6 +222,10 @@ class FakePeerConnectionBase : public PeerConnectionInternal { return false; } + bool StartRtcEventLog(std::unique_ptr output) override { + return false; + } + void StopRtcEventLog() override {} void Close() override {}