OLD | NEW |
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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 bool ready_to_send) { | 578 bool ready_to_send) { |
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 GetTransportOverheadPerPacket(*selected_candidate_pair)); |
589 } | 590 } |
590 invoker_.AsyncInvoke<void>( | 591 invoker_.AsyncInvoke<void>( |
591 RTC_FROM_HERE, worker_thread_, | 592 RTC_FROM_HERE, worker_thread_, |
592 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, | 593 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, |
593 network_route)); | 594 network_route)); |
594 } | 595 } |
595 | 596 |
596 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { | 597 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { |
597 RTC_DCHECK(network_thread_->IsCurrent()); | 598 RTC_DCHECK(network_thread_->IsCurrent()); |
598 if (rtcp) { | 599 if (rtcp) { |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 } | 1655 } |
1655 } | 1656 } |
1656 | 1657 |
1657 void BaseChannel::UpdateMediaSendRecvState() { | 1658 void BaseChannel::UpdateMediaSendRecvState() { |
1658 RTC_DCHECK(network_thread_->IsCurrent()); | 1659 RTC_DCHECK(network_thread_->IsCurrent()); |
1659 invoker_.AsyncInvoke<void>( | 1660 invoker_.AsyncInvoke<void>( |
1660 RTC_FROM_HERE, worker_thread_, | 1661 RTC_FROM_HERE, worker_thread_, |
1661 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this)); | 1662 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this)); |
1662 } | 1663 } |
1663 | 1664 |
| 1665 int BaseChannel::GetTransportOverheadPerPacket( |
| 1666 const CandidatePairInterface& selected_candidate_pair) { |
| 1667 constexpr int kIpv4Overhaed = 20; |
| 1668 constexpr int kIpv6Overhaed = 40; |
| 1669 constexpr int kUdpOverhaed = 8; |
| 1670 constexpr int kTcpOverhaed = 20; |
| 1671 constexpr int kSrtpAuthOverhaed = 4; |
| 1672 |
| 1673 int ransport_overhead_per_packet = 0; |
| 1674 ransport_overhead_per_packet += |
| 1675 selected_candidate_pair.local_candidate().protocol() == TCP_PROTOCOL_NAME |
| 1676 ? kTcpOverhaed |
| 1677 : kUdpOverhaed; |
| 1678 ransport_overhead_per_packet += |
| 1679 selected_candidate_pair.local_candidate().address().family() == AF_INET |
| 1680 ? kIpv4Overhaed |
| 1681 : kIpv6Overhaed; |
| 1682 if (secure()) { |
| 1683 ransport_overhead_per_packet += kSrtpAuthOverhaed; |
| 1684 } |
| 1685 return ransport_overhead_per_packet; |
| 1686 } |
| 1687 |
1664 void VoiceChannel::UpdateMediaSendRecvState_w() { | 1688 void VoiceChannel::UpdateMediaSendRecvState_w() { |
1665 // Render incoming data if we're the active call, and we have the local | 1689 // 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. | 1690 // content. We receive data on the default channel and multiplexed streams. |
1667 bool recv = IsReadyToReceiveMedia_w(); | 1691 bool recv = IsReadyToReceiveMedia_w(); |
1668 media_channel()->SetPlayout(recv); | 1692 media_channel()->SetPlayout(recv); |
1669 | 1693 |
1670 // Send outgoing data if we're the active call, we have the remote content, | 1694 // Send outgoing data if we're the active call, we have the remote content, |
1671 // and we have had some form of connectivity. | 1695 // and we have had some form of connectivity. |
1672 bool send = IsReadyToSendMedia_w(); | 1696 bool send = IsReadyToSendMedia_w(); |
1673 media_channel()->SetSend(send); | 1697 media_channel()->SetSend(send); |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2410 } | 2434 } |
2411 | 2435 |
2412 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 2436 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { |
2413 rtc::TypedMessageData<uint32_t>* message = | 2437 rtc::TypedMessageData<uint32_t>* message = |
2414 new rtc::TypedMessageData<uint32_t>(sid); | 2438 new rtc::TypedMessageData<uint32_t>(sid); |
2415 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, | 2439 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, |
2416 message); | 2440 message); |
2417 } | 2441 } |
2418 | 2442 |
2419 } // namespace cricket | 2443 } // namespace cricket |
OLD | NEW |