Deprecate RemoveTrack (old signature)
This also removes all internal usage of RemoveTrack, and changes
the replacement function to RemoveTrackOrError rather than RemoveTrackNew.
Bug: webrtc:9534
Change-Id: Idf7bb17495686de77c70428dcbfb12278328ce59
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244094
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35624}
diff --git a/api/peer_connection_interface.cc b/api/peer_connection_interface.cc
index 230731c..9f159ea 100644
--- a/api/peer_connection_interface.cc
+++ b/api/peer_connection_interface.cc
@@ -41,12 +41,6 @@
PeerConnectionInterface::RTCConfiguration::~RTCConfiguration() = default;
-RTCError PeerConnectionInterface::RemoveTrackNew(
- rtc::scoped_refptr<RtpSenderInterface> sender) {
- return RTCError(RemoveTrack(sender) ? RTCErrorType::NONE
- : RTCErrorType::INTERNAL_ERROR);
-}
-
RTCError PeerConnectionInterface::SetConfiguration(
const PeerConnectionInterface::RTCConfiguration& config) {
return RTCError();
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index 7a2ac12..c367fae 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -805,23 +805,41 @@
rtc::scoped_refptr<MediaStreamTrackInterface> track,
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) = 0;
-
- // Plan B semantics: Removes the RtpSender from this PeerConnection.
- // Unified Plan semantics: Stop sending on the RtpSender and mark the
+ // Removes the connection between a MediaStreamTrack and the PeerConnection.
+ // Stops sending on the RtpSender and marks the
// corresponding RtpTransceiver direction as no longer sending.
+ // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-removetrack
//
// Errors:
// - INVALID_PARAMETER: `sender` is null or (Plan B only) the sender is not
// associated with this PeerConnection.
// - INVALID_STATE: PeerConnection is closed.
+ //
+ // Plan B semantics: Removes the RtpSender from this PeerConnection.
+ //
// TODO(bugs.webrtc.org/9534): Rename to RemoveTrack once the other signature
- // is removed.
+ // is removed; remove default implementation once upstream is updated.
+ virtual RTCError RemoveTrackOrError(
+ rtc::scoped_refptr<RtpSenderInterface> sender) {
+ RTC_CHECK_NOTREACHED();
+ return RTCError();
+ }
+
+ // Legacy API for removing a track from the PeerConnection.
+ // Returns true on success.
+ // TODO(bugs.webrtc.org/9534): Replace with signature that returns RTCError.
+ ABSL_DEPRECATED("Use RemoveTrackOrError")
+ virtual bool RemoveTrack(RtpSenderInterface* sender) {
+ return RemoveTrackOrError(rtc::scoped_refptr<RtpSenderInterface>(sender))
+ .ok();
+ }
+
+ // Old name for the new API. Will be removed when clients are updated.
+ ABSL_DEPRECATED("Use RemoveTrackOrError")
virtual RTCError RemoveTrackNew(
- rtc::scoped_refptr<RtpSenderInterface> sender);
+ rtc::scoped_refptr<RtpSenderInterface> sender) {
+ return RemoveTrackOrError(sender);
+ }
// AddTransceiver creates a new RtpTransceiver and adds it to the set of
// transceivers. Adding a transceiver will cause future calls to CreateOffer
diff --git a/api/test/dummy_peer_connection.h b/api/test/dummy_peer_connection.h
index 80ae20c..a477d56 100644
--- a/api/test/dummy_peer_connection.h
+++ b/api/test/dummy_peer_connection.h
@@ -47,7 +47,7 @@
bool RemoveTrack(RtpSenderInterface* sender) override { return false; }
- RTCError RemoveTrackNew(
+ RTCError RemoveTrackOrError(
rtc::scoped_refptr<RtpSenderInterface> sender) override {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
}
diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h
index cd67d32..fc740b0 100644
--- a/api/test/mock_peerconnectioninterface.h
+++ b/api/test/mock_peerconnectioninterface.h
@@ -50,7 +50,7 @@
(override));
MOCK_METHOD(bool, RemoveTrack, (RtpSenderInterface*), (override));
MOCK_METHOD(RTCError,
- RemoveTrackNew,
+ RemoveTrackOrError,
(rtc::scoped_refptr<RtpSenderInterface>),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,