From 47d657b68e753d7afb9656c1fa2f421674ed742d Mon Sep 17 00:00:00 2001 From: "mflodman@webrtc.org" Date: Thu, 19 Feb 2015 10:29:32 +0000 Subject: [PATCH] Remove Set/Get sending status from the default RTP module. This is now taken care of by the payload router and the calls to set_active. BUG=769 R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/42379004 Cr-Commit-Position: refs/heads/master@{#8427} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8427 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 40 ++++++++----------- webrtc/video_engine/payload_router.cc | 2 +- webrtc/video_engine/vie_channel.cc | 3 +- webrtc/video_engine/vie_encoder.cc | 8 +--- 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 98c9bf9713..fe5566bcfd 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -10,11 +10,11 @@ #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" -#include #include #include +#include "webrtc/base/checks.h" #include "webrtc/common_types.h" #include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/trace.h" @@ -115,7 +115,7 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration) ModuleRtpRtcpImpl::~ModuleRtpRtcpImpl() { // All child modules MUST be deleted before deleting the default. - assert(child_modules_.empty()); + DCHECK(child_modules_.empty()); // Deregister for the child modules. // Will go in to the default and remove it self. @@ -283,7 +283,7 @@ int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket( int32_t ModuleRtpRtcpImpl::RegisterSendPayload( const CodecInst& voice_codec) { - assert(!IsDefaultModule()); + DCHECK(!IsDefaultModule()); return rtp_sender_.RegisterPayload( voice_codec.plname, voice_codec.pltype, @@ -382,7 +382,7 @@ void ModuleRtpRtcpImpl::SetSSRC(const uint32_t ssrc) { } void ModuleRtpRtcpImpl::SetCsrcs(const std::vector& csrcs) { - assert(!IsDefaultModule()); + DCHECK(!IsDefaultModule()); rtcp_sender_.SetCsrcs(csrcs); rtp_sender_.SetCsrcs(csrcs); } @@ -419,6 +419,8 @@ int ModuleRtpRtcpImpl::CurrentSendFrequencyHz() const { } int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { + DCHECK(!IsDefaultModule()); + if (rtcp_sender_.Sending() != sending) { // Sends RTCP BYE when going from true to false if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) { @@ -447,28 +449,18 @@ int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { } bool ModuleRtpRtcpImpl::Sending() const { + DCHECK(!IsDefaultModule()); return rtcp_sender_.Sending(); } void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { + DCHECK(!IsDefaultModule()); rtp_sender_.SetSendingMediaStatus(sending); } bool ModuleRtpRtcpImpl::SendingMedia() const { - if (!IsDefaultModule()) { - return rtp_sender_.SendingMedia(); - } - - CriticalSectionScoped lock(critical_section_module_ptrs_.get()); - std::vector::const_iterator it = child_modules_.begin(); - while (it != child_modules_.end()) { - RTPSender& rtp_sender = (*it)->rtp_sender_; - if (rtp_sender.SendingMedia()) { - return true; - } - it++; - } - return false; + DCHECK(!IsDefaultModule()); + return rtp_sender_.SendingMedia(); } int32_t ModuleRtpRtcpImpl::SendOutgoingData( @@ -480,7 +472,7 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData( size_t payload_size, const RTPFragmentationHeader* fragmentation, const RTPVideoHeader* rtp_video_hdr) { - assert(!IsDefaultModule()); + DCHECK(!IsDefaultModule()); rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms); if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) { @@ -501,7 +493,7 @@ bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms, bool retransmission) { - assert(!IsDefaultModule()); + DCHECK(!IsDefaultModule()); if (SendingMedia() && ssrc == rtp_sender_.SSRC()) { return rtp_sender_.TimeToSendPacket( sequence_number, capture_time_ms, retransmission); @@ -511,14 +503,14 @@ bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, } size_t ModuleRtpRtcpImpl::TimeToSendPadding(size_t bytes) { - assert(!IsDefaultModule()); + DCHECK(!IsDefaultModule()); return rtp_sender_.TimeToSendPadding(bytes); } bool ModuleRtpRtcpImpl::GetSendSideDelay(int* avg_send_delay_ms, int* max_send_delay_ms) const { - assert(avg_send_delay_ms); - assert(max_send_delay_ms); + DCHECK(avg_send_delay_ms); + DCHECK(max_send_delay_ms); if (IsDefaultModule()) { // This API is only supported for child modules. @@ -532,7 +524,7 @@ uint16_t ModuleRtpRtcpImpl::MaxPayloadLength() const { } uint16_t ModuleRtpRtcpImpl::MaxDataPayloadLength() const { - assert(!IsDefaultModule()); + DCHECK(!IsDefaultModule()); return rtp_sender_.MaxDataPayloadLength(); } diff --git a/webrtc/video_engine/payload_router.cc b/webrtc/video_engine/payload_router.cc index 58a2fb4dc7..15ef0cc4ff 100644 --- a/webrtc/video_engine/payload_router.cc +++ b/webrtc/video_engine/payload_router.cc @@ -45,7 +45,7 @@ void PayloadRouter::set_active(bool active) { bool PayloadRouter::active() { CriticalSectionScoped cs(crit_.get()); - return active_; + return active_ && !rtp_modules_.empty(); } bool PayloadRouter::RoutePayload(FrameType frame_type, diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc index dcb9596d09..83e7152c7f 100644 --- a/webrtc/video_engine/vie_channel.cc +++ b/webrtc/video_engine/vie_channel.cc @@ -13,6 +13,7 @@ #include #include +#include "webrtc/base/checks.h" #include "webrtc/common.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" #include "webrtc/experiments.h" @@ -138,7 +139,7 @@ int32_t ViEChannel::Init() { if (sender_) { std::list send_rtp_modules(1, rtp_rtcp_.get()); send_payload_router_->SetSendingRtpModules(send_rtp_modules); - send_payload_router_->set_active(true); + DCHECK(!send_payload_router_->active()); } if (vcm_->InitializeReceiver() != 0) { return -1; diff --git a/webrtc/video_engine/vie_encoder.cc b/webrtc/video_engine/vie_encoder.cc index 90abacc164..dae03f05da 100644 --- a/webrtc/video_engine/vie_encoder.cc +++ b/webrtc/video_engine/vie_encoder.cc @@ -393,12 +393,6 @@ int32_t ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) { return -1; } - // Set this module as sending right away, let the slave module in the channel - // start and stop sending. - if (default_rtp_rtcp_->SetSendingStatus(true) != 0) { - return -1; - } - bitrate_controller_->SetBitrateObserver(bitrate_observer_.get(), video_codec.startBitrate * 1000, video_codec.minBitrate * 1000, @@ -521,7 +515,7 @@ void ViEEncoder::DeliverFrame(int id, const std::vector& csrcs) { DCHECK(send_payload_router_ != NULL); DCHECK(csrcs.empty()); - if (!default_rtp_rtcp_->SendingMedia() || !send_payload_router_->active()) { + if (!send_payload_router_->active()) { // We've paused or we have no channels attached, don't waste resources on // encoding. return;