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/packettransportinterface.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( |
| 442 rtc::PacketTransportInterface* transport) { |
441 ASSERT(rtc::Thread::Current() == worker_thread_); | 443 ASSERT(rtc::Thread::Current() == worker_thread_); |
442 ASSERT(channel == channel_); | 444 RTC_DCHECK(transport == |
| 445 static_cast<rtc::PacketTransportInterface*>(channel_)); |
443 LOG_J(LS_VERBOSE, this) | 446 LOG_J(LS_VERBOSE, this) |
444 << "DTLSTransportChannelWrapper: channel writable state changed to " | 447 << "DTLSTransportChannelWrapper: channel writable state changed to " |
445 << channel_->writable(); | 448 << channel_->writable(); |
446 | 449 |
447 if (!dtls_active_) { | 450 if (!dtls_active_) { |
448 // Not doing DTLS. | 451 // Not doing DTLS. |
449 // Note: SignalWritableState fired by set_writable. | 452 // Note: SignalWritableState fired by set_writable. |
450 set_writable(channel_->writable()); | 453 set_writable(channel_->writable()); |
451 return; | 454 return; |
452 } | 455 } |
(...skipping 11 matching lines...) Expand all Loading... |
464 break; | 467 break; |
465 case DTLS_TRANSPORT_FAILED: | 468 case DTLS_TRANSPORT_FAILED: |
466 case DTLS_TRANSPORT_CLOSED: | 469 case DTLS_TRANSPORT_CLOSED: |
467 // Should not happen. Do nothing. | 470 // Should not happen. Do nothing. |
468 break; | 471 break; |
469 } | 472 } |
470 } | 473 } |
471 | 474 |
472 void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { | 475 void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { |
473 ASSERT(rtc::Thread::Current() == worker_thread_); | 476 ASSERT(rtc::Thread::Current() == worker_thread_); |
474 ASSERT(channel == channel_); | 477 RTC_DCHECK(channel == channel_); |
475 LOG_J(LS_VERBOSE, this) | 478 LOG_J(LS_VERBOSE, this) |
476 << "DTLSTransportChannelWrapper: channel receiving state changed to " | 479 << "DTLSTransportChannelWrapper: channel receiving state changed to " |
477 << channel_->receiving(); | 480 << channel_->receiving(); |
478 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { | 481 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { |
479 // Note: SignalReceivingState fired by set_receiving. | 482 // Note: SignalReceivingState fired by set_receiving. |
480 set_receiving(channel_->receiving()); | 483 set_receiving(channel_->receiving()); |
481 } | 484 } |
482 } | 485 } |
483 | 486 |
484 void DtlsTransportChannelWrapper::OnReadPacket( | 487 void DtlsTransportChannelWrapper::OnReadPacket( |
485 TransportChannel* channel, const char* data, size_t size, | 488 rtc::PacketTransportInterface* transport, |
486 const rtc::PacketTime& packet_time, int flags) { | 489 const char* data, |
| 490 size_t size, |
| 491 const rtc::PacketTime& packet_time, |
| 492 int flags) { |
| 493 TransportChannel* channel = static_cast<TransportChannel*>(transport); |
487 ASSERT(rtc::Thread::Current() == worker_thread_); | 494 ASSERT(rtc::Thread::Current() == worker_thread_); |
488 ASSERT(channel == channel_); | 495 RTC_DCHECK(channel == channel_); |
489 ASSERT(flags == 0); | 496 ASSERT(flags == 0); |
490 | 497 |
491 if (!dtls_active_) { | 498 if (!dtls_active_) { |
492 // Not doing DTLS. | 499 // Not doing DTLS. |
493 SignalReadPacket(this, data, size, packet_time, 0); | 500 SignalReadPacket(this, data, size, packet_time, 0); |
494 return; | 501 return; |
495 } | 502 } |
496 | 503 |
497 switch (dtls_state()) { | 504 switch (dtls_state()) { |
498 case DTLS_TRANSPORT_NEW: | 505 case DTLS_TRANSPORT_NEW: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } | 558 } |
552 break; | 559 break; |
553 case DTLS_TRANSPORT_FAILED: | 560 case DTLS_TRANSPORT_FAILED: |
554 case DTLS_TRANSPORT_CLOSED: | 561 case DTLS_TRANSPORT_CLOSED: |
555 // This shouldn't be happening. Drop the packet. | 562 // This shouldn't be happening. Drop the packet. |
556 break; | 563 break; |
557 } | 564 } |
558 } | 565 } |
559 | 566 |
560 void DtlsTransportChannelWrapper::OnSentPacket( | 567 void DtlsTransportChannelWrapper::OnSentPacket( |
561 TransportChannel* channel, | 568 rtc::PacketTransportInterface* transport, |
562 const rtc::SentPacket& sent_packet) { | 569 const rtc::SentPacket& sent_packet) { |
563 ASSERT(rtc::Thread::Current() == worker_thread_); | 570 ASSERT(rtc::Thread::Current() == worker_thread_); |
564 | 571 |
565 SignalSentPacket(this, sent_packet); | 572 SignalSentPacket(this, sent_packet); |
566 } | 573 } |
567 | 574 |
568 void DtlsTransportChannelWrapper::OnReadyToSend(TransportChannel* channel) { | 575 void DtlsTransportChannelWrapper::OnReadyToSend( |
| 576 rtc::PacketTransportInterface* transport) { |
569 if (writable()) { | 577 if (writable()) { |
570 SignalReadyToSend(this); | 578 SignalReadyToSend(this); |
571 } | 579 } |
572 } | 580 } |
573 | 581 |
574 void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls, | 582 void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls, |
575 int sig, int err) { | 583 int sig, int err) { |
576 ASSERT(rtc::Thread::Current() == worker_thread_); | 584 ASSERT(rtc::Thread::Current() == worker_thread_); |
577 ASSERT(dtls == dtls_.get()); | 585 ASSERT(dtls == dtls_.get()); |
578 if (sig & rtc::SE_OPEN) { | 586 if (sig & rtc::SE_OPEN) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 ASSERT(channel == channel_); | 731 ASSERT(channel == channel_); |
724 SignalStateChanged(this); | 732 SignalStateChanged(this); |
725 } | 733 } |
726 | 734 |
727 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( | 735 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( |
728 rtc::SSLHandshakeError error) { | 736 rtc::SSLHandshakeError error) { |
729 SignalDtlsHandshakeError(error); | 737 SignalDtlsHandshakeError(error); |
730 } | 738 } |
731 | 739 |
732 } // namespace cricket | 740 } // namespace cricket |
OLD | NEW |