Add/remove receive streams with SSRC 0 from media channels

This enables creation and removal of receive streams with SSRC 0.
Several related methods, for example SetOutputVolume, still use 0 as a
special value.

Bug: webrtc:8694
Change-Id: I341e6bd6c981c9838997510d8d712ad2948f6460
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152780
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Saurav Das <dinosaurav@chromium.org>
Cr-Commit-Position: refs/heads/master@{#29398}
This commit is contained in:
Saurav Das
2019-09-20 11:05:30 -07:00
committed by Commit Bot
parent a639f7a244
commit ff27da5ca1
12 changed files with 47 additions and 28 deletions

View File

@ -580,6 +580,11 @@ bool BaseChannel::RemoveRecvStream_w(uint32_t ssrc) {
return media_channel()->RemoveRecvStream(ssrc);
}
void BaseChannel::ResetUnsignaledRecvStream_w() {
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
media_channel()->ResetUnsignaledRecvStream();
}
bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams,
SdpType type,
std::string* error_desc) {
@ -666,8 +671,11 @@ bool BaseChannel::UpdateRemoteStreams_w(
for (const StreamParams& old_stream : remote_streams_) {
// If we no longer have an unsignaled stream, we would like to remove
// the unsignaled stream params that are cached.
if ((!old_stream.has_ssrcs() && !HasStreamWithNoSsrcs(streams)) ||
!GetStreamBySsrc(streams, old_stream.first_ssrc())) {
if (!old_stream.has_ssrcs() && !HasStreamWithNoSsrcs(streams)) {
ResetUnsignaledRecvStream_w();
RTC_LOG(LS_INFO) << "Reset unsignaled remote stream.";
} else if (old_stream.has_ssrcs() &&
!GetStreamBySsrc(streams, old_stream.first_ssrc())) {
if (RemoveRecvStream_w(old_stream.first_ssrc())) {
RTC_LOG(LS_INFO) << "Remove remote ssrc: " << old_stream.first_ssrc();
} else {
@ -688,10 +696,16 @@ bool BaseChannel::UpdateRemoteStreams_w(
if ((!new_stream.has_ssrcs() && !HasStreamWithNoSsrcs(remote_streams_)) ||
!GetStreamBySsrc(remote_streams_, new_stream.first_ssrc())) {
if (AddRecvStream_w(new_stream)) {
RTC_LOG(LS_INFO) << "Add remote ssrc: " << new_stream.first_ssrc();
RTC_LOG(LS_INFO) << "Add remote ssrc: "
<< (new_stream.has_ssrcs()
? std::to_string(new_stream.first_ssrc())
: "unsignaled");
} else {
rtc::StringBuilder desc;
desc << "Failed to add remote stream ssrc: " << new_stream.first_ssrc();
desc << "Failed to add remote stream ssrc: "
<< (new_stream.has_ssrcs()
? std::to_string(new_stream.first_ssrc())
: "unsignaled");
SafeSetError(desc.str(), error_desc);
ret = false;
}

View File

@ -233,6 +233,7 @@ class BaseChannel : public ChannelInterface,
bool AddRecvStream_w(const StreamParams& sp);
bool RemoveRecvStream_w(uint32_t ssrc);
void ResetUnsignaledRecvStream_w();
bool AddSendStream_w(const StreamParams& sp);
bool RemoveSendStream_w(uint32_t ssrc);