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

Side by Side Diff: webrtc/pc/channel.cc

Issue 2437503004: Set actual transport overhead in rtp_rtcp (Closed)
Patch Set: Add unittest for changing transport overhead. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 TransportController* transport_controller, 165 TransportController* transport_controller,
166 const std::string& content_name, 166 const std::string& content_name,
167 bool rtcp) 167 bool rtcp)
168 : worker_thread_(worker_thread), 168 : worker_thread_(worker_thread),
169 network_thread_(network_thread), 169 network_thread_(network_thread),
170 170
171 content_name_(content_name), 171 content_name_(content_name),
172 172
173 transport_controller_(transport_controller), 173 transport_controller_(transport_controller),
174 rtcp_enabled_(rtcp), 174 rtcp_enabled_(rtcp),
175 media_channel_(media_channel) { 175 media_channel_(media_channel),
176 selected_candidate_pair_(nullptr) {
176 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 177 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
177 if (transport_controller) { 178 if (transport_controller) {
178 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread()); 179 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread());
179 } 180 }
180 LOG(LS_INFO) << "Created channel for " << content_name; 181 LOG(LS_INFO) << "Created channel for " << content_name;
181 } 182 }
182 183
183 BaseChannel::~BaseChannel() { 184 BaseChannel::~BaseChannel() {
184 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); 185 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
185 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 186 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 575 }
575 576
576 void BaseChannel::OnSelectedCandidatePairChanged( 577 void BaseChannel::OnSelectedCandidatePairChanged(
577 TransportChannel* channel, 578 TransportChannel* channel,
578 CandidatePairInterface* selected_candidate_pair, 579 CandidatePairInterface* selected_candidate_pair,
579 int last_sent_packet_id, 580 int last_sent_packet_id,
580 bool ready_to_send) { 581 bool ready_to_send) {
581 RTC_DCHECK(channel == transport_channel_ || 582 RTC_DCHECK(channel == transport_channel_ ||
582 channel == rtcp_transport_channel_); 583 channel == rtcp_transport_channel_);
583 RTC_DCHECK(network_thread_->IsCurrent()); 584 RTC_DCHECK(network_thread_->IsCurrent());
585 selected_candidate_pair_ = selected_candidate_pair;
584 std::string transport_name = channel->transport_name(); 586 std::string transport_name = channel->transport_name();
585 rtc::NetworkRoute network_route; 587 rtc::NetworkRoute network_route;
586 if (selected_candidate_pair) { 588 if (selected_candidate_pair) {
587 network_route = rtc::NetworkRoute( 589 network_route = rtc::NetworkRoute(
588 ready_to_send, selected_candidate_pair->local_candidate().network_id(), 590 ready_to_send, selected_candidate_pair->local_candidate().network_id(),
589 selected_candidate_pair->remote_candidate().network_id(), 591 selected_candidate_pair->remote_candidate().network_id(),
590 last_sent_packet_id); 592 last_sent_packet_id);
593
594 invoker_.AsyncInvoke<void>(
595 RTC_FROM_HERE, worker_thread_,
596 Bind(&MediaChannel::OnTransportOverheadChange, media_channel_,
597 GetTransportOverheadPerPacket()));
591 } 598 }
592 invoker_.AsyncInvoke<void>( 599 invoker_.AsyncInvoke<void>(
593 RTC_FROM_HERE, worker_thread_, 600 RTC_FROM_HERE, worker_thread_,
594 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, 601 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name,
595 network_route)); 602 network_route));
596 } 603 }
597 604
598 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { 605 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) {
599 RTC_DCHECK(network_thread_->IsCurrent()); 606 RTC_DCHECK(network_thread_->IsCurrent());
600 if (rtcp) { 607 if (rtcp) {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 static_cast<int>(send_key->size()), 1033 static_cast<int>(send_key->size()),
1027 selected_crypto_suite, &(*recv_key)[0], 1034 selected_crypto_suite, &(*recv_key)[0],
1028 static_cast<int>(recv_key->size())); 1035 static_cast<int>(recv_key->size()));
1029 } else { 1036 } else {
1030 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], 1037 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0],
1031 static_cast<int>(send_key->size()), 1038 static_cast<int>(send_key->size()),
1032 selected_crypto_suite, &(*recv_key)[0], 1039 selected_crypto_suite, &(*recv_key)[0],
1033 static_cast<int>(recv_key->size())); 1040 static_cast<int>(recv_key->size()));
1034 } 1041 }
1035 1042
1036 if (!ret) 1043 if (!ret) {
1037 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; 1044 LOG(LS_WARNING) << "DTLS-SRTP key installation failed";
1038 else 1045 } else {
1039 dtls_keyed_ = true; 1046 dtls_keyed_ = true;
1040 1047 invoker_.AsyncInvoke<void>(
1048 RTC_FROM_HERE, worker_thread_,
1049 Bind(&MediaChannel::OnTransportOverheadChange, media_channel_,
1050 GetTransportOverheadPerPacket()));
1051 }
1041 return ret; 1052 return ret;
1042 } 1053 }
1043 1054
1044 void BaseChannel::MaybeSetupDtlsSrtp_n() { 1055 void BaseChannel::MaybeSetupDtlsSrtp_n() {
1045 if (srtp_filter_.IsActive()) { 1056 if (srtp_filter_.IsActive()) {
1046 return; 1057 return;
1047 } 1058 }
1048 1059
1049 if (!ShouldSetupDtlsSrtp_n()) { 1060 if (!ShouldSetupDtlsSrtp_n()) {
1050 return; 1061 return;
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 } 1669 }
1659 } 1670 }
1660 1671
1661 void BaseChannel::UpdateMediaSendRecvState() { 1672 void BaseChannel::UpdateMediaSendRecvState() {
1662 RTC_DCHECK(network_thread_->IsCurrent()); 1673 RTC_DCHECK(network_thread_->IsCurrent());
1663 invoker_.AsyncInvoke<void>( 1674 invoker_.AsyncInvoke<void>(
1664 RTC_FROM_HERE, worker_thread_, 1675 RTC_FROM_HERE, worker_thread_,
1665 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this)); 1676 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this));
1666 } 1677 }
1667 1678
1679 int BaseChannel::GetTransportOverheadPerPacket() {
1680 RTC_DCHECK(network_thread_->IsCurrent());
1681
1682 if (!selected_candidate_pair_)
1683 return 0;
1684
1685 int transport_overhead_per_packet = 0;
1686
1687 constexpr int kIpv4Overhaed = 20;
1688 constexpr int kIpv6Overhaed = 40;
1689 transport_overhead_per_packet +=
1690 selected_candidate_pair_->local_candidate().address().family() == AF_INET
1691 ? kIpv4Overhaed
1692 : kIpv6Overhaed;
1693
1694 constexpr int kUdpOverhaed = 8;
1695 constexpr int kTcpOverhaed = 20;
1696 transport_overhead_per_packet +=
1697 selected_candidate_pair_->local_candidate().protocol() ==
1698 TCP_PROTOCOL_NAME
1699 ? kTcpOverhaed
1700 : kUdpOverhaed;
1701
1702 if (secure()) {
1703 int srtp_overhead = 0;
1704 if (srtp_filter_.GetSrtpOverhead(&srtp_overhead))
1705 transport_overhead_per_packet += srtp_overhead;
1706 }
1707
1708 return transport_overhead_per_packet;
1709 }
1710
1668 void VoiceChannel::UpdateMediaSendRecvState_w() { 1711 void VoiceChannel::UpdateMediaSendRecvState_w() {
1669 // Render incoming data if we're the active call, and we have the local 1712 // Render incoming data if we're the active call, and we have the local
1670 // content. We receive data on the default channel and multiplexed streams. 1713 // content. We receive data on the default channel and multiplexed streams.
1671 bool recv = IsReadyToReceiveMedia_w(); 1714 bool recv = IsReadyToReceiveMedia_w();
1672 media_channel()->SetPlayout(recv); 1715 media_channel()->SetPlayout(recv);
1673 1716
1674 // Send outgoing data if we're the active call, we have the remote content, 1717 // Send outgoing data if we're the active call, we have the remote content,
1675 // and we have had some form of connectivity. 1718 // and we have had some form of connectivity.
1676 bool send = IsReadyToSendMedia_w(); 1719 bool send = IsReadyToSendMedia_w();
1677 media_channel()->SetSend(send); 1720 media_channel()->SetSend(send);
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 } 2457 }
2415 2458
2416 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2459 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2417 rtc::TypedMessageData<uint32_t>* message = 2460 rtc::TypedMessageData<uint32_t>* message =
2418 new rtc::TypedMessageData<uint32_t>(sid); 2461 new rtc::TypedMessageData<uint32_t>(sid);
2419 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, 2462 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY,
2420 message); 2463 message);
2421 } 2464 }
2422 2465
2423 } // namespace cricket 2466 } // namespace cricket
OLDNEW
« 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