Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Unified Diff: webrtc/pc/channel.cc

Issue 2437503004: Set actual transport overhead in rtp_rtcp (Closed)
Patch Set: Save selected candidate pair in transport channel. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/pc/channel.cc
diff --git a/webrtc/pc/channel.cc b/webrtc/pc/channel.cc
index f22bdc4ca41029155f2fe4fe511bb9c2765ee679..7f0195023c5faa1d0ce0a49e001febdfd10d11bc 100644
--- a/webrtc/pc/channel.cc
+++ b/webrtc/pc/channel.cc
@@ -582,10 +582,20 @@ void BaseChannel::OnSelectedCandidatePairChanged(
std::string transport_name = channel->transport_name();
rtc::NetworkRoute network_route;
if (selected_candidate_pair) {
+ selected_candidate_pair_ =
+ rtc::Optional<CandidatePair>(CandidatePair(*selected_candidate_pair));
honghaiz3 2016/10/31 17:42:09 You don't need to save a copy of CandidatePair her
+
network_route = rtc::NetworkRoute(
ready_to_send, selected_candidate_pair->local_candidate().network_id(),
selected_candidate_pair->remote_candidate().network_id(),
last_sent_packet_id);
+
+ invoker_.AsyncInvoke<void>(
+ RTC_FROM_HERE, worker_thread_,
+ Bind(&MediaChannel::OnTransportOverheadChange, media_channel_,
+ GetTransportOverheadPerPacket()));
+ } else {
+ selected_candidate_pair_ = rtc::Optional<CandidatePair>();
}
invoker_.AsyncInvoke<void>(
RTC_FROM_HERE, worker_thread_,
@@ -1030,11 +1040,15 @@ bool BaseChannel::SetupDtlsSrtp_n(bool rtcp_channel) {
static_cast<int>(recv_key->size()));
}
- if (!ret)
+ if (!ret) {
LOG(LS_WARNING) << "DTLS-SRTP key installation failed";
- else
+ } else {
dtls_keyed_ = true;
-
+ invoker_.AsyncInvoke<void>(
+ RTC_FROM_HERE, worker_thread_,
+ Bind(&MediaChannel::OnTransportOverheadChange, media_channel_,
+ GetTransportOverheadPerPacket()));
+ }
return ret;
}
@@ -1661,6 +1675,34 @@ void BaseChannel::UpdateMediaSendRecvState() {
Bind(&BaseChannel::UpdateMediaSendRecvState_w, this));
}
+int BaseChannel::GetTransportOverheadPerPacket() {
+ constexpr int kIpv4Overhaed = 20;
+ constexpr int kIpv6Overhaed = 40;
+ constexpr int kUdpOverhaed = 8;
+ constexpr int kTcpOverhaed = 20;
honghaiz3 2016/10/31 17:42:09 If you just use the saved selected_candidate_pair
michaelt 2016/11/01 08:31:37 Done.
+
+ int transport_overhead_per_packet = 0;
+
+ if (selected_candidate_pair_) {
honghaiz3 2016/10/31 17:42:09 Can you use an early return? That would be more re
michaelt 2016/11/01 08:31:37 Done.
+ transport_overhead_per_packet +=
+ selected_candidate_pair_->local_candidate().protocol() ==
+ TCP_PROTOCOL_NAME
+ ? kTcpOverhaed
+ : kUdpOverhaed;
+ transport_overhead_per_packet +=
+ selected_candidate_pair_->local_candidate().address().family() ==
+ AF_INET
+ ? kIpv4Overhaed
+ : kIpv6Overhaed;
+ if (secure()) {
+ int srtp_overhead = 0;
+ if (srtp_filter_.GetSrtpOverhead(&srtp_overhead))
+ transport_overhead_per_packet += srtp_overhead;
+ }
+ }
+ return transport_overhead_per_packet;
+}
+
void VoiceChannel::UpdateMediaSendRecvState_w() {
// Render incoming data if we're the active call, and we have the local
// content. We receive data on the default channel and multiplexed streams.

Powered by Google App Engine
This is Rietveld 408576698