Replace PeerConnection::Action with cricket::ContentAction
PeerConnection had an Action enum as a holdover from the WebRtcSession merge with the same members as cricket::ContentAction. Since ContentAction is used in more places outside of PeerConnection, this change removes the Action enum and replaces its use with cricket::ContentAction. Bug: webrtc:8587 Change-Id: I3e825fe285dbaf6b3f128eccde0f38864171af13 Reviewed-on: https://webrtc-review.googlesource.com/27321 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@{#21063}
This commit is contained in:
@ -532,6 +532,20 @@ bool CheckForRemoteIceRestart(const SessionDescriptionInterface* old_desc,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Converts from SessionDescriptionInterface type to cricket::ContentAction.
|
||||
cricket::ContentAction ContentActionFromSessionType(
|
||||
const std::string& session_type) {
|
||||
if (session_type == SessionDescriptionInterface::kOffer) {
|
||||
return cricket::CA_OFFER;
|
||||
} else if (session_type == SessionDescriptionInterface::kPrAnswer) {
|
||||
return cricket::CA_PRANSWER;
|
||||
} else if (session_type == SessionDescriptionInterface::kAnswer) {
|
||||
return cricket::CA_ANSWER;
|
||||
}
|
||||
RTC_NOTREACHED() << "unknown action type";
|
||||
return cricket::CA_OFFER;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Upon completion, posts a task to execute the callback of the
|
||||
@ -1517,9 +1531,9 @@ RTCError PeerConnection::ApplyLocalDescription(
|
||||
stats_->UpdateStats(kStatsOutputLevelStandard);
|
||||
|
||||
// Update the initial_offerer flag if this session is the initial_offerer.
|
||||
Action action = GetAction(desc->type());
|
||||
cricket::ContentAction action = ContentActionFromSessionType(desc->type());
|
||||
if (!initial_offerer_.has_value()) {
|
||||
initial_offerer_.emplace(action == kOffer);
|
||||
initial_offerer_.emplace(action == cricket::CA_OFFER);
|
||||
if (*initial_offerer_) {
|
||||
transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLING);
|
||||
} else {
|
||||
@ -1527,7 +1541,7 @@ RTCError PeerConnection::ApplyLocalDescription(
|
||||
}
|
||||
}
|
||||
|
||||
if (action == kAnswer) {
|
||||
if (action == cricket::CA_ANSWER) {
|
||||
current_local_description_ = std::move(desc);
|
||||
pending_local_description_ = nullptr;
|
||||
current_remote_description_ = std::move(pending_remote_description_);
|
||||
@ -1539,7 +1553,7 @@ RTCError PeerConnection::ApplyLocalDescription(
|
||||
RTC_DCHECK(local_description());
|
||||
|
||||
// Transport and Media channels will be created only when offer is set.
|
||||
if (action == kOffer) {
|
||||
if (action == cricket::CA_OFFER) {
|
||||
// TODO(mallinath) - Handle CreateChannel failure, as new local description
|
||||
// is applied. Restore back to old description.
|
||||
RTCError error = CreateChannels(local_description()->description());
|
||||
@ -1686,8 +1700,8 @@ RTCError PeerConnection::ApplyRemoteDescription(
|
||||
// Grab ownership of the description being replaced for the remainder of this
|
||||
// method, since it's used below as |old_remote_description|.
|
||||
std::unique_ptr<SessionDescriptionInterface> replaced_remote_description;
|
||||
Action action = GetAction(desc->type());
|
||||
if (action == kAnswer) {
|
||||
cricket::ContentAction action = ContentActionFromSessionType(desc->type());
|
||||
if (action == cricket::CA_ANSWER) {
|
||||
replaced_remote_description = pending_remote_description_
|
||||
? std::move(pending_remote_description_)
|
||||
: std::move(current_remote_description_);
|
||||
@ -1703,7 +1717,7 @@ RTCError PeerConnection::ApplyRemoteDescription(
|
||||
RTC_DCHECK(remote_description());
|
||||
|
||||
// Transport and Media channels will be created only when offer is set.
|
||||
if (action == kOffer) {
|
||||
if (action == cricket::CA_OFFER) {
|
||||
// TODO(mallinath) - Handle CreateChannel failure, as new local description
|
||||
// is applied. Restore back to old description.
|
||||
RTCError error = CreateChannels(remote_description()->description());
|
||||
@ -1737,7 +1751,7 @@ RTCError PeerConnection::ApplyRemoteDescription(
|
||||
// against the current description.
|
||||
if (CheckForRemoteIceRestart(old_remote_description, remote_description(),
|
||||
content.name)) {
|
||||
if (action == kOffer) {
|
||||
if (action == cricket::CA_OFFER) {
|
||||
pending_ice_restarts_.insert(content.name);
|
||||
}
|
||||
} else {
|
||||
@ -3479,7 +3493,7 @@ void PeerConnection::SetSessionError(SessionError error,
|
||||
}
|
||||
}
|
||||
|
||||
RTCError PeerConnection::UpdateSessionState(Action action,
|
||||
RTCError PeerConnection::UpdateSessionState(cricket::ContentAction action,
|
||||
cricket::ContentSource source) {
|
||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||
|
||||
@ -3487,7 +3501,7 @@ RTCError PeerConnection::UpdateSessionState(Action action,
|
||||
// But all call-sites should be verifying this before calling us!
|
||||
RTC_DCHECK(session_error() == SessionError::kNone);
|
||||
std::string td_err;
|
||||
if (action == kOffer) {
|
||||
if (action == cricket::CA_OFFER) {
|
||||
RTCError error = PushdownTransportDescription(source, cricket::CA_OFFER);
|
||||
if (!error.ok()) {
|
||||
return error;
|
||||
@ -3502,7 +3516,7 @@ RTCError PeerConnection::UpdateSessionState(Action action,
|
||||
if (session_error() != SessionError::kNone) {
|
||||
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR, GetSessionErrorMsg());
|
||||
}
|
||||
} else if (action == kPrAnswer) {
|
||||
} else if (action == cricket::CA_PRANSWER) {
|
||||
RTCError error = PushdownTransportDescription(source, cricket::CA_PRANSWER);
|
||||
if (!error.ok()) {
|
||||
return error;
|
||||
@ -3518,7 +3532,7 @@ RTCError PeerConnection::UpdateSessionState(Action action,
|
||||
if (session_error() != SessionError::kNone) {
|
||||
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR, GetSessionErrorMsg());
|
||||
}
|
||||
} else if (action == kAnswer) {
|
||||
} else if (action == cricket::CA_ANSWER) {
|
||||
const cricket::ContentGroup* local_bundle =
|
||||
local_description()->description()->GetGroupByName(
|
||||
cricket::GROUP_TYPE_BUNDLE);
|
||||
@ -3553,18 +3567,6 @@ RTCError PeerConnection::UpdateSessionState(Action action,
|
||||
return RTCError::OK();
|
||||
}
|
||||
|
||||
PeerConnection::Action PeerConnection::GetAction(const std::string& type) {
|
||||
if (type == SessionDescriptionInterface::kOffer) {
|
||||
return PeerConnection::kOffer;
|
||||
} else if (type == SessionDescriptionInterface::kPrAnswer) {
|
||||
return PeerConnection::kPrAnswer;
|
||||
} else if (type == SessionDescriptionInterface::kAnswer) {
|
||||
return PeerConnection::kAnswer;
|
||||
}
|
||||
RTC_NOTREACHED() << "unknown action type";
|
||||
return PeerConnection::kOffer;
|
||||
}
|
||||
|
||||
RTCError PeerConnection::PushdownMediaDescription(
|
||||
cricket::ContentAction action,
|
||||
cricket::ContentSource source) {
|
||||
@ -4542,7 +4544,7 @@ RTCError PeerConnection::ValidateSessionDescription(
|
||||
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, kInvalidSdp);
|
||||
}
|
||||
|
||||
Action action = GetAction(sdesc->type());
|
||||
cricket::ContentAction action = ContentActionFromSessionType(sdesc->type());
|
||||
if ((source == cricket::CS_LOCAL && !ExpectSetLocalDescription(action)) ||
|
||||
(source == cricket::CS_REMOTE && !ExpectSetRemoteDescription(action))) {
|
||||
LOG_AND_RETURN_ERROR(
|
||||
@ -4575,7 +4577,7 @@ RTCError PeerConnection::ValidateSessionDescription(
|
||||
// m-lines that do not rtcp-mux enabled.
|
||||
|
||||
// Verify m-lines in Answer when compared against Offer.
|
||||
if (action == kAnswer || action == kPrAnswer) {
|
||||
if (action == cricket::CA_ANSWER || action == cricket::CA_PRANSWER) {
|
||||
const cricket::SessionDescription* offer_desc =
|
||||
(source == cricket::CS_LOCAL) ? remote_description()->description()
|
||||
: local_description()->description();
|
||||
@ -4603,23 +4605,25 @@ RTCError PeerConnection::ValidateSessionDescription(
|
||||
return RTCError::OK();
|
||||
}
|
||||
|
||||
bool PeerConnection::ExpectSetLocalDescription(Action action) {
|
||||
bool PeerConnection::ExpectSetLocalDescription(cricket::ContentAction action) {
|
||||
PeerConnectionInterface::SignalingState state = signaling_state();
|
||||
if (action == kOffer) {
|
||||
if (action == cricket::CA_OFFER) {
|
||||
return (state == PeerConnectionInterface::kStable) ||
|
||||
(state == PeerConnectionInterface::kHaveLocalOffer);
|
||||
} else { // Answer or PrAnswer
|
||||
} else {
|
||||
RTC_DCHECK(action == cricket::CA_ANSWER || action == cricket::CA_PRANSWER);
|
||||
return (state == PeerConnectionInterface::kHaveRemoteOffer) ||
|
||||
(state == PeerConnectionInterface::kHaveLocalPrAnswer);
|
||||
}
|
||||
}
|
||||
|
||||
bool PeerConnection::ExpectSetRemoteDescription(Action action) {
|
||||
bool PeerConnection::ExpectSetRemoteDescription(cricket::ContentAction action) {
|
||||
PeerConnectionInterface::SignalingState state = signaling_state();
|
||||
if (action == kOffer) {
|
||||
if (action == cricket::CA_OFFER) {
|
||||
return (state == PeerConnectionInterface::kStable) ||
|
||||
(state == PeerConnectionInterface::kHaveRemoteOffer);
|
||||
} else { // Answer or PrAnswer.
|
||||
} else {
|
||||
RTC_DCHECK(action == cricket::CA_ANSWER || action == cricket::CA_PRANSWER);
|
||||
return (state == PeerConnectionInterface::kHaveLocalOffer) ||
|
||||
(state == PeerConnectionInterface::kHaveRemotePrAnswer);
|
||||
}
|
||||
|
@ -550,14 +550,6 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
cricket::ChannelManager* channel_manager() const;
|
||||
MetricsObserverInterface* metrics_observer() const;
|
||||
|
||||
// Indicates the type of SessionDescription in a call to SetLocalDescription
|
||||
// and SetRemoteDescription.
|
||||
enum Action {
|
||||
kOffer,
|
||||
kPrAnswer,
|
||||
kAnswer,
|
||||
};
|
||||
|
||||
enum class SessionError {
|
||||
kNone, // No error.
|
||||
kContent, // Error in BaseChannel SetLocalContent/SetRemoteContent.
|
||||
@ -615,8 +607,8 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
// Updates the error state, signaling if necessary.
|
||||
void SetSessionError(SessionError error, const std::string& error_desc);
|
||||
|
||||
RTCError UpdateSessionState(Action action, cricket::ContentSource source);
|
||||
Action GetAction(const std::string& type);
|
||||
RTCError UpdateSessionState(cricket::ContentAction action,
|
||||
cricket::ContentSource source);
|
||||
// Push the media parts of the local or remote session description
|
||||
// down to all of the channels.
|
||||
RTCError PushdownMediaDescription(cricket::ContentAction action,
|
||||
@ -703,12 +695,12 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
cricket::ContentSource source);
|
||||
|
||||
// Check if a call to SetLocalDescription is acceptable with |action|.
|
||||
bool ExpectSetLocalDescription(Action action);
|
||||
bool ExpectSetLocalDescription(cricket::ContentAction action);
|
||||
// Check if a call to SetRemoteDescription is acceptable with |action|.
|
||||
bool ExpectSetRemoteDescription(Action action);
|
||||
bool ExpectSetRemoteDescription(cricket::ContentAction action);
|
||||
// Verifies a=setup attribute as per RFC 5763.
|
||||
bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc,
|
||||
Action action);
|
||||
cricket::ContentAction action);
|
||||
|
||||
// Returns true if we are ready to push down the remote candidate.
|
||||
// |remote_desc| is the new remote description, or NULL if the current remote
|
||||
|
Reference in New Issue
Block a user