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
This commit is contained in:
jiayl@webrtc.org
2014-07-18 20:54:27 +00:00
parent ff50debd37
commit 8636fc852e
2 changed files with 42 additions and 2 deletions

View File

@@ -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.

View File

@@ -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<SessionDescriptionInterface> 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) {