Also fail CreateOffer and CreateAnswer if there is a session error
Bug: chromium:974509 Change-Id: I952047dcf1e0fe5f3655bd94ea4b47c76655d262 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143843 Reviewed-by: Bjorn Mellem <mellem@webrtc.org> Commit-Queue: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28375}
This commit is contained in:
parent
9a5c2e82eb
commit
25ca0ac73d
@ -1973,6 +1973,17 @@ void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer,
|
||||
return;
|
||||
}
|
||||
|
||||
// If a session error has occurred the PeerConnection is in a possibly
|
||||
// inconsistent state so fail right away.
|
||||
if (session_error() != SessionError::kNone) {
|
||||
std::string error_message = GetSessionErrorMsg();
|
||||
RTC_LOG(LS_ERROR) << "CreateOffer: " << error_message;
|
||||
PostCreateSessionDescriptionFailure(
|
||||
observer,
|
||||
RTCError(RTCErrorType::INTERNAL_ERROR, std::move(error_message)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidateOfferAnswerOptions(options)) {
|
||||
std::string error = "CreateOffer called with invalid options.";
|
||||
RTC_LOG(LS_ERROR) << error;
|
||||
@ -2079,6 +2090,17 @@ void PeerConnection::CreateAnswer(CreateSessionDescriptionObserver* observer,
|
||||
return;
|
||||
}
|
||||
|
||||
// If a session error has occurred the PeerConnection is in a possibly
|
||||
// inconsistent state so fail right away.
|
||||
if (session_error() != SessionError::kNone) {
|
||||
std::string error_message = GetSessionErrorMsg();
|
||||
RTC_LOG(LS_ERROR) << "CreateAnswer: " << error_message;
|
||||
PostCreateSessionDescriptionFailure(
|
||||
observer,
|
||||
RTCError(RTCErrorType::INTERNAL_ERROR, std::move(error_message)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(signaling_state_ == kHaveRemoteOffer ||
|
||||
signaling_state_ == kHaveLocalPrAnswer)) {
|
||||
std::string error =
|
||||
|
||||
@ -720,7 +720,8 @@ TEST_P(PeerConnectionCryptoTest, SessionErrorIfFingerprintInvalid) {
|
||||
ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
|
||||
|
||||
// Create an invalid answer with the other certificate's fingerprint.
|
||||
auto invalid_answer = callee->CreateAnswer();
|
||||
auto valid_answer = callee->CreateAnswer();
|
||||
auto invalid_answer = CloneSessionDescription(valid_answer.get());
|
||||
auto* audio_content =
|
||||
cricket::GetFirstAudioContent(invalid_answer->description());
|
||||
ASSERT_TRUE(audio_content);
|
||||
@ -741,7 +742,7 @@ TEST_P(PeerConnectionCryptoTest, SessionErrorIfFingerprintInvalid) {
|
||||
ASSERT_FALSE(callee->SetRemoteDescription(caller->CreateOffer(), &error));
|
||||
EXPECT_PRED_FORMAT2(AssertStringContains, error,
|
||||
"Session error code: ERROR_CONTENT.");
|
||||
ASSERT_FALSE(callee->SetLocalDescription(callee->CreateAnswer(), &error));
|
||||
ASSERT_FALSE(callee->SetLocalDescription(std::move(valid_answer), &error));
|
||||
EXPECT_PRED_FORMAT2(AssertStringContains, error,
|
||||
"Session error code: ERROR_CONTENT.");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user