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