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 |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "webrtc/p2p/base/dtlstransportchannel.h" | 14 #include "webrtc/p2p/base/dtlstransportchannel.h" |
15 | 15 |
16 #include "webrtc/p2p/base/common.h" | 16 #include "webrtc/p2p/base/common.h" |
17 #include "webrtc/p2p/base/packettransport.h" | |
17 #include "webrtc/base/buffer.h" | 18 #include "webrtc/base/buffer.h" |
18 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
19 #include "webrtc/base/dscp.h" | 20 #include "webrtc/base/dscp.h" |
20 #include "webrtc/base/messagequeue.h" | 21 #include "webrtc/base/messagequeue.h" |
21 #include "webrtc/base/sslstreamadapter.h" | 22 #include "webrtc/base/sslstreamadapter.h" |
22 #include "webrtc/base/stream.h" | 23 #include "webrtc/base/stream.h" |
23 #include "webrtc/base/thread.h" | 24 #include "webrtc/base/thread.h" |
24 | 25 |
25 namespace cricket { | 26 namespace cricket { |
26 | 27 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 // The state transition logic here is as follows: | 431 // The state transition logic here is as follows: |
431 // (1) If we're not doing DTLS-SRTP, then the state is just the | 432 // (1) If we're not doing DTLS-SRTP, then the state is just the |
432 // state of the underlying impl() | 433 // state of the underlying impl() |
433 // (2) If we're doing DTLS-SRTP: | 434 // (2) If we're doing DTLS-SRTP: |
434 // - Prior to the DTLS handshake, the state is neither receiving nor | 435 // - Prior to the DTLS handshake, the state is neither receiving nor |
435 // writable | 436 // writable |
436 // - When the impl goes writable for the first time we | 437 // - When the impl goes writable for the first time we |
437 // start the DTLS handshake | 438 // start the DTLS handshake |
438 // - Once the DTLS handshake completes, the state is that of the | 439 // - Once the DTLS handshake completes, the state is that of the |
439 // impl again | 440 // impl again |
440 void DtlsTransportChannelWrapper::OnWritableState(TransportChannel* channel) { | 441 void DtlsTransportChannelWrapper::OnWritableState(rtc::PacketTransport* pt) { |
442 TransportChannel* channel = static_cast<TransportChannel*>(pt); | |
pthatcher1
2016/10/13 20:26:37
The only thing this method needs from pt is ->writ
johan
2016/10/14 16:09:33
Done.
| |
441 ASSERT(rtc::Thread::Current() == worker_thread_); | 443 ASSERT(rtc::Thread::Current() == worker_thread_); |
442 ASSERT(channel == channel_); | 444 RTC_DCHECK(channel == channel_); |
443 LOG_J(LS_VERBOSE, this) | 445 LOG_J(LS_VERBOSE, this) |
444 << "DTLSTransportChannelWrapper: channel writable state changed to " | 446 << "DTLSTransportChannelWrapper: channel writable state changed to " |
445 << channel_->writable(); | 447 << channel_->writable(); |
446 | 448 |
447 if (!dtls_active_) { | 449 if (!dtls_active_) { |
448 // Not doing DTLS. | 450 // Not doing DTLS. |
449 // Note: SignalWritableState fired by set_writable. | 451 // Note: SignalWritableState fired by set_writable. |
450 set_writable(channel_->writable()); | 452 set_writable(channel_->writable()); |
451 return; | 453 return; |
452 } | 454 } |
(...skipping 11 matching lines...) Expand all Loading... | |
464 break; | 466 break; |
465 case DTLS_TRANSPORT_FAILED: | 467 case DTLS_TRANSPORT_FAILED: |
466 case DTLS_TRANSPORT_CLOSED: | 468 case DTLS_TRANSPORT_CLOSED: |
467 // Should not happen. Do nothing. | 469 // Should not happen. Do nothing. |
468 break; | 470 break; |
469 } | 471 } |
470 } | 472 } |
471 | 473 |
472 void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { | 474 void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { |
473 ASSERT(rtc::Thread::Current() == worker_thread_); | 475 ASSERT(rtc::Thread::Current() == worker_thread_); |
474 ASSERT(channel == channel_); | 476 RTC_DCHECK(channel == channel_); |
475 LOG_J(LS_VERBOSE, this) | 477 LOG_J(LS_VERBOSE, this) |
476 << "DTLSTransportChannelWrapper: channel receiving state changed to " | 478 << "DTLSTransportChannelWrapper: channel receiving state changed to " |
477 << channel_->receiving(); | 479 << channel_->receiving(); |
478 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { | 480 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { |
479 // Note: SignalReceivingState fired by set_receiving. | 481 // Note: SignalReceivingState fired by set_receiving. |
480 set_receiving(channel_->receiving()); | 482 set_receiving(channel_->receiving()); |
481 } | 483 } |
482 } | 484 } |
483 | 485 |
484 void DtlsTransportChannelWrapper::OnReadPacket( | 486 void DtlsTransportChannelWrapper::OnReadPacket( |
485 TransportChannel* channel, const char* data, size_t size, | 487 rtc::PacketTransport* pt, |
486 const rtc::PacketTime& packet_time, int flags) { | 488 const char* data, |
489 size_t size, | |
490 const rtc::PacketTime& packet_time, | |
491 int flags) { | |
492 TransportChannel* channel = static_cast<TransportChannel*>(pt); | |
487 ASSERT(rtc::Thread::Current() == worker_thread_); | 493 ASSERT(rtc::Thread::Current() == worker_thread_); |
488 ASSERT(channel == channel_); | 494 RTC_DCHECK(channel == channel_); |
489 ASSERT(flags == 0); | 495 ASSERT(flags == 0); |
490 | 496 |
491 if (!dtls_active_) { | 497 if (!dtls_active_) { |
492 // Not doing DTLS. | 498 // Not doing DTLS. |
493 SignalReadPacket(this, data, size, packet_time, 0); | 499 SignalReadPacket(this, data, size, packet_time, 0); |
494 return; | 500 return; |
495 } | 501 } |
496 | 502 |
497 switch (dtls_state()) { | 503 switch (dtls_state()) { |
498 case DTLS_TRANSPORT_NEW: | 504 case DTLS_TRANSPORT_NEW: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 } | 557 } |
552 break; | 558 break; |
553 case DTLS_TRANSPORT_FAILED: | 559 case DTLS_TRANSPORT_FAILED: |
554 case DTLS_TRANSPORT_CLOSED: | 560 case DTLS_TRANSPORT_CLOSED: |
555 // This shouldn't be happening. Drop the packet. | 561 // This shouldn't be happening. Drop the packet. |
556 break; | 562 break; |
557 } | 563 } |
558 } | 564 } |
559 | 565 |
560 void DtlsTransportChannelWrapper::OnSentPacket( | 566 void DtlsTransportChannelWrapper::OnSentPacket( |
561 TransportChannel* channel, | 567 rtc::PacketTransport* pt, |
562 const rtc::SentPacket& sent_packet) { | 568 const rtc::SentPacket& sent_packet) { |
563 ASSERT(rtc::Thread::Current() == worker_thread_); | 569 ASSERT(rtc::Thread::Current() == worker_thread_); |
564 | 570 |
565 SignalSentPacket(this, sent_packet); | 571 SignalSentPacket(this, sent_packet); |
566 } | 572 } |
567 | 573 |
568 void DtlsTransportChannelWrapper::OnReadyToSend(TransportChannel* channel) { | 574 void DtlsTransportChannelWrapper::OnReadyToSend(rtc::PacketTransport* pt) { |
569 if (writable()) { | 575 if (writable()) { |
570 SignalReadyToSend(this); | 576 SignalReadyToSend(this); |
571 } | 577 } |
572 } | 578 } |
573 | 579 |
574 void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls, | 580 void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls, |
575 int sig, int err) { | 581 int sig, int err) { |
576 ASSERT(rtc::Thread::Current() == worker_thread_); | 582 ASSERT(rtc::Thread::Current() == worker_thread_); |
577 ASSERT(dtls == dtls_.get()); | 583 ASSERT(dtls == dtls_.get()); |
578 if (sig & rtc::SE_OPEN) { | 584 if (sig & rtc::SE_OPEN) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
723 ASSERT(channel == channel_); | 729 ASSERT(channel == channel_); |
724 SignalStateChanged(this); | 730 SignalStateChanged(this); |
725 } | 731 } |
726 | 732 |
727 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( | 733 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( |
728 rtc::SSLHandshakeError error) { | 734 rtc::SSLHandshakeError error) { |
729 SignalDtlsHandshakeError(error); | 735 SignalDtlsHandshakeError(error); |
730 } | 736 } |
731 | 737 |
732 } // namespace cricket | 738 } // namespace cricket |
OLD | NEW |