Reland "Implement transceiver.stop()" This is a reland of 11dc6571cb4ff3e71dee1557dfff8d9076e108d3 One fix that makes Web Platform Tests pass in debug mode is applied. Original change's description: > Implement transceiver.stop() > > This adds RtpTransceiver.StopStandard(), which behaves according to > the specification at > https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stop > > It modifies RTCPeerConnection.getTransceivers() to return only > transceivers that have not been stopped. > > Rebase of armax' https://webrtc-review.googlesource.com/c/src/+/172762 > > Bug: chromium:980879 > Change-Id: I7d383ee874ccc0a006fdcf280496b5d4235425ce > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180580 > Reviewed-by: Kári Helgason <kthelgason@webrtc.org> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> > Reviewed-by: Guido Urdaneta <guidou@webrtc.org> > Commit-Queue: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31893} Bug: chromium:980879 Change-Id: Ide31d929ac5ea118d83fdf6a35a592af23f7dfa7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181263 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Guido Urdaneta <guidou@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31907}
diff --git a/api/rtp_transceiver_interface.cc b/api/rtp_transceiver_interface.cc index e795e51..1dc0fcc 100644 --- a/api/rtp_transceiver_interface.cc +++ b/api/rtp_transceiver_interface.cc
@@ -25,6 +25,23 @@ return absl::nullopt; } +bool RtpTransceiverInterface::stopping() const { + return false; +} + +void RtpTransceiverInterface::Stop() { + StopInternal(); +} + +RTCError RtpTransceiverInterface::StopStandard() { + RTC_NOTREACHED() << "DEBUG: RtpTransceiverInterface::StopStandard called"; + return RTCError::OK(); +} + +void RtpTransceiverInterface::StopInternal() { + RTC_NOTREACHED() << "DEBUG: RtpTransceiverInterface::StopInternal called"; +} + RTCError RtpTransceiverInterface::SetCodecPreferences( rtc::ArrayView<RtpCodecCapability>) { RTC_NOTREACHED() << "Not implemented"; @@ -47,4 +64,17 @@ return webrtc::RTCError(webrtc::RTCErrorType::UNSUPPORTED_OPERATION); } +// TODO(bugs.webrtc.org/11839) Remove default implementations when clients +// are updated. +void RtpTransceiverInterface::SetDirection( + RtpTransceiverDirection new_direction) { + SetDirectionWithError(new_direction); +} + +RTCError RtpTransceiverInterface::SetDirectionWithError( + RtpTransceiverDirection new_direction) { + RTC_NOTREACHED() << "Default implementation called"; + return RTCError::OK(); +} + } // namespace webrtc
diff --git a/api/rtp_transceiver_interface.h b/api/rtp_transceiver_interface.h index 13277d9..cdda34b 100644 --- a/api/rtp_transceiver_interface.h +++ b/api/rtp_transceiver_interface.h
@@ -89,6 +89,16 @@ // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stopped virtual bool stopped() const = 0; + // The stopping attribute indicates that the user has indicated that the + // sender of this transceiver will stop sending, and that the receiver will + // no longer receive. It is always true if stopped() is true. + // If stopping() is true and stopped() is false, it means that the + // transceiver's stop() method has been called, but the negotiation with + // the other end for shutting down the transceiver is not yet done. + // https://w3c.github.io/webrtc-pc/#dfn-stopping-0 + // TODO(hta): Remove default implementation. + virtual bool stopping() const; + // The direction attribute indicates the preferred direction of this // transceiver, which will be used in calls to CreateOffer and CreateAnswer. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction @@ -99,7 +109,10 @@ // CreateOffer and CreateAnswer mark the corresponding media descriptions as // sendrecv, sendonly, recvonly, or inactive. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction - virtual void SetDirection(RtpTransceiverDirection new_direction) = 0; + // TODO(hta): Deprecate SetDirection without error and rename + // SetDirectionWithError to SetDirection, remove default implementations. + virtual void SetDirection(RtpTransceiverDirection new_direction); + virtual RTCError SetDirectionWithError(RtpTransceiverDirection new_direction); // The current_direction attribute indicates the current direction negotiated // for this transceiver. If this transceiver has never been represented in an @@ -114,10 +127,19 @@ // Exposed in the public interface for use by Chromium. virtual absl::optional<RtpTransceiverDirection> fired_direction() const; - // The Stop method irreversibly stops the RtpTransceiver. The sender of this - // transceiver will no longer send, the receiver will no longer receive. + // Initiates a stop of the transceiver. + // The stop is complete when stopped() returns true. + // A stopped transceiver can be reused for a different track. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stop - virtual void Stop() = 0; + // TODO(hta): Rename to Stop() when users of the non-standard Stop() are + // updated. + virtual RTCError StopStandard(); + + // Stops a transceiver immediately, without waiting for signalling. + // This is an internal function, and is exposed for historical reasons. + // https://w3c.github.io/webrtc-pc/#dfn-stop-the-rtcrtptransceiver + virtual void StopInternal(); + RTC_DEPRECATED virtual void Stop(); // The SetCodecPreferences method overrides the default codec preferences used // by WebRTC for this transceiver.