Make PeerConnectionInteface methods pure virtual.

Bug: none
Change-Id: I64fc23f5159bc6a5cd83c0b00b292641f4976513
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/340143
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41782}
This commit is contained in:
Per K 2024-02-21 13:24:13 +01:00 committed by WebRTC LUCI CQ
parent e166dec0a9
commit bff68580b5
4 changed files with 37 additions and 24 deletions

View file

@ -1003,8 +1003,6 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface {
// for negotiation and subsequent CreateOffer() calls will act as if // for negotiation and subsequent CreateOffer() calls will act as if
// RTCOfferAnswerOptions::ice_restart is true. // RTCOfferAnswerOptions::ice_restart is true.
// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-restartice // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-restartice
// TODO(hbos): Remove default implementation when downstream projects
// implement this.
virtual void RestartIce() = 0; virtual void RestartIce() = 0;
// Create a new offer. // Create a new offer.
@ -1075,9 +1073,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface {
// sure that even if there was a delay (e.g. due to a PostTask) between the // sure that even if there was a delay (e.g. due to a PostTask) between the
// event being generated and the time of firing, the Operations Chain is empty // event being generated and the time of firing, the Operations Chain is empty
// and the event is still valid to be fired. // and the event is still valid to be fired.
virtual bool ShouldFireNegotiationNeededEvent(uint32_t event_id) { virtual bool ShouldFireNegotiationNeededEvent(uint32_t event_id) = 0;
return true;
}
virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() = 0; virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() = 0;
@ -1139,7 +1135,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface {
// Estimation starts when the first RTP packet is sent. // Estimation starts when the first RTP packet is sent.
// Estimation will be restarted if already started. // Estimation will be restarted if already started.
virtual void ReconfigureBandwidthEstimation( virtual void ReconfigureBandwidthEstimation(
const BandwidthEstimationSettings& settings) {} const BandwidthEstimationSettings& settings) = 0;
// Enable/disable playout of received audio streams. Enabled by default. Note // Enable/disable playout of received audio streams. Enabled by default. Note
// that even if playout is enabled, streams will only be played out if the // that even if playout is enabled, streams will only be played out if the
@ -1147,12 +1143,12 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface {
// playout of the underlying audio device but starts a task which will poll // playout of the underlying audio device but starts a task which will poll
// for audio data every 10ms to ensure that audio processing happens and the // for audio data every 10ms to ensure that audio processing happens and the
// audio statistics are updated. // audio statistics are updated.
virtual void SetAudioPlayout(bool playout) {} virtual void SetAudioPlayout(bool playout) = 0;
// Enable/disable recording of transmitted audio streams. Enabled by default. // Enable/disable recording of transmitted audio streams. Enabled by default.
// Note that even if recording is enabled, streams will only be recorded if // Note that even if recording is enabled, streams will only be recorded if
// the appropriate SDP is also applied. // the appropriate SDP is also applied.
virtual void SetAudioRecording(bool recording) {} virtual void SetAudioRecording(bool recording) = 0;
// Looks up the DtlsTransport associated with a MID value. // Looks up the DtlsTransport associated with a MID value.
// In the Javascript API, DtlsTransport is a property of a sender, but // In the Javascript API, DtlsTransport is a property of a sender, but
@ -1184,28 +1180,25 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface {
// Returns the current state of canTrickleIceCandidates per // Returns the current state of canTrickleIceCandidates per
// https://w3c.github.io/webrtc-pc/#attributes-1 // https://w3c.github.io/webrtc-pc/#attributes-1
virtual absl::optional<bool> can_trickle_ice_candidates() { virtual absl::optional<bool> can_trickle_ice_candidates() = 0;
// TODO(crbug.com/708484): Remove default implementation.
return absl::nullopt;
}
// When a resource is overused, the PeerConnection will try to reduce the load // When a resource is overused, the PeerConnection will try to reduce the load
// on the sysem, for example by reducing the resolution or frame rate of // on the sysem, for example by reducing the resolution or frame rate of
// encoded streams. The Resource API allows injecting platform-specific usage // encoded streams. The Resource API allows injecting platform-specific usage
// measurements. The conditions to trigger kOveruse or kUnderuse are up to the // measurements. The conditions to trigger kOveruse or kUnderuse are up to the
// implementation. // implementation.
// TODO(hbos): Make pure virtual when implemented by downstream projects. virtual void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) = 0;
virtual void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) {}
// Start RtcEventLog using an existing output-sink. Takes ownership of // Start RtcEventLog using an existing output-sink. Takes ownership of
// `output` and passes it on to Call, which will take the ownership. If the // `output` and passes it on to Call, which will take the ownership. If
// operation fails the output will be closed and deallocated. The event log // the operation fails the output will be closed and deallocated. The
// will send serialized events to the output object every `output_period_ms`. // event log will send serialized events to the output object every
// Applications using the event log should generally make their own trade-off // `output_period_ms`. Applications using the event log should generally
// regarding the output period. A long period is generally more efficient, // make their own trade-off regarding the output period. A long period is
// with potential drawbacks being more bursty thread usage, and more events // generally more efficient, with potential drawbacks being more bursty
// lost in case the application crashes. If the `output_period_ms` argument is // thread usage, and more events lost in case the application crashes. If
// omitted, webrtc selects a default deemed to be workable in most cases. // 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, virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms) = 0; int64_t output_period_ms) = 0;
virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) = 0; virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) = 0;
@ -1226,8 +1219,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface {
// //
// Also the only thread on which it's safe to use SessionDescriptionInterface // Also the only thread on which it's safe to use SessionDescriptionInterface
// pointers. // pointers.
// TODO(deadbeef): Make pure virtual when all subclasses implement it. virtual rtc::Thread* signaling_thread() const = 0;
virtual rtc::Thread* signaling_thread() const { return nullptr; }
protected: protected:
// Dtor protected as objects shouldn't be deleted via this interface. // Dtor protected as objects shouldn't be deleted via this interface.

View file

@ -160,6 +160,10 @@ class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface {
(std::unique_ptr<SessionDescriptionInterface>, (std::unique_ptr<SessionDescriptionInterface>,
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>), rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>),
(override)); (override));
MOCK_METHOD(bool,
ShouldFireNegotiationNeededEvent,
(uint32_t event_id),
(override));
MOCK_METHOD(PeerConnectionInterface::RTCConfiguration, MOCK_METHOD(PeerConnectionInterface::RTCConfiguration,
GetConfiguration, GetConfiguration,
(), (),
@ -195,6 +199,10 @@ class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface {
(override)); (override));
MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override)); MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override));
MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override)); MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override));
MOCK_METHOD(void,
AddAdaptationResource,
(rtc::scoped_refptr<Resource>),
(override));
MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override)); MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override));
MOCK_METHOD(bool, MOCK_METHOD(bool,
StartRtcEventLog, StartRtcEventLog,
@ -206,6 +214,7 @@ class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface {
(override)); (override));
MOCK_METHOD(void, StopRtcEventLog, (), (override)); MOCK_METHOD(void, StopRtcEventLog, (), (override));
MOCK_METHOD(void, Close, (), (override)); MOCK_METHOD(void, Close, (), (override));
MOCK_METHOD(rtc::Thread*, signaling_thread, (), (const override));
}; };
static_assert( static_assert(

View file

@ -177,6 +177,8 @@ class FakePeerConnectionBase : public PeerConnectionInternal {
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer) rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
override {} override {}
bool ShouldFireNegotiationNeededEvent(uint32_t event_id) { return true; }
RTCConfiguration GetConfiguration() override { return RTCConfiguration(); } RTCConfiguration GetConfiguration() override { return RTCConfiguration(); }
RTCError SetConfiguration( RTCError SetConfiguration(
@ -229,6 +231,8 @@ class FakePeerConnectionBase : public PeerConnectionInternal {
absl::optional<bool> can_trickle_ice_candidates() { return absl::nullopt; } absl::optional<bool> can_trickle_ice_candidates() { return absl::nullopt; }
void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) {}
bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output, bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms) override { int64_t output_period_ms) override {
return false; return false;

View file

@ -153,6 +153,10 @@ class MockPeerConnectionInternal : public PeerConnectionInternal {
(std::unique_ptr<SessionDescriptionInterface>, (std::unique_ptr<SessionDescriptionInterface>,
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>), rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>),
(override)); (override));
MOCK_METHOD(bool,
ShouldFireNegotiationNeededEvent,
(uint32_t event_id),
(override));
MOCK_METHOD(PeerConnectionInterface::RTCConfiguration, MOCK_METHOD(PeerConnectionInterface::RTCConfiguration,
GetConfiguration, GetConfiguration,
(), (),
@ -192,6 +196,10 @@ class MockPeerConnectionInternal : public PeerConnectionInternal {
(override)); (override));
MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override)); MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override));
MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override)); MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override));
MOCK_METHOD(void,
AddAdaptationResource,
(rtc::scoped_refptr<Resource>),
(override));
MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override)); MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override));
MOCK_METHOD(bool, MOCK_METHOD(bool,
StartRtcEventLog, StartRtcEventLog,