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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 TransportChannel* channel, | 575 TransportChannel* channel, |
576 CandidatePairInterface* selected_candidate_pair, | 576 CandidatePairInterface* selected_candidate_pair, |
577 int last_sent_packet_id, | 577 int last_sent_packet_id, |
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 selected_candidate_pair_ = | |
586 rtc::Optional<CandidatePair>(CandidatePair(*selected_candidate_pair)); | |
honghaiz3
2016/10/31 17:42:09
You don't need to save a copy of CandidatePair her
| |
587 | |
585 network_route = rtc::NetworkRoute( | 588 network_route = rtc::NetworkRoute( |
586 ready_to_send, selected_candidate_pair->local_candidate().network_id(), | 589 ready_to_send, selected_candidate_pair->local_candidate().network_id(), |
587 selected_candidate_pair->remote_candidate().network_id(), | 590 selected_candidate_pair->remote_candidate().network_id(), |
588 last_sent_packet_id); | 591 last_sent_packet_id); |
592 | |
593 invoker_.AsyncInvoke<void>( | |
594 RTC_FROM_HERE, worker_thread_, | |
595 Bind(&MediaChannel::OnTransportOverheadChange, media_channel_, | |
596 GetTransportOverheadPerPacket())); | |
597 } else { | |
598 selected_candidate_pair_ = rtc::Optional<CandidatePair>(); | |
589 } | 599 } |
590 invoker_.AsyncInvoke<void>( | 600 invoker_.AsyncInvoke<void>( |
591 RTC_FROM_HERE, worker_thread_, | 601 RTC_FROM_HERE, worker_thread_, |
592 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, | 602 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, |
593 network_route)); | 603 network_route)); |
594 } | 604 } |
595 | 605 |
596 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { | 606 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { |
597 RTC_DCHECK(network_thread_->IsCurrent()); | 607 RTC_DCHECK(network_thread_->IsCurrent()); |
598 if (rtcp) { | 608 if (rtcp) { |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1023 static_cast<int>(send_key->size()), | 1033 static_cast<int>(send_key->size()), |
1024 selected_crypto_suite, &(*recv_key)[0], | 1034 selected_crypto_suite, &(*recv_key)[0], |
1025 static_cast<int>(recv_key->size())); | 1035 static_cast<int>(recv_key->size())); |
1026 } else { | 1036 } else { |
1027 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], | 1037 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], |
1028 static_cast<int>(send_key->size()), | 1038 static_cast<int>(send_key->size()), |
1029 selected_crypto_suite, &(*recv_key)[0], | 1039 selected_crypto_suite, &(*recv_key)[0], |
1030 static_cast<int>(recv_key->size())); | 1040 static_cast<int>(recv_key->size())); |
1031 } | 1041 } |
1032 | 1042 |
1033 if (!ret) | 1043 if (!ret) { |
1034 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; | 1044 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; |
1035 else | 1045 } else { |
1036 dtls_keyed_ = true; | 1046 dtls_keyed_ = true; |
1037 | 1047 invoker_.AsyncInvoke<void>( |
1048 RTC_FROM_HERE, worker_thread_, | |
1049 Bind(&MediaChannel::OnTransportOverheadChange, media_channel_, | |
1050 GetTransportOverheadPerPacket())); | |
1051 } | |
1038 return ret; | 1052 return ret; |
1039 } | 1053 } |
1040 | 1054 |
1041 void BaseChannel::MaybeSetupDtlsSrtp_n() { | 1055 void BaseChannel::MaybeSetupDtlsSrtp_n() { |
1042 if (srtp_filter_.IsActive()) { | 1056 if (srtp_filter_.IsActive()) { |
1043 return; | 1057 return; |
1044 } | 1058 } |
1045 | 1059 |
1046 if (!ShouldSetupDtlsSrtp_n()) { | 1060 if (!ShouldSetupDtlsSrtp_n()) { |
1047 return; | 1061 return; |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1654 } | 1668 } |
1655 } | 1669 } |
1656 | 1670 |
1657 void BaseChannel::UpdateMediaSendRecvState() { | 1671 void BaseChannel::UpdateMediaSendRecvState() { |
1658 RTC_DCHECK(network_thread_->IsCurrent()); | 1672 RTC_DCHECK(network_thread_->IsCurrent()); |
1659 invoker_.AsyncInvoke<void>( | 1673 invoker_.AsyncInvoke<void>( |
1660 RTC_FROM_HERE, worker_thread_, | 1674 RTC_FROM_HERE, worker_thread_, |
1661 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this)); | 1675 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this)); |
1662 } | 1676 } |
1663 | 1677 |
1678 int BaseChannel::GetTransportOverheadPerPacket() { | |
1679 constexpr int kIpv4Overhaed = 20; | |
1680 constexpr int kIpv6Overhaed = 40; | |
1681 constexpr int kUdpOverhaed = 8; | |
1682 constexpr int kTcpOverhaed = 20; | |
honghaiz3
2016/10/31 17:42:09
If you just use the saved selected_candidate_pair
michaelt
2016/11/01 08:31:37
Done.
| |
1683 | |
1684 int transport_overhead_per_packet = 0; | |
1685 | |
1686 if (selected_candidate_pair_) { | |
honghaiz3
2016/10/31 17:42:09
Can you use an early return? That would be more re
michaelt
2016/11/01 08:31:37
Done.
| |
1687 transport_overhead_per_packet += | |
1688 selected_candidate_pair_->local_candidate().protocol() == | |
1689 TCP_PROTOCOL_NAME | |
1690 ? kTcpOverhaed | |
1691 : kUdpOverhaed; | |
1692 transport_overhead_per_packet += | |
1693 selected_candidate_pair_->local_candidate().address().family() == | |
1694 AF_INET | |
1695 ? kIpv4Overhaed | |
1696 : kIpv6Overhaed; | |
1697 if (secure()) { | |
1698 int srtp_overhead = 0; | |
1699 if (srtp_filter_.GetSrtpOverhead(&srtp_overhead)) | |
1700 transport_overhead_per_packet += srtp_overhead; | |
1701 } | |
1702 } | |
1703 return transport_overhead_per_packet; | |
1704 } | |
1705 | |
1664 void VoiceChannel::UpdateMediaSendRecvState_w() { | 1706 void VoiceChannel::UpdateMediaSendRecvState_w() { |
1665 // Render incoming data if we're the active call, and we have the local | 1707 // 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. | 1708 // content. We receive data on the default channel and multiplexed streams. |
1667 bool recv = IsReadyToReceiveMedia_w(); | 1709 bool recv = IsReadyToReceiveMedia_w(); |
1668 media_channel()->SetPlayout(recv); | 1710 media_channel()->SetPlayout(recv); |
1669 | 1711 |
1670 // Send outgoing data if we're the active call, we have the remote content, | 1712 // Send outgoing data if we're the active call, we have the remote content, |
1671 // and we have had some form of connectivity. | 1713 // and we have had some form of connectivity. |
1672 bool send = IsReadyToSendMedia_w(); | 1714 bool send = IsReadyToSendMedia_w(); |
1673 media_channel()->SetSend(send); | 1715 media_channel()->SetSend(send); |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2410 } | 2452 } |
2411 | 2453 |
2412 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 2454 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { |
2413 rtc::TypedMessageData<uint32_t>* message = | 2455 rtc::TypedMessageData<uint32_t>* message = |
2414 new rtc::TypedMessageData<uint32_t>(sid); | 2456 new rtc::TypedMessageData<uint32_t>(sid); |
2415 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, | 2457 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, |
2416 message); | 2458 message); |
2417 } | 2459 } |
2418 | 2460 |
2419 } // namespace cricket | 2461 } // namespace cricket |
OLD | NEW |