本文主要是介绍「Mutilated Webrtc」Fec Encode,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
从这里计算丢包率
void RtpTransportControllerSend::OnReceivedRtcpReceiverReportBlocks(const ReportBlockList& report_blocks,int64_t now_ms) {if (report_blocks.empty())return;int total_packets_lost_delta = 0;int total_packets_delta = 0;// Compute the packet loss from all report blocks.for (const RTCPReportBlock& report_block : report_blocks) {auto it = last_report_blocks_.find(report_block.source_ssrc);if (it != last_report_blocks_.end()) {auto number_of_packets = report_block.extended_highest_sequence_number -it->second.extended_highest_sequence_number;total_packets_delta += number_of_packets;auto lost_delta = report_block.packets_lost - it->second.packets_lost;total_packets_lost_delta += lost_delta;}last_report_blocks_[report_block.source_ssrc] = report_block;}// Can only compute delta if there has been previous blocks to compare to. If// not, total_packets_delta will be unchanged and there's nothing more to do.if (!total_packets_delta)return;int packets_received_delta = total_packets_delta - total_packets_lost_delta;// To detect lost packets, at least one packet has to be received. This check// is needed to avoid bandwith detection update in// VideoSendStreamTest.SuspendBelowMinBitrateif (packets_received_delta < 1)return;Timestamp now = Timestamp::Millis(now_ms);TransportLossReport msg;msg.packets_lost_delta = total_packets_lost_delta;msg.packets_received_delta = packets_received_delta;msg.receive_time = now;msg.start_time = last_report_block_time_;msg.end_time = now;if (controller_) {RTC_LOG(LS_ERROR) << "kiki-fec: RtpTransportControllerSend::OnReceivedRtcpReceiverReportBlocks";PostUpdates(controller_->OnTransportLossReport(msg));}last_report_block_time_ = now;
}
123
void RtpTransportControllerSend::PostUpdates(NetworkControlUpdate update) {if (update.congestion_window) {pacer()->SetCongestionWindow(*update.congestion_window);}if (update.pacer_config) {pacer()->SetPacingRates(update.pacer_config->data_rate(),update.pacer_config->pad_rate());}for (const auto& probe : update.probe_cluster_configs) {pacer()->CreateProbeCluster(probe.target_data_rate, probe.id);}if (update.target_rate) {control_handler_->SetTargetRate(*update.target_rate);UpdateControlState();}
}
在这里被设置
void CongestionControlHandler::SetTargetRate(TargetTransferRate new_target_rate) {RTC_DCHECK_RUN_ON(&sequenced_checker_);RTC_CHECK(new_target_rate.at_time.IsFinite());last_incoming_ = new_target_rate;
}
这里定期获得最后的记录,传递下去。值得注意的是,这里有个标志位disable_pacer_emergency_stop_是0。
void RtpTransportControllerSend::UpdateControlState() {absl::optional<TargetTransferRate> update = control_handler_->GetUpdate();if (!update)return;retransmission_rate_limiter_.SetMaxRate(update->target_rate.bps());// We won't create control_handler_ until we have an observers.RTC_DCHECK(observer_ != nullptr);observer_->OnTargetTransferRate(*update);
}
absl::optional<TargetTransferRate> CongestionControlHandler::GetUpdate() {RTC_DCHECK_RUN_ON(&sequenced_checker_);if (!last_incoming_.has_value())return absl::nullopt;TargetTransferRate new_outgoing = *last_incoming_;DataRate log_target_rate = new_outgoing.target_rate;bool pause_encoding = false;if (!network_available_) {pause_encoding = true;} else if (!disable_pacer_emergency_stop_ &&pacer_expected_queue_ms_ > PacedSender::kMaxQueueLengthMs) {pause_encoding = true;}if (pause_encoding)new_outgoing.target_rate = DataRate::Zero();if (!last_reported_ ||last_reported_->target_rate != new_outgoing.target_rate ||(!new_outgoing.target_rate.IsZero() &&(last_reported_->network_estimate.loss_rate_ratio !=new_outgoing.network_estimate.loss_rate_ratio ||last_reported_->network_estimate.round_trip_time !=new_outgoing.network_estimate.round_trip_time))) {if (encoder_paused_in_last_report_ != pause_encoding)RTC_LOG(LS_INFO) << "Bitrate estimate state changed, BWE: "<< ToString(log_target_rate) << ".";encoder_paused_in_last_report_ = pause_encoding;last_reported_ = new_outgoing;return new_outgoing;}return absl::nullopt;
}
Call::OnTargetTransferRate
void BitrateAllocator::OnNetworkEstimateChanged(TargetTransferRate msg) {
src/video/video_send_stream_impl.cc
uint32_t VideoSendStreamImpl::OnBitrateUpdated(BitrateAllocationUpdate update) {...rtp_video_sender_->OnBitrateUpdated(update, stats_proxy_->GetSendFrameRate());...
}
src/call/rtp_video_sender.cc
void RtpVideoSender::OnBitrateUpdated(BitrateAllocationUpdate update,int framerate) {...encoder_target_rate_bps_ = fec_controller_->UpdateFecRates(payload_bitrate_bps, framerate,rtc::saturated_cast<uint8_t>(update.packet_loss_ratio * 256),loss_mask_vector_, update.round_trip_time.ms());...
}
这篇关于「Mutilated Webrtc」Fec Encode的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!