Break out RTCPSender dependency on ModuleRtpRtcpImpl.

BUG=
R=stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2191004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4706 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2013-09-09 16:02:19 +00:00
parent 26b0d77baf
commit 59f20bb735
7 changed files with 158 additions and 123 deletions

View File

@ -88,8 +88,8 @@ void RtcpFormatRembTest::SetUp() {
configuration.clock = system_clock_;
configuration.remote_bitrate_estimator = remote_bitrate_estimator_.get();
dummy_rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration);
rtcp_sender_ = new RTCPSender(0, false, system_clock_, dummy_rtp_rtcp_impl_,
receive_statistics_.get());
rtcp_sender_ =
new RTCPSender(0, false, system_clock_, receive_statistics_.get());
rtcp_receiver_ = new RTCPReceiver(0, system_clock_, dummy_rtp_rtcp_impl_);
test_transport_ = new TestTransport(rtcp_receiver_);
@ -118,13 +118,15 @@ TEST_F(RtcpFormatRembTest, TestNonCompund) {
uint32_t SSRC = 456789;
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpNonCompound));
EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, 1, &SSRC));
EXPECT_EQ(0, rtcp_sender_->SendRTCP(kRtcpRemb));
RTCPSender::FeedbackState feedback_state(dummy_rtp_rtcp_impl_);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb));
}
TEST_F(RtcpFormatRembTest, TestCompund) {
uint32_t SSRCs[2] = {456789, 98765};
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound));
EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, 2, SSRCs));
EXPECT_EQ(0, rtcp_sender_->SendRTCP(kRtcpRemb));
RTCPSender::FeedbackState feedback_state(dummy_rtp_rtcp_impl_);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb));
}
} // namespace

View File

@ -65,16 +65,41 @@ std::string NACKStringBuilder::GetResult()
return _stream.str();
}
RTCPSender::FeedbackState::FeedbackState(ModuleRtpRtcpImpl* module)
: send_payload_type(module->SendPayloadType()),
frequency_hz(module->CurrentSendFrequencyHz()),
packet_count_sent(module->PacketCountSent()),
byte_count_sent(module->ByteCountSent()),
module(module) {
uint32_t last_ntp_secs = 0, last_ntp_frac = 0, last_remote_sr = 0;
module->LastReceivedNTP(last_ntp_secs, last_ntp_frac, last_remote_sr);
last_rr_ntp_secs = last_ntp_secs;
last_rr_ntp_frac = last_ntp_frac;
remote_sr = last_remote_sr;
uint32_t send_bitrate = 0, tmp;
module->BitrateSent(&send_bitrate, &tmp, &tmp, &tmp);
this->send_bitrate = send_bitrate;
}
RTCPSender::FeedbackState::FeedbackState()
: send_payload_type(0),
frequency_hz(0),
packet_count_sent(0),
byte_count_sent(0),
send_bitrate(0),
last_rr_ntp_secs(0),
last_rr_ntp_frac(0),
remote_sr(0) {}
RTCPSender::RTCPSender(const int32_t id,
const bool audio,
Clock* clock,
ModuleRtpRtcpImpl* owner,
ReceiveStatistics* receive_statistics) :
_id(id),
_audio(audio),
_clock(clock),
_method(kRtcpOff),
_rtpRtcp(*owner),
_criticalSectionTransport(CriticalSectionWrapper::CreateCriticalSection()),
_cbTransport(NULL),
@ -260,7 +285,7 @@ RTCPSender::Sending() const
}
int32_t
RTCPSender::SetSendingStatus(const bool sending)
RTCPSender::SetSendingStatus(const FeedbackState& feedback_state, bool sending)
{
bool sendRTCPBye = false;
{
@ -278,7 +303,7 @@ RTCPSender::SetSendingStatus(const bool sending)
}
if(sendRTCPBye)
{
return SendRTCP(kRtcpBye);
return SendRTCP(feedback_state, kRtcpBye);
}
return 0;
}
@ -614,11 +639,11 @@ int32_t RTCPSender::RemoveExternalReportBlock(uint32_t SSRC) {
return 0;
}
int32_t
RTCPSender::BuildSR(uint8_t* rtcpbuffer,
int& pos,
const uint32_t NTPsec,
const uint32_t NTPfrac)
int32_t RTCPSender::BuildSR(const FeedbackState& feedback_state,
uint8_t* rtcpbuffer,
int& pos,
uint32_t NTPsec,
uint32_t NTPfrac)
{
// sanity
if(pos + 52 >= IP_PACKET_SIZE)
@ -644,11 +669,6 @@ RTCPSender::BuildSR(uint8_t* rtcpbuffer,
_lastRTCPTime[0] = Clock::NtpToMs(NTPsec, NTPfrac);
_lastSendReport[0] = (NTPsec << 16) + (NTPfrac >> 16);
uint32_t freqHz = 90000; // For video
if(_audio) {
freqHz = _rtpRtcp.CurrentSendFrequencyHz();
}
// The timestamp of this RTCP packet should be estimated as the timestamp of
// the frame being captured at this moment. We are calculating that
// timestamp as the last frame's timestamp + the time since the last frame
@ -658,7 +678,7 @@ RTCPSender::BuildSR(uint8_t* rtcpbuffer,
CriticalSectionScoped lock(_criticalSectionRTCPSender);
RTPtime = start_timestamp_ + last_rtp_timestamp_ + (
_clock->TimeInMilliseconds() - last_frame_capture_time_ms_) *
(freqHz / 1000);
(feedback_state.frequency_hz / 1000);
}
// Add sender data
@ -678,11 +698,13 @@ RTCPSender::BuildSR(uint8_t* rtcpbuffer,
pos += 4;
//sender's packet count
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, _rtpRtcp.PacketCountSent());
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos,
feedback_state.packet_count_sent);
pos += 4;
//sender's octet count
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, _rtpRtcp.ByteCountSent());
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos,
feedback_state.byte_count_sent);
pos += 4;
uint8_t numberOfReportBlocks = 0;
@ -1147,9 +1169,11 @@ RTCPSender::SetTargetBitrate(unsigned int target_bitrate)
_tmmbr_Send = target_bitrate / 1000;
}
int32_t
RTCPSender::BuildTMMBR(uint8_t* rtcpbuffer, int& pos)
{
int32_t RTCPSender::BuildTMMBR(ModuleRtpRtcpImpl* rtp_rtcp_module,
uint8_t* rtcpbuffer,
int& pos) {
if (rtp_rtcp_module == NULL)
return -1;
// Before sending the TMMBR check the received TMMBN, only an owner is allowed to raise the bitrate
// If the sender is an owner of the TMMBN -> send TMMBR
// If not an owner but the TMMBR would enter the TMMBN -> send TMMBR
@ -1162,8 +1186,8 @@ RTCPSender::BuildTMMBR(uint8_t* rtcpbuffer, int& pos)
// holding _criticalSectionRTCPSender while calling RTCPreceiver which
// will accuire _criticalSectionRTCPReceiver is a potental deadlock but
// since RTCPreceiver is not doing the reverse we should be fine
int32_t lengthOfBoundingSet
= _rtpRtcp.BoundingSet(tmmbrOwner, candidateSet);
int32_t lengthOfBoundingSet =
rtp_rtcp_module->BoundingSet(tmmbrOwner, candidateSet);
if(lengthOfBoundingSet > 0)
{
@ -1551,14 +1575,12 @@ RTCPSender::BuildVoIPMetric(uint8_t* rtcpbuffer, int& pos)
return 0;
}
int32_t
RTCPSender::SendRTCP(
uint32_t packetTypeFlags,
int32_t nackSize,
const uint16_t* nackList,
bool repeat,
uint64_t pictureID)
{
int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state,
uint32_t packetTypeFlags,
int32_t nackSize,
const uint16_t* nackList,
bool repeat,
uint64_t pictureID) {
{
CriticalSectionScoped lock(_criticalSectionRTCPSender);
if(_method == kRtcpOff)
@ -1569,8 +1591,14 @@ RTCPSender::SendRTCP(
}
}
uint8_t rtcp_buffer[IP_PACKET_SIZE];
int rtcp_length = PrepareRTCP(packetTypeFlags, nackSize, nackList, repeat,
pictureID, rtcp_buffer, IP_PACKET_SIZE);
int rtcp_length = PrepareRTCP(feedback_state,
packetTypeFlags,
nackSize,
nackList,
repeat,
pictureID,
rtcp_buffer,
IP_PACKET_SIZE);
if (rtcp_length < 0) {
return -1;
}
@ -1582,14 +1610,14 @@ RTCPSender::SendRTCP(
return SendToNetwork(rtcp_buffer, static_cast<uint16_t>(rtcp_length));
}
int RTCPSender::PrepareRTCP(
uint32_t packetTypeFlags,
int32_t nackSize,
const uint16_t* nackList,
bool repeat,
uint64_t pictureID,
uint8_t* rtcp_buffer,
int buffer_size) {
int RTCPSender::PrepareRTCP(const FeedbackState& feedback_state,
uint32_t packetTypeFlags,
int32_t nackSize,
const uint16_t* nackList,
bool repeat,
uint64_t pictureID,
uint8_t* rtcp_buffer,
int buffer_size) {
uint32_t rtcpPacketTypeFlags = packetTypeFlags;
// Collect the received information.
uint32_t NTPsec = 0;
@ -1664,20 +1692,10 @@ int RTCPSender::PrepareRTCP(
uint32_t minIntervalMs = RTCP_INTERVAL_AUDIO_MS;
if(_sending)
{
// Calculate bandwidth for video; 360 / send bandwidth in kbit/s.
uint32_t sendBitrateKbit = 0;
uint32_t videoRate = 0;
uint32_t fecRate = 0;
uint32_t nackRate = 0;
_rtpRtcp.BitrateSent(&sendBitrateKbit,
&videoRate,
&fecRate,
&nackRate);
sendBitrateKbit /= 1000;
if(sendBitrateKbit != 0)
{
minIntervalMs = 360000/sendBitrateKbit;
}
// Calculate bandwidth for video; 360 / send bandwidth in kbit/s.
uint32_t send_bitrate_kbit = feedback_state.send_bitrate / 1000;
if (send_bitrate_kbit != 0)
minIntervalMs = 360000 / send_bitrate_kbit;
}
if(minIntervalMs > RTCP_INTERVAL_VIDEO_MS)
{
@ -1702,7 +1720,8 @@ int RTCPSender::PrepareRTCP(
for (it = statisticians.begin(), i = 0; it != statisticians.end();
++it, ++i) {
RTCPReportBlock report_block;
if (PrepareReport(it->second, &report_block, &NTPsec, &NTPfrac))
if (PrepareReport(
feedback_state, it->second, &report_block, &NTPsec, &NTPfrac))
AddReportBlock(it->first, &internal_report_blocks_, &report_block);
}
if (_IJ && !statisticians.empty()) {
@ -1714,7 +1733,7 @@ int RTCPSender::PrepareRTCP(
if(rtcpPacketTypeFlags & kRtcpSr)
{
buildVal = BuildSR(rtcp_buffer, position, NTPsec, NTPfrac);
buildVal = BuildSR(feedback_state, rtcp_buffer, position, NTPsec, NTPfrac);
if (buildVal == -1) {
return -1;
} else if (buildVal == -2) {
@ -1792,7 +1811,7 @@ int RTCPSender::PrepareRTCP(
}
if(rtcpPacketTypeFlags & kRtcpRpsi)
{
const int8_t payloadType = _rtpRtcp.SendPayloadType();
const int8_t payloadType = feedback_state.send_payload_type;
if (payloadType == -1) {
return -1;
}
@ -1834,7 +1853,7 @@ int RTCPSender::PrepareRTCP(
}
if(rtcpPacketTypeFlags & kRtcpTmmbr)
{
buildVal = BuildTMMBR(rtcp_buffer, position);
buildVal = BuildTMMBR(feedback_state.module, rtcp_buffer, position);
if (buildVal == -1) {
return -1;
} else if (buildVal == -2) {
@ -1884,7 +1903,8 @@ bool RTCPSender::ShouldSendReportBlocks(uint32_t rtcp_packet_type) const {
(rtcp_packet_type & kRtcpRr);
}
bool RTCPSender::PrepareReport(StreamStatistician* statistician,
bool RTCPSender::PrepareReport(const FeedbackState& feedback_state,
StreamStatistician* statistician,
RTCPReportBlock* report_block,
uint32_t* ntp_secs, uint32_t* ntp_frac) {
// Do we have receive statistics to send?
@ -1897,34 +1917,26 @@ bool RTCPSender::PrepareReport(StreamStatistician* statistician,
stats.extended_max_sequence_number;
report_block->jitter = stats.jitter;
uint32_t lastReceivedRRNTPsecs = 0;
uint32_t lastReceivedRRNTPfrac = 0;
uint32_t remoteSR = 0;
// ok even if we have not received a SR, we will send 0 in that case
_rtpRtcp.LastReceivedNTP(lastReceivedRRNTPsecs,
lastReceivedRRNTPfrac,
remoteSR);
// get our NTP as late as possible to avoid a race
_clock->CurrentNtp(*ntp_secs, *ntp_frac);
// Delay since last received report
uint32_t delaySinceLastReceivedSR = 0;
if((lastReceivedRRNTPsecs !=0) || (lastReceivedRRNTPfrac !=0)) {
if ((feedback_state.last_rr_ntp_secs != 0) ||
(feedback_state.last_rr_ntp_frac != 0)) {
// get the 16 lowest bits of seconds and the 16 higest bits of fractions
uint32_t now=*ntp_secs&0x0000FFFF;
now <<=16;
now += (*ntp_frac&0xffff0000)>>16;
uint32_t receiveTime = lastReceivedRRNTPsecs&0x0000FFFF;
uint32_t receiveTime = feedback_state.last_rr_ntp_secs&0x0000FFFF;
receiveTime <<=16;
receiveTime += (lastReceivedRRNTPfrac&0xffff0000)>>16;
receiveTime += (feedback_state.last_rr_ntp_frac&0xffff0000)>>16;
delaySinceLastReceivedSR = now-receiveTime;
}
report_block->delaySinceLastSR = delaySinceLastReceivedSR;
report_block->lastSR = remoteSR;
report_block->lastSR = feedback_state.remote_sr;
return true;
}

View File

@ -28,6 +28,7 @@
namespace webrtc {
class ModuleRtpRtcpImpl;
class RTCPReceiver;
class NACKStringBuilder
{
@ -48,8 +49,25 @@ private:
class RTCPSender
{
public:
struct FeedbackState {
explicit FeedbackState(ModuleRtpRtcpImpl* module);
FeedbackState();
uint8_t send_payload_type;
uint32_t frequency_hz;
uint32_t packet_count_sent;
uint32_t byte_count_sent;
uint32_t send_bitrate;
uint32_t last_rr_ntp_secs;
uint32_t last_rr_ntp_frac;
uint32_t remote_sr;
// Used when generating TMMBR.
ModuleRtpRtcpImpl* module;
};
RTCPSender(const int32_t id, const bool audio,
Clock* clock, ModuleRtpRtcpImpl* owner,
Clock* clock,
ReceiveStatistics* receive_statistics);
virtual ~RTCPSender();
@ -63,7 +81,8 @@ public:
int32_t SetRTCPStatus(const RTCPMethod method);
bool Sending() const;
int32_t SetSendingStatus(const bool enabled); // combine the functions
int32_t SetSendingStatus(const FeedbackState& feedback_state,
bool enabled); // combine the functions
int32_t SetNackStatus(const bool enable);
@ -93,6 +112,7 @@ public:
uint32_t LastSendReport(uint32_t& lastRTCPTime);
int32_t SendRTCP(
const FeedbackState& feedback_state,
uint32_t rtcpPacketTypeFlags,
int32_t nackSize = 0,
const uint16_t* nackList = 0,
@ -172,14 +192,16 @@ private:
std::map<uint32_t, RTCPReportBlock*>* report_blocks,
const RTCPReportBlock* receiveBlock);
bool PrepareReport(StreamStatistician* statistician,
bool PrepareReport(const FeedbackState& feedback_state,
StreamStatistician* statistician,
RTCPReportBlock* report_block,
uint32_t* ntp_secs, uint32_t* ntp_frac);
int32_t BuildSR(uint8_t* rtcpbuffer,
int32_t BuildSR(const FeedbackState& feedback_state,
uint8_t* rtcpbuffer,
int& pos,
const uint32_t NTPsec,
const uint32_t NTPfrac);
uint32_t NTPsec,
uint32_t NTPfrac);
int32_t BuildRR(uint8_t* rtcpbuffer,
int& pos,
@ -187,6 +209,7 @@ private:
const uint32_t NTPfrac);
int PrepareRTCP(
const FeedbackState& feedback_state,
uint32_t packetTypeFlags,
int32_t nackSize,
const uint16_t* nackList,
@ -205,7 +228,9 @@ private:
int32_t BuildSDEC(uint8_t* rtcpbuffer, int& pos);
int32_t BuildPLI(uint8_t* rtcpbuffer, int& pos);
int32_t BuildREMB(uint8_t* rtcpbuffer, int& pos);
int32_t BuildTMMBR(uint8_t* rtcpbuffer, int& pos);
int32_t BuildTMMBR(ModuleRtpRtcpImpl* module,
uint8_t* rtcpbuffer,
int& pos);
int32_t BuildTMMBN(uint8_t* rtcpbuffer, int& pos);
int32_t BuildAPP(uint8_t* rtcpbuffer, int& pos);
int32_t BuildVoIPMetric(uint8_t* rtcpbuffer, int& pos);
@ -231,8 +256,6 @@ private:
Clock* _clock;
RTCPMethod _method;
ModuleRtpRtcpImpl& _rtpRtcp;
CriticalSectionWrapper* _criticalSectionTransport;
Transport* _cbTransport;

View File

@ -299,8 +299,8 @@ class RtcpSenderTest : public ::testing::Test {
rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration);
rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver(
0, system_clock_, test_transport_, NULL, rtp_payload_registry_.get()));
rtcp_sender_ = new RTCPSender(0, false, system_clock_, rtp_rtcp_impl_,
receive_statistics_.get());
rtcp_sender_ =
new RTCPSender(0, false, system_clock_, receive_statistics_.get());
rtcp_receiver_ = new RTCPReceiver(0, system_clock_, rtp_rtcp_impl_);
test_transport_->SetRTCPReceiver(rtcp_receiver_);
// Initialize
@ -338,7 +338,8 @@ class RtcpSenderTest : public ::testing::Test {
TEST_F(RtcpSenderTest, RtcpOff) {
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpOff));
EXPECT_EQ(-1, rtcp_sender_->SendRTCP(kRtcpSr));
RTCPSender::FeedbackState feedback_state(rtp_rtcp_impl_);
EXPECT_EQ(-1, rtcp_sender_->SendRTCP(feedback_state, kRtcpSr));
}
TEST_F(RtcpSenderTest, IJStatus) {
@ -381,7 +382,8 @@ TEST_F(RtcpSenderTest, TestCompound) {
EXPECT_EQ(0, rtcp_sender_->SetIJStatus(true));
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound));
EXPECT_EQ(0, rtcp_sender_->SendRTCP(kRtcpRr));
RTCPSender::FeedbackState feedback_state(rtp_rtcp_impl_);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRr));
// Transmission time offset packet should be received.
ASSERT_TRUE(test_transport_->rtcp_packet_info_.rtcpPacketTypeFlags &
@ -391,7 +393,8 @@ TEST_F(RtcpSenderTest, TestCompound) {
TEST_F(RtcpSenderTest, TestCompound_NoRtpReceived) {
EXPECT_EQ(0, rtcp_sender_->SetIJStatus(true));
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound));
EXPECT_EQ(0, rtcp_sender_->SendRTCP(kRtcpRr));
RTCPSender::FeedbackState feedback_state(rtp_rtcp_impl_);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRr));
// Transmission time offset packet should not be received.
ASSERT_FALSE(test_transport_->rtcp_packet_info_.rtcpPacketTypeFlags &
@ -409,7 +412,8 @@ TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndEmpty) {
TMMBRSet bounding_set;
EXPECT_EQ(0, rtcp_sender_->SetTMMBN(&bounding_set, 3));
ASSERT_EQ(0U, test_transport_->rtcp_packet_info_.rtcpPacketTypeFlags);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(kRtcpSr));
RTCPSender::FeedbackState feedback_state(rtp_rtcp_impl_);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state,kRtcpSr));
// We now expect the packet to show up in the rtcp_packet_info_ of
// test_transport_.
ASSERT_NE(0U, test_transport_->rtcp_packet_info_.rtcpPacketTypeFlags);
@ -431,7 +435,8 @@ TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndValid) {
EXPECT_EQ(0, rtcp_sender_->SetTMMBN(&bounding_set, 3));
ASSERT_EQ(0U, test_transport_->rtcp_packet_info_.rtcpPacketTypeFlags);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(kRtcpSr));
RTCPSender::FeedbackState feedback_state(rtp_rtcp_impl_);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpSr));
// We now expect the packet to show up in the rtcp_packet_info_ of
// test_transport_.
ASSERT_NE(0U, test_transport_->rtcp_packet_info_.rtcpPacketTypeFlags);

View File

@ -74,7 +74,7 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
configuration.audio_messages,
configuration.paced_sender),
rtcp_sender_(configuration.id, configuration.audio, configuration.clock,
this, configuration.receive_statistics),
configuration.receive_statistics),
rtcp_receiver_(configuration.id, configuration.clock, this),
clock_(configuration.clock),
id_(configuration.id),
@ -246,7 +246,8 @@ int32_t ModuleRtpRtcpImpl::Process() {
}
}
if (rtcp_sender_.TimeToSendRTCPReport()) {
rtcp_sender_.SendRTCP(kRtcpReport);
RTCPSender::FeedbackState feedback_state(this);
rtcp_sender_.SendRTCP(feedback_state, kRtcpReport);
}
}
@ -490,7 +491,8 @@ int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
}
if (rtcp_sender_.Sending() != sending) {
// Sends RTCP BYE when going from true to false
if (rtcp_sender_.SetSendingStatus(sending) != 0) {
RTCPSender::FeedbackState feedback_state(this);
if (rtcp_sender_.SetSendingStatus(feedback_state, sending) != 0) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"Failed to send RTCP BYE");
}
@ -575,7 +577,8 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData(
if (!have_child_modules) {
// Don't send RTCP from default module.
if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) {
rtcp_sender_.SendRTCP(kRtcpReport);
RTCPSender::FeedbackState feedback_state(this);
rtcp_sender_.SendRTCP(feedback_state, kRtcpReport);
}
return rtp_sender_.SendOutgoingData(frame_type,
payload_type,
@ -917,7 +920,8 @@ int32_t ModuleRtpRtcpImpl::ResetSendDataCountersRTP() {
int32_t ModuleRtpRtcpImpl::SendRTCP(uint32_t rtcp_packet_type) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SendRTCP(0x%x)",
rtcp_packet_type);
return rtcp_sender_.SendRTCP(rtcp_packet_type);
RTCPSender::FeedbackState feedback_state(this);
return rtcp_sender_.SendRTCP(feedback_state, rtcp_packet_type);
}
int32_t ModuleRtpRtcpImpl::SetRTCPApplicationSpecificData(
@ -1134,7 +1138,9 @@ int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list,
}
nack_last_seq_number_sent_ = nack_list[start_id + nackLength - 1];
return rtcp_sender_.SendRTCP(kRtcpNack, nackLength, &nack_list[start_id]);
RTCPSender::FeedbackState feedback_state(this);
return rtcp_sender_.SendRTCP(
feedback_state, kRtcpNack, nackLength, &nack_list[start_id]);
}
// Store the sent packets, needed to answer to a Negative acknowledgment
@ -1323,7 +1329,9 @@ int32_t ModuleRtpRtcpImpl::SendRTCPSliceLossIndication(
"SendRTCPSliceLossIndication (picture_id:%d)",
picture_id);
return rtcp_sender_.SendRTCP(kRtcpSli, 0, 0, false, picture_id);
RTCPSender::FeedbackState feedback_state(this);
return rtcp_sender_.SendRTCP(
feedback_state, kRtcpSli, 0, 0, false, picture_id);
}
int32_t ModuleRtpRtcpImpl::SetCameraDelay(const int32_t delay_ms) {
@ -1521,7 +1529,9 @@ void ModuleRtpRtcpImpl::OnRequestSendReport() {
int32_t ModuleRtpRtcpImpl::SendRTCPReferencePictureSelection(
const uint64_t picture_id) {
return rtcp_sender_.SendRTCP(kRtcpRpsi, 0, 0, false, picture_id);
RTCPSender::FeedbackState feedback_state(this);
return rtcp_sender_.SendRTCP(
feedback_state, kRtcpRpsi, 0, 0, false, picture_id);
}
uint32_t ModuleRtpRtcpImpl::SendTimeOfSendReport(

View File

@ -232,7 +232,9 @@ int32_t RTPSender::DeRegisterSendPayload(
int8_t RTPSender::SendPayloadType() const { return payload_type_; }
int RTPSender::SendPayloadFrequency() const { return audio_->AudioFrequency(); }
int RTPSender::SendPayloadFrequency() const {
return audio_ != NULL ? audio_->AudioFrequency() : kVideoPayloadTypeFrequency;
}
int32_t RTPSender::SetMaxPayloadLength(
const uint16_t max_payload_length,
@ -1168,28 +1170,9 @@ bool RTPSender::UpdateAbsoluteSendTime(
return true;
}
void RTPSender::SetSendingStatus(const bool enabled) {
void RTPSender::SetSendingStatus(bool enabled) {
if (enabled) {
uint32_t frequency_hz;
if (audio_configured_) {
uint32_t frequency = audio_->AudioFrequency();
// sanity
switch (frequency) {
case 8000:
case 12000:
case 16000:
case 24000:
case 32000:
break;
default:
assert(false);
return;
}
frequency_hz = frequency;
} else {
frequency_hz = kVideoPayloadTypeFrequency;
}
uint32_t frequency_hz = SendPayloadFrequency();
uint32_t RTPtime = ModuleRTPUtility::GetCurrentRTP(clock_, frequency_hz);
// Will be ignored if it's already configured via API.

View File

@ -94,7 +94,7 @@ class RTPSender : public Bitrate, public RTPSenderInterface {
int SendPayloadFrequency() const;
void SetSendingStatus(const bool enabled);
void SetSendingStatus(bool enabled);
void SetSendingMediaStatus(const bool enabled);
bool SendingMedia() const;