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

Unified Diff: webrtc/pc/channel.cc

Issue 2437503004: Set actual transport overhead in rtp_rtcp (Closed)
Patch Set: Responde to comments. 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..406c2a6e93ea13b7e02bc6abb302f03e25bc6dc1 100644
--- a/webrtc/pc/channel.cc
+++ b/webrtc/pc/channel.cc
@@ -586,7 +586,14 @@ 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(
+ selected_candidate_pair->local_candidate())));
}
+
invoker_.AsyncInvoke<void>(
RTC_FROM_HERE, worker_thread_,
Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name,
@@ -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,42 @@ void BaseChannel::UpdateMediaSendRecvState() {
Bind(&BaseChannel::UpdateMediaSendRecvState_w, this));
}
+int BaseChannel::GetTransportOverheadPerPacket() {
+ if (transport_channel_) {
+ std::vector<ConnectionInfo> connection_infos;
+ transport_channel_->GetStats(&connection_infos);
honghaiz3 2016/10/27 18:57:44 Does it make sense to just remember the last signa
michaelt 2016/10/31 09:59:26 store now the last signaled candidate pair in chan
+ for (auto& connection_info : connection_infos) {
+ if (connection_info.best_connection) {
+ return GetTransportOverheadPerPacket(connection_info.local_candidate);
+ break;
honghaiz3 2016/10/27 18:57:44 You don't need a break after return.
michaelt 2016/10/31 09:59:26 :) I removed the function.
+ }
+ }
+ }
+ return 0;
+}
+
+int BaseChannel::GetTransportOverheadPerPacket(
+ const Candidate& local_candidate) {
+ constexpr int kIpv4Overhaed = 20;
+ constexpr int kIpv6Overhaed = 40;
+ constexpr int kUdpOverhaed = 8;
+ constexpr int kTcpOverhaed = 20;
+
+ int transport_overhead_per_packet = 0;
+ transport_overhead_per_packet +=
+ local_candidate.protocol() == TCP_PROTOCOL_NAME ? kTcpOverhaed
+ : kUdpOverhaed;
+ transport_overhead_per_packet += 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.
« webrtc/pc/channel.h ('K') | « webrtc/pc/channel.h ('k') | webrtc/pc/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698