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

Side by Side Diff: webrtc/pc/channel.h

Issue 3012953002: Created the DtlsSrtpTransport.
Patch Set: Initial review. Created 3 years, 3 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 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 12 matching lines...) Expand all
23 #include "webrtc/media/base/mediachannel.h" 23 #include "webrtc/media/base/mediachannel.h"
24 #include "webrtc/media/base/mediaengine.h" 24 #include "webrtc/media/base/mediaengine.h"
25 #include "webrtc/media/base/streamparams.h" 25 #include "webrtc/media/base/streamparams.h"
26 #include "webrtc/media/base/videosinkinterface.h" 26 #include "webrtc/media/base/videosinkinterface.h"
27 #include "webrtc/media/base/videosourceinterface.h" 27 #include "webrtc/media/base/videosourceinterface.h"
28 #include "webrtc/p2p/base/dtlstransportinternal.h" 28 #include "webrtc/p2p/base/dtlstransportinternal.h"
29 #include "webrtc/p2p/base/packettransportinternal.h" 29 #include "webrtc/p2p/base/packettransportinternal.h"
30 #include "webrtc/p2p/base/transportcontroller.h" 30 #include "webrtc/p2p/base/transportcontroller.h"
31 #include "webrtc/p2p/client/socketmonitor.h" 31 #include "webrtc/p2p/client/socketmonitor.h"
32 #include "webrtc/pc/audiomonitor.h" 32 #include "webrtc/pc/audiomonitor.h"
33 #include "webrtc/pc/dtlssrtptransport.h"
33 #include "webrtc/pc/mediamonitor.h" 34 #include "webrtc/pc/mediamonitor.h"
34 #include "webrtc/pc/mediasession.h" 35 #include "webrtc/pc/mediasession.h"
35 #include "webrtc/pc/rtcpmuxfilter.h" 36 #include "webrtc/pc/rtcpmuxfilter.h"
37 #include "webrtc/pc/rtptransport.h"
36 #include "webrtc/pc/srtpfilter.h" 38 #include "webrtc/pc/srtpfilter.h"
39 #include "webrtc/pc/srtptransport.h"
37 #include "webrtc/rtc_base/asyncinvoker.h" 40 #include "webrtc/rtc_base/asyncinvoker.h"
38 #include "webrtc/rtc_base/asyncudpsocket.h" 41 #include "webrtc/rtc_base/asyncudpsocket.h"
39 #include "webrtc/rtc_base/criticalsection.h" 42 #include "webrtc/rtc_base/criticalsection.h"
40 #include "webrtc/rtc_base/network.h" 43 #include "webrtc/rtc_base/network.h"
41 #include "webrtc/rtc_base/sigslot.h" 44 #include "webrtc/rtc_base/sigslot.h"
42 #include "webrtc/rtc_base/window.h" 45 #include "webrtc/rtc_base/window.h"
43 46
44 namespace webrtc { 47 namespace webrtc {
45 class AudioSinkInterface; 48 class AudioSinkInterface;
46 class RtpTransportInternal; 49 class RtpTransportInternal;
47 class SrtpTransport;
48 } // namespace webrtc 50 } // namespace webrtc
49 51
50 namespace cricket { 52 namespace cricket {
51 53
52 struct CryptoParams; 54 struct CryptoParams;
53 class MediaContentDescription; 55 class MediaContentDescription;
54 56
55 // BaseChannel contains logic common to voice and video, including enable, 57 // BaseChannel contains logic common to voice and video, including enable,
56 // marshaling calls to a worker and network threads, and connection and media 58 // marshaling calls to a worker and network threads, and connection and media
57 // monitors. 59 // monitors.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 rtc::Thread* worker_thread() const { return worker_thread_; } 98 rtc::Thread* worker_thread() const { return worker_thread_; }
97 rtc::Thread* network_thread() const { return network_thread_; } 99 rtc::Thread* network_thread() const { return network_thread_; }
98 const std::string& content_name() const { return content_name_; } 100 const std::string& content_name() const { return content_name_; }
99 // TODO(deadbeef): This is redundant; remove this. 101 // TODO(deadbeef): This is redundant; remove this.
100 const std::string& transport_name() const { return transport_name_; } 102 const std::string& transport_name() const { return transport_name_; }
101 bool enabled() const { return enabled_; } 103 bool enabled() const { return enabled_; }
102 104
103 // This function returns true if we are using SDES. 105 // This function returns true if we are using SDES.
104 bool sdes_active() const { return sdes_negotiator_.IsActive(); } 106 bool sdes_active() const { return sdes_negotiator_.IsActive(); }
105 // The following function returns true if we are using DTLS-based keying. 107 // The following function returns true if we are using DTLS-based keying.
106 bool dtls_active() const { return dtls_active_; } 108 bool dtls_active() const {
109 return dtls_srtp_transport_ && dtls_srtp_transport_->IsActive();
110 }
107 // This function returns true if using SRTP (DTLS-based keying or SDES). 111 // This function returns true if using SRTP (DTLS-based keying or SDES).
108 bool srtp_active() const { return sdes_active() || dtls_active(); } 112 bool srtp_active() const { return sdes_active() || dtls_active(); }
109 113
110 bool writable() const { return writable_; } 114 bool writable() const { return writable_; }
111 115
112 // Set the transport(s), and update writability and "ready-to-send" state. 116 // Set the transport(s), and update writability and "ready-to-send" state.
113 // |rtp_transport| must be non-null. 117 // |rtp_transport| must be non-null.
114 // |rtcp_transport| must be supplied if NeedsRtcpTransport() is true (meaning 118 // |rtcp_transport| must be supplied if NeedsRtcpTransport() is true (meaning
115 // RTCP muxing is not fully active yet). 119 // RTCP muxing is not fully active yet).
116 // |rtp_transport| and |rtcp_transport| must share the same transport name as 120 // |rtp_transport| and |rtcp_transport| must share the same transport name as
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 void DisconnectTransportChannels_n(); 376 void DisconnectTransportChannels_n();
373 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, 377 void SignalSentPacket_n(rtc::PacketTransportInternal* transport,
374 const rtc::SentPacket& sent_packet); 378 const rtc::SentPacket& sent_packet);
375 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); 379 void SignalSentPacket_w(const rtc::SentPacket& sent_packet);
376 bool IsReadyToSendMedia_n() const; 380 bool IsReadyToSendMedia_n() const;
377 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); 381 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id);
378 int GetTransportOverheadPerPacket() const; 382 int GetTransportOverheadPerPacket() const;
379 void UpdateTransportOverhead(); 383 void UpdateTransportOverhead();
380 // Wraps the existing RtpTransport in an SrtpTransport. 384 // Wraps the existing RtpTransport in an SrtpTransport.
381 void EnableSrtpTransport_n(); 385 void EnableSrtpTransport_n();
386 // Create an SrtpTransport and wrap it in an DtlsSrptTransport.
387 void EnableDtlsSrtpTransport_n();
388 // Cache the send/recv encrypted header extension ids before the
389 // DtlsSrtpTransport is enabled.
390 void CacheEncryptedHeaderExtensionIds(cricket::ContentSource source,
391 const std::vector<int>& extension_ids);
382 392
383 rtc::Thread* const worker_thread_; 393 rtc::Thread* const worker_thread_;
384 rtc::Thread* const network_thread_; 394 rtc::Thread* const network_thread_;
385 rtc::Thread* const signaling_thread_; 395 rtc::Thread* const signaling_thread_;
386 rtc::AsyncInvoker invoker_; 396 rtc::AsyncInvoker invoker_;
387 397
388 const std::string content_name_; 398 const std::string content_name_;
389 std::unique_ptr<ConnectionMonitor> connection_monitor_; 399 std::unique_ptr<ConnectionMonitor> connection_monitor_;
390 400
391 // Won't be set when using raw packet transports. SDP-specific thing. 401 // Won't be set when using raw packet transports. SDP-specific thing.
392 std::string transport_name_; 402 std::string transport_name_;
393 403
394 const bool rtcp_mux_required_; 404 const bool rtcp_mux_required_;
395 405
406 std::vector<int> send_encrypted_header_extension_ids_;
407 std::vector<int> recv_encrypted_header_extension_ids_;
408
396 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. 409 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS.
397 // Temporary measure until more refactoring is done. 410 // Temporary measure until more refactoring is done.
398 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". 411 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_".
399 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; 412 DtlsTransportInternal* rtp_dtls_transport_ = nullptr;
400 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; 413 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr;
414
401 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_; 415 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_;
402 webrtc::SrtpTransport* srtp_transport_ = nullptr; 416 webrtc::SrtpTransport* srtp_transport_ = nullptr;
417 webrtc::DtlsSrtpTransport* dtls_srtp_transport_ = nullptr;
418
403 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; 419 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_;
404 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; 420 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_;
405 SrtpFilter sdes_negotiator_; 421 SrtpFilter sdes_negotiator_;
406 RtcpMuxFilter rtcp_mux_filter_; 422 RtcpMuxFilter rtcp_mux_filter_;
407 bool writable_ = false; 423 bool writable_ = false;
408 bool was_ever_writable_ = false; 424 bool was_ever_writable_ = false;
409 bool has_received_packet_ = false; 425 bool has_received_packet_ = false;
410 bool dtls_active_ = false;
411 const bool srtp_required_ = true; 426 const bool srtp_required_ = true;
412 427
413 // MediaChannel related members that should be accessed from the worker 428 // MediaChannel related members that should be accessed from the worker
414 // thread. 429 // thread.
415 MediaChannel* const media_channel_; 430 MediaChannel* const media_channel_;
416 // Currently the |enabled_| flag is accessed from the signaling thread as 431 // Currently the |enabled_| flag is accessed from the signaling thread as
417 // well, but it can be changed only when signaling thread does a synchronous 432 // well, but it can be changed only when signaling thread does a synchronous
418 // call to the worker thread, so it should be safe. 433 // call to the worker thread, so it should be safe.
419 bool enabled_ = false; 434 bool enabled_ = false;
420 std::vector<StreamParams> local_streams_; 435 std::vector<StreamParams> local_streams_;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 // SetSendParameters. 744 // SetSendParameters.
730 DataSendParameters last_send_params_; 745 DataSendParameters last_send_params_;
731 // Last DataRecvParameters sent down to the media_channel() via 746 // Last DataRecvParameters sent down to the media_channel() via
732 // SetRecvParameters. 747 // SetRecvParameters.
733 DataRecvParameters last_recv_params_; 748 DataRecvParameters last_recv_params_;
734 }; 749 };
735 750
736 } // namespace cricket 751 } // namespace cricket
737 752
738 #endif // WEBRTC_PC_CHANNEL_H_ 753 #endif // WEBRTC_PC_CHANNEL_H_
OLDNEW
« no previous file with comments | « webrtc/pc/BUILD.gn ('k') | webrtc/pc/channel.cc » ('j') | webrtc/pc/channel.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698