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

Unified Diff: webrtc/pc/channel.cc

Issue 2437503004: Set actual transport overhead in rtp_rtcp (Closed)
Patch Set: Response to comments of honghaiz3 Created 4 years, 1 month 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..9375b79430b1281025bb9faa2e898e33698617c3 100644
--- a/webrtc/pc/channel.cc
+++ b/webrtc/pc/channel.cc
@@ -171,7 +171,8 @@ BaseChannel::BaseChannel(rtc::Thread* worker_thread,
transport_controller_(transport_controller),
rtcp_enabled_(rtcp),
- media_channel_(media_channel) {
+ media_channel_(media_channel),
+ selected_candidate_pair_(nullptr) {
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
if (transport_controller) {
RTC_DCHECK_EQ(network_thread, transport_controller->network_thread());
@@ -579,6 +580,7 @@ void BaseChannel::OnSelectedCandidatePairChanged(
RTC_DCHECK(channel == transport_channel_ ||
channel == rtcp_transport_channel_);
RTC_DCHECK(network_thread_->IsCurrent());
+ selected_candidate_pair_ = selected_candidate_pair;
std::string transport_name = channel->transport_name();
rtc::NetworkRoute network_route;
if (selected_candidate_pair) {
@@ -586,6 +588,11 @@ void BaseChannel::OnSelectedCandidatePairChanged(
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()));
}
invoker_.AsyncInvoke<void>(
RTC_FROM_HERE, worker_thread_,
@@ -1030,11 +1037,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 +1672,38 @@ void BaseChannel::UpdateMediaSendRecvState() {
Bind(&BaseChannel::UpdateMediaSendRecvState_w, this));
}
+int BaseChannel::GetTransportOverheadPerPacket() {
+ RTC_DCHECK(network_thread_->IsCurrent());
+
+ if (!selected_candidate_pair_)
+ return 0;
+
+ int transport_overhead_per_packet = 0;
+
+ constexpr int kIpv4Overhaed = 20;
+ constexpr int kIpv6Overhaed = 40;
+ transport_overhead_per_packet +=
+ selected_candidate_pair_->local_candidate().address().family() == AF_INET
+ ? kIpv4Overhaed
+ : kIpv6Overhaed;
+
+ constexpr int kUdpOverhaed = 8;
+ constexpr int kTcpOverhaed = 20;
+ transport_overhead_per_packet +=
+ selected_candidate_pair_->local_candidate().protocol() ==
+ TCP_PROTOCOL_NAME
+ ? kTcpOverhaed
+ : kUdpOverhaed;
+
+ 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