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

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

Issue 2437503004: Set actual transport overhead in rtp_rtcp (Closed)
Patch Set: Responde to comments. 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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 RTC_DCHECK(channel == transport_channel_ || 579 RTC_DCHECK(channel == transport_channel_ ||
580 channel == rtcp_transport_channel_); 580 channel == rtcp_transport_channel_);
581 RTC_DCHECK(network_thread_->IsCurrent()); 581 RTC_DCHECK(network_thread_->IsCurrent());
582 std::string transport_name = channel->transport_name(); 582 std::string transport_name = channel->transport_name();
583 rtc::NetworkRoute network_route; 583 rtc::NetworkRoute network_route;
584 if (selected_candidate_pair) { 584 if (selected_candidate_pair) {
585 network_route = rtc::NetworkRoute( 585 network_route = rtc::NetworkRoute(
586 ready_to_send, selected_candidate_pair->local_candidate().network_id(), 586 ready_to_send, selected_candidate_pair->local_candidate().network_id(),
587 selected_candidate_pair->remote_candidate().network_id(), 587 selected_candidate_pair->remote_candidate().network_id(),
588 last_sent_packet_id); 588 last_sent_packet_id);
589
590 invoker_.AsyncInvoke<void>(
591 RTC_FROM_HERE, worker_thread_,
592 Bind(&MediaChannel::OnTransportOverheadChange, media_channel_,
593 GetTransportOverheadPerPacket(
594 selected_candidate_pair->local_candidate())));
589 } 595 }
596
590 invoker_.AsyncInvoke<void>( 597 invoker_.AsyncInvoke<void>(
591 RTC_FROM_HERE, worker_thread_, 598 RTC_FROM_HERE, worker_thread_,
592 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, 599 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name,
593 network_route)); 600 network_route));
594 } 601 }
595 602
596 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { 603 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) {
597 RTC_DCHECK(network_thread_->IsCurrent()); 604 RTC_DCHECK(network_thread_->IsCurrent());
598 if (rtcp) { 605 if (rtcp) {
599 rtcp_ready_to_send_ = ready; 606 rtcp_ready_to_send_ = ready;
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 static_cast<int>(send_key->size()), 1030 static_cast<int>(send_key->size()),
1024 selected_crypto_suite, &(*recv_key)[0], 1031 selected_crypto_suite, &(*recv_key)[0],
1025 static_cast<int>(recv_key->size())); 1032 static_cast<int>(recv_key->size()));
1026 } else { 1033 } else {
1027 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], 1034 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0],
1028 static_cast<int>(send_key->size()), 1035 static_cast<int>(send_key->size()),
1029 selected_crypto_suite, &(*recv_key)[0], 1036 selected_crypto_suite, &(*recv_key)[0],
1030 static_cast<int>(recv_key->size())); 1037 static_cast<int>(recv_key->size()));
1031 } 1038 }
1032 1039
1033 if (!ret) 1040 if (!ret) {
1034 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; 1041 LOG(LS_WARNING) << "DTLS-SRTP key installation failed";
1035 else 1042 } else {
1036 dtls_keyed_ = true; 1043 dtls_keyed_ = true;
1037 1044 invoker_.AsyncInvoke<void>(
1045 RTC_FROM_HERE, worker_thread_,
1046 Bind(&MediaChannel::OnTransportOverheadChange, media_channel_,
1047 GetTransportOverheadPerPacket()));
1048 }
1038 return ret; 1049 return ret;
1039 } 1050 }
1040 1051
1041 void BaseChannel::MaybeSetupDtlsSrtp_n() { 1052 void BaseChannel::MaybeSetupDtlsSrtp_n() {
1042 if (srtp_filter_.IsActive()) { 1053 if (srtp_filter_.IsActive()) {
1043 return; 1054 return;
1044 } 1055 }
1045 1056
1046 if (!ShouldSetupDtlsSrtp_n()) { 1057 if (!ShouldSetupDtlsSrtp_n()) {
1047 return; 1058 return;
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 } 1665 }
1655 } 1666 }
1656 1667
1657 void BaseChannel::UpdateMediaSendRecvState() { 1668 void BaseChannel::UpdateMediaSendRecvState() {
1658 RTC_DCHECK(network_thread_->IsCurrent()); 1669 RTC_DCHECK(network_thread_->IsCurrent());
1659 invoker_.AsyncInvoke<void>( 1670 invoker_.AsyncInvoke<void>(
1660 RTC_FROM_HERE, worker_thread_, 1671 RTC_FROM_HERE, worker_thread_,
1661 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this)); 1672 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this));
1662 } 1673 }
1663 1674
1675 int BaseChannel::GetTransportOverheadPerPacket() {
1676 if (transport_channel_) {
1677 std::vector<ConnectionInfo> connection_infos;
1678 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
1679 for (auto& connection_info : connection_infos) {
1680 if (connection_info.best_connection) {
1681 return GetTransportOverheadPerPacket(connection_info.local_candidate);
1682 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.
1683 }
1684 }
1685 }
1686 return 0;
1687 }
1688
1689 int BaseChannel::GetTransportOverheadPerPacket(
1690 const Candidate& local_candidate) {
1691 constexpr int kIpv4Overhaed = 20;
1692 constexpr int kIpv6Overhaed = 40;
1693 constexpr int kUdpOverhaed = 8;
1694 constexpr int kTcpOverhaed = 20;
1695
1696 int transport_overhead_per_packet = 0;
1697 transport_overhead_per_packet +=
1698 local_candidate.protocol() == TCP_PROTOCOL_NAME ? kTcpOverhaed
1699 : kUdpOverhaed;
1700 transport_overhead_per_packet += local_candidate.address().family() == AF_INET
1701 ? kIpv4Overhaed
1702 : kIpv6Overhaed;
1703 if (secure()) {
1704 int srtp_overhead = 0;
1705 if (srtp_filter_.GetSrtpOverhead(&srtp_overhead))
1706 transport_overhead_per_packet += srtp_overhead;
1707 }
1708 return transport_overhead_per_packet;
1709 }
1710
1664 void VoiceChannel::UpdateMediaSendRecvState_w() { 1711 void VoiceChannel::UpdateMediaSendRecvState_w() {
1665 // 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
1666 // content. We receive data on the default channel and multiplexed streams. 1713 // content. We receive data on the default channel and multiplexed streams.
1667 bool recv = IsReadyToReceiveMedia_w(); 1714 bool recv = IsReadyToReceiveMedia_w();
1668 media_channel()->SetPlayout(recv); 1715 media_channel()->SetPlayout(recv);
1669 1716
1670 // 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,
1671 // and we have had some form of connectivity. 1718 // and we have had some form of connectivity.
1672 bool send = IsReadyToSendMedia_w(); 1719 bool send = IsReadyToSendMedia_w();
1673 media_channel()->SetSend(send); 1720 media_channel()->SetSend(send);
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 } 2457 }
2411 2458
2412 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2459 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2413 rtc::TypedMessageData<uint32_t>* message = 2460 rtc::TypedMessageData<uint32_t>* message =
2414 new rtc::TypedMessageData<uint32_t>(sid); 2461 new rtc::TypedMessageData<uint32_t>(sid);
2415 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, 2462 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY,
2416 message); 2463 message);
2417 } 2464 }
2418 2465
2419 } // 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