Delete almost all default methods on PeerConnectionInterface

Keeping default implementations only for methods involved in
ongoing transitions.

Intended to catch inconsistencies between the interface and the
PeerConnectionProxy class, at compile time.

Bug: webrtc:10716
Change-Id: I4cb126c353855f7288ba09273fa6f87aaa0f32eb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140860
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29224}
This commit is contained in:
Niels Möller
2019-09-13 15:41:21 +02:00
committed by Commit Bot
parent e607a06338
commit 7b04a91f4a
5 changed files with 63 additions and 159 deletions

View File

@ -42,103 +42,17 @@ PeerConnectionInterface::RTCConfiguration::RTCConfiguration(
PeerConnectionInterface::RTCConfiguration::~RTCConfiguration() = default;
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>
PeerConnectionInterface::AddTrack(
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids) {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
}
bool PeerConnectionInterface::RemoveTrack(RtpSenderInterface* sender) {
return RemoveTrackNew(sender).ok();
}
RTCError PeerConnectionInterface::RemoveTrackNew(
rtc::scoped_refptr<RtpSenderInterface> sender) {
return RTCError(RemoveTrack(sender) ? RTCErrorType::NONE
: RTCErrorType::INTERNAL_ERROR);
}
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
PeerConnectionInterface::AddTransceiver(
rtc::scoped_refptr<MediaStreamTrackInterface> track) {
return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented");
}
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
PeerConnectionInterface::AddTransceiver(
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const RtpTransceiverInit& init) {
return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented");
}
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
PeerConnectionInterface::AddTransceiver(cricket::MediaType media_type) {
return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented");
}
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
PeerConnectionInterface::AddTransceiver(cricket::MediaType media_type,
const RtpTransceiverInit& init) {
return RTCError(RTCErrorType::INTERNAL_ERROR, "not implemented");
}
rtc::scoped_refptr<RtpSenderInterface> PeerConnectionInterface::CreateSender(
const std::string& kind,
const std::string& stream_id) {
return rtc::scoped_refptr<RtpSenderInterface>();
}
std::vector<rtc::scoped_refptr<RtpSenderInterface>>
PeerConnectionInterface::GetSenders() const {
return std::vector<rtc::scoped_refptr<RtpSenderInterface>>();
}
std::vector<rtc::scoped_refptr<RtpReceiverInterface>>
PeerConnectionInterface::GetReceivers() const {
return std::vector<rtc::scoped_refptr<RtpReceiverInterface>>();
}
std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>
PeerConnectionInterface::GetTransceivers() const {
return std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>();
}
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<cricket::Candidate>& 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<RtcEventLogOutput> output,
int64_t output_period_ms) {
return false;
}
bool PeerConnectionInterface::StartRtcEventLog(
std::unique_ptr<RtcEventLogOutput> output) {
return false;
}
rtc::scoped_refptr<DtlsTransportInterface>
PeerConnectionInterface::LookupDtlsTransportByMid(const std::string& mid) {
RTC_NOTREACHED();
return nullptr;
}
rtc::scoped_refptr<SctpTransportInterface>
PeerConnectionInterface::GetSctpTransport() const {
RTC_NOTREACHED();
return nullptr;
}
PeerConnectionInterface::BitrateParameters::BitrateParameters() = default;
PeerConnectionInterface::BitrateParameters::~BitrateParameters() = default;

View File

@ -760,12 +760,12 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
// - INVALID_STATE: The PeerConnection is closed.
virtual RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids);
const std::vector<std::string>& 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<rtc::scoped_refptr<RtpTransceiverInterface>>
AddTransceiver(rtc::scoped_refptr<MediaStreamTrackInterface> track);
AddTransceiver(rtc::scoped_refptr<MediaStreamTrackInterface> track) = 0;
virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
AddTransceiver(rtc::scoped_refptr<MediaStreamTrackInterface> 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<rtc::scoped_refptr<RtpTransceiverInterface>>
AddTransceiver(cricket::MediaType media_type);
AddTransceiver(cricket::MediaType media_type) = 0;
virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
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<RtpSenderInterface> 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<rtc::scoped_refptr<RtpSenderInterface>> 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<rtc::scoped_refptr<RtpReceiverInterface>> 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<rtc::scoped_refptr<RtpTransceiverInterface>>
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<RtpSenderInterface> selector,
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) {}
rtc::scoped_refptr<RTCStatsCollectorCallback> 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<RtpReceiverInterface> selector,
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) {}
rtc::scoped_refptr<RTCStatsCollectorCallback> 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<SessionDescriptionInterface> desc,
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer) {}
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> 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<cricket::Candidate>& candidates);
const std::vector<cricket::Candidate>& 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<DtlsTransportInterface> 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<SctpTransportInterface> GetSctpTransport() const;
virtual rtc::scoped_refptr<SctpTransportInterface> 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<RtcEventLogOutput> output,
int64_t output_period_ms);
virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output);
int64_t output_period_ms) = 0;
virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> 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.

View File

@ -72,6 +72,7 @@ PROXY_METHOD2(void,
GetStats,
rtc::scoped_refptr<RtpReceiverInterface>,
rtc::scoped_refptr<RTCStatsCollectorCallback>)
PROXY_METHOD0(void, ClearStatsCache)
PROXY_METHOD2(rtc::scoped_refptr<DataChannelInterface>,
CreateDataChannel,
const std::string&,

View File

@ -13,6 +13,7 @@
#include <memory>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
@ -39,6 +40,8 @@ class MockPeerConnectionInterface
MediaStreamTrackInterface*,
std::vector<MediaStreamInterface*>));
MOCK_METHOD1(RemoveTrack, bool(RtpSenderInterface*));
MOCK_METHOD1(RemoveTrackNew,
RTCError(rtc::scoped_refptr<RtpSenderInterface>));
MOCK_METHOD1(AddTransceiver,
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
rtc::scoped_refptr<MediaStreamTrackInterface>));
@ -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<DtlsTransportInterface>(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<RtcEventLogOutput>, int64_t));
MOCK_METHOD1(StartRtcEventLog, bool(std::unique_ptr<RtcEventLogOutput>));
MOCK_METHOD0(StopRtcEventLog, void());
MOCK_METHOD0(Close, void());
};
static_assert(!std::is_abstract<MockPeerConnectionInterface>::value, "");
} // namespace webrtc
#endif // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_

View File

@ -52,6 +52,11 @@ class FakePeerConnectionBase : public PeerConnectionInternal {
bool RemoveTrack(RtpSenderInterface* sender) override { return false; }
RTCError RemoveTrackNew(
rtc::scoped_refptr<RtpSenderInterface> sender) override {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
}
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
rtc::scoped_refptr<MediaStreamTrackInterface> 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<RtcEventLogOutput> output) override {
return false;
}
void StopRtcEventLog() override {}
void Close() override {}