Rename PeerConnection::Error to PeerConnection::SessionError
Also renames methods for interacting with the session error. This clarifies the scope of this error type and lets methods have a local variable named |error| without confusing it with the |error()| getter. Bug: webrtc:8587 Change-Id: I90e6eed24d961abbce15e56a76a8793ff1a806ea Reviewed-on: https://webrtc-review.googlesource.com/27124 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> Reviewed-by: Zhi Huang <zhihuang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21060}
This commit is contained in:
@ -576,24 +576,6 @@ std::string BadStateErrMsg(PeerConnectionInterface::SignalingState state) {
|
||||
return desc.str();
|
||||
}
|
||||
|
||||
#define GET_STRING_OF_ERROR_CODE(err) \
|
||||
case webrtc::PeerConnection::err: \
|
||||
result = #err; \
|
||||
break;
|
||||
|
||||
std::string GetErrorCodeString(webrtc::PeerConnection::Error err) {
|
||||
std::string result;
|
||||
switch (err) {
|
||||
GET_STRING_OF_ERROR_CODE(ERROR_NONE)
|
||||
GET_STRING_OF_ERROR_CODE(ERROR_CONTENT)
|
||||
GET_STRING_OF_ERROR_CODE(ERROR_TRANSPORT)
|
||||
default:
|
||||
RTC_NOTREACHED();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string MakeErrorString(const std::string& error, const std::string& desc) {
|
||||
std::ostringstream ret;
|
||||
ret << error << " " << desc;
|
||||
@ -3446,7 +3428,7 @@ bool PeerConnection::SetCurrentOrPendingLocalDescription(
|
||||
}
|
||||
|
||||
pending_ice_restarts_.clear();
|
||||
if (error() != ERROR_NONE) {
|
||||
if (session_error() != SessionError::kNone) {
|
||||
return BadLocalSdp(local_description()->type(), GetSessionErrorMsg(),
|
||||
err_desc);
|
||||
}
|
||||
@ -3535,7 +3517,7 @@ bool PeerConnection::SetCurrentOrPendingRemoteDescription(
|
||||
}
|
||||
}
|
||||
|
||||
if (error() != ERROR_NONE) {
|
||||
if (session_error() != SessionError::kNone) {
|
||||
return BadRemoteSdp(remote_description()->type(), GetSessionErrorMsg(),
|
||||
err_desc);
|
||||
}
|
||||
@ -3572,11 +3554,12 @@ std::vector<cricket::BaseChannel*> PeerConnection::Channels() const {
|
||||
return channels;
|
||||
}
|
||||
|
||||
void PeerConnection::SetError(Error error, const std::string& error_desc) {
|
||||
RTC_DCHECK(signaling_thread()->IsCurrent());
|
||||
if (error != error_) {
|
||||
error_ = error;
|
||||
error_desc_ = error_desc;
|
||||
void PeerConnection::SetSessionError(SessionError error,
|
||||
const std::string& error_desc) {
|
||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||
if (error != session_error_) {
|
||||
session_error_ = error;
|
||||
session_error_desc_ = error_desc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3587,7 +3570,7 @@ bool PeerConnection::UpdateSessionState(Action action,
|
||||
|
||||
// If there's already a pending error then no state transition should happen.
|
||||
// But all call-sites should be verifying this before calling us!
|
||||
RTC_DCHECK(error() == ERROR_NONE);
|
||||
RTC_DCHECK(session_error() == SessionError::kNone);
|
||||
std::string td_err;
|
||||
if (action == kOffer) {
|
||||
if (!PushdownTransportDescription(source, cricket::CA_OFFER, &td_err)) {
|
||||
@ -3597,9 +3580,9 @@ bool PeerConnection::UpdateSessionState(Action action,
|
||||
? PeerConnectionInterface::kHaveLocalOffer
|
||||
: PeerConnectionInterface::kHaveRemoteOffer);
|
||||
if (!PushdownMediaDescription(cricket::CA_OFFER, source, err_desc)) {
|
||||
SetError(ERROR_CONTENT, *err_desc);
|
||||
SetSessionError(SessionError::kContent, *err_desc);
|
||||
}
|
||||
if (error() != ERROR_NONE) {
|
||||
if (session_error() != SessionError::kNone) {
|
||||
return BadOfferSdp(source, GetSessionErrorMsg(), err_desc);
|
||||
}
|
||||
} else if (action == kPrAnswer) {
|
||||
@ -3611,9 +3594,9 @@ bool PeerConnection::UpdateSessionState(Action action,
|
||||
? PeerConnectionInterface::kHaveLocalPrAnswer
|
||||
: PeerConnectionInterface::kHaveRemotePrAnswer);
|
||||
if (!PushdownMediaDescription(cricket::CA_PRANSWER, source, err_desc)) {
|
||||
SetError(ERROR_CONTENT, *err_desc);
|
||||
SetSessionError(SessionError::kContent, *err_desc);
|
||||
}
|
||||
if (error() != ERROR_NONE) {
|
||||
if (session_error() != SessionError::kNone) {
|
||||
return BadPranswerSdp(source, GetSessionErrorMsg(), err_desc);
|
||||
}
|
||||
} else if (action == kAnswer) {
|
||||
@ -3640,9 +3623,9 @@ bool PeerConnection::UpdateSessionState(Action action,
|
||||
EnableChannels();
|
||||
ChangeSignalingState(PeerConnectionInterface::kStable);
|
||||
if (!PushdownMediaDescription(cricket::CA_ANSWER, source, err_desc)) {
|
||||
SetError(ERROR_CONTENT, *err_desc);
|
||||
SetSessionError(SessionError::kContent, *err_desc);
|
||||
}
|
||||
if (error() != ERROR_NONE) {
|
||||
if (session_error() != SessionError::kNone) {
|
||||
return BadAnswerSdp(source, GetSessionErrorMsg(), err_desc);
|
||||
}
|
||||
}
|
||||
@ -4044,8 +4027,8 @@ void PeerConnection::OnCertificateReady(
|
||||
}
|
||||
|
||||
void PeerConnection::OnDtlsSrtpSetupFailure(cricket::BaseChannel*, bool rtcp) {
|
||||
SetError(ERROR_TRANSPORT,
|
||||
rtcp ? kDtlsSrtpSetupFailureRtcp : kDtlsSrtpSetupFailureRtp);
|
||||
SetSessionError(SessionError::kTransport,
|
||||
rtcp ? kDtlsSrtpSetupFailureRtcp : kDtlsSrtpSetupFailureRtp);
|
||||
}
|
||||
|
||||
void PeerConnection::OnTransportControllerConnectionState(
|
||||
@ -4651,7 +4634,7 @@ bool PeerConnection::ValidateSessionDescription(
|
||||
cricket::ContentSource source,
|
||||
std::string* err_desc) {
|
||||
std::string type;
|
||||
if (error() != ERROR_NONE) {
|
||||
if (session_error() != SessionError::kNone) {
|
||||
return BadSdp(source, type, GetSessionErrorMsg(), err_desc);
|
||||
}
|
||||
|
||||
@ -4738,10 +4721,23 @@ bool PeerConnection::ExpectSetRemoteDescription(Action action) {
|
||||
}
|
||||
}
|
||||
|
||||
const char* PeerConnection::SessionErrorToString(SessionError error) const {
|
||||
switch (error) {
|
||||
case SessionError::kNone:
|
||||
return "ERROR_NONE";
|
||||
case SessionError::kContent:
|
||||
return "ERROR_CONTENT";
|
||||
case SessionError::kTransport:
|
||||
return "ERROR_TRANSPORT";
|
||||
}
|
||||
RTC_NOTREACHED();
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string PeerConnection::GetSessionErrorMsg() {
|
||||
std::ostringstream desc;
|
||||
desc << kSessionError << GetErrorCodeString(error()) << ". ";
|
||||
desc << kSessionErrorDesc << error_desc() << ".";
|
||||
desc << kSessionError << SessionErrorToString(session_error()) << ". ";
|
||||
desc << kSessionErrorDesc << session_error_desc() << ".";
|
||||
return desc.str();
|
||||
}
|
||||
|
||||
|
@ -278,12 +278,6 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
// factory, it shouldn't really be public).
|
||||
bool GetSslRole(const std::string& content_name, rtc::SSLRole* role);
|
||||
|
||||
enum Error {
|
||||
ERROR_NONE = 0, // no error
|
||||
ERROR_CONTENT = 1, // channel errors in SetLocalContent/SetRemoteContent
|
||||
ERROR_TRANSPORT = 2, // transport error of some kind
|
||||
};
|
||||
|
||||
protected:
|
||||
~PeerConnection() override;
|
||||
|
||||
@ -557,9 +551,15 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
kAnswer,
|
||||
};
|
||||
|
||||
enum class SessionError {
|
||||
kNone, // No error.
|
||||
kContent, // Error in BaseChannel SetLocalContent/SetRemoteContent.
|
||||
kTransport, // Error from the underlying transport.
|
||||
};
|
||||
|
||||
// Returns the last error in the session. See the enum above for details.
|
||||
Error error() const { return error_; }
|
||||
const std::string& error_desc() const { return error_desc_; }
|
||||
SessionError session_error() const { return session_error_; }
|
||||
const std::string& session_error_desc() const { return session_error_desc_; }
|
||||
|
||||
cricket::BaseChannel* GetChannel(const std::string& content_name);
|
||||
|
||||
@ -616,7 +616,7 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
}
|
||||
|
||||
// Updates the error state, signaling if necessary.
|
||||
void SetError(Error error, const std::string& error_desc);
|
||||
void SetSessionError(SessionError error, const std::string& error_desc);
|
||||
|
||||
bool UpdateSessionState(Action action,
|
||||
cricket::ContentSource source,
|
||||
@ -750,6 +750,7 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
const std::vector<cricket::Candidate>& candidates);
|
||||
void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error);
|
||||
|
||||
const char* SessionErrorToString(SessionError error) const;
|
||||
std::string GetSessionErrorMsg();
|
||||
|
||||
// Invoked when TransportController connection completion is signaled.
|
||||
@ -833,8 +834,8 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
|
||||
transceivers_;
|
||||
|
||||
Error error_ = ERROR_NONE;
|
||||
std::string error_desc_;
|
||||
SessionError session_error_ = SessionError::kNone;
|
||||
std::string session_error_desc_;
|
||||
|
||||
std::string session_id_;
|
||||
rtc::Optional<bool> initial_offerer_;
|
||||
|
Reference in New Issue
Block a user