Step 1: Add RemoveTrackNew which returns an RTCError

Bug: webrtc:9534
Change-Id: I400bdcd0eb2e993b3f2252a2c7606cd105854e6b
Reviewed-on: https://webrtc-review.googlesource.com/89480
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24070}
This commit is contained in:
Steve Anton
2018-07-23 10:27:33 -07:00
parent a76af0ca2e
commit 24db573bea
4 changed files with 29 additions and 6 deletions

View File

@ -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<RtpSenderInterface> sender) {
return RTCError(RemoveTrack(sender) ? RTCErrorType::NONE
: RTCErrorType::INTERNAL_ERROR);
}
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
PeerConnectionInterface::AddTransceiver(
rtc::scoped_refptr<MediaStreamTrackInterface> track) {

View File

@ -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<RtpSenderInterface> sender);
// AddTransceiver creates a new RtpTransceiver and adds it to the set of
// transceivers. Adding a transceiver will cause future calls to CreateOffer

View File

@ -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<RtpSenderInterface> sender) {
if (!sender) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "Sender is null.");

View File

@ -88,6 +88,8 @@ class PeerConnection : public PeerConnectionInternal,
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids) override;
bool RemoveTrack(RtpSenderInterface* sender) override;
RTCError RemoveTrackNew(
rtc::scoped_refptr<RtpSenderInterface> sender) override;
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
rtc::scoped_refptr<MediaStreamTrackInterface> track) override;
@ -345,9 +347,6 @@ class PeerConnection : public PeerConnectionInternal,
FindFirstTransceiverForAddedTrack(
rtc::scoped_refptr<MediaStreamTrackInterface> track);
// RemoveTrack that returns an RTCError.
RTCError RemoveTrackInternal(rtc::scoped_refptr<RtpSenderInterface> sender);
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
FindTransceiverBySender(rtc::scoped_refptr<RtpSenderInterface> sender);