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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 // Bon voyage. | 741 // Bon voyage. |
742 int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL; | 742 int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL; |
743 return rtp_transport_->SendPacket(rtcp, packet, updated_options, flags); | 743 return rtp_transport_->SendPacket(rtcp, packet, updated_options, flags); |
744 } | 744 } |
745 | 745 |
746 bool BaseChannel::HandlesPayloadType(int packet_type) const { | 746 bool BaseChannel::HandlesPayloadType(int packet_type) const { |
747 return rtp_transport_->HandlesPayloadType(packet_type); | 747 return rtp_transport_->HandlesPayloadType(packet_type); |
748 } | 748 } |
749 | 749 |
750 void BaseChannel::OnPacketReceived(bool rtcp, | 750 void BaseChannel::OnPacketReceived(bool rtcp, |
751 rtc::CopyOnWriteBuffer& packet, | 751 rtc::CopyOnWriteBuffer* packet, |
752 const rtc::PacketTime& packet_time) { | 752 const rtc::PacketTime& packet_time) { |
753 if (!has_received_packet_ && !rtcp) { | 753 if (!has_received_packet_ && !rtcp) { |
754 has_received_packet_ = true; | 754 has_received_packet_ = true; |
755 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED); | 755 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED); |
756 } | 756 } |
757 | 757 |
758 // Unprotect the packet, if needed. | 758 // Unprotect the packet, if needed. |
759 if (srtp_filter_.IsActive()) { | 759 if (srtp_filter_.IsActive()) { |
760 TRACE_EVENT0("webrtc", "SRTP Decode"); | 760 TRACE_EVENT0("webrtc", "SRTP Decode"); |
761 char* data = packet.data<char>(); | 761 char* data = packet->data<char>(); |
762 int len = static_cast<int>(packet.size()); | 762 int len = static_cast<int>(packet->size()); |
763 bool res; | 763 bool res; |
764 if (!rtcp) { | 764 if (!rtcp) { |
765 res = srtp_filter_.UnprotectRtp(data, len, &len); | 765 res = srtp_filter_.UnprotectRtp(data, len, &len); |
766 if (!res) { | 766 if (!res) { |
767 int seq_num = -1; | 767 int seq_num = -1; |
768 uint32_t ssrc = 0; | 768 uint32_t ssrc = 0; |
769 GetRtpSeqNum(data, len, &seq_num); | 769 GetRtpSeqNum(data, len, &seq_num); |
770 GetRtpSsrc(data, len, &ssrc); | 770 GetRtpSsrc(data, len, &ssrc); |
771 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ | 771 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ |
772 << " RTP packet: size=" << len << ", seqnum=" << seq_num | 772 << " RTP packet: size=" << len << ", seqnum=" << seq_num |
773 << ", SSRC=" << ssrc; | 773 << ", SSRC=" << ssrc; |
774 return; | 774 return; |
775 } | 775 } |
776 } else { | 776 } else { |
777 res = srtp_filter_.UnprotectRtcp(data, len, &len); | 777 res = srtp_filter_.UnprotectRtcp(data, len, &len); |
778 if (!res) { | 778 if (!res) { |
779 int type = -1; | 779 int type = -1; |
780 GetRtcpType(data, len, &type); | 780 GetRtcpType(data, len, &type); |
781 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ | 781 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ |
782 << " RTCP packet: size=" << len << ", type=" << type; | 782 << " RTCP packet: size=" << len << ", type=" << type; |
783 return; | 783 return; |
784 } | 784 } |
785 } | 785 } |
786 | 786 |
787 packet.SetSize(len); | 787 packet->SetSize(len); |
788 } else if (srtp_required_) { | 788 } else if (srtp_required_) { |
789 // Our session description indicates that SRTP is required, but we got a | 789 // Our session description indicates that SRTP is required, but we got a |
790 // packet before our SRTP filter is active. This means either that | 790 // packet before our SRTP filter is active. This means either that |
791 // a) we got SRTP packets before we received the SDES keys, in which case | 791 // a) we got SRTP packets before we received the SDES keys, in which case |
792 // we can't decrypt it anyway, or | 792 // we can't decrypt it anyway, or |
793 // b) we got SRTP packets before DTLS completed on both the RTP and RTCP | 793 // b) we got SRTP packets before DTLS completed on both the RTP and RTCP |
794 // transports, so we haven't yet extracted keys, even if DTLS did | 794 // transports, so we haven't yet extracted keys, even if DTLS did |
795 // complete on the transport that the packets are being sent on. It's | 795 // complete on the transport that the packets are being sent on. It's |
796 // really good practice to wait for both RTP and RTCP to be good to go | 796 // really good practice to wait for both RTP and RTCP to be good to go |
797 // before sending media, to prevent weird failure modes, so it's fine | 797 // before sending media, to prevent weird failure modes, so it's fine |
798 // for us to just eat packets here. This is all sidestepped if RTCP mux | 798 // for us to just eat packets here. This is all sidestepped if RTCP mux |
799 // is used anyway. | 799 // is used anyway. |
800 LOG(LS_WARNING) << "Can't process incoming " << RtpRtcpStringLiteral(rtcp) | 800 LOG(LS_WARNING) << "Can't process incoming " << RtpRtcpStringLiteral(rtcp) |
801 << " packet when SRTP is inactive and crypto is required"; | 801 << " packet when SRTP is inactive and crypto is required"; |
802 return; | 802 return; |
803 } | 803 } |
804 | 804 |
805 invoker_.AsyncInvoke<void>( | 805 invoker_.AsyncInvoke<void>( |
806 RTC_FROM_HERE, worker_thread_, | 806 RTC_FROM_HERE, worker_thread_, |
807 Bind(&BaseChannel::ProcessPacket, this, rtcp, packet, packet_time)); | 807 Bind(&BaseChannel::ProcessPacket, this, rtcp, *packet, packet_time)); |
808 } | 808 } |
809 | 809 |
810 void BaseChannel::ProcessPacket(bool rtcp, | 810 void BaseChannel::ProcessPacket(bool rtcp, |
811 const rtc::CopyOnWriteBuffer& packet, | 811 const rtc::CopyOnWriteBuffer& packet, |
812 const rtc::PacketTime& packet_time) { | 812 const rtc::PacketTime& packet_time) { |
813 RTC_DCHECK(worker_thread_->IsCurrent()); | 813 RTC_DCHECK(worker_thread_->IsCurrent()); |
814 | 814 |
815 // Need to copy variable because OnRtcpReceived/OnPacketReceived | 815 // Need to copy variable because OnRtcpReceived/OnPacketReceived |
816 // requires non-const pointer to buffer. This doesn't memcpy the actual data. | 816 // requires non-const pointer to buffer. This doesn't memcpy the actual data. |
817 rtc::CopyOnWriteBuffer data(packet); | 817 rtc::CopyOnWriteBuffer data(packet); |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 | 1671 |
1672 int VoiceChannel::GetOutputLevel_w() { | 1672 int VoiceChannel::GetOutputLevel_w() { |
1673 return media_channel()->GetOutputLevel(); | 1673 return media_channel()->GetOutputLevel(); |
1674 } | 1674 } |
1675 | 1675 |
1676 void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) { | 1676 void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) { |
1677 media_channel()->GetActiveStreams(actives); | 1677 media_channel()->GetActiveStreams(actives); |
1678 } | 1678 } |
1679 | 1679 |
1680 void VoiceChannel::OnPacketReceived(bool rtcp, | 1680 void VoiceChannel::OnPacketReceived(bool rtcp, |
1681 rtc::CopyOnWriteBuffer& packet, | 1681 rtc::CopyOnWriteBuffer* packet, |
1682 const rtc::PacketTime& packet_time) { | 1682 const rtc::PacketTime& packet_time) { |
1683 BaseChannel::OnPacketReceived(rtcp, packet, packet_time); | 1683 BaseChannel::OnPacketReceived(rtcp, packet, packet_time); |
1684 // Set a flag when we've received an RTP packet. If we're waiting for early | 1684 // Set a flag when we've received an RTP packet. If we're waiting for early |
1685 // media, this will disable the timeout. | 1685 // media, this will disable the timeout. |
1686 if (!received_media_ && !rtcp) { | 1686 if (!received_media_ && !rtcp) { |
1687 received_media_ = true; | 1687 received_media_ = true; |
1688 } | 1688 } |
1689 } | 1689 } |
1690 | 1690 |
1691 void BaseChannel::UpdateMediaSendRecvState() { | 1691 void BaseChannel::UpdateMediaSendRecvState() { |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2448 | 2448 |
2449 void RtpDataChannel::OnDataChannelReadyToSend(bool writable) { | 2449 void RtpDataChannel::OnDataChannelReadyToSend(bool writable) { |
2450 // This is usded for congestion control to indicate that the stream is ready | 2450 // This is usded for congestion control to indicate that the stream is ready |
2451 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates | 2451 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates |
2452 // that the transport channel is ready. | 2452 // that the transport channel is ready. |
2453 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, | 2453 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, |
2454 new DataChannelReadyToSendMessageData(writable)); | 2454 new DataChannelReadyToSendMessageData(writable)); |
2455 } | 2455 } |
2456 | 2456 |
2457 } // namespace cricket | 2457 } // namespace cricket |
OLD | NEW |