diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index cb67bbd8e5..6d963bad8f 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -744,12 +744,14 @@ class CreateSessionDescriptionObserverOperationWrapper RTC_DCHECK(observer_); } ~CreateSessionDescriptionObserverOperationWrapper() override { +#if RTC_DCHECK_IS_ON RTC_DCHECK(was_called_); +#endif } void OnSuccess(SessionDescriptionInterface* desc) override { +#if RTC_DCHECK_IS_ON RTC_DCHECK(!was_called_); -#ifdef RTC_DCHECK_IS_ON was_called_ = true; #endif // RTC_DCHECK_IS_ON // Completing the operation before invoking the observer allows the observer @@ -759,8 +761,8 @@ class CreateSessionDescriptionObserverOperationWrapper } void OnFailure(RTCError error) override { +#if RTC_DCHECK_IS_ON RTC_DCHECK(!was_called_); -#ifdef RTC_DCHECK_IS_ON was_called_ = true; #endif // RTC_DCHECK_IS_ON operation_complete_callback_(); @@ -768,7 +770,7 @@ class CreateSessionDescriptionObserverOperationWrapper } private: -#ifdef RTC_DCHECK_IS_ON +#if RTC_DCHECK_IS_ON bool was_called_ = false; #endif // RTC_DCHECK_IS_ON rtc::scoped_refptr observer_; @@ -2919,6 +2921,7 @@ SdpOfferAnswerHandler::AssociateTransceiver( const ContentInfo* old_local_content, const ContentInfo* old_remote_content) { RTC_DCHECK(IsUnifiedPlan()); +#if RTC_DCHECK_IS_ON // If this is an offer then the m= section might be recycled. If the m= // section is being recycled (defined as: rejected in the current local or // remote description and not rejected in new description), the transceiver @@ -2933,6 +2936,8 @@ SdpOfferAnswerHandler::AssociateTransceiver( // The transceiver should be disassociated in RemoveStoppedTransceivers() RTC_DCHECK(!old_transceiver); } +#endif + const MediaContentDescription* media_desc = content.media_description(); auto transceiver = transceivers().FindByMid(content.name); if (source == cricket::CS_LOCAL) { @@ -2984,6 +2989,9 @@ SdpOfferAnswerHandler::AssociateTransceiver( transceivers().StableState(transceiver)->set_newly_created(); } } + + RTC_DCHECK(transceiver); + // Check if the offer indicated simulcast but the answer rejected it. // This can happen when simulcast is not supported on the remote party. if (SimulcastIsRejected(old_local_content, *media_desc)) { @@ -2996,12 +3004,13 @@ SdpOfferAnswerHandler::AssociateTransceiver( } } } - RTC_DCHECK(transceiver); + if (transceiver->media_type() != media_desc->type()) { LOG_AND_RETURN_ERROR( RTCErrorType::INVALID_PARAMETER, "Transceiver type does not match media description type."); } + if (media_desc->HasSimulcast()) { std::vector layers = source == cricket::CS_LOCAL diff --git a/rtc_base/operations_chain.cc b/rtc_base/operations_chain.cc index 189b2373fb..f707d339b6 100644 --- a/rtc_base/operations_chain.cc +++ b/rtc_base/operations_chain.cc @@ -19,12 +19,14 @@ OperationsChain::CallbackHandle::CallbackHandle( : operations_chain_(std::move(operations_chain)) {} OperationsChain::CallbackHandle::~CallbackHandle() { +#if RTC_DCHECK_IS_ON RTC_DCHECK(has_run_); +#endif } void OperationsChain::CallbackHandle::OnOperationComplete() { +#if RTC_DCHECK_IS_ON RTC_DCHECK(!has_run_); -#ifdef RTC_DCHECK_IS_ON has_run_ = true; #endif // RTC_DCHECK_IS_ON operations_chain_->OnOperationComplete(); diff --git a/rtc_base/operations_chain.h b/rtc_base/operations_chain.h index a3768ddc25..a7252d46f0 100644 --- a/rtc_base/operations_chain.h +++ b/rtc_base/operations_chain.h @@ -51,11 +51,15 @@ class OperationWithFunctor final : public Operation { : functor_(std::forward(functor)), callback_(std::move(callback)) {} - ~OperationWithFunctor() override { RTC_DCHECK(has_run_); } + ~OperationWithFunctor() override { +#if RTC_DCHECK_IS_ON + RTC_DCHECK(has_run_); +#endif // RTC_DCHECK_IS_ON + } void Run() override { +#if RTC_DCHECK_IS_ON RTC_DCHECK(!has_run_); -#ifdef RTC_DCHECK_IS_ON has_run_ = true; #endif // RTC_DCHECK_IS_ON // The functor being executed may invoke the callback synchronously, @@ -71,7 +75,7 @@ class OperationWithFunctor final : public Operation { private: typename std::remove_reference::type functor_; std::function callback_; -#ifdef RTC_DCHECK_IS_ON +#if RTC_DCHECK_IS_ON bool has_run_ = false; #endif // RTC_DCHECK_IS_ON }; @@ -168,7 +172,7 @@ class OperationsChain final : public RefCountedObject { private: scoped_refptr operations_chain_; -#ifdef RTC_DCHECK_IS_ON +#if RTC_DCHECK_IS_ON bool has_run_ = false; #endif // RTC_DCHECK_IS_ON