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
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 98c9bf9..fe5566b 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 <assert.h>
#include <string.h>
#include <set>
+#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() {
// 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::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::SetCsrcs(const std::vector<uint32_t>& csrcs) {
- assert(!IsDefaultModule());
+ DCHECK(!IsDefaultModule());
rtcp_sender_.SetCsrcs(csrcs);
rtp_sender_.SetCsrcs(csrcs);
}
@@ -419,6 +419,8 @@
}
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 @@
}
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<ModuleRtpRtcpImpl*>::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 @@
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 @@
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 @@
}
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::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 58a2fb4..15ef0cc 100644
--- a/webrtc/video_engine/payload_router.cc
+++ b/webrtc/video_engine/payload_router.cc
@@ -45,7 +45,7 @@
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 dcb9596..83e7152 100644
--- a/webrtc/video_engine/vie_channel.cc
+++ b/webrtc/video_engine/vie_channel.cc
@@ -13,6 +13,7 @@
#include <algorithm>
#include <vector>
+#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 @@
if (sender_) {
std::list<RtpRtcp*> 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 90abacc..dae03f0 100644
--- a/webrtc/video_engine/vie_encoder.cc
+++ b/webrtc/video_engine/vie_encoder.cc
@@ -393,12 +393,6 @@
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 @@
const std::vector<uint32_t>& 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;