| 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 "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/mediamonitor.h" | 33 #include "pc/mediamonitor.h" |
| 34 #include "pc/mediasession.h" | 34 #include "pc/mediasession.h" |
| 35 #include "pc/rtcpmuxfilter.h" | 35 #include "pc/rtcpmuxfilter.h" |
| 36 #include "pc/rtptransportinternal.h" |
| 36 #include "pc/srtpfilter.h" | 37 #include "pc/srtpfilter.h" |
| 37 #include "rtc_base/asyncinvoker.h" | 38 #include "rtc_base/asyncinvoker.h" |
| 38 #include "rtc_base/asyncudpsocket.h" | 39 #include "rtc_base/asyncudpsocket.h" |
| 39 #include "rtc_base/criticalsection.h" | 40 #include "rtc_base/criticalsection.h" |
| 40 #include "rtc_base/network.h" | 41 #include "rtc_base/network.h" |
| 41 #include "rtc_base/sigslot.h" | 42 #include "rtc_base/sigslot.h" |
| 42 #include "rtc_base/window.h" | 43 #include "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...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 bool NeedsRtcpTransport(); | 175 bool NeedsRtcpTransport(); |
| 177 | 176 |
| 178 // From RtpTransport - public for testing only | 177 // From RtpTransport - public for testing only |
| 179 void OnTransportReadyToSend(bool ready); | 178 void OnTransportReadyToSend(bool ready); |
| 180 | 179 |
| 181 // Only public for unit tests. Otherwise, consider protected. | 180 // Only public for unit tests. Otherwise, consider protected. |
| 182 int SetOption(SocketType type, rtc::Socket::Option o, int val) | 181 int SetOption(SocketType type, rtc::Socket::Option o, int val) |
| 183 override; | 182 override; |
| 184 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); | 183 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); |
| 185 | 184 |
| 185 SrtpFilter* srtp_filter() { return &srtp_filter_; } |
| 186 |
| 186 virtual cricket::MediaType media_type() = 0; | 187 virtual cricket::MediaType media_type() = 0; |
| 187 | 188 |
| 188 // This function returns true if we require SRTP for call setup. | 189 // This function returns true if we require SRTP for call setup. |
| 189 bool srtp_required_for_testing() const { return srtp_required_; } | 190 bool srtp_required_for_testing() const { return srtp_required_; } |
| 190 | 191 |
| 191 // Public for testing. | 192 // Public for testing. |
| 192 // TODO(zstein): Remove this once channels register themselves with | 193 // TODO(zstein): Remove this once channels register themselves with |
| 193 // an RtpTransport in a more explicit way. | 194 // an RtpTransport in a more explicit way. |
| 194 bool HandlesPayloadType(int payload_type) const; | 195 bool HandlesPayloadType(int payload_type) const; |
| 195 | 196 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 rtc::PacketTransportInternal* rtp_packet_transport, | 362 rtc::PacketTransportInternal* rtp_packet_transport, |
| 362 rtc::PacketTransportInternal* rtcp_packet_transport); | 363 rtc::PacketTransportInternal* rtcp_packet_transport); |
| 363 void DisconnectTransportChannels_n(); | 364 void DisconnectTransportChannels_n(); |
| 364 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, | 365 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, |
| 365 const rtc::SentPacket& sent_packet); | 366 const rtc::SentPacket& sent_packet); |
| 366 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); | 367 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); |
| 367 bool IsReadyToSendMedia_n() const; | 368 bool IsReadyToSendMedia_n() const; |
| 368 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); | 369 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); |
| 369 int GetTransportOverheadPerPacket() const; | 370 int GetTransportOverheadPerPacket() const; |
| 370 void UpdateTransportOverhead(); | 371 void UpdateTransportOverhead(); |
| 371 // Wraps the existing RtpTransport in an SrtpTransport. | |
| 372 void EnableSrtpTransport_n(); | |
| 373 | 372 |
| 374 rtc::Thread* const worker_thread_; | 373 rtc::Thread* const worker_thread_; |
| 375 rtc::Thread* const network_thread_; | 374 rtc::Thread* const network_thread_; |
| 376 rtc::Thread* const signaling_thread_; | 375 rtc::Thread* const signaling_thread_; |
| 377 rtc::AsyncInvoker invoker_; | 376 rtc::AsyncInvoker invoker_; |
| 378 | 377 |
| 379 const std::string content_name_; | 378 const std::string content_name_; |
| 380 std::unique_ptr<ConnectionMonitor> connection_monitor_; | 379 std::unique_ptr<ConnectionMonitor> connection_monitor_; |
| 381 | 380 |
| 382 // Won't be set when using raw packet transports. SDP-specific thing. | 381 // Won't be set when using raw packet transports. SDP-specific thing. |
| 383 std::string transport_name_; | 382 std::string transport_name_; |
| 384 | 383 |
| 385 const bool rtcp_mux_required_; | 384 const bool rtcp_mux_required_; |
| 386 | 385 |
| 387 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. | 386 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. |
| 388 // Temporary measure until more refactoring is done. | 387 // Temporary measure until more refactoring is done. |
| 389 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". | 388 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". |
| 390 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; | 389 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; |
| 391 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; | 390 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; |
| 392 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_; | 391 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_; |
| 393 webrtc::SrtpTransport* srtp_transport_ = nullptr; | |
| 394 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; | 392 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; |
| 395 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; | 393 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; |
| 396 SrtpFilter sdes_negotiator_; | 394 SrtpFilter srtp_filter_; |
| 397 RtcpMuxFilter rtcp_mux_filter_; | 395 RtcpMuxFilter rtcp_mux_filter_; |
| 398 bool writable_ = false; | 396 bool writable_ = false; |
| 399 bool was_ever_writable_ = false; | 397 bool was_ever_writable_ = false; |
| 400 bool has_received_packet_ = false; | 398 bool has_received_packet_ = false; |
| 401 bool dtls_active_ = false; | 399 bool dtls_keyed_ = false; |
| 402 const bool srtp_required_ = true; | 400 const bool srtp_required_ = true; |
| 401 int rtp_abs_sendtime_extn_id_ = -1; |
| 403 | 402 |
| 404 // MediaChannel related members that should be accessed from the worker | 403 // MediaChannel related members that should be accessed from the worker |
| 405 // thread. | 404 // thread. |
| 406 MediaChannel* const media_channel_; | 405 MediaChannel* const media_channel_; |
| 407 // Currently the |enabled_| flag is accessed from the signaling thread as | 406 // 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 | 407 // well, but it can be changed only when signaling thread does a synchronous |
| 409 // call to the worker thread, so it should be safe. | 408 // call to the worker thread, so it should be safe. |
| 410 bool enabled_ = false; | 409 bool enabled_ = false; |
| 411 std::vector<StreamParams> local_streams_; | 410 std::vector<StreamParams> local_streams_; |
| 412 std::vector<StreamParams> remote_streams_; | 411 std::vector<StreamParams> remote_streams_; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 // SetSendParameters. | 716 // SetSendParameters. |
| 718 DataSendParameters last_send_params_; | 717 DataSendParameters last_send_params_; |
| 719 // Last DataRecvParameters sent down to the media_channel() via | 718 // Last DataRecvParameters sent down to the media_channel() via |
| 720 // SetRecvParameters. | 719 // SetRecvParameters. |
| 721 DataRecvParameters last_recv_params_; | 720 DataRecvParameters last_recv_params_; |
| 722 }; | 721 }; |
| 723 | 722 |
| 724 } // namespace cricket | 723 } // namespace cricket |
| 725 | 724 |
| 726 #endif // PC_CHANNEL_H_ | 725 #endif // PC_CHANNEL_H_ |
| OLD | NEW |