Allow to turn RtcpTransciever on and off at runtime.

Bug: webrtc:8239
Change-Id: I8678d1ee9cd0da194a1243d40b508bb62cb3f257
Reviewed-on: https://webrtc-review.googlesource.com/60180
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22311}
This commit is contained in:
Danil Chapovalov
2018-03-06 14:33:20 +01:00
committed by Commit Bot
parent 70473fcac4
commit e3927c5885
6 changed files with 110 additions and 2 deletions

View File

@ -86,9 +86,11 @@ class RtcpTransceiverImpl::PacketSender {
};
RtcpTransceiverImpl::RtcpTransceiverImpl(const RtcpTransceiverConfig& config)
: config_(config), ptr_factory_(this) {
: config_(config),
ready_to_send_(config.initial_ready_to_send),
ptr_factory_(this) {
RTC_CHECK(config_.Validate());
if (config_.schedule_periodic_compound_packets)
if (ready_to_send_ && config_.schedule_periodic_compound_packets)
SchedulePeriodicCompoundPackets(config_.initial_report_delay_ms);
}
@ -115,6 +117,17 @@ void RtcpTransceiverImpl::RemoveMediaReceiverRtcpObserver(
stored.erase(it);
}
void RtcpTransceiverImpl::SetReadyToSend(bool ready) {
if (config_.schedule_periodic_compound_packets) {
if (ready_to_send_ && !ready) // Stop existent send task.
ptr_factory_.InvalidateWeakPtrs();
if (!ready_to_send_ && ready) // Restart periodic sending.
SchedulePeriodicCompoundPackets(config_.report_period_ms / 2);
}
ready_to_send_ = ready;
}
void RtcpTransceiverImpl::ReceivePacket(rtc::ArrayView<const uint8_t> packet,
int64_t now_us) {
while (!packet.empty()) {
@ -130,6 +143,8 @@ void RtcpTransceiverImpl::ReceivePacket(rtc::ArrayView<const uint8_t> packet,
}
void RtcpTransceiverImpl::SendCompoundPacket() {
if (!ready_to_send_)
return;
SendPeriodicCompoundPacket();
ReschedulePeriodicCompoundPackets();
}
@ -150,6 +165,8 @@ void RtcpTransceiverImpl::UnsetRemb() {
}
void RtcpTransceiverImpl::SendRawPacket(rtc::ArrayView<const uint8_t> packet) {
if (!ready_to_send_)
return;
// Unlike other senders, this functions just tries to send packet away and
// disregard rtcp_mode, max_packet_size or anything else.
// TODO(bugs.webrtc.org/8239): respect config_ by creating the
@ -160,6 +177,8 @@ void RtcpTransceiverImpl::SendRawPacket(rtc::ArrayView<const uint8_t> packet) {
void RtcpTransceiverImpl::SendNack(uint32_t ssrc,
std::vector<uint16_t> sequence_numbers) {
RTC_DCHECK(!sequence_numbers.empty());
if (!ready_to_send_)
return;
rtcp::Nack nack;
nack.SetSenderSsrc(config_.feedback_ssrc);
nack.SetMediaSsrc(ssrc);
@ -168,6 +187,8 @@ void RtcpTransceiverImpl::SendNack(uint32_t ssrc,
}
void RtcpTransceiverImpl::SendPictureLossIndication(uint32_t ssrc) {
if (!ready_to_send_)
return;
rtcp::Pli pli;
pli.SetSenderSsrc(config_.feedback_ssrc);
pli.SetMediaSsrc(ssrc);
@ -177,6 +198,8 @@ void RtcpTransceiverImpl::SendPictureLossIndication(uint32_t ssrc) {
void RtcpTransceiverImpl::SendFullIntraRequest(
rtc::ArrayView<const uint32_t> ssrcs) {
RTC_DCHECK(!ssrcs.empty());
if (!ready_to_send_)
return;
rtcp::Fir fir;
fir.SetSenderSsrc(config_.feedback_ssrc);
for (uint32_t media_ssrc : ssrcs)