| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2  *  Copyright 2011 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 43     return false; | 43     return false; | 
| 44   } | 44   } | 
| 45   const uint8_t* u = reinterpret_cast<const uint8_t*>(data); | 45   const uint8_t* u = reinterpret_cast<const uint8_t*>(data); | 
| 46   return len > 17 && u[0] == 22 && u[13] == 1; | 46   return len > 17 && u[0] == 22 && u[13] == 1; | 
| 47 } | 47 } | 
| 48 static bool IsRtpPacket(const char* data, size_t len) { | 48 static bool IsRtpPacket(const char* data, size_t len) { | 
| 49   const uint8_t* u = reinterpret_cast<const uint8_t*>(data); | 49   const uint8_t* u = reinterpret_cast<const uint8_t*>(data); | 
| 50   return (len >= kMinRtpPacketLen && (u[0] & 0xC0) == 0x80); | 50   return (len >= kMinRtpPacketLen && (u[0] & 0xC0) == 0x80); | 
| 51 } | 51 } | 
| 52 | 52 | 
| 53 StreamInterfaceChannel::StreamInterfaceChannel(IceTransportInternal* channel) | 53 StreamInterfaceChannel::StreamInterfaceChannel(TransportChannel* channel) | 
| 54     : channel_(channel), | 54     : channel_(channel), | 
| 55       state_(rtc::SS_OPEN), | 55       state_(rtc::SS_OPEN), | 
| 56       packets_(kMaxPendingPackets, kMaxDtlsPacketLen) {} | 56       packets_(kMaxPendingPackets, kMaxDtlsPacketLen) { | 
|  | 57 } | 
| 57 | 58 | 
| 58 rtc::StreamResult StreamInterfaceChannel::Read(void* buffer, | 59 rtc::StreamResult StreamInterfaceChannel::Read(void* buffer, | 
| 59                                                      size_t buffer_len, | 60                                                      size_t buffer_len, | 
| 60                                                      size_t* read, | 61                                                      size_t* read, | 
| 61                                                      int* error) { | 62                                                      int* error) { | 
| 62   if (state_ == rtc::SS_CLOSED) | 63   if (state_ == rtc::SS_CLOSED) | 
| 63     return rtc::SR_EOS; | 64     return rtc::SR_EOS; | 
| 64   if (state_ == rtc::SS_OPENING) | 65   if (state_ == rtc::SS_OPENING) | 
| 65     return rtc::SR_BLOCK; | 66     return rtc::SR_BLOCK; | 
| 66 | 67 | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 95   } | 96   } | 
| 96   return ret; | 97   return ret; | 
| 97 } | 98 } | 
| 98 | 99 | 
| 99 void StreamInterfaceChannel::Close() { | 100 void StreamInterfaceChannel::Close() { | 
| 100   packets_.Clear(); | 101   packets_.Clear(); | 
| 101   state_ = rtc::SS_CLOSED; | 102   state_ = rtc::SS_CLOSED; | 
| 102 } | 103 } | 
| 103 | 104 | 
| 104 DtlsTransportChannelWrapper::DtlsTransportChannelWrapper( | 105 DtlsTransportChannelWrapper::DtlsTransportChannelWrapper( | 
| 105     IceTransportInternal* channel) | 106     TransportChannelImpl* channel) | 
| 106     : TransportChannelImpl(channel->transport_name(), channel->component()), | 107     : TransportChannelImpl(channel->transport_name(), channel->component()), | 
| 107       network_thread_(rtc::Thread::Current()), | 108       network_thread_(rtc::Thread::Current()), | 
| 108       channel_(channel), | 109       channel_(channel), | 
| 109       downward_(NULL), | 110       downward_(NULL), | 
| 110       ssl_role_(rtc::SSL_CLIENT), | 111       ssl_role_(rtc::SSL_CLIENT), | 
| 111       ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_12) { | 112       ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_12) { | 
| 112   channel_->SignalWritableState.connect(this, | 113   channel_->SignalWritableState.connect(this, | 
| 113       &DtlsTransportChannelWrapper::OnWritableState); | 114       &DtlsTransportChannelWrapper::OnWritableState); | 
| 114   channel_->SignalReadPacket.connect(this, | 115   channel_->SignalReadPacket.connect(this, | 
| 115       &DtlsTransportChannelWrapper::OnReadPacket); | 116       &DtlsTransportChannelWrapper::OnReadPacket); | 
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 676     tmp_data += record_len + kDtlsRecordHeaderLen; | 677     tmp_data += record_len + kDtlsRecordHeaderLen; | 
| 677     tmp_size -= record_len + kDtlsRecordHeaderLen; | 678     tmp_size -= record_len + kDtlsRecordHeaderLen; | 
| 678   } | 679   } | 
| 679 | 680 | 
| 680   // Looks good. Pass to the SIC which ends up being passed to | 681   // Looks good. Pass to the SIC which ends up being passed to | 
| 681   // the DTLS stack. | 682   // the DTLS stack. | 
| 682   return downward_->OnPacketReceived(data, size); | 683   return downward_->OnPacketReceived(data, size); | 
| 683 } | 684 } | 
| 684 | 685 | 
| 685 void DtlsTransportChannelWrapper::OnGatheringState( | 686 void DtlsTransportChannelWrapper::OnGatheringState( | 
| 686     IceTransportInternal* channel) { | 687     TransportChannelImpl* channel) { | 
| 687   ASSERT(channel == channel_); | 688   ASSERT(channel == channel_); | 
| 688   SignalGatheringState(this); | 689   SignalGatheringState(this); | 
| 689 } | 690 } | 
| 690 | 691 | 
| 691 void DtlsTransportChannelWrapper::OnCandidateGathered( | 692 void DtlsTransportChannelWrapper::OnCandidateGathered( | 
| 692     IceTransportInternal* channel, | 693     TransportChannelImpl* channel, | 
| 693     const Candidate& c) { | 694     const Candidate& c) { | 
| 694   ASSERT(channel == channel_); | 695   ASSERT(channel == channel_); | 
| 695   SignalCandidateGathered(this, c); | 696   SignalCandidateGathered(this, c); | 
| 696 } | 697 } | 
| 697 | 698 | 
| 698 void DtlsTransportChannelWrapper::OnCandidatesRemoved( | 699 void DtlsTransportChannelWrapper::OnCandidatesRemoved( | 
| 699     IceTransportInternal* channel, | 700     TransportChannelImpl* channel, | 
| 700     const Candidates& candidates) { | 701     const Candidates& candidates) { | 
| 701   ASSERT(channel == channel_); | 702   ASSERT(channel == channel_); | 
| 702   SignalCandidatesRemoved(this, candidates); | 703   SignalCandidatesRemoved(this, candidates); | 
| 703 } | 704 } | 
| 704 | 705 | 
| 705 void DtlsTransportChannelWrapper::OnRoleConflict( | 706 void DtlsTransportChannelWrapper::OnRoleConflict( | 
| 706     IceTransportInternal* channel) { | 707     TransportChannelImpl* channel) { | 
| 707   ASSERT(channel == channel_); | 708   ASSERT(channel == channel_); | 
| 708   SignalRoleConflict(this); | 709   SignalRoleConflict(this); | 
| 709 } | 710 } | 
| 710 | 711 | 
| 711 void DtlsTransportChannelWrapper::OnRouteChange(IceTransportInternal* channel, | 712 void DtlsTransportChannelWrapper::OnRouteChange( | 
| 712                                                 const Candidate& candidate) { | 713     TransportChannel* channel, const Candidate& candidate) { | 
| 713   ASSERT(channel == channel_); | 714   ASSERT(channel == channel_); | 
| 714   SignalRouteChange(this, candidate); | 715   SignalRouteChange(this, candidate); | 
| 715 } | 716 } | 
| 716 | 717 | 
| 717 void DtlsTransportChannelWrapper::OnSelectedCandidatePairChanged( | 718 void DtlsTransportChannelWrapper::OnSelectedCandidatePairChanged( | 
| 718     IceTransportInternal* channel, | 719     TransportChannel* channel, | 
| 719     CandidatePairInterface* selected_candidate_pair, | 720     CandidatePairInterface* selected_candidate_pair, | 
| 720     int last_sent_packet_id, | 721     int last_sent_packet_id, | 
| 721     bool ready_to_send) { | 722     bool ready_to_send) { | 
| 722   ASSERT(channel == channel_); | 723   ASSERT(channel == channel_); | 
| 723   SignalSelectedCandidatePairChanged(this, selected_candidate_pair, | 724   SignalSelectedCandidatePairChanged(this, selected_candidate_pair, | 
| 724                                      last_sent_packet_id, ready_to_send); | 725                                      last_sent_packet_id, ready_to_send); | 
| 725 } | 726 } | 
| 726 | 727 | 
| 727 void DtlsTransportChannelWrapper::OnChannelStateChanged( | 728 void DtlsTransportChannelWrapper::OnChannelStateChanged( | 
| 728     IceTransportInternal* channel) { | 729     TransportChannelImpl* channel) { | 
| 729   ASSERT(channel == channel_); | 730   ASSERT(channel == channel_); | 
| 730   SignalStateChanged(this); | 731   SignalStateChanged(this); | 
| 731 } | 732 } | 
| 732 | 733 | 
| 733 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( | 734 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( | 
| 734     rtc::SSLHandshakeError error) { | 735     rtc::SSLHandshakeError error) { | 
| 735   SignalDtlsHandshakeError(error); | 736   SignalDtlsHandshakeError(error); | 
| 736 } | 737 } | 
| 737 | 738 | 
| 738 }  // namespace cricket | 739 }  // namespace cricket | 
| OLD | NEW | 
|---|