diff --git a/api/peerconnectioninterface.cc b/api/peerconnectioninterface.cc index aa23da32d0..adae14fe55 100644 --- a/api/peerconnectioninterface.cc +++ b/api/peerconnectioninterface.cc @@ -46,6 +46,16 @@ PeerConnectionInterface::AddTrack( 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) { diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index a32050862b..4851206cb4 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -664,7 +664,21 @@ class PeerConnectionInterface : public rtc::RefCountInterface { // Remove an RtpSender from this PeerConnection. // Returns true on success. - virtual bool RemoveTrack(RtpSenderInterface* sender) = 0; + // TODO(steveanton): Replace with signature that returns RTCError. + virtual bool RemoveTrack(RtpSenderInterface* sender); + + // Plan B semantics: Removes the RtpSender from this PeerConnection. + // Unified Plan semantics: Stop sending on the RtpSender and mark the + // corresponding RtpTransceiver direction as no longer sending. + // + // Errors: + // - INVALID_PARAMETER: |sender| is null or (Plan B only) the sender is not + // associated with this PeerConnection. + // - INVALID_STATE: PeerConnection is closed. + // TODO(bugs.webrtc.org/9534): Rename to RemoveTrack once the other signature + // is removed. + virtual RTCError RemoveTrackNew( + rtc::scoped_refptr 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/pc/peerconnection.cc b/pc/peerconnection.cc index 1064892953..6edc19ac79 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -1294,10 +1294,10 @@ PeerConnection::FindFirstTransceiverForAddedTrack( bool PeerConnection::RemoveTrack(RtpSenderInterface* sender) { TRACE_EVENT0("webrtc", "PeerConnection::RemoveTrack"); - return RemoveTrackInternal(sender).ok(); + return RemoveTrackNew(sender).ok(); } -RTCError PeerConnection::RemoveTrackInternal( +RTCError PeerConnection::RemoveTrackNew( rtc::scoped_refptr sender) { if (!sender) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "Sender is null."); diff --git a/pc/peerconnection.h b/pc/peerconnection.h index 22f94b0bae..bb37e9ab45 100644 --- a/pc/peerconnection.h +++ b/pc/peerconnection.h @@ -88,6 +88,8 @@ class PeerConnection : public PeerConnectionInternal, rtc::scoped_refptr track, const std::vector& stream_ids) override; bool RemoveTrack(RtpSenderInterface* sender) override; + RTCError RemoveTrackNew( + rtc::scoped_refptr sender) override; RTCErrorOr> AddTransceiver( rtc::scoped_refptr track) override; @@ -345,9 +347,6 @@ class PeerConnection : public PeerConnectionInternal, FindFirstTransceiverForAddedTrack( rtc::scoped_refptr track); - // RemoveTrack that returns an RTCError. - RTCError RemoveTrackInternal(rtc::scoped_refptr sender); - rtc::scoped_refptr> FindTransceiverBySender(rtc::scoped_refptr sender);