summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-01-15 23:15:54 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-01-15 23:15:54 +0000
commitf32dd31e14521d7f845e7776af6d44d411573370 (patch)
tree92b2f6acd6a3b09f82802f866bfb2b7567d8a033 /app
parent68463fd664dfbe943d20292f0beb9892aa86a5f2 (diff)
downloadtalk-f32dd31e14521d7f845e7776af6d44d411573370.tar.gz
Update libjingle to 59676287
R=wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/7229004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@5390 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'app')
-rw-r--r--app/webrtc/videosource_unittest.cc6
-rw-r--r--app/webrtc/webrtcsession.cc190
-rw-r--r--app/webrtc/webrtcsession.h19
-rw-r--r--app/webrtc/webrtcsession_unittest.cc150
4 files changed, 219 insertions, 146 deletions
diff --git a/app/webrtc/videosource_unittest.cc b/app/webrtc/videosource_unittest.cc
index 69e9b3f..213508f 100644
--- a/app/webrtc/videosource_unittest.cc
+++ b/app/webrtc/videosource_unittest.cc
@@ -238,7 +238,7 @@ TEST_F(VideoSourceTest, MandatoryConstraintCif5Fps) {
ASSERT_TRUE(format != NULL);
EXPECT_EQ(352, format->width);
EXPECT_EQ(288, format->height);
- EXPECT_EQ(5, format->framerate());
+ EXPECT_EQ(30, format->framerate());
}
// Test that the capture output is 720P if the camera support it and the
@@ -491,7 +491,7 @@ TEST_F(VideoSourceTest, MixedOptionsAndConstraints) {
ASSERT_TRUE(format != NULL);
EXPECT_EQ(352, format->width);
EXPECT_EQ(288, format->height);
- EXPECT_EQ(5, format->framerate());
+ EXPECT_EQ(30, format->framerate());
bool value = true;
EXPECT_TRUE(source_->options()->video_noise_reduction.Get(&value));
@@ -554,6 +554,6 @@ TEST_F(VideoSourceTest, OptionalSubOneFpsConstraints) {
kMaxWaitMs);
const cricket::VideoFormat* format = capturer_->GetCaptureFormat();
ASSERT_TRUE(format != NULL);
- EXPECT_EQ(1, format->framerate());
+ EXPECT_EQ(30, format->framerate());
}
diff --git a/app/webrtc/webrtcsession.cc b/app/webrtc/webrtcsession.cc
index 404d963..0de46e7 100644
--- a/app/webrtc/webrtcsession.cc
+++ b/app/webrtc/webrtcsession.cc
@@ -55,29 +55,22 @@ using cricket::TransportInfo;
namespace webrtc {
// Error messages
-const char kSetLocalSdpFailed[] = "SetLocalDescription failed: ";
-const char kSetRemoteSdpFailed[] = "SetRemoteDescription failed: ";
-const char kCreateChannelFailed[] = "Failed to create channels.";
const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE "
"is enabled.";
+const char kCreateChannelFailed[] = "Failed to create channels.";
const char kInvalidCandidates[] = "Description contains invalid candidates.";
const char kInvalidSdp[] = "Invalid session description.";
const char kMlineMismatch[] =
- "Offer and answer descriptions m-lines are not matching. "
- "Rejecting answer.";
+ "Offer and answer descriptions m-lines are not matching. Rejecting answer.";
+const char kPushDownTDFailed[] =
+ "Failed to push down transport description:";
const char kSdpWithoutCrypto[] = "Called with a SDP without crypto enabled.";
-const char kSdpWithoutSdesAndDtlsDisabled[] =
- "Called with an SDP without SDES crypto and DTLS disabled locally.";
const char kSdpWithoutIceUfragPwd[] =
- "Called with an SDP without ice-ufrag and ice-pwd.";
+ "Called with a SDP without ice-ufrag and ice-pwd.";
+const char kSdpWithoutSdesAndDtlsDisabled[] =
+ "Called with a SDP without SDES crypto and DTLS disabled locally.";
const char kSessionError[] = "Session error code: ";
-const char kUpdateStateFailed[] = "Failed to update session state: ";
-const char kPushDownOfferTDFailed[] =
- "Failed to push down offer transport description.";
-const char kPushDownPranswerTDFailed[] =
- "Failed to push down pranswer transport description.";
-const char kPushDownAnswerTDFailed[] =
- "Failed to push down answer transport description.";
+const char kSessionErrorDesc[] = "Session error description: ";
// Compares |answer| against |offer|. Comparision is done
// for number of m-lines in answer against offer. If matches true will be
@@ -245,39 +238,60 @@ static bool GetTrackIdBySsrc(const SessionDescription* session_description,
return false;
}
-static bool BadSdp(const std::string& desc, std::string* err_desc) {
+static bool BadSdp(const std::string& source,
+ const std::string& type,
+ const std::string& reason,
+ std::string* err_desc) {
+ std::ostringstream desc;
+ desc << "Failed to set " << source << " " << type << " sdp: " << reason;
+
if (err_desc) {
- *err_desc = desc;
+ *err_desc = desc.str();
}
- LOG(LS_ERROR) << desc;
+ LOG(LS_ERROR) << desc.str();
return false;
}
-static bool BadLocalSdp(const std::string& desc, std::string* err_desc) {
- std::string set_local_sdp_failed = kSetLocalSdpFailed;
- set_local_sdp_failed.append(desc);
- return BadSdp(set_local_sdp_failed, err_desc);
-}
-
-static bool BadRemoteSdp(const std::string& desc, std::string* err_desc) {
- std::string set_remote_sdp_failed = kSetRemoteSdpFailed;
- set_remote_sdp_failed.append(desc);
- return BadSdp(set_remote_sdp_failed, err_desc);
-}
-
static bool BadSdp(cricket::ContentSource source,
- const std::string& desc, std::string* err_desc) {
+ const std::string& type,
+ const std::string& reason,
+ std::string* err_desc) {
if (source == cricket::CS_LOCAL) {
- return BadLocalSdp(desc, err_desc);
+ return BadSdp("local", type, reason, err_desc);
} else {
- return BadRemoteSdp(desc, err_desc);
+ return BadSdp("remote", type, reason, err_desc);
}
}
-static std::string SessionErrorMsg(cricket::BaseSession::Error error) {
- std::ostringstream desc;
- desc << kSessionError << error;
- return desc.str();
+static bool BadLocalSdp(const std::string& type,
+ const std::string& reason,
+ std::string* err_desc) {
+ return BadSdp(cricket::CS_LOCAL, type, reason, err_desc);
+}
+
+static bool BadRemoteSdp(const std::string& type,
+ const std::string& reason,
+ std::string* err_desc) {
+ return BadSdp(cricket::CS_REMOTE, type, reason, err_desc);
+}
+
+static bool BadOfferSdp(cricket::ContentSource source,
+ const std::string& reason,
+ std::string* err_desc) {
+ return BadSdp(source, SessionDescriptionInterface::kOffer, reason, err_desc);
+}
+
+static bool BadPranswerSdp(cricket::ContentSource source,
+ const std::string& reason,
+ std::string* err_desc) {
+ return BadSdp(source, SessionDescriptionInterface::kPrAnswer,
+ reason, err_desc);
+}
+
+static bool BadAnswerSdp(cricket::ContentSource source,
+ const std::string& reason,
+ std::string* err_desc) {
+ return BadSdp(source, SessionDescriptionInterface::kAnswer, reason, err_desc);
}
#define GET_STRING_OF_STATE(state) \
@@ -311,20 +325,20 @@ static std::string GetStateString(cricket::BaseSession::State state) {
return result;
}
-#define GET_STRING_OF_ERROR(err) \
+#define GET_STRING_OF_ERROR_CODE(err) \
case cricket::BaseSession::err: \
result = #err; \
break;
-static std::string GetErrorString(cricket::BaseSession::Error err) {
+static std::string GetErrorCodeString(cricket::BaseSession::Error err) {
std::string result;
switch (err) {
- GET_STRING_OF_ERROR(ERROR_NONE)
- GET_STRING_OF_ERROR(ERROR_TIME)
- GET_STRING_OF_ERROR(ERROR_RESPONSE)
- GET_STRING_OF_ERROR(ERROR_NETWORK)
- GET_STRING_OF_ERROR(ERROR_CONTENT)
- GET_STRING_OF_ERROR(ERROR_TRANSPORT)
+ GET_STRING_OF_ERROR_CODE(ERROR_NONE)
+ GET_STRING_OF_ERROR_CODE(ERROR_TIME)
+ GET_STRING_OF_ERROR_CODE(ERROR_RESPONSE)
+ GET_STRING_OF_ERROR_CODE(ERROR_NETWORK)
+ GET_STRING_OF_ERROR_CODE(ERROR_CONTENT)
+ GET_STRING_OF_ERROR_CODE(ERROR_TRANSPORT)
default:
ASSERT(false);
break;
@@ -332,12 +346,15 @@ static std::string GetErrorString(cricket::BaseSession::Error err) {
return result;
}
-static bool SetSessionStateFailed(cricket::ContentSource source,
- cricket::BaseSession::Error err,
- std::string* err_desc) {
- std::string set_state_err = kUpdateStateFailed;
- set_state_err.append(GetErrorString(err));
- return BadSdp(source, set_state_err, err_desc);
+static std::string MakeErrorString(const std::string& error,
+ const std::string& desc) {
+ std::ostringstream ret;
+ ret << error << " " << desc;
+ return ret.str();
+}
+
+static std::string MakeTdErrorString(const std::string& desc) {
+ return MakeErrorString(kPushDownTDFailed, desc);
}
// Help class used to remember if a a remote peer has requested ice restart by
@@ -604,15 +621,14 @@ bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc,
if (action == kOffer && !CreateChannels(local_desc_->description())) {
// TODO(mallinath) - Handle CreateChannel failure, as new local description
// is applied. Restore back to old description.
- return BadLocalSdp(kCreateChannelFailed, err_desc);
+ return BadLocalSdp(desc->type(), kCreateChannelFailed, err_desc);
}
// Remove channel and transport proxies, if MediaContentDescription is
// rejected.
RemoveUnusedChannelsAndTransports(local_desc_->description());
- if (!UpdateSessionState(action, cricket::CS_LOCAL,
- local_desc_->description(), err_desc)) {
+ if (!UpdateSessionState(action, cricket::CS_LOCAL, err_desc)) {
return false;
}
// Kick starting the ice candidates allocation.
@@ -627,7 +643,7 @@ bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc,
mediastream_signaling_->OnDtlsRoleReadyForSctp(role);
}
if (error() != cricket::BaseSession::ERROR_NONE) {
- return BadLocalSdp(SessionErrorMsg(error()), err_desc);
+ return BadLocalSdp(desc->type(), GetSessionErrorMsg(), err_desc);
}
return true;
}
@@ -647,7 +663,7 @@ bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc,
if (action == kOffer && !CreateChannels(desc->description())) {
// TODO(mallinath) - Handle CreateChannel failure, as new local description
// is applied. Restore back to old description.
- return BadRemoteSdp(kCreateChannelFailed, err_desc);
+ return BadRemoteSdp(desc->type(), kCreateChannelFailed, err_desc);
}
// Remove channel and transport proxies, if MediaContentDescription is
@@ -657,15 +673,14 @@ bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc,
// NOTE: Candidates allocation will be initiated only when SetLocalDescription
// is called.
set_remote_description(desc->description()->Copy());
- if (!UpdateSessionState(action, cricket::CS_REMOTE,
- desc->description(), err_desc)) {
+ if (!UpdateSessionState(action, cricket::CS_REMOTE, err_desc)) {
return false;
}
// Update remote MediaStreams.
mediastream_signaling_->OnRemoteDescriptionChanged(desc);
if (local_description() && !UseCandidatesInSessionDescription(desc)) {
- return BadRemoteSdp(kInvalidCandidates, err_desc);
+ return BadRemoteSdp(desc->type(), kInvalidCandidates, err_desc);
}
// Copy all saved candidates.
@@ -685,47 +700,47 @@ bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc,
}
if (error() != cricket::BaseSession::ERROR_NONE) {
- return BadRemoteSdp(SessionErrorMsg(error()), err_desc);
+ return BadRemoteSdp(desc->type(), GetSessionErrorMsg(), err_desc);
}
return true;
}
bool WebRtcSession::UpdateSessionState(
Action action, cricket::ContentSource source,
- const cricket::SessionDescription* desc,
std::string* err_desc) {
// If there's already a pending error then no state transition should happen.
// But all call-sites should be verifying this before calling us!
ASSERT(error() == cricket::BaseSession::ERROR_NONE);
+ std::string td_err;
if (action == kOffer) {
- if (!PushdownTransportDescription(source, cricket::CA_OFFER)) {
- return BadSdp(source, kPushDownOfferTDFailed, err_desc);
+ if (!PushdownTransportDescription(source, cricket::CA_OFFER, &td_err)) {
+ return BadOfferSdp(source, MakeTdErrorString(td_err), err_desc);
}
SetState(source == cricket::CS_LOCAL ?
STATE_SENTINITIATE : STATE_RECEIVEDINITIATE);
if (error() != cricket::BaseSession::ERROR_NONE) {
- return SetSessionStateFailed(source, error(), err_desc);
+ return BadOfferSdp(source, GetSessionErrorMsg(), err_desc);
}
} else if (action == kPrAnswer) {
- if (!PushdownTransportDescription(source, cricket::CA_PRANSWER)) {
- return BadSdp(source, kPushDownPranswerTDFailed, err_desc);
+ if (!PushdownTransportDescription(source, cricket::CA_PRANSWER, &td_err)) {
+ return BadPranswerSdp(source, MakeTdErrorString(td_err), err_desc);
}
EnableChannels();
SetState(source == cricket::CS_LOCAL ?
STATE_SENTPRACCEPT : STATE_RECEIVEDPRACCEPT);
if (error() != cricket::BaseSession::ERROR_NONE) {
- return SetSessionStateFailed(source, error(), err_desc);
+ return BadPranswerSdp(source, GetSessionErrorMsg(), err_desc);
}
} else if (action == kAnswer) {
- if (!PushdownTransportDescription(source, cricket::CA_ANSWER)) {
- return BadSdp(source, kPushDownAnswerTDFailed, err_desc);
+ if (!PushdownTransportDescription(source, cricket::CA_ANSWER, &td_err)) {
+ return BadAnswerSdp(source, MakeTdErrorString(td_err), err_desc);
}
MaybeEnableMuxingSupport();
EnableChannels();
SetState(source == cricket::CS_LOCAL ?
STATE_SENTACCEPT : STATE_RECEIVEDACCEPT);
if (error() != cricket::BaseSession::ERROR_NONE) {
- return SetSessionStateFailed(source, error(), err_desc);
+ return BadAnswerSdp(source, GetSessionErrorMsg(), err_desc);
}
}
return true;
@@ -801,11 +816,9 @@ bool WebRtcSession::GetRemoteTrackId(uint32 ssrc, std::string* track_id) {
BaseSession::remote_description(), ssrc, track_id);
}
-std::string WebRtcSession::BadStateErrMsg(
- const std::string& type, State state) {
+std::string WebRtcSession::BadStateErrMsg(State state) {
std::ostringstream desc;
- desc << "Called with type in wrong state, "
- << "type: " << type << " state: " << GetStateString(state);
+ desc << "Called in wrong state: " << GetStateString(state);
return desc.str();
}
@@ -1447,40 +1460,40 @@ bool WebRtcSession::HasRtcpMuxEnabled(
bool WebRtcSession::ValidateSessionDescription(
const SessionDescriptionInterface* sdesc,
- cricket::ContentSource source, std::string* error_desc) {
-
+ cricket::ContentSource source, std::string* err_desc) {
+ std::string type;
if (error() != cricket::BaseSession::ERROR_NONE) {
- return BadSdp(source, SessionErrorMsg(error()), error_desc);
+ return BadSdp(source, type, GetSessionErrorMsg(), err_desc);
}
if (!sdesc || !sdesc->description()) {
- return BadSdp(source, kInvalidSdp, error_desc);
+ return BadSdp(source, type, kInvalidSdp, err_desc);
}
- std::string type = sdesc->type();
+ type = sdesc->type();
Action action = GetAction(sdesc->type());
if (source == cricket::CS_LOCAL) {
if (!ExpectSetLocalDescription(action))
- return BadSdp(source, BadStateErrMsg(type, state()), error_desc);
+ return BadLocalSdp(type, BadStateErrMsg(state()), err_desc);
} else {
if (!ExpectSetRemoteDescription(action))
- return BadSdp(source, BadStateErrMsg(type, state()), error_desc);
+ return BadRemoteSdp(type, BadStateErrMsg(state()), err_desc);
}
// Verify crypto settings.
std::string crypto_error;
if (webrtc_session_desc_factory_->Secure() == cricket::SEC_REQUIRED &&
!VerifyCrypto(sdesc->description(), dtls_enabled_, &crypto_error)) {
- return BadSdp(source, crypto_error, error_desc);
+ return BadSdp(source, type, crypto_error, err_desc);
}
// Verify ice-ufrag and ice-pwd.
if (!VerifyIceUfragPwdPresent(sdesc->description())) {
- return BadSdp(source, kSdpWithoutIceUfragPwd, error_desc);
+ return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc);
}
if (!ValidateBundleSettings(sdesc->description())) {
- return BadSdp(source, kBundleWithoutRtcpMux, error_desc);
+ return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc);
}
// Verify m-lines in Answer when compared against Offer.
@@ -1489,7 +1502,7 @@ bool WebRtcSession::ValidateSessionDescription(
(source == cricket::CS_LOCAL) ? remote_description()->description() :
local_description()->description();
if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) {
- return BadSdp(source, kMlineMismatch, error_desc);
+ return BadAnswerSdp(source, kMlineMismatch, err_desc);
}
}
@@ -1526,4 +1539,11 @@ bool WebRtcSession::ExpectSetRemoteDescription(Action action) {
(action == kPrAnswer && state() == STATE_RECEIVEDPRACCEPT));
}
+std::string WebRtcSession::GetSessionErrorMsg() {
+ std::ostringstream desc;
+ desc << kSessionError << GetErrorCodeString(error()) << ". ";
+ desc << kSessionErrorDesc << error_desc() << ".";
+ return desc.str();
+}
+
} // namespace webrtc
diff --git a/app/webrtc/webrtcsession.h b/app/webrtc/webrtcsession.h
index 6b58877..384ac47 100644
--- a/app/webrtc/webrtcsession.h
+++ b/app/webrtc/webrtcsession.h
@@ -57,21 +57,17 @@ class IceRestartAnswerLatch;
class MediaStreamSignaling;
class WebRtcSessionDescriptionFactory;
-extern const char kSetLocalSdpFailed[];
-extern const char kSetRemoteSdpFailed[];
-extern const char kCreateChannelFailed[];
extern const char kBundleWithoutRtcpMux[];
+extern const char kCreateChannelFailed[];
extern const char kInvalidCandidates[];
extern const char kInvalidSdp[];
extern const char kMlineMismatch[];
+extern const char kPushDownTDFailed[];
extern const char kSdpWithoutCrypto[];
-extern const char kSdpWithoutSdesAndDtlsDisabled[];
extern const char kSdpWithoutIceUfragPwd[];
+extern const char kSdpWithoutSdesAndDtlsDisabled[];
extern const char kSessionError[];
-extern const char kUpdateStateFailed[];
-extern const char kPushDownOfferTDFailed[];
-extern const char kPushDownPranswerTDFailed[];
-extern const char kPushDownAnswerTDFailed[];
+extern const char kSessionErrorDesc[];
// ICE state callback interface.
class IceObserver {
@@ -226,7 +222,6 @@ class WebRtcSession : public cricket::BaseSession,
// candidates allocation.
bool StartCandidatesAllocation();
bool UpdateSessionState(Action action, cricket::ContentSource source,
- const cricket::SessionDescription* desc,
std::string* err_desc);
static Action GetAction(const std::string& type);
@@ -285,7 +280,7 @@ class WebRtcSession : public cricket::BaseSession,
bool GetLocalTrackId(uint32 ssrc, std::string* track_id);
bool GetRemoteTrackId(uint32 ssrc, std::string* track_id);
- std::string BadStateErrMsg(const std::string& type, State state);
+ std::string BadStateErrMsg(State state);
void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state);
bool ValidateBundleSettings(const cricket::SessionDescription* desc);
@@ -293,7 +288,7 @@ class WebRtcSession : public cricket::BaseSession,
// Below methods are helper methods which verifies SDP.
bool ValidateSessionDescription(const SessionDescriptionInterface* sdesc,
cricket::ContentSource source,
- std::string* error_desc);
+ std::string* err_desc);
// Check if a call to SetLocalDescription is acceptable with |action|.
bool ExpectSetLocalDescription(Action action);
@@ -303,6 +298,8 @@ class WebRtcSession : public cricket::BaseSession,
bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc,
Action action);
+ std::string GetSessionErrorMsg();
+
talk_base::scoped_ptr<cricket::VoiceChannel> voice_channel_;
talk_base::scoped_ptr<cricket::VideoChannel> video_channel_;
talk_base::scoped_ptr<cricket::DataChannel> data_channel_;
diff --git a/app/webrtc/webrtcsession_unittest.cc b/app/webrtc/webrtcsession_unittest.cc
index 3fa4775..6d3a581 100644
--- a/app/webrtc/webrtcsession_unittest.cc
+++ b/app/webrtc/webrtcsession_unittest.cc
@@ -87,15 +87,15 @@ using webrtc::SessionDescriptionInterface;
using webrtc::StreamCollection;
using webrtc::WebRtcSession;
using webrtc::kBundleWithoutRtcpMux;
+using webrtc::kCreateChannelFailed;
+using webrtc::kInvalidSdp;
using webrtc::kMlineMismatch;
-using webrtc::kPushDownAnswerTDFailed;
-using webrtc::kPushDownPranswerTDFailed;
+using webrtc::kPushDownTDFailed;
using webrtc::kSdpWithoutCrypto;
using webrtc::kSdpWithoutIceUfragPwd;
using webrtc::kSdpWithoutSdesAndDtlsDisabled;
using webrtc::kSessionError;
-using webrtc::kSetLocalSdpFailed;
-using webrtc::kSetRemoteSdpFailed;
+using webrtc::kSessionErrorDesc;
static const int kClientAddrPort = 0;
static const char kClientAddrHost1[] = "11.11.11.11";
@@ -475,8 +475,8 @@ class WebRtcSessionTest : public testing::Test {
CreateRemoteOffer(options, cricket::SEC_DISABLED));
ASSERT_TRUE(offer != NULL);
VerifyNoCryptoParams(offer->description(), false);
- SetRemoteDescriptionExpectError("Called with a SDP without crypto enabled",
- offer);
+ SetRemoteDescriptionOfferExpectError(
+ "Called with a SDP without crypto enabled", offer);
const webrtc::SessionDescriptionInterface* answer = CreateAnswer(NULL);
// Answer should be NULL as no crypto params in offer.
ASSERT_TRUE(answer == NULL);
@@ -567,13 +567,26 @@ class WebRtcSessionTest : public testing::Test {
SetLocalDescriptionWithoutError(desc);
EXPECT_EQ(expected_state, session_->state());
}
- void SetLocalDescriptionExpectError(const std::string& expected_error,
+ void SetLocalDescriptionExpectError(const std::string& action,
+ const std::string& expected_error,
SessionDescriptionInterface* desc) {
std::string error;
EXPECT_FALSE(session_->SetLocalDescription(desc, &error));
- EXPECT_NE(std::string::npos, error.find(kSetLocalSdpFailed));
+ std::string sdp_type = "local ";
+ sdp_type.append(action);
+ EXPECT_NE(std::string::npos, error.find(sdp_type));
EXPECT_NE(std::string::npos, error.find(expected_error));
}
+ void SetLocalDescriptionOfferExpectError(const std::string& expected_error,
+ SessionDescriptionInterface* desc) {
+ SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer,
+ expected_error, desc);
+ }
+ void SetLocalDescriptionAnswerExpectError(const std::string& expected_error,
+ SessionDescriptionInterface* desc) {
+ SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer,
+ expected_error, desc);
+ }
void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) {
EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL));
}
@@ -582,13 +595,31 @@ class WebRtcSessionTest : public testing::Test {
SetRemoteDescriptionWithoutError(desc);
EXPECT_EQ(expected_state, session_->state());
}
- void SetRemoteDescriptionExpectError(const std::string& expected_error,
+ void SetRemoteDescriptionExpectError(const std::string& action,
+ const std::string& expected_error,
SessionDescriptionInterface* desc) {
std::string error;
EXPECT_FALSE(session_->SetRemoteDescription(desc, &error));
- EXPECT_NE(std::string::npos, error.find(kSetRemoteSdpFailed));
+ std::string sdp_type = "remote ";
+ sdp_type.append(action);
+ EXPECT_NE(std::string::npos, error.find(sdp_type));
EXPECT_NE(std::string::npos, error.find(expected_error));
}
+ void SetRemoteDescriptionOfferExpectError(
+ const std::string& expected_error, SessionDescriptionInterface* desc) {
+ SetRemoteDescriptionExpectError(SessionDescriptionInterface::kOffer,
+ expected_error, desc);
+ }
+ void SetRemoteDescriptionPranswerExpectError(
+ const std::string& expected_error, SessionDescriptionInterface* desc) {
+ SetRemoteDescriptionExpectError(SessionDescriptionInterface::kPrAnswer,
+ expected_error, desc);
+ }
+ void SetRemoteDescriptionAnswerExpectError(
+ const std::string& expected_error, SessionDescriptionInterface* desc) {
+ SetRemoteDescriptionExpectError(SessionDescriptionInterface::kAnswer,
+ expected_error, desc);
+ }
void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer,
SessionDescriptionInterface** nocrypto_answer) {
@@ -998,6 +1029,15 @@ TEST_F(WebRtcSessionTest, TestStunError) {
EXPECT_EQ(6u, observer_.mline_1_candidates_.size());
}
+TEST_F(WebRtcSessionTest, SetSdpFailedOnInvalidSdp) {
+ Init(NULL);
+ SessionDescriptionInterface* offer = NULL;
+ // Since |offer| is NULL, there's no way to tell if it's an offer or answer.
+ std::string unknown_action;
+ SetLocalDescriptionExpectError(unknown_action, kInvalidSdp, offer);
+ SetRemoteDescriptionExpectError(unknown_action, kInvalidSdp, offer);
+}
+
// Test creating offers and receive answers and make sure the
// media engine creates the expected send and receive streams.
TEST_F(WebRtcSessionTest, TestCreateOfferReceiveAnswer) {
@@ -1109,6 +1149,20 @@ TEST_F(WebRtcSessionTest, TestReceiveOfferCreateAnswer) {
EXPECT_EQ(0u, voice_channel_->send_streams().size());
}
+TEST_F(WebRtcSessionTest, SetLocalSdpFailedOnCreateChannel) {
+ Init(NULL);
+ media_engine_->set_fail_create_channel(true);
+
+ SessionDescriptionInterface* offer = CreateOffer(NULL);
+ ASSERT_TRUE(offer != NULL);
+ // SetRemoteDescription and SetLocalDescription will take the ownership of
+ // the offer.
+ SetRemoteDescriptionOfferExpectError(kCreateChannelFailed, offer);
+ offer = CreateOffer(NULL);
+ ASSERT_TRUE(offer != NULL);
+ SetLocalDescriptionOfferExpectError(kCreateChannelFailed, offer);
+}
+
// Test we will return fail when apply an offer that doesn't have
// crypto enabled.
TEST_F(WebRtcSessionTest, SetNonCryptoOffer) {
@@ -1121,10 +1175,10 @@ TEST_F(WebRtcSessionTest, SetNonCryptoOffer) {
VerifyNoCryptoParams(offer->description(), false);
// SetRemoteDescription and SetLocalDescription will take the ownership of
// the offer.
- SetRemoteDescriptionExpectError(kSdpWithoutCrypto, offer);
+ SetRemoteDescriptionOfferExpectError(kSdpWithoutCrypto, offer);
offer = CreateRemoteOffer(options, cricket::SEC_DISABLED);
ASSERT_TRUE(offer != NULL);
- SetLocalDescriptionExpectError(kSdpWithoutCrypto, offer);
+ SetLocalDescriptionOfferExpectError(kSdpWithoutCrypto, offer);
}
// Test we will return fail when apply an answer that doesn't have
@@ -1137,7 +1191,7 @@ TEST_F(WebRtcSessionTest, SetLocalNonCryptoAnswer) {
// SetRemoteDescription and SetLocalDescription will take the ownership of
// the offer.
SetRemoteDescriptionWithoutError(offer);
- SetLocalDescriptionExpectError(kSdpWithoutCrypto, answer);
+ SetLocalDescriptionAnswerExpectError(kSdpWithoutCrypto, answer);
}
// Test we will return fail when apply an answer that doesn't have
@@ -1150,7 +1204,7 @@ TEST_F(WebRtcSessionTest, SetRemoteNonCryptoAnswer) {
// SetRemoteDescription and SetLocalDescription will take the ownership of
// the offer.
SetLocalDescriptionWithoutError(offer);
- SetRemoteDescriptionExpectError(kSdpWithoutCrypto, answer);
+ SetRemoteDescriptionAnswerExpectError(kSdpWithoutCrypto, answer);
}
// Test that we can create and set an offer with a DTLS fingerprint.
@@ -1245,9 +1299,8 @@ TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) {
SessionDescriptionInterface* offer = CreateOffer(NULL);
SetLocalDescriptionWithoutError(offer);
offer = CreateOffer(NULL);
- SetRemoteDescriptionExpectError(
- "Called with type in wrong state, type: offer state: STATE_SENTINITIATE",
- offer);
+ SetRemoteDescriptionOfferExpectError(
+ "Called in wrong state: STATE_SENTINITIATE", offer);
}
TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) {
@@ -1256,10 +1309,8 @@ TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) {
SessionDescriptionInterface* offer = CreateOffer(NULL);
SetRemoteDescriptionWithoutError(offer);
offer = CreateOffer(NULL);
- SetLocalDescriptionExpectError(
- "Called with type in wrong state, type: "
- "offer state: STATE_RECEIVEDINITIATE",
- offer);
+ SetLocalDescriptionOfferExpectError(
+ "Called in wrong state: STATE_RECEIVEDINITIATE", offer);
}
TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) {
@@ -1319,9 +1370,8 @@ TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) {
CreateOffer(NULL));
SessionDescriptionInterface* answer =
CreateRemoteAnswer(offer.get());
- SetLocalDescriptionExpectError(
- "Called with type in wrong state, type: answer state: STATE_INIT",
- answer);
+ SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT",
+ answer);
}
TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithoutOffer) {
@@ -1331,9 +1381,8 @@ TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithoutOffer) {
CreateOffer(NULL));
SessionDescriptionInterface* answer =
CreateRemoteAnswer(offer.get());
- SetRemoteDescriptionExpectError(
- "Called with type in wrong state, type: answer state: STATE_INIT",
- answer);
+ SetRemoteDescriptionAnswerExpectError(
+ "Called in wrong state: STATE_INIT", answer);
}
TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) {
@@ -1979,7 +2028,7 @@ TEST_F(WebRtcSessionTest, TestSetLocalDescriptionWithoutIce) {
RemoveIceUfragPwdLines(offer.get(), &sdp);
SessionDescriptionInterface* modified_offer =
CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
- SetLocalDescriptionExpectError(kSdpWithoutIceUfragPwd, modified_offer);
+ SetLocalDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer);
}
// This test verifies that setRemoteDescription fails if
@@ -1991,7 +2040,7 @@ TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithoutIce) {
RemoveIceUfragPwdLines(offer.get(), &sdp);
SessionDescriptionInterface* modified_offer =
CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
- SetRemoteDescriptionExpectError(kSdpWithoutIceUfragPwd, modified_offer);
+ SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer);
}
TEST_F(WebRtcSessionTest, VerifyBundleFlagInPA) {
@@ -2071,11 +2120,11 @@ TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) {
JsepSessionDescription *local_offer =
new JsepSessionDescription(JsepSessionDescription::kOffer);
EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL));
- SetLocalDescriptionExpectError(kBundleWithoutRtcpMux, local_offer);
+ SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer);
JsepSessionDescription *remote_offer =
new JsepSessionDescription(JsepSessionDescription::kOffer);
EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL));
- SetRemoteDescriptionExpectError(kBundleWithoutRtcpMux, remote_offer);
+ SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer);
// Trying unmodified SDP.
SetLocalDescriptionWithoutError(offer);
}
@@ -2319,13 +2368,13 @@ TEST_F(WebRtcSessionTest, TestIceOfferGIceOnlyAnswer) {
SessionDescriptionInterface* pranswer_with_gice =
CreateSessionDescription(JsepSessionDescription::kPrAnswer,
original_offer_sdp, NULL);
- SetRemoteDescriptionExpectError(kPushDownPranswerTDFailed,
- pranswer_with_gice);
+ SetRemoteDescriptionPranswerExpectError(kPushDownTDFailed,
+ pranswer_with_gice);
SessionDescriptionInterface* answer_with_gice =
CreateSessionDescription(JsepSessionDescription::kAnswer,
original_offer_sdp, NULL);
- SetRemoteDescriptionExpectError(kPushDownAnswerTDFailed,
- answer_with_gice);
+ SetRemoteDescriptionAnswerExpectError(kPushDownTDFailed,
+ answer_with_gice);
}
// Verifing local offer and remote answer have matching m-lines as per RFC 3264.
@@ -2345,7 +2394,7 @@ TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) {
EXPECT_TRUE(modified_answer->Initialize(answer_copy,
answer->session_id(),
answer->session_version()));
- SetRemoteDescriptionExpectError(kMlineMismatch, modified_answer);
+ SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer);
// Modifying content names.
std::string sdp;
@@ -2361,7 +2410,7 @@ TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) {
SessionDescriptionInterface* modified_answer1 =
CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL);
- SetRemoteDescriptionExpectError(kMlineMismatch, modified_answer1);
+ SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer1);
SetRemoteDescriptionWithoutError(answer.release());
}
@@ -2383,7 +2432,7 @@ TEST_F(WebRtcSessionTest, TestIncorrectMLinesInLocalAnswer) {
EXPECT_TRUE(modified_answer->Initialize(answer_copy,
answer->session_id(),
answer->session_version()));
- SetLocalDescriptionExpectError(kMlineMismatch, modified_answer);
+ SetLocalDescriptionAnswerExpectError(kMlineMismatch, modified_answer);
SetLocalDescriptionWithoutError(answer);
}
@@ -2537,7 +2586,7 @@ TEST_F(WebRtcSessionTest, TestSessionContentError) {
mediastream_signaling_.SendAudioVideoStream2();
SessionDescriptionInterface* answer =
CreateRemoteAnswer(session_->local_description());
- SetRemoteDescriptionExpectError("ERROR_CONTENT", answer);
+ SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer);
}
// Runs the loopback call test with BUNDLE and STUN disabled.
@@ -2550,20 +2599,27 @@ TEST_F(WebRtcSessionTest, TestIceStatesBasic) {
TestLoopbackCall();
}
-// Regression-test for a crash which should have been an error.
-TEST_F(WebRtcSessionTest, TestNoStateTransitionPendingError) {
+TEST_F(WebRtcSessionTest, SetSdpFailedOnSessionError) {
Init(NULL);
cricket::MediaSessionOptions options;
options.has_audio = true;
options.has_video = true;
- session_->SetError(cricket::BaseSession::ERROR_CONTENT);
+ cricket::BaseSession::Error error_code = cricket::BaseSession::ERROR_CONTENT;
+ std::string error_code_str = "ERROR_CONTENT";
+ std::string error_desc = "Fake session error description.";
+ session_->SetError(error_code, error_desc);
+
SessionDescriptionInterface* offer = CreateRemoteOffer(options);
SessionDescriptionInterface* answer =
CreateRemoteAnswer(offer, options);
- SetRemoteDescriptionExpectError(kSessionError, offer);
- SetLocalDescriptionExpectError(kSessionError, answer);
- // Not crashing is our success.
+
+ std::string action;
+ std::ostringstream session_error_msg;
+ session_error_msg << kSessionError << error_code_str << ". ";
+ session_error_msg << kSessionErrorDesc << error_desc << ".";
+ SetRemoteDescriptionExpectError(action, session_error_msg.str(), offer);
+ SetLocalDescriptionExpectError(action, session_error_msg.str(), answer);
}
TEST_F(WebRtcSessionTest, TestRtpDataChannel) {
@@ -2803,8 +2859,8 @@ TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) {
audio->description.identity_fingerprint.reset(
talk_base::SSLFingerprint::CreateFromRfc4572(
talk_base::DIGEST_SHA_256, kFakeDtlsFingerprint));
- SetRemoteDescriptionExpectError(kSdpWithoutSdesAndDtlsDisabled,
- offer);
+ SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesAndDtlsDisabled,
+ offer);
}
// This test verifies DSCP is properly applied on the media channels.