Remove the default RTP module.
This CL removes the default module owned by ViEEncoder, functionality in the module to register default modules and the final changes in rtp_rtcp_impl using default/child modules. BUG=769 R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/42509004 Cr-Commit-Position: refs/heads/master@{#8514} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8514 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
3e6e271ec3
commit
9dd0ebc379
@ -55,7 +55,6 @@ class RtpRtcp : public Module {
|
||||
int32_t id;
|
||||
bool audio;
|
||||
Clock* clock;
|
||||
RtpRtcp* default_module;
|
||||
ReceiveStatistics* receive_statistics;
|
||||
Transport* outgoing_transport;
|
||||
RtcpIntraFrameObserver* intra_frame_callback;
|
||||
@ -196,7 +195,8 @@ class RtpRtcp : public Module {
|
||||
*/
|
||||
virtual void SetSequenceNumber(uint16_t seq) = 0;
|
||||
|
||||
virtual void SetRtpStateForSsrc(uint32_t ssrc,
|
||||
// Returns true if the ssrc matched this module, false otherwise.
|
||||
virtual bool SetRtpStateForSsrc(uint32_t ssrc,
|
||||
const RtpState& rtp_state) = 0;
|
||||
virtual bool GetRtpStateForSsrc(uint32_t ssrc, RtpState* rtp_state) = 0;
|
||||
|
||||
|
@ -82,7 +82,7 @@ class MockRtpRtcp : public RtpRtcp {
|
||||
uint16_t());
|
||||
MOCK_METHOD1(SetSequenceNumber, void(const uint16_t seq));
|
||||
MOCK_METHOD2(SetRtpStateForSsrc,
|
||||
void(uint32_t ssrc, const RtpState& rtp_state));
|
||||
bool(uint32_t ssrc, const RtpState& rtp_state));
|
||||
MOCK_METHOD2(GetRtpStateForSsrc, bool(uint32_t ssrc, RtpState* rtp_state));
|
||||
MOCK_CONST_METHOD0(SSRC,
|
||||
uint32_t());
|
||||
|
@ -30,7 +30,6 @@ RtpRtcp::Configuration::Configuration()
|
||||
: id(-1),
|
||||
audio(false),
|
||||
clock(NULL),
|
||||
default_module(NULL),
|
||||
receive_statistics(NullObjectReceiveStatistics()),
|
||||
outgoing_transport(NULL),
|
||||
intra_frame_callback(NULL),
|
||||
@ -87,18 +86,11 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
||||
last_bitrate_process_time_(configuration.clock->TimeInMilliseconds()),
|
||||
last_rtt_process_time_(configuration.clock->TimeInMilliseconds()),
|
||||
packet_overhead_(28), // IPV4 UDP.
|
||||
critical_section_module_ptrs_(
|
||||
CriticalSectionWrapper::CreateCriticalSection()),
|
||||
critical_section_module_ptrs_feedback_(
|
||||
CriticalSectionWrapper::CreateCriticalSection()),
|
||||
default_module_(
|
||||
static_cast<ModuleRtpRtcpImpl*>(configuration.default_module)),
|
||||
padding_index_(static_cast<size_t>(-1)), // Start padding at first child.
|
||||
nack_method_(kNackOff),
|
||||
nack_last_time_sent_full_(0),
|
||||
nack_last_time_sent_full_prev_(0),
|
||||
nack_last_seq_number_sent_(0),
|
||||
simulcast_(false),
|
||||
key_frame_req_method_(kKeyFrameReqFirRtp),
|
||||
remote_bitrate_(configuration.remote_bitrate_estimator),
|
||||
rtt_stats_(configuration.rtt_stats),
|
||||
@ -106,9 +98,6 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
||||
rtt_ms_(0) {
|
||||
send_video_codec_.codecType = kVideoCodecUnknown;
|
||||
|
||||
if (default_module_) {
|
||||
default_module_->RegisterChildModule(this);
|
||||
}
|
||||
// TODO(pwestin) move to constructors of each rtp/rtcp sender/receiver object.
|
||||
rtcp_sender_.RegisterSendTransport(configuration.outgoing_transport);
|
||||
|
||||
@ -118,47 +107,6 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
||||
SetRtcpReceiverSsrcs(SSRC);
|
||||
}
|
||||
|
||||
ModuleRtpRtcpImpl::~ModuleRtpRtcpImpl() {
|
||||
// All child modules MUST be deleted before deleting the default.
|
||||
DCHECK(child_modules_.empty());
|
||||
|
||||
// Deregister for the child modules.
|
||||
// Will go in to the default and remove it self.
|
||||
if (default_module_) {
|
||||
default_module_->DeRegisterChildModule(this);
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleRtpRtcpImpl::RegisterChildModule(RtpRtcp* module) {
|
||||
CriticalSectionScoped lock(
|
||||
critical_section_module_ptrs_.get());
|
||||
CriticalSectionScoped double_lock(
|
||||
critical_section_module_ptrs_feedback_.get());
|
||||
|
||||
// We use two locks for protecting child_modules_, one
|
||||
// (critical_section_module_ptrs_feedback_) for incoming
|
||||
// messages (BitrateSent) and critical_section_module_ptrs_
|
||||
// for all outgoing messages sending packets etc.
|
||||
child_modules_.push_back(static_cast<ModuleRtpRtcpImpl*>(module));
|
||||
}
|
||||
|
||||
void ModuleRtpRtcpImpl::DeRegisterChildModule(RtpRtcp* remove_module) {
|
||||
CriticalSectionScoped lock(
|
||||
critical_section_module_ptrs_.get());
|
||||
CriticalSectionScoped double_lock(
|
||||
critical_section_module_ptrs_feedback_.get());
|
||||
|
||||
std::vector<ModuleRtpRtcpImpl*>::iterator it = child_modules_.begin();
|
||||
while (it != child_modules_.end()) {
|
||||
RtpRtcp* module = *it;
|
||||
if (module == remove_module) {
|
||||
child_modules_.erase(it);
|
||||
return;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the number of milliseconds until the module want a worker thread
|
||||
// to call Process.
|
||||
int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() {
|
||||
@ -178,71 +126,67 @@ int32_t ModuleRtpRtcpImpl::Process() {
|
||||
last_bitrate_process_time_ = now;
|
||||
}
|
||||
|
||||
if (!IsDefaultModule()) {
|
||||
const int64_t kRtpRtcpRttProcessTimeMs = 1000;
|
||||
bool process_rtt = now >= last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs;
|
||||
if (rtcp_sender_.Sending()) {
|
||||
// Process RTT if we have received a receiver report and we haven't
|
||||
// processed RTT for at least |kRtpRtcpRttProcessTimeMs| milliseconds.
|
||||
if (rtcp_receiver_.LastReceivedReceiverReport() >
|
||||
last_rtt_process_time_ && process_rtt) {
|
||||
std::vector<RTCPReportBlock> receive_blocks;
|
||||
rtcp_receiver_.StatisticsReceived(&receive_blocks);
|
||||
int64_t max_rtt = 0;
|
||||
for (std::vector<RTCPReportBlock>::iterator it = receive_blocks.begin();
|
||||
it != receive_blocks.end(); ++it) {
|
||||
int64_t rtt = 0;
|
||||
rtcp_receiver_.RTT(it->remoteSSRC, &rtt, NULL, NULL, NULL);
|
||||
max_rtt = (rtt > max_rtt) ? rtt : max_rtt;
|
||||
}
|
||||
// Report the rtt.
|
||||
if (rtt_stats_ && max_rtt != 0)
|
||||
rtt_stats_->OnRttUpdate(max_rtt);
|
||||
}
|
||||
|
||||
// Verify receiver reports are delivered and the reported sequence number
|
||||
// is increasing.
|
||||
int64_t rtcp_interval = RtcpReportInterval();
|
||||
if (rtcp_receiver_.RtcpRrTimeout(rtcp_interval)) {
|
||||
LOG_F(LS_WARNING) << "Timeout: No RTCP RR received.";
|
||||
} else if (rtcp_receiver_.RtcpRrSequenceNumberTimeout(rtcp_interval)) {
|
||||
LOG_F(LS_WARNING) <<
|
||||
"Timeout: No increase in RTCP RR extended highest sequence number.";
|
||||
}
|
||||
|
||||
if (remote_bitrate_ && rtcp_sender_.TMMBR()) {
|
||||
unsigned int target_bitrate = 0;
|
||||
std::vector<unsigned int> ssrcs;
|
||||
if (remote_bitrate_->LatestEstimate(&ssrcs, &target_bitrate)) {
|
||||
if (!ssrcs.empty()) {
|
||||
target_bitrate = target_bitrate / ssrcs.size();
|
||||
}
|
||||
rtcp_sender_.SetTargetBitrate(target_bitrate);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Report rtt from receiver.
|
||||
if (process_rtt) {
|
||||
int64_t rtt_ms;
|
||||
if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) {
|
||||
rtt_stats_->OnRttUpdate(rtt_ms);
|
||||
}
|
||||
const int64_t kRtpRtcpRttProcessTimeMs = 1000;
|
||||
bool process_rtt = now >= last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs;
|
||||
if (rtcp_sender_.Sending()) {
|
||||
// Process RTT if we have received a receiver report and we haven't
|
||||
// processed RTT for at least |kRtpRtcpRttProcessTimeMs| milliseconds.
|
||||
if (rtcp_receiver_.LastReceivedReceiverReport() >
|
||||
last_rtt_process_time_ && process_rtt) {
|
||||
std::vector<RTCPReportBlock> receive_blocks;
|
||||
rtcp_receiver_.StatisticsReceived(&receive_blocks);
|
||||
int64_t max_rtt = 0;
|
||||
for (std::vector<RTCPReportBlock>::iterator it = receive_blocks.begin();
|
||||
it != receive_blocks.end(); ++it) {
|
||||
int64_t rtt = 0;
|
||||
rtcp_receiver_.RTT(it->remoteSSRC, &rtt, NULL, NULL, NULL);
|
||||
max_rtt = (rtt > max_rtt) ? rtt : max_rtt;
|
||||
}
|
||||
// Report the rtt.
|
||||
if (rtt_stats_ && max_rtt != 0)
|
||||
rtt_stats_->OnRttUpdate(max_rtt);
|
||||
}
|
||||
|
||||
// Get processed rtt.
|
||||
// Verify receiver reports are delivered and the reported sequence number
|
||||
// is increasing.
|
||||
int64_t rtcp_interval = RtcpReportInterval();
|
||||
if (rtcp_receiver_.RtcpRrTimeout(rtcp_interval)) {
|
||||
LOG_F(LS_WARNING) << "Timeout: No RTCP RR received.";
|
||||
} else if (rtcp_receiver_.RtcpRrSequenceNumberTimeout(rtcp_interval)) {
|
||||
LOG_F(LS_WARNING) <<
|
||||
"Timeout: No increase in RTCP RR extended highest sequence number.";
|
||||
}
|
||||
|
||||
if (remote_bitrate_ && rtcp_sender_.TMMBR()) {
|
||||
unsigned int target_bitrate = 0;
|
||||
std::vector<unsigned int> ssrcs;
|
||||
if (remote_bitrate_->LatestEstimate(&ssrcs, &target_bitrate)) {
|
||||
if (!ssrcs.empty()) {
|
||||
target_bitrate = target_bitrate / ssrcs.size();
|
||||
}
|
||||
rtcp_sender_.SetTargetBitrate(target_bitrate);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Report rtt from receiver.
|
||||
if (process_rtt) {
|
||||
last_rtt_process_time_ = now;
|
||||
if (rtt_stats_) {
|
||||
set_rtt_ms(rtt_stats_->LastProcessedRtt());
|
||||
}
|
||||
}
|
||||
|
||||
if (rtcp_sender_.TimeToSendRTCPReport()) {
|
||||
rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport);
|
||||
int64_t rtt_ms;
|
||||
if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) {
|
||||
rtt_stats_->OnRttUpdate(rtt_ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get processed rtt.
|
||||
if (process_rtt) {
|
||||
last_rtt_process_time_ = now;
|
||||
if (rtt_stats_)
|
||||
set_rtt_ms(rtt_stats_->LastProcessedRtt());
|
||||
}
|
||||
|
||||
if (rtcp_sender_.TimeToSendRTCPReport())
|
||||
rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport);
|
||||
|
||||
if (UpdateRTCPReceiveInformationTimers()) {
|
||||
// A receiver has timed out
|
||||
rtcp_receiver_.UpdateTMMBR();
|
||||
@ -288,7 +232,6 @@ int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
|
||||
|
||||
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
|
||||
const CodecInst& voice_codec) {
|
||||
DCHECK(!IsDefaultModule());
|
||||
return rtp_sender_.RegisterPayload(
|
||||
voice_codec.plname,
|
||||
voice_codec.pltype,
|
||||
@ -299,12 +242,6 @@ int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
|
||||
|
||||
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const VideoCodec& video_codec) {
|
||||
send_video_codec_ = video_codec;
|
||||
{
|
||||
// simulcast_ is accessed when accessing child_modules_, so this write needs
|
||||
// to be protected by the same lock.
|
||||
CriticalSectionScoped lock(critical_section_module_ptrs_.get());
|
||||
simulcast_ = video_codec.numberOfSimulcastStreams > 1;
|
||||
}
|
||||
return rtp_sender_.RegisterPayload(video_codec.plName,
|
||||
video_codec.plType,
|
||||
90000,
|
||||
@ -339,21 +276,17 @@ void ModuleRtpRtcpImpl::SetSequenceNumber(const uint16_t seq_num) {
|
||||
rtp_sender_.SetSequenceNumber(seq_num);
|
||||
}
|
||||
|
||||
void ModuleRtpRtcpImpl::SetRtpStateForSsrc(uint32_t ssrc,
|
||||
bool ModuleRtpRtcpImpl::SetRtpStateForSsrc(uint32_t ssrc,
|
||||
const RtpState& rtp_state) {
|
||||
if (rtp_sender_.SSRC() == ssrc) {
|
||||
rtp_sender_.SetRtpState(rtp_state);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (rtp_sender_.RtxSsrc() == ssrc) {
|
||||
rtp_sender_.SetRtxRtpState(rtp_state);
|
||||
return;
|
||||
}
|
||||
|
||||
CriticalSectionScoped lock(critical_section_module_ptrs_.get());
|
||||
for (size_t i = 0; i < child_modules_.size(); ++i) {
|
||||
child_modules_[i]->SetRtpStateForSsrc(ssrc, rtp_state);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ModuleRtpRtcpImpl::GetRtpStateForSsrc(uint32_t ssrc, RtpState* rtp_state) {
|
||||
@ -361,17 +294,10 @@ bool ModuleRtpRtcpImpl::GetRtpStateForSsrc(uint32_t ssrc, RtpState* rtp_state) {
|
||||
*rtp_state = rtp_sender_.GetRtpState();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rtp_sender_.RtxSsrc() == ssrc) {
|
||||
*rtp_state = rtp_sender_.GetRtxRtpState();
|
||||
return true;
|
||||
}
|
||||
|
||||
CriticalSectionScoped lock(critical_section_module_ptrs_.get());
|
||||
for (size_t i = 0; i < child_modules_.size(); ++i) {
|
||||
if (child_modules_[i]->GetRtpStateForSsrc(ssrc, rtp_state))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -387,7 +313,6 @@ void ModuleRtpRtcpImpl::SetSSRC(const uint32_t ssrc) {
|
||||
}
|
||||
|
||||
void ModuleRtpRtcpImpl::SetCsrcs(const std::vector<uint32_t>& csrcs) {
|
||||
DCHECK(!IsDefaultModule());
|
||||
rtcp_sender_.SetCsrcs(csrcs);
|
||||
rtp_sender_.SetCsrcs(csrcs);
|
||||
}
|
||||
@ -424,8 +349,6 @@ 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) {
|
||||
@ -454,17 +377,14 @@ 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 {
|
||||
DCHECK(!IsDefaultModule());
|
||||
return rtp_sender_.SendingMedia();
|
||||
}
|
||||
|
||||
@ -477,8 +397,6 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData(
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation,
|
||||
const RTPVideoHeader* rtp_video_hdr) {
|
||||
DCHECK(!IsDefaultModule());
|
||||
|
||||
rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms);
|
||||
if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) {
|
||||
rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport);
|
||||
@ -498,7 +416,6 @@ bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc,
|
||||
uint16_t sequence_number,
|
||||
int64_t capture_time_ms,
|
||||
bool retransmission) {
|
||||
DCHECK(!IsDefaultModule());
|
||||
if (SendingMedia() && ssrc == rtp_sender_.SSRC()) {
|
||||
return rtp_sender_.TimeToSendPacket(
|
||||
sequence_number, capture_time_ms, retransmission);
|
||||
@ -508,7 +425,6 @@ bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc,
|
||||
}
|
||||
|
||||
size_t ModuleRtpRtcpImpl::TimeToSendPadding(size_t bytes) {
|
||||
DCHECK(!IsDefaultModule());
|
||||
return rtp_sender_.TimeToSendPadding(bytes);
|
||||
}
|
||||
|
||||
@ -516,11 +432,6 @@ bool ModuleRtpRtcpImpl::GetSendSideDelay(int* avg_send_delay_ms,
|
||||
int* max_send_delay_ms) const {
|
||||
DCHECK(avg_send_delay_ms);
|
||||
DCHECK(max_send_delay_ms);
|
||||
|
||||
if (IsDefaultModule()) {
|
||||
// This API is only supported for child modules.
|
||||
return false;
|
||||
}
|
||||
return rtp_sender_.GetSendSideDelay(avg_send_delay_ms, max_send_delay_ms);
|
||||
}
|
||||
|
||||
@ -529,7 +440,6 @@ uint16_t ModuleRtpRtcpImpl::MaxPayloadLength() const {
|
||||
}
|
||||
|
||||
uint16_t ModuleRtpRtcpImpl::MaxDataPayloadLength() const {
|
||||
DCHECK(!IsDefaultModule());
|
||||
return rtp_sender_.MaxDataPayloadLength();
|
||||
}
|
||||
|
||||
@ -895,7 +805,6 @@ int32_t ModuleRtpRtcpImpl::SendREDPayloadType(
|
||||
}
|
||||
|
||||
void ModuleRtpRtcpImpl::SetTargetSendBitrate(uint32_t bitrate_bps) {
|
||||
DCHECK(!IsDefaultModule());
|
||||
rtp_sender_.SetTargetBitrate(bitrate_bps);
|
||||
}
|
||||
|
||||
@ -936,41 +845,13 @@ int32_t ModuleRtpRtcpImpl::GenericFECStatus(
|
||||
bool& enable,
|
||||
uint8_t& payload_type_red,
|
||||
uint8_t& payload_type_fec) {
|
||||
bool child_enabled = false;
|
||||
if (IsDefaultModule()) {
|
||||
// For default we need to check all child modules too.
|
||||
CriticalSectionScoped lock(critical_section_module_ptrs_.get());
|
||||
std::vector<ModuleRtpRtcpImpl*>::iterator it = child_modules_.begin();
|
||||
while (it != child_modules_.end()) {
|
||||
RtpRtcp* module = *it;
|
||||
if (module) {
|
||||
bool enabled = false;
|
||||
uint8_t dummy_ptype_red = 0;
|
||||
uint8_t dummy_ptype_fec = 0;
|
||||
if (module->GenericFECStatus(enabled,
|
||||
dummy_ptype_red,
|
||||
dummy_ptype_fec) == 0 && enabled) {
|
||||
child_enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
int32_t ret_val = rtp_sender_.GenericFECStatus(&enable,
|
||||
&payload_type_red,
|
||||
&payload_type_fec);
|
||||
if (child_enabled) {
|
||||
// Returns true if enabled for any child module.
|
||||
enable = child_enabled;
|
||||
}
|
||||
return ret_val;
|
||||
return rtp_sender_.GenericFECStatus(&enable, &payload_type_red,
|
||||
&payload_type_fec);
|
||||
}
|
||||
|
||||
int32_t ModuleRtpRtcpImpl::SetFecParameters(
|
||||
const FecProtectionParams* delta_params,
|
||||
const FecProtectionParams* key_params) {
|
||||
DCHECK(!IsDefaultModule());
|
||||
return rtp_sender_.SetFecParameters(delta_params, key_params);
|
||||
}
|
||||
|
||||
@ -1002,7 +883,6 @@ void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate,
|
||||
uint32_t* video_rate,
|
||||
uint32_t* fec_rate,
|
||||
uint32_t* nack_rate) const {
|
||||
DCHECK(!IsDefaultModule());
|
||||
*total_rate = rtp_sender_.BitrateSent();
|
||||
*video_rate = rtp_sender_.VideoBitrateSent();
|
||||
*fec_rate = rtp_sender_.FecOverheadRate();
|
||||
@ -1118,10 +998,4 @@ StreamDataCountersCallback*
|
||||
ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const {
|
||||
return rtp_sender_.GetRtpStatisticsCallback();
|
||||
}
|
||||
|
||||
bool ModuleRtpRtcpImpl::IsDefaultModule() const {
|
||||
CriticalSectionScoped cs(critical_section_module_ptrs_.get());
|
||||
return !child_modules_.empty();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -27,8 +27,6 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
public:
|
||||
explicit ModuleRtpRtcpImpl(const RtpRtcp::Configuration& configuration);
|
||||
|
||||
virtual ~ModuleRtpRtcpImpl();
|
||||
|
||||
// Returns the number of milliseconds until the module want a worker thread to
|
||||
// call Process.
|
||||
virtual int64_t TimeUntilNextProcess() OVERRIDE;
|
||||
@ -72,7 +70,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
// Set SequenceNumber, default is a random number.
|
||||
virtual void SetSequenceNumber(uint16_t seq) OVERRIDE;
|
||||
|
||||
virtual void SetRtpStateForSsrc(uint32_t ssrc,
|
||||
virtual bool SetRtpStateForSsrc(uint32_t ssrc,
|
||||
const RtpState& rtp_state) OVERRIDE;
|
||||
virtual bool GetRtpStateForSsrc(uint32_t ssrc, RtpState* rtp_state) OVERRIDE;
|
||||
|
||||
@ -345,10 +343,6 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
void OnRequestSendReport();
|
||||
|
||||
protected:
|
||||
void RegisterChildModule(RtpRtcp* module);
|
||||
|
||||
void DeRegisterChildModule(RtpRtcp* module);
|
||||
|
||||
bool UpdateRTCPReceiveInformationTimers();
|
||||
|
||||
uint32_t BitrateReceivedNow() const;
|
||||
@ -377,8 +371,6 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
|
||||
bool TimeToSendFullNackList(int64_t now) const;
|
||||
|
||||
bool IsDefaultModule() const;
|
||||
|
||||
int32_t id_;
|
||||
const bool audio_;
|
||||
bool collision_detected_;
|
||||
@ -387,10 +379,6 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
int64_t last_rtt_process_time_;
|
||||
uint16_t packet_overhead_;
|
||||
|
||||
scoped_ptr<CriticalSectionWrapper> critical_section_module_ptrs_;
|
||||
scoped_ptr<CriticalSectionWrapper> critical_section_module_ptrs_feedback_;
|
||||
ModuleRtpRtcpImpl* default_module_;
|
||||
std::vector<ModuleRtpRtcpImpl*> child_modules_;
|
||||
size_t padding_index_;
|
||||
|
||||
// Send side
|
||||
@ -399,7 +387,6 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
uint32_t nack_last_time_sent_full_prev_;
|
||||
uint16_t nack_last_seq_number_sent_;
|
||||
|
||||
bool simulcast_;
|
||||
VideoCodec send_video_codec_;
|
||||
KeyFrameRequestMethod key_frame_req_method_;
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace webrtc {
|
||||
class MockVieEncoder : public ViEEncoder {
|
||||
public:
|
||||
explicit MockVieEncoder(ProcessThread* process_thread)
|
||||
: ViEEncoder(1, 1, 1, config_, *process_thread, NULL, false) {}
|
||||
: ViEEncoder(1, 1, config_, *process_thread, NULL, false) {}
|
||||
~MockVieEncoder() {}
|
||||
|
||||
MOCK_METHOD1(OnReceivedIntraFrameRequest,
|
||||
|
@ -91,7 +91,6 @@ ViEChannel::ViEChannel(int32_t channel_id,
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator,
|
||||
RtcpRttStats* rtt_stats,
|
||||
PacedSender* paced_sender,
|
||||
RtpRtcp* default_rtp_rtcp,
|
||||
bool sender,
|
||||
bool disable_default_encoder)
|
||||
: ViEFrameProviderBase(channel_id, engine_id),
|
||||
@ -101,7 +100,6 @@ ViEChannel::ViEChannel(int32_t channel_id,
|
||||
num_socket_threads_(kViESocketThreads),
|
||||
callback_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
rtp_rtcp_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
default_rtp_rtcp_(default_rtp_rtcp),
|
||||
send_payload_router_(new PayloadRouter()),
|
||||
vcm_protection_callback_(new ViEChannelProtectionCallback(this)),
|
||||
vcm_(VideoCodingModule::Create()),
|
||||
@ -1009,16 +1007,36 @@ int32_t ViEChannel::SetStartSequenceNumber(uint16_t sequence_number) {
|
||||
|
||||
void ViEChannel::SetRtpStateForSsrc(uint32_t ssrc, const RtpState& rtp_state) {
|
||||
assert(!rtp_rtcp_->Sending());
|
||||
default_rtp_rtcp_->SetRtpStateForSsrc(ssrc, rtp_state);
|
||||
if (rtp_rtcp_->SetRtpStateForSsrc(ssrc, rtp_state))
|
||||
return;
|
||||
CriticalSectionScoped cs(rtp_rtcp_cs_.get());
|
||||
for (auto* module : simulcast_rtp_rtcp_) {
|
||||
if (module->SetRtpStateForSsrc(ssrc, rtp_state))
|
||||
return;
|
||||
}
|
||||
for (auto* module : removed_rtp_rtcp_) {
|
||||
if (module->SetRtpStateForSsrc(ssrc, rtp_state))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) {
|
||||
assert(!rtp_rtcp_->Sending());
|
||||
|
||||
RtpState rtp_state;
|
||||
if (!default_rtp_rtcp_->GetRtpStateForSsrc(ssrc, &rtp_state)) {
|
||||
LOG(LS_ERROR) << "Couldn't get RTP state for ssrc: " << ssrc;
|
||||
if (rtp_rtcp_->GetRtpStateForSsrc(ssrc, &rtp_state))
|
||||
return rtp_state;
|
||||
|
||||
CriticalSectionScoped cs(rtp_rtcp_cs_.get());
|
||||
for (auto* module : simulcast_rtp_rtcp_) {
|
||||
if (module->GetRtpStateForSsrc(ssrc, &rtp_state))
|
||||
return rtp_state;
|
||||
}
|
||||
for (auto* module : removed_rtp_rtcp_) {
|
||||
if (module->GetRtpStateForSsrc(ssrc, &rtp_state))
|
||||
return rtp_state;
|
||||
}
|
||||
LOG(LS_ERROR) << "Couldn't get RTP state for ssrc: " << ssrc;
|
||||
return rtp_state;
|
||||
}
|
||||
|
||||
@ -1759,7 +1777,6 @@ RtpRtcp::Configuration ViEChannel::CreateRtpRtcpConfiguration() {
|
||||
RtpRtcp::Configuration configuration;
|
||||
configuration.id = ViEModuleId(engine_id_, channel_id_);
|
||||
configuration.audio = false;
|
||||
configuration.default_module = default_rtp_rtcp_;
|
||||
configuration.outgoing_transport = &vie_sender_;
|
||||
configuration.intra_frame_callback = intra_frame_observer_;
|
||||
configuration.bandwidth_callback = bandwidth_observer_.get();
|
||||
|
@ -76,7 +76,6 @@ class ViEChannel
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator,
|
||||
RtcpRttStats* rtt_stats,
|
||||
PacedSender* paced_sender,
|
||||
RtpRtcp* default_rtp_rtcp,
|
||||
bool sender,
|
||||
bool disable_default_encoder);
|
||||
~ViEChannel();
|
||||
@ -500,8 +499,6 @@ class ViEChannel
|
||||
scoped_ptr<CriticalSectionWrapper> callback_cs_;
|
||||
scoped_ptr<CriticalSectionWrapper> rtp_rtcp_cs_;
|
||||
|
||||
RtpRtcp* default_rtp_rtcp_;
|
||||
|
||||
// Owned modules/classes.
|
||||
scoped_ptr<RtpRtcp> rtp_rtcp_;
|
||||
std::list<RtpRtcp*> simulcast_rtp_rtcp_;
|
||||
|
@ -90,7 +90,7 @@ int ViEChannelManager::CreateChannel(int* channel_id,
|
||||
ChannelGroup* group = new ChannelGroup(module_process_thread_,
|
||||
channel_group_config);
|
||||
BitrateController* bitrate_controller = group->GetBitrateController();
|
||||
ViEEncoder* vie_encoder = new ViEEncoder(engine_id_, new_channel_id,
|
||||
ViEEncoder* vie_encoder = new ViEEncoder(new_channel_id,
|
||||
number_of_cores_,
|
||||
engine_config_,
|
||||
*module_process_thread_,
|
||||
@ -166,7 +166,7 @@ int ViEChannelManager::CreateChannel(int* channel_id,
|
||||
ViEEncoder* vie_encoder = NULL;
|
||||
if (sender) {
|
||||
// We need to create a new ViEEncoder.
|
||||
vie_encoder = new ViEEncoder(engine_id_, new_channel_id, number_of_cores_,
|
||||
vie_encoder = new ViEEncoder(new_channel_id, number_of_cores_,
|
||||
engine_config_,
|
||||
*module_process_thread_,
|
||||
bitrate_controller,
|
||||
@ -435,9 +435,6 @@ bool ViEChannelManager::CreateChannelObject(
|
||||
bool disable_default_encoder) {
|
||||
PacedSender* paced_sender = vie_encoder->GetPacedSender();
|
||||
|
||||
// Register the channel at the encoder.
|
||||
RtpRtcp* send_rtp_rtcp_module = vie_encoder->SendRtpRtcpModule();
|
||||
|
||||
ViEChannel* vie_channel = new ViEChannel(channel_id, engine_id_,
|
||||
number_of_cores_,
|
||||
engine_config_,
|
||||
@ -447,7 +444,6 @@ bool ViEChannelManager::CreateChannelObject(
|
||||
remote_bitrate_estimator,
|
||||
rtcp_rtt_stats,
|
||||
paced_sender,
|
||||
send_rtp_rtcp_module,
|
||||
sender,
|
||||
disable_default_encoder);
|
||||
if (vie_channel->Init() != 0) {
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/frame_callback.h"
|
||||
#include "webrtc/modules/pacing/include/paced_sender.h"
|
||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
|
||||
#include "webrtc/modules/utility/interface/process_thread.h"
|
||||
#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
|
||||
#include "webrtc/modules/video_coding/main/interface/video_coding.h"
|
||||
@ -128,20 +127,17 @@ class ViEPacedSenderCallback : public PacedSender::Callback {
|
||||
ViEEncoder* owner_;
|
||||
};
|
||||
|
||||
ViEEncoder::ViEEncoder(int32_t engine_id,
|
||||
int32_t channel_id,
|
||||
ViEEncoder::ViEEncoder(int32_t channel_id,
|
||||
uint32_t number_of_cores,
|
||||
const Config& config,
|
||||
ProcessThread& module_process_thread,
|
||||
BitrateController* bitrate_controller,
|
||||
bool disable_default_encoder)
|
||||
: engine_id_(engine_id),
|
||||
channel_id_(channel_id),
|
||||
: channel_id_(channel_id),
|
||||
number_of_cores_(number_of_cores),
|
||||
disable_default_encoder_(disable_default_encoder),
|
||||
vcm_(*webrtc::VideoCodingModule::Create()),
|
||||
vpm_(*webrtc::VideoProcessingModule::Create(ViEModuleId(engine_id,
|
||||
channel_id))),
|
||||
vpm_(*webrtc::VideoProcessingModule::Create(ViEModuleId(-1, channel_id))),
|
||||
send_payload_router_(NULL),
|
||||
vcm_protection_callback_(NULL),
|
||||
callback_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
@ -169,11 +165,6 @@ ViEEncoder::ViEEncoder(int32_t engine_id,
|
||||
pre_encode_callback_(NULL),
|
||||
start_ms_(Clock::GetRealTimeClock()->TimeInMilliseconds()),
|
||||
send_statistics_proxy_(NULL) {
|
||||
RtpRtcp::Configuration configuration;
|
||||
configuration.id = ViEModuleId(engine_id_, channel_id_);
|
||||
configuration.audio = false; // Video.
|
||||
|
||||
default_rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(configuration));
|
||||
bitrate_observer_.reset(new ViEBitrateObserver(this));
|
||||
pacing_callback_.reset(new ViEPacedSenderCallback(this));
|
||||
paced_sender_.reset(new PacedSender(
|
||||
@ -239,7 +230,6 @@ void ViEEncoder::StartThreadsAndSetSharedMembers(
|
||||
vcm_protection_callback_ = vcm_protection_callback;
|
||||
|
||||
module_process_thread_.RegisterModule(&vcm_);
|
||||
module_process_thread_.RegisterModule(default_rtp_rtcp_.get());
|
||||
pacer_thread_->RegisterModule(paced_sender_.get());
|
||||
pacer_thread_->Start();
|
||||
}
|
||||
@ -251,7 +241,6 @@ void ViEEncoder::StopThreadsAndRemoveSharedMembers() {
|
||||
pacer_thread_->DeRegisterModule(paced_sender_.get());
|
||||
module_process_thread_.DeRegisterModule(&vcm_);
|
||||
module_process_thread_.DeRegisterModule(&vpm_);
|
||||
module_process_thread_.DeRegisterModule(default_rtp_rtcp_.get());
|
||||
}
|
||||
|
||||
ViEEncoder::~ViEEncoder() {
|
||||
@ -510,10 +499,6 @@ void ViEEncoder::TraceFrameDropEnd() {
|
||||
encoder_paused_and_dropped_frame_ = false;
|
||||
}
|
||||
|
||||
RtpRtcp* ViEEncoder::SendRtpRtcpModule() {
|
||||
return default_rtp_rtcp_.get();
|
||||
}
|
||||
|
||||
void ViEEncoder::DeliverFrame(int id,
|
||||
I420VideoFrame* video_frame,
|
||||
const std::vector<uint32_t>& csrcs) {
|
||||
|
@ -37,7 +37,6 @@ class PacedSender;
|
||||
class PayloadRouter;
|
||||
class ProcessThread;
|
||||
class QMVideoSettingsCallback;
|
||||
class RtpRtcp;
|
||||
class SendStatisticsProxy;
|
||||
class ViEBitrateObserver;
|
||||
class ViEEffectFilter;
|
||||
@ -54,8 +53,7 @@ class ViEEncoder
|
||||
friend class ViEBitrateObserver;
|
||||
friend class ViEPacedSenderCallback;
|
||||
|
||||
ViEEncoder(int32_t engine_id,
|
||||
int32_t channel_id,
|
||||
ViEEncoder(int32_t channel_id,
|
||||
uint32_t number_of_cores,
|
||||
const Config& config,
|
||||
ProcessThread& module_process_thread,
|
||||
@ -105,9 +103,6 @@ class ViEEncoder
|
||||
// Scale or crop/pad image.
|
||||
int32_t ScaleInputImage(bool enable);
|
||||
|
||||
// RTP settings.
|
||||
RtpRtcp* SendRtpRtcpModule();
|
||||
|
||||
// Implementing ViEFrameCallback.
|
||||
virtual void DeliverFrame(int id,
|
||||
I420VideoFrame* video_frame,
|
||||
@ -201,14 +196,12 @@ class ViEEncoder
|
||||
|
||||
void UpdateHistograms();
|
||||
|
||||
int32_t engine_id_;
|
||||
const int channel_id_;
|
||||
const uint32_t number_of_cores_;
|
||||
const bool disable_default_encoder_;
|
||||
|
||||
VideoCodingModule& vcm_;
|
||||
VideoProcessingModule& vpm_;
|
||||
rtc::scoped_ptr<RtpRtcp> default_rtp_rtcp_;
|
||||
scoped_refptr<PayloadRouter> send_payload_router_;
|
||||
VCMProtectionCallback* vcm_protection_callback_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user