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

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel.cc

Issue 2606123002: Remove the dependency of TransportChannel and TransportChannelImpl. (Closed)
Patch Set: Merge Created 3 years, 11 months 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 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
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(TransportChannel* channel) 53 StreamInterfaceChannel::StreamInterfaceChannel(IceTransportInternal* 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 }
58 57
59 rtc::StreamResult StreamInterfaceChannel::Read(void* buffer, 58 rtc::StreamResult StreamInterfaceChannel::Read(void* buffer,
60 size_t buffer_len, 59 size_t buffer_len,
61 size_t* read, 60 size_t* read,
62 int* error) { 61 int* error) {
63 if (state_ == rtc::SS_CLOSED) 62 if (state_ == rtc::SS_CLOSED)
64 return rtc::SR_EOS; 63 return rtc::SR_EOS;
65 if (state_ == rtc::SS_OPENING) 64 if (state_ == rtc::SS_OPENING)
66 return rtc::SR_BLOCK; 65 return rtc::SR_BLOCK;
67 66
(...skipping 28 matching lines...) Expand all
96 } 95 }
97 return ret; 96 return ret;
98 } 97 }
99 98
100 void StreamInterfaceChannel::Close() { 99 void StreamInterfaceChannel::Close() {
101 packets_.Clear(); 100 packets_.Clear();
102 state_ = rtc::SS_CLOSED; 101 state_ = rtc::SS_CLOSED;
103 } 102 }
104 103
105 DtlsTransportChannelWrapper::DtlsTransportChannelWrapper( 104 DtlsTransportChannelWrapper::DtlsTransportChannelWrapper(
106 TransportChannelImpl* channel) 105 IceTransportInternal* channel)
107 : TransportChannelImpl(channel->transport_name(), channel->component()), 106 : transport_name_(channel->transport_name()),
107 component_(channel->component()),
108 network_thread_(rtc::Thread::Current()), 108 network_thread_(rtc::Thread::Current()),
109 channel_(channel), 109 channel_(channel),
110 downward_(NULL), 110 downward_(NULL),
111 ssl_role_(rtc::SSL_CLIENT), 111 ssl_role_(rtc::SSL_CLIENT),
112 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_12) { 112 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_12) {
113 channel_->SignalWritableState.connect(this, 113 channel_->SignalWritableState.connect(this,
114 &DtlsTransportChannelWrapper::OnWritableState); 114 &DtlsTransportChannelWrapper::OnWritableState);
115 channel_->SignalReadPacket.connect(this, 115 channel_->SignalReadPacket.connect(this,
116 &DtlsTransportChannelWrapper::OnReadPacket); 116 &DtlsTransportChannelWrapper::OnReadPacket);
117 channel_->SignalSentPacket.connect( 117 channel_->SignalSentPacket.connect(
118 this, &DtlsTransportChannelWrapper::OnSentPacket); 118 this, &DtlsTransportChannelWrapper::OnSentPacket);
119 channel_->SignalReadyToSend.connect(this, 119 channel_->SignalReadyToSend.connect(this,
120 &DtlsTransportChannelWrapper::OnReadyToSend); 120 &DtlsTransportChannelWrapper::OnReadyToSend);
121 channel_->SignalGatheringState.connect(
122 this, &DtlsTransportChannelWrapper::OnGatheringState);
123 channel_->SignalCandidateGathered.connect(
124 this, &DtlsTransportChannelWrapper::OnCandidateGathered);
125 channel_->SignalCandidatesRemoved.connect(
126 this, &DtlsTransportChannelWrapper::OnCandidatesRemoved);
127 channel_->SignalRoleConflict.connect(this,
128 &DtlsTransportChannelWrapper::OnRoleConflict);
129 channel_->SignalRouteChange.connect(this,
130 &DtlsTransportChannelWrapper::OnRouteChange);
131 channel_->SignalSelectedCandidatePairChanged.connect(
132 this, &DtlsTransportChannelWrapper::OnSelectedCandidatePairChanged);
133 channel_->SignalStateChanged.connect(
134 this, &DtlsTransportChannelWrapper::OnChannelStateChanged);
135 channel_->SignalReceivingState.connect(this, 121 channel_->SignalReceivingState.connect(this,
136 &DtlsTransportChannelWrapper::OnReceivingState); 122 &DtlsTransportChannelWrapper::OnReceivingState);
137 } 123 }
138 124
139 DtlsTransportChannelWrapper::~DtlsTransportChannelWrapper() { 125 DtlsTransportChannelWrapper::~DtlsTransportChannelWrapper() {
140 } 126 }
141 127
142 bool DtlsTransportChannelWrapper::SetLocalCertificate( 128 bool DtlsTransportChannelWrapper::SetLocalCertificate(
143 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { 129 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
144 if (dtls_active_) { 130 if (dtls_active_) {
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 662
677 tmp_data += record_len + kDtlsRecordHeaderLen; 663 tmp_data += record_len + kDtlsRecordHeaderLen;
678 tmp_size -= record_len + kDtlsRecordHeaderLen; 664 tmp_size -= record_len + kDtlsRecordHeaderLen;
679 } 665 }
680 666
681 // Looks good. Pass to the SIC which ends up being passed to 667 // Looks good. Pass to the SIC which ends up being passed to
682 // the DTLS stack. 668 // the DTLS stack.
683 return downward_->OnPacketReceived(data, size); 669 return downward_->OnPacketReceived(data, size);
684 } 670 }
685 671
686 void DtlsTransportChannelWrapper::OnGatheringState(
687 TransportChannelImpl* channel) {
688 ASSERT(channel == channel_);
689 SignalGatheringState(this);
690 }
691
692 void DtlsTransportChannelWrapper::OnCandidateGathered(
693 TransportChannelImpl* channel,
694 const Candidate& c) {
695 ASSERT(channel == channel_);
696 SignalCandidateGathered(this, c);
697 }
698
699 void DtlsTransportChannelWrapper::OnCandidatesRemoved(
700 TransportChannelImpl* channel,
701 const Candidates& candidates) {
702 ASSERT(channel == channel_);
703 SignalCandidatesRemoved(this, candidates);
704 }
705
706 void DtlsTransportChannelWrapper::OnRoleConflict(
707 TransportChannelImpl* channel) {
708 ASSERT(channel == channel_);
709 SignalRoleConflict(this);
710 }
711
712 void DtlsTransportChannelWrapper::OnRouteChange(
713 TransportChannel* channel, const Candidate& candidate) {
714 ASSERT(channel == channel_);
715 SignalRouteChange(this, candidate);
716 }
717
718 void DtlsTransportChannelWrapper::OnSelectedCandidatePairChanged(
719 TransportChannel* channel,
720 CandidatePairInterface* selected_candidate_pair,
721 int last_sent_packet_id,
722 bool ready_to_send) {
723 ASSERT(channel == channel_);
724 SignalSelectedCandidatePairChanged(this, selected_candidate_pair,
725 last_sent_packet_id, ready_to_send);
726 }
727
728 void DtlsTransportChannelWrapper::OnChannelStateChanged(
729 TransportChannelImpl* channel) {
730 ASSERT(channel == channel_);
731 SignalStateChanged(this);
732 }
733
734 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( 672 void DtlsTransportChannelWrapper::OnDtlsHandshakeError(
735 rtc::SSLHandshakeError error) { 673 rtc::SSLHandshakeError error) {
736 SignalDtlsHandshakeError(error); 674 SignalDtlsHandshakeError(error);
737 } 675 }
738 676
677 void DtlsTransportChannelWrapper::set_receiving(bool receiving) {
678 if (receiving_ == receiving) {
679 return;
680 }
681 receiving_ = receiving;
682 SignalReceivingState(this);
683 }
684
685 void DtlsTransportChannelWrapper::set_writable(bool writable) {
686 if (writable_ == writable) {
687 return;
688 }
689 LOG_J(LS_VERBOSE, this) << "set_writable from:" << writable_ << " to "
690 << writable;
691 writable_ = writable;
692 if (writable_) {
693 SignalReadyToSend(this);
694 }
695 SignalWritableState(this);
696 }
697
698 void DtlsTransportChannelWrapper::set_dtls_state(DtlsTransportState state) {
699 if (dtls_state_ == state) {
700 return;
701 }
702 LOG_J(LS_VERBOSE, this) << "set_dtls_state from:" << dtls_state_ << " to "
703 << state;
704 dtls_state_ = state;
705 SignalDtlsState(this, state);
706 }
707
739 } // namespace cricket 708 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698