From 8636fc852e0bc22a7f582d88e54211c858ec92aa Mon Sep 17 00:00:00 2001 From: "jiayl@webrtc.org" Date: Fri, 18 Jul 2014 20:54:27 +0000 Subject: [PATCH] Creates the default track if the remote media content is send-only and there is no stream in the SDP. BUG=2628 R=wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/16909004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6734 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/app/webrtc/mediastreamsignaling.cc | 10 ++++-- .../webrtc/mediastreamsignaling_unittest.cc | 34 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/talk/app/webrtc/mediastreamsignaling.cc b/talk/app/webrtc/mediastreamsignaling.cc index 99f627a1d3..ad3c01aed4 100644 --- a/talk/app/webrtc/mediastreamsignaling.cc +++ b/talk/app/webrtc/mediastreamsignaling.cc @@ -123,6 +123,10 @@ static bool EvaluateNeedForBundle(const cricket::MediaSessionOptions& options) { (options.has_audio || options.has_video || options.has_data()); } +static bool MediaContentDirectionHasSend(cricket::MediaContentDirection dir) { + return dir == cricket::MD_SENDONLY || dir == cricket::MD_SENDRECV; +} + // Factory class for creating remote MediaStreams and MediaStreamTracks. class RemoteMediaStreamFactory { public: @@ -406,7 +410,8 @@ void MediaStreamSignaling::OnRemoteDescriptionChanged( audio_content->description); UpdateRemoteStreamsList(desc->streams(), desc->type(), new_streams); remote_info_.default_audio_track_needed = - desc->direction() == cricket::MD_SENDRECV && desc->streams().empty(); + MediaContentDirectionHasSend(desc->direction()) && + desc->streams().empty(); } // Find all video rtp streams and create corresponding remote VideoTracks @@ -418,7 +423,8 @@ void MediaStreamSignaling::OnRemoteDescriptionChanged( video_content->description); UpdateRemoteStreamsList(desc->streams(), desc->type(), new_streams); remote_info_.default_video_track_needed = - desc->direction() == cricket::MD_SENDRECV && desc->streams().empty(); + MediaContentDirectionHasSend(desc->direction()) && + desc->streams().empty(); } // Update the DataChannels with the information from the remote peer. diff --git a/talk/app/webrtc/mediastreamsignaling_unittest.cc b/talk/app/webrtc/mediastreamsignaling_unittest.cc index 150058eea0..47034f6f51 100644 --- a/talk/app/webrtc/mediastreamsignaling_unittest.cc +++ b/talk/app/webrtc/mediastreamsignaling_unittest.cc @@ -148,6 +148,21 @@ static const char kSdpStringWithoutStreamsAudioOnly[] = "a=mid:audio\r\n" "a=rtpmap:103 ISAC/16000\r\n"; +// Reference SENDONLY SDP without MediaStreams. Msid is not supported. +static const char kSdpStringSendOnlyWithWithoutStreams[] = + "v=0\r\n" + "o=- 0 0 IN IP4 127.0.0.1\r\n" + "s=-\r\n" + "t=0 0\r\n" + "m=audio 1 RTP/AVPF 103\r\n" + "a=mid:audio\r\n" + "a=sendonly" + "a=rtpmap:103 ISAC/16000\r\n" + "m=video 1 RTP/AVPF 120\r\n" + "a=mid:video\r\n" + "a=sendonly" + "a=rtpmap:120 VP8/90000\r\n"; + static const char kSdpStringInit[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" @@ -913,6 +928,25 @@ TEST_F(MediaStreamSignalingTest, SdpWithoutMsidCreatesDefaultStream) { observer_->VerifyRemoteVideoTrack("default", "defaultv0", 0); } +// This tests that a default MediaStream is created if a remote session +// description doesn't contain any streams and media direction is send only. +TEST_F(MediaStreamSignalingTest, RecvOnlySdpWithoutMsidCreatesDefaultStream) { + talk_base::scoped_ptr desc( + webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, + kSdpStringSendOnlyWithWithoutStreams, + NULL)); + ASSERT_TRUE(desc != NULL); + signaling_->OnRemoteDescriptionChanged(desc.get()); + + EXPECT_EQ(1u, signaling_->remote_streams()->count()); + ASSERT_EQ(1u, observer_->remote_streams()->count()); + MediaStreamInterface* remote_stream = observer_->remote_streams()->at(0); + + EXPECT_EQ(1u, remote_stream->GetAudioTracks().size()); + EXPECT_EQ(1u, remote_stream->GetVideoTracks().size()); + EXPECT_EQ("default", remote_stream->label()); +} + // This tests that it won't crash when MediaStreamSignaling tries to remove // a remote track that as already been removed from the mediastream. TEST_F(MediaStreamSignalingTest, RemoveAlreadyGoneRemoteStream) {