OLD | NEW |
---|---|
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 Loading... | |
23 #include "media/base/mediachannel.h" | 23 #include "media/base/mediachannel.h" |
24 #include "media/base/mediaengine.h" | 24 #include "media/base/mediaengine.h" |
25 #include "media/base/streamparams.h" | 25 #include "media/base/streamparams.h" |
26 #include "media/base/videosinkinterface.h" | 26 #include "media/base/videosinkinterface.h" |
27 #include "media/base/videosourceinterface.h" | 27 #include "media/base/videosourceinterface.h" |
28 #include "p2p/base/dtlstransportinternal.h" | 28 #include "p2p/base/dtlstransportinternal.h" |
29 #include "p2p/base/packettransportinternal.h" | 29 #include "p2p/base/packettransportinternal.h" |
30 #include "p2p/base/transportcontroller.h" | 30 #include "p2p/base/transportcontroller.h" |
31 #include "p2p/client/socketmonitor.h" | 31 #include "p2p/client/socketmonitor.h" |
32 #include "pc/audiomonitor.h" | 32 #include "pc/audiomonitor.h" |
33 #include "pc/dtlssrtptransport.h" | |
33 #include "pc/mediamonitor.h" | 34 #include "pc/mediamonitor.h" |
34 #include "pc/mediasession.h" | 35 #include "pc/mediasession.h" |
35 #include "pc/rtcpmuxfilter.h" | 36 #include "pc/rtcpmuxfilter.h" |
37 #include "pc/rtptransport.h" | |
36 #include "pc/srtpfilter.h" | 38 #include "pc/srtpfilter.h" |
39 #include "pc/srtptransport.h" | |
37 #include "rtc_base/asyncinvoker.h" | 40 #include "rtc_base/asyncinvoker.h" |
38 #include "rtc_base/asyncudpsocket.h" | 41 #include "rtc_base/asyncudpsocket.h" |
39 #include "rtc_base/criticalsection.h" | 42 #include "rtc_base/criticalsection.h" |
40 #include "rtc_base/network.h" | 43 #include "rtc_base/network.h" |
41 #include "rtc_base/sigslot.h" | 44 #include "rtc_base/sigslot.h" |
42 #include "rtc_base/window.h" | 45 #include "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 Loading... | |
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 const std::vector<webrtc::RtpExtension>& extensions); | 332 const std::vector<webrtc::RtpExtension>& extensions); |
329 | 333 |
330 bool CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, | 334 bool CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, |
331 bool* dtls, | 335 bool* dtls, |
332 std::string* error_desc); | 336 std::string* error_desc); |
333 bool SetSrtp_n(const std::vector<CryptoParams>& params, | 337 bool SetSrtp_n(const std::vector<CryptoParams>& params, |
334 ContentAction action, | 338 ContentAction action, |
335 ContentSource src, | 339 ContentSource src, |
336 const std::vector<int>& encrypted_extension_ids, | 340 const std::vector<int>& encrypted_extension_ids, |
337 std::string* error_desc); | 341 std::string* error_desc); |
342 bool SetSdesSrtp_n(const std::vector<CryptoParams>& params, | |
343 ContentAction action, | |
344 ContentSource src, | |
345 const std::vector<int>& encrypted_extension_ids); | |
346 bool SetDtlsSrtp_n(ContentSource src, | |
347 const std::vector<int>& encrypted_extension_ids); | |
348 | |
338 bool SetRtcpMux_n(bool enable, | 349 bool SetRtcpMux_n(bool enable, |
339 ContentAction action, | 350 ContentAction action, |
340 ContentSource src, | 351 ContentSource src, |
341 std::string* error_desc); | 352 std::string* error_desc); |
342 | 353 |
343 // From MessageHandler | 354 // From MessageHandler |
344 void OnMessage(rtc::Message* pmsg) override; | 355 void OnMessage(rtc::Message* pmsg) override; |
345 | 356 |
346 // Handled in derived classes | 357 // Handled in derived classes |
347 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, | 358 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, |
(...skipping 14 matching lines...) Expand all Loading... | |
362 rtc::PacketTransportInternal* rtcp_packet_transport); | 373 rtc::PacketTransportInternal* rtcp_packet_transport); |
363 void DisconnectTransportChannels_n(); | 374 void DisconnectTransportChannels_n(); |
364 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, | 375 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, |
365 const rtc::SentPacket& sent_packet); | 376 const rtc::SentPacket& sent_packet); |
366 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); | 377 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); |
367 bool IsReadyToSendMedia_n() const; | 378 bool IsReadyToSendMedia_n() const; |
368 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); | 379 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); |
369 int GetTransportOverheadPerPacket() const; | 380 int GetTransportOverheadPerPacket() const; |
370 void UpdateTransportOverhead(); | 381 void UpdateTransportOverhead(); |
371 // Wraps the existing RtpTransport in an SrtpTransport. | 382 // Wraps the existing RtpTransport in an SrtpTransport. |
372 void EnableSrtpTransport_n(); | 383 void EnableSdes_n(); |
384 // Create an SrtpTransport and wrap it in an DtlsSrptTransport. | |
Taylor Brandstetter
2017/09/27 23:54:48
DtlsSrtpTransport
| |
385 void EnableDtlsSrtp_n(); | |
386 // Cache the send/recv encrypted header extension ids before the | |
387 // DtlsSrtpTransport is enabled. | |
388 void CacheEncryptedHeaderExtensionIds(cricket::ContentSource source, | |
389 const std::vector<int>& extension_ids); | |
373 | 390 |
374 rtc::Thread* const worker_thread_; | 391 rtc::Thread* const worker_thread_; |
375 rtc::Thread* const network_thread_; | 392 rtc::Thread* const network_thread_; |
376 rtc::Thread* const signaling_thread_; | 393 rtc::Thread* const signaling_thread_; |
377 rtc::AsyncInvoker invoker_; | 394 rtc::AsyncInvoker invoker_; |
378 | 395 |
379 const std::string content_name_; | 396 const std::string content_name_; |
380 std::unique_ptr<ConnectionMonitor> connection_monitor_; | 397 std::unique_ptr<ConnectionMonitor> connection_monitor_; |
381 | 398 |
382 // Won't be set when using raw packet transports. SDP-specific thing. | 399 // Won't be set when using raw packet transports. SDP-specific thing. |
383 std::string transport_name_; | 400 std::string transport_name_; |
384 | 401 |
385 const bool rtcp_mux_required_; | 402 const bool rtcp_mux_required_; |
386 | 403 |
404 std::vector<int> send_encrypted_header_extension_ids_; | |
405 std::vector<int> recv_encrypted_header_extension_ids_; | |
406 | |
387 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. | 407 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. |
388 // Temporary measure until more refactoring is done. | 408 // Temporary measure until more refactoring is done. |
389 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". | 409 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". |
390 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; | 410 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; |
391 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; | 411 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; |
392 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_; | 412 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_; |
393 webrtc::SrtpTransport* srtp_transport_ = nullptr; | 413 webrtc::SrtpTransport* sdes_transport_ = nullptr; |
414 webrtc::DtlsSrtpTransport* dtls_srtp_transport_ = nullptr; | |
415 | |
394 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; | 416 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; |
395 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; | 417 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; |
396 SrtpFilter sdes_negotiator_; | 418 SrtpFilter sdes_negotiator_; |
397 RtcpMuxFilter rtcp_mux_filter_; | 419 RtcpMuxFilter rtcp_mux_filter_; |
398 bool writable_ = false; | 420 bool writable_ = false; |
399 bool was_ever_writable_ = false; | 421 bool was_ever_writable_ = false; |
400 bool has_received_packet_ = false; | 422 bool has_received_packet_ = false; |
401 bool dtls_active_ = false; | |
402 const bool srtp_required_ = true; | 423 const bool srtp_required_ = true; |
403 | 424 |
404 // MediaChannel related members that should be accessed from the worker | 425 // MediaChannel related members that should be accessed from the worker |
405 // thread. | 426 // thread. |
406 MediaChannel* const media_channel_; | 427 MediaChannel* const media_channel_; |
407 // Currently the |enabled_| flag is accessed from the signaling thread as | 428 // Currently the |enabled_| flag is accessed from the signaling thread as |
408 // well, but it can be changed only when signaling thread does a synchronous | 429 // well, but it can be changed only when signaling thread does a synchronous |
409 // call to the worker thread, so it should be safe. | 430 // call to the worker thread, so it should be safe. |
410 bool enabled_ = false; | 431 bool enabled_ = false; |
411 std::vector<StreamParams> local_streams_; | 432 std::vector<StreamParams> local_streams_; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 // SetSendParameters. | 738 // SetSendParameters. |
718 DataSendParameters last_send_params_; | 739 DataSendParameters last_send_params_; |
719 // Last DataRecvParameters sent down to the media_channel() via | 740 // Last DataRecvParameters sent down to the media_channel() via |
720 // SetRecvParameters. | 741 // SetRecvParameters. |
721 DataRecvParameters last_recv_params_; | 742 DataRecvParameters last_recv_params_; |
722 }; | 743 }; |
723 | 744 |
724 } // namespace cricket | 745 } // namespace cricket |
725 | 746 |
726 #endif // PC_CHANNEL_H_ | 747 #endif // PC_CHANNEL_H_ |
OLD | NEW |