Chromium Code Reviews

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

Issue 3012333003: Revert of Completed the functionalities of SrtpTransport. (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « webrtc/p2p/base/fakepackettransport.h ('k') | webrtc/pc/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15 matching lines...)
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/mediamonitor.h" 33 #include "webrtc/pc/mediamonitor.h"
34 #include "webrtc/pc/mediasession.h" 34 #include "webrtc/pc/mediasession.h"
35 #include "webrtc/pc/rtcpmuxfilter.h" 35 #include "webrtc/pc/rtcpmuxfilter.h"
36 #include "webrtc/pc/rtptransportinternal.h"
36 #include "webrtc/pc/srtpfilter.h" 37 #include "webrtc/pc/srtpfilter.h"
37 #include "webrtc/rtc_base/asyncinvoker.h" 38 #include "webrtc/rtc_base/asyncinvoker.h"
38 #include "webrtc/rtc_base/asyncudpsocket.h" 39 #include "webrtc/rtc_base/asyncudpsocket.h"
39 #include "webrtc/rtc_base/criticalsection.h" 40 #include "webrtc/rtc_base/criticalsection.h"
40 #include "webrtc/rtc_base/network.h" 41 #include "webrtc/rtc_base/network.h"
41 #include "webrtc/rtc_base/sigslot.h" 42 #include "webrtc/rtc_base/sigslot.h"
42 #include "webrtc/rtc_base/window.h" 43 #include "webrtc/rtc_base/window.h"
43 44
44 namespace webrtc { 45 namespace webrtc {
45 class AudioSinkInterface; 46 class AudioSinkInterface;
46 class RtpTransportInternal;
47 class SrtpTransport;
48 } // namespace webrtc 47 } // namespace webrtc
49 48
50 namespace cricket { 49 namespace cricket {
51 50
52 struct CryptoParams; 51 struct CryptoParams;
53 class MediaContentDescription; 52 class MediaContentDescription;
54 53
55 // BaseChannel contains logic common to voice and video, including enable, 54 // BaseChannel contains logic common to voice and video, including enable,
56 // marshaling calls to a worker and network threads, and connection and media 55 // marshaling calls to a worker and network threads, and connection and media
57 // monitors. 56 // monitors.
(...skipping 35 matching lines...)
93 // done. 92 // done.
94 void Deinit(); 93 void Deinit();
95 94
96 rtc::Thread* worker_thread() const { return worker_thread_; } 95 rtc::Thread* worker_thread() const { return worker_thread_; }
97 rtc::Thread* network_thread() const { return network_thread_; } 96 rtc::Thread* network_thread() const { return network_thread_; }
98 const std::string& content_name() const { return content_name_; } 97 const std::string& content_name() const { return content_name_; }
99 // TODO(deadbeef): This is redundant; remove this. 98 // TODO(deadbeef): This is redundant; remove this.
100 const std::string& transport_name() const { return transport_name_; } 99 const std::string& transport_name() const { return transport_name_; }
101 bool enabled() const { return enabled_; } 100 bool enabled() const { return enabled_; }
102 101
103 // This function returns true if we are using SDES. 102 // This function returns true if we are using SRTP.
104 bool sdes_active() const { return sdes_negotiator_.IsActive(); } 103 bool secure() const { return srtp_filter_.IsActive(); }
105 // The following function returns true if we are using DTLS-based keying. 104 // The following function returns true if we are using
106 bool dtls_active() const { return dtls_active_; } 105 // DTLS-based keying. If you turned off SRTP later, however
107 // This function returns true if using SRTP (DTLS-based keying or SDES). 106 // you could have secure() == false and dtls_secure() == true.
108 bool srtp_active() const { return sdes_active() || dtls_active(); } 107 bool secure_dtls() const { return dtls_keyed_; }
109 108
110 bool writable() const { return writable_; } 109 bool writable() const { return writable_; }
111 110
112 // Set the transport(s), and update writability and "ready-to-send" state. 111 // Set the transport(s), and update writability and "ready-to-send" state.
113 // |rtp_transport| must be non-null. 112 // |rtp_transport| must be non-null.
114 // |rtcp_transport| must be supplied if NeedsRtcpTransport() is true (meaning 113 // |rtcp_transport| must be supplied if NeedsRtcpTransport() is true (meaning
115 // RTCP muxing is not fully active yet). 114 // RTCP muxing is not fully active yet).
116 // |rtp_transport| and |rtcp_transport| must share the same transport name as 115 // |rtp_transport| and |rtcp_transport| must share the same transport name as
117 // well. 116 // well.
118 // Can not start with "rtc::PacketTransportInternal" and switch to 117 // Can not start with "rtc::PacketTransportInternal" and switch to
(...skipping 63 matching lines...)
182 bool NeedsRtcpTransport(); 181 bool NeedsRtcpTransport();
183 182
184 // From RtpTransport - public for testing only 183 // From RtpTransport - public for testing only
185 void OnTransportReadyToSend(bool ready); 184 void OnTransportReadyToSend(bool ready);
186 185
187 // Only public for unit tests. Otherwise, consider protected. 186 // Only public for unit tests. Otherwise, consider protected.
188 int SetOption(SocketType type, rtc::Socket::Option o, int val) 187 int SetOption(SocketType type, rtc::Socket::Option o, int val)
189 override; 188 override;
190 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); 189 int SetOption_n(SocketType type, rtc::Socket::Option o, int val);
191 190
191 SrtpFilter* srtp_filter() { return &srtp_filter_; }
192
192 virtual cricket::MediaType media_type() = 0; 193 virtual cricket::MediaType media_type() = 0;
193 194
194 // This function returns true if we require SRTP for call setup. 195 // This function returns true if we require SRTP for call setup.
195 bool srtp_required_for_testing() const { return srtp_required_; } 196 bool srtp_required_for_testing() const { return srtp_required_; }
196 197
197 // Public for testing. 198 // Public for testing.
198 // TODO(zstein): Remove this once channels register themselves with 199 // TODO(zstein): Remove this once channels register themselves with
199 // an RtpTransport in a more explicit way. 200 // an RtpTransport in a more explicit way.
200 bool HandlesPayloadType(int payload_type) const; 201 bool HandlesPayloadType(int payload_type) const;
201 202
(...skipping 168 matching lines...)
370 rtc::PacketTransportInternal* rtp_packet_transport, 371 rtc::PacketTransportInternal* rtp_packet_transport,
371 rtc::PacketTransportInternal* rtcp_packet_transport); 372 rtc::PacketTransportInternal* rtcp_packet_transport);
372 void DisconnectTransportChannels_n(); 373 void DisconnectTransportChannels_n();
373 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, 374 void SignalSentPacket_n(rtc::PacketTransportInternal* transport,
374 const rtc::SentPacket& sent_packet); 375 const rtc::SentPacket& sent_packet);
375 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); 376 void SignalSentPacket_w(const rtc::SentPacket& sent_packet);
376 bool IsReadyToSendMedia_n() const; 377 bool IsReadyToSendMedia_n() const;
377 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); 378 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id);
378 int GetTransportOverheadPerPacket() const; 379 int GetTransportOverheadPerPacket() const;
379 void UpdateTransportOverhead(); 380 void UpdateTransportOverhead();
380 // Wraps the existing RtpTransport in an SrtpTransport.
381 void EnableSrtpTransport_n();
382 381
383 rtc::Thread* const worker_thread_; 382 rtc::Thread* const worker_thread_;
384 rtc::Thread* const network_thread_; 383 rtc::Thread* const network_thread_;
385 rtc::Thread* const signaling_thread_; 384 rtc::Thread* const signaling_thread_;
386 rtc::AsyncInvoker invoker_; 385 rtc::AsyncInvoker invoker_;
387 386
388 const std::string content_name_; 387 const std::string content_name_;
389 std::unique_ptr<ConnectionMonitor> connection_monitor_; 388 std::unique_ptr<ConnectionMonitor> connection_monitor_;
390 389
391 // Won't be set when using raw packet transports. SDP-specific thing. 390 // Won't be set when using raw packet transports. SDP-specific thing.
392 std::string transport_name_; 391 std::string transport_name_;
393 392
394 const bool rtcp_mux_required_; 393 const bool rtcp_mux_required_;
395 394
396 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. 395 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS.
397 // Temporary measure until more refactoring is done. 396 // Temporary measure until more refactoring is done.
398 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". 397 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_".
399 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; 398 DtlsTransportInternal* rtp_dtls_transport_ = nullptr;
400 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; 399 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr;
401 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_; 400 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_;
402 webrtc::SrtpTransport* srtp_transport_ = nullptr;
403 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; 401 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_;
404 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; 402 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_;
405 SrtpFilter sdes_negotiator_; 403 SrtpFilter srtp_filter_;
406 RtcpMuxFilter rtcp_mux_filter_; 404 RtcpMuxFilter rtcp_mux_filter_;
407 bool writable_ = false; 405 bool writable_ = false;
408 bool was_ever_writable_ = false; 406 bool was_ever_writable_ = false;
409 bool has_received_packet_ = false; 407 bool has_received_packet_ = false;
410 bool dtls_active_ = false; 408 bool dtls_keyed_ = false;
411 const bool srtp_required_ = true; 409 const bool srtp_required_ = true;
410 int rtp_abs_sendtime_extn_id_ = -1;
412 411
413 // MediaChannel related members that should be accessed from the worker 412 // MediaChannel related members that should be accessed from the worker
414 // thread. 413 // thread.
415 MediaChannel* const media_channel_; 414 MediaChannel* const media_channel_;
416 // Currently the |enabled_| flag is accessed from the signaling thread as 415 // 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 416 // well, but it can be changed only when signaling thread does a synchronous
418 // call to the worker thread, so it should be safe. 417 // call to the worker thread, so it should be safe.
419 bool enabled_ = false; 418 bool enabled_ = false;
420 std::vector<StreamParams> local_streams_; 419 std::vector<StreamParams> local_streams_;
421 std::vector<StreamParams> remote_streams_; 420 std::vector<StreamParams> remote_streams_;
(...skipping 307 matching lines...)
729 // SetSendParameters. 728 // SetSendParameters.
730 DataSendParameters last_send_params_; 729 DataSendParameters last_send_params_;
731 // Last DataRecvParameters sent down to the media_channel() via 730 // Last DataRecvParameters sent down to the media_channel() via
732 // SetRecvParameters. 731 // SetRecvParameters.
733 DataRecvParameters last_recv_params_; 732 DataRecvParameters last_recv_params_;
734 }; 733 };
735 734
736 } // namespace cricket 735 } // namespace cricket
737 736
738 #endif // WEBRTC_PC_CHANNEL_H_ 737 #endif // WEBRTC_PC_CHANNEL_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/fakepackettransport.h ('k') | webrtc/pc/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine