Index: talk/app/webrtc/peerconnection.cc |
diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc |
index e7b33c43acdbd917ad549aac93df2611fd818475..b3c8b8769752700defbf66a802f422becbe207d6 100644 |
--- a/talk/app/webrtc/peerconnection.cc |
+++ b/talk/app/webrtc/peerconnection.cc |
@@ -348,6 +348,16 @@ bool MediaContentDirectionHasSend(cricket::MediaContentDirection dir) { |
return dir == cricket::MD_SENDONLY || dir == cricket::MD_SENDRECV; |
} |
+// If the direction is "recvonly" or "inactive", treat the description |
+// as containing no streams. |
+// See: https://code.google.com/p/webrtc/issues/detail?id=5054 |
+std::vector<cricket::StreamParams> GetActiveStreams( |
+ const cricket::MediaContentDescription* desc) { |
+ return MediaContentDirectionHasSend(desc->direction()) |
+ ? desc->streams() |
+ : std::vector<cricket::StreamParams>(); |
+} |
+ |
bool IsValidOfferToReceiveMedia(int value) { |
typedef PeerConnectionInterface::RTCOfferAnswerOptions Options; |
return (value >= Options::kUndefined) && |
@@ -1029,7 +1039,7 @@ void PeerConnection::SetRemoteDescription( |
const cricket::AudioContentDescription* desc = |
static_cast<const cricket::AudioContentDescription*>( |
audio_content->description); |
- UpdateRemoteStreamsList(desc->streams(), desc->type(), new_streams); |
+ UpdateRemoteStreamsList(GetActiveStreams(desc), desc->type(), new_streams); |
remote_info_.default_audio_track_needed = |
MediaContentDirectionHasSend(desc->direction()) && |
desc->streams().empty(); |
@@ -1042,7 +1052,7 @@ void PeerConnection::SetRemoteDescription( |
const cricket::VideoContentDescription* desc = |
static_cast<const cricket::VideoContentDescription*>( |
video_content->description); |
- UpdateRemoteStreamsList(desc->streams(), desc->type(), new_streams); |
+ UpdateRemoteStreamsList(GetActiveStreams(desc), desc->type(), new_streams); |
remote_info_.default_video_track_needed = |
MediaContentDirectionHasSend(desc->direction()) && |
desc->streams().empty(); |
@@ -1051,12 +1061,12 @@ void PeerConnection::SetRemoteDescription( |
// Update the DataChannels with the information from the remote peer. |
const cricket::ContentInfo* data_content = GetFirstDataContent(remote_desc); |
if (data_content) { |
- const cricket::DataContentDescription* data_desc = |
+ const cricket::DataContentDescription* desc = |
static_cast<const cricket::DataContentDescription*>( |
data_content->description); |
- if (rtc::starts_with(data_desc->protocol().data(), |
+ if (rtc::starts_with(desc->protocol().data(), |
cricket::kMediaProtocolRtpPrefix)) { |
- UpdateRemoteRtpDataChannels(data_desc->streams()); |
+ UpdateRemoteRtpDataChannels(GetActiveStreams(desc)); |
} |
} |