| 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 18 matching lines...) Expand all Loading... |
| 29 #include "webrtc/media/base/mediachannel.h" | 29 #include "webrtc/media/base/mediachannel.h" |
| 30 #include "webrtc/media/base/mediaengine.h" | 30 #include "webrtc/media/base/mediaengine.h" |
| 31 #include "webrtc/media/base/streamparams.h" | 31 #include "webrtc/media/base/streamparams.h" |
| 32 #include "webrtc/media/base/videosinkinterface.h" | 32 #include "webrtc/media/base/videosinkinterface.h" |
| 33 #include "webrtc/media/base/videosourceinterface.h" | 33 #include "webrtc/media/base/videosourceinterface.h" |
| 34 #include "webrtc/p2p/base/dtlstransportinternal.h" | 34 #include "webrtc/p2p/base/dtlstransportinternal.h" |
| 35 #include "webrtc/p2p/base/packettransportinternal.h" | 35 #include "webrtc/p2p/base/packettransportinternal.h" |
| 36 #include "webrtc/p2p/base/transportcontroller.h" | 36 #include "webrtc/p2p/base/transportcontroller.h" |
| 37 #include "webrtc/p2p/client/socketmonitor.h" | 37 #include "webrtc/p2p/client/socketmonitor.h" |
| 38 #include "webrtc/pc/audiomonitor.h" | 38 #include "webrtc/pc/audiomonitor.h" |
| 39 #include "webrtc/pc/bundlefilter.h" | |
| 40 #include "webrtc/pc/mediamonitor.h" | 39 #include "webrtc/pc/mediamonitor.h" |
| 41 #include "webrtc/pc/mediasession.h" | 40 #include "webrtc/pc/mediasession.h" |
| 42 #include "webrtc/pc/rtcpmuxfilter.h" | 41 #include "webrtc/pc/rtcpmuxfilter.h" |
| 43 #include "webrtc/pc/rtptransport.h" | 42 #include "webrtc/pc/rtptransport.h" |
| 44 #include "webrtc/pc/srtpfilter.h" | 43 #include "webrtc/pc/srtpfilter.h" |
| 45 | 44 |
| 46 namespace webrtc { | 45 namespace webrtc { |
| 47 class AudioSinkInterface; | 46 class AudioSinkInterface; |
| 48 } // namespace webrtc | 47 } // namespace webrtc |
| 49 | 48 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 bool RemoveRecvStream(uint32_t ssrc); | 141 bool RemoveRecvStream(uint32_t ssrc); |
| 143 bool AddSendStream(const StreamParams& sp); | 142 bool AddSendStream(const StreamParams& sp); |
| 144 bool RemoveSendStream(uint32_t ssrc); | 143 bool RemoveSendStream(uint32_t ssrc); |
| 145 | 144 |
| 146 // Monitoring | 145 // Monitoring |
| 147 void StartConnectionMonitor(int cms); | 146 void StartConnectionMonitor(int cms); |
| 148 void StopConnectionMonitor(); | 147 void StopConnectionMonitor(); |
| 149 // For ConnectionStatsGetter, used by ConnectionMonitor | 148 // For ConnectionStatsGetter, used by ConnectionMonitor |
| 150 bool GetConnectionStats(ConnectionInfos* infos) override; | 149 bool GetConnectionStats(ConnectionInfos* infos) override; |
| 151 | 150 |
| 152 BundleFilter* bundle_filter() { return &bundle_filter_; } | |
| 153 | |
| 154 const std::vector<StreamParams>& local_streams() const { | 151 const std::vector<StreamParams>& local_streams() const { |
| 155 return local_streams_; | 152 return local_streams_; |
| 156 } | 153 } |
| 157 const std::vector<StreamParams>& remote_streams() const { | 154 const std::vector<StreamParams>& remote_streams() const { |
| 158 return remote_streams_; | 155 return remote_streams_; |
| 159 } | 156 } |
| 160 | 157 |
| 161 sigslot::signal2<BaseChannel*, bool> SignalDtlsSrtpSetupFailure; | 158 sigslot::signal2<BaseChannel*, bool> SignalDtlsSrtpSetupFailure; |
| 162 void SignalDtlsSrtpSetupFailure_n(bool rtcp); | 159 void SignalDtlsSrtpSetupFailure_n(bool rtcp); |
| 163 void SignalDtlsSrtpSetupFailure_s(bool rtcp); | 160 void SignalDtlsSrtpSetupFailure_s(bool rtcp); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 191 override; | 188 override; |
| 192 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); | 189 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); |
| 193 | 190 |
| 194 SrtpFilter* srtp_filter() { return &srtp_filter_; } | 191 SrtpFilter* srtp_filter() { return &srtp_filter_; } |
| 195 | 192 |
| 196 virtual cricket::MediaType media_type() = 0; | 193 virtual cricket::MediaType media_type() = 0; |
| 197 | 194 |
| 198 // This function returns true if we require SRTP for call setup. | 195 // This function returns true if we require SRTP for call setup. |
| 199 bool srtp_required_for_testing() const { return srtp_required_; } | 196 bool srtp_required_for_testing() const { return srtp_required_; } |
| 200 | 197 |
| 198 // Public for testing. |
| 199 // TODO(zstein): Remove this once channels register themselves with |
| 200 // an RtpTransport in a more explicit way. |
| 201 bool HandlesPayloadType(int payload_type) const; |
| 202 |
| 201 protected: | 203 protected: |
| 202 virtual MediaChannel* media_channel() const { return media_channel_; } | 204 virtual MediaChannel* media_channel() const { return media_channel_; } |
| 203 | 205 |
| 204 void SetTransports_n(DtlsTransportInternal* rtp_dtls_transport, | 206 void SetTransports_n(DtlsTransportInternal* rtp_dtls_transport, |
| 205 DtlsTransportInternal* rtcp_dtls_transport, | 207 DtlsTransportInternal* rtcp_dtls_transport, |
| 206 rtc::PacketTransportInternal* rtp_packet_transport, | 208 rtc::PacketTransportInternal* rtp_packet_transport, |
| 207 rtc::PacketTransportInternal* rtcp_packet_transport); | 209 rtc::PacketTransportInternal* rtcp_packet_transport); |
| 208 | 210 |
| 209 // This does not update writability or "ready-to-send" state; it just | 211 // This does not update writability or "ready-to-send" state; it just |
| 210 // disconnects from the old channel and connects to the new one. | 212 // disconnects from the old channel and connects to the new one. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 241 void FlushRtcpMessages_n(); | 243 void FlushRtcpMessages_n(); |
| 242 | 244 |
| 243 // NetworkInterface implementation, called by MediaEngine | 245 // NetworkInterface implementation, called by MediaEngine |
| 244 bool SendPacket(rtc::CopyOnWriteBuffer* packet, | 246 bool SendPacket(rtc::CopyOnWriteBuffer* packet, |
| 245 const rtc::PacketOptions& options) override; | 247 const rtc::PacketOptions& options) override; |
| 246 bool SendRtcp(rtc::CopyOnWriteBuffer* packet, | 248 bool SendRtcp(rtc::CopyOnWriteBuffer* packet, |
| 247 const rtc::PacketOptions& options) override; | 249 const rtc::PacketOptions& options) override; |
| 248 | 250 |
| 249 // From TransportChannel | 251 // From TransportChannel |
| 250 void OnWritableState(rtc::PacketTransportInternal* transport); | 252 void OnWritableState(rtc::PacketTransportInternal* transport); |
| 251 virtual void OnPacketRead(rtc::PacketTransportInternal* transport, | |
| 252 const char* data, | |
| 253 size_t len, | |
| 254 const rtc::PacketTime& packet_time, | |
| 255 int flags); | |
| 256 | 253 |
| 257 void OnDtlsState(DtlsTransportInternal* transport, DtlsTransportState state); | 254 void OnDtlsState(DtlsTransportInternal* transport, DtlsTransportState state); |
| 258 | 255 |
| 259 void OnSelectedCandidatePairChanged( | 256 void OnSelectedCandidatePairChanged( |
| 260 IceTransportInternal* ice_transport, | 257 IceTransportInternal* ice_transport, |
| 261 CandidatePairInterface* selected_candidate_pair, | 258 CandidatePairInterface* selected_candidate_pair, |
| 262 int last_sent_packet_id, | 259 int last_sent_packet_id, |
| 263 bool ready_to_send); | 260 bool ready_to_send); |
| 264 | 261 |
| 265 bool PacketIsRtcp(const rtc::PacketTransportInternal* transport, | 262 bool PacketIsRtcp(const rtc::PacketTransportInternal* transport, |
| 266 const char* data, | 263 const char* data, |
| 267 size_t len); | 264 size_t len); |
| 268 bool SendPacket(bool rtcp, | 265 bool SendPacket(bool rtcp, |
| 269 rtc::CopyOnWriteBuffer* packet, | 266 rtc::CopyOnWriteBuffer* packet, |
| 270 const rtc::PacketOptions& options); | 267 const rtc::PacketOptions& options); |
| 271 | 268 |
| 272 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); | 269 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); |
| 273 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, | 270 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, |
| 274 const rtc::PacketTime& packet_time); | 271 const rtc::PacketTime& packet_time); |
| 275 void OnPacketReceived(bool rtcp, | 272 // TODO(zstein): packet can be const once the RtpTransport handles protection. |
| 276 const rtc::CopyOnWriteBuffer& packet, | 273 virtual void OnPacketReceived(bool rtcp, |
| 277 const rtc::PacketTime& packet_time); | 274 rtc::CopyOnWriteBuffer& packet, |
| 275 const rtc::PacketTime& packet_time); |
| 276 void ProcessPacket(bool rtcp, |
| 277 const rtc::CopyOnWriteBuffer& packet, |
| 278 const rtc::PacketTime& packet_time); |
| 278 | 279 |
| 279 void EnableMedia_w(); | 280 void EnableMedia_w(); |
| 280 void DisableMedia_w(); | 281 void DisableMedia_w(); |
| 281 | 282 |
| 282 // Performs actions if the RTP/RTCP writable state changed. This should | 283 // Performs actions if the RTP/RTCP writable state changed. This should |
| 283 // be called whenever a channel's writable state changes or when RTCP muxing | 284 // be called whenever a channel's writable state changes or when RTCP muxing |
| 284 // becomes active/inactive. | 285 // becomes active/inactive. |
| 285 void UpdateWritableState_n(); | 286 void UpdateWritableState_n(); |
| 286 void ChannelWritable_n(); | 287 void ChannelWritable_n(); |
| 287 void ChannelNotWritable_n(); | 288 void ChannelNotWritable_n(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, | 351 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, |
| 351 const std::vector<ConnectionInfo>& infos) = 0; | 352 const std::vector<ConnectionInfo>& infos) = 0; |
| 352 | 353 |
| 353 // Helper function for invoking bool-returning methods on the worker thread. | 354 // Helper function for invoking bool-returning methods on the worker thread. |
| 354 template <class FunctorT> | 355 template <class FunctorT> |
| 355 bool InvokeOnWorker(const rtc::Location& posted_from, | 356 bool InvokeOnWorker(const rtc::Location& posted_from, |
| 356 const FunctorT& functor) { | 357 const FunctorT& functor) { |
| 357 return worker_thread_->Invoke<bool>(posted_from, functor); | 358 return worker_thread_->Invoke<bool>(posted_from, functor); |
| 358 } | 359 } |
| 359 | 360 |
| 361 void AddHandledPayloadType(int payload_type); |
| 362 |
| 360 private: | 363 private: |
| 361 bool InitNetwork_n(DtlsTransportInternal* rtp_dtls_transport, | 364 bool InitNetwork_n(DtlsTransportInternal* rtp_dtls_transport, |
| 362 DtlsTransportInternal* rtcp_dtls_transport, | 365 DtlsTransportInternal* rtcp_dtls_transport, |
| 363 rtc::PacketTransportInternal* rtp_packet_transport, | 366 rtc::PacketTransportInternal* rtp_packet_transport, |
| 364 rtc::PacketTransportInternal* rtcp_packet_transport); | 367 rtc::PacketTransportInternal* rtcp_packet_transport); |
| 365 void DisconnectTransportChannels_n(); | 368 void DisconnectTransportChannels_n(); |
| 366 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, | 369 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, |
| 367 const rtc::SentPacket& sent_packet); | 370 const rtc::SentPacket& sent_packet); |
| 368 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); | 371 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); |
| 369 bool IsReadyToSendMedia_n() const; | 372 bool IsReadyToSendMedia_n() const; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 387 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. | 390 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. |
| 388 // Temporary measure until more refactoring is done. | 391 // Temporary measure until more refactoring is done. |
| 389 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". | 392 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". |
| 390 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; | 393 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; |
| 391 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; | 394 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; |
| 392 webrtc::RtpTransport rtp_transport_; | 395 webrtc::RtpTransport rtp_transport_; |
| 393 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; | 396 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; |
| 394 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; | 397 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; |
| 395 SrtpFilter srtp_filter_; | 398 SrtpFilter srtp_filter_; |
| 396 RtcpMuxFilter rtcp_mux_filter_; | 399 RtcpMuxFilter rtcp_mux_filter_; |
| 397 BundleFilter bundle_filter_; | |
| 398 bool writable_ = false; | 400 bool writable_ = false; |
| 399 bool was_ever_writable_ = false; | 401 bool was_ever_writable_ = false; |
| 400 bool has_received_packet_ = false; | 402 bool has_received_packet_ = false; |
| 401 bool dtls_keyed_ = false; | 403 bool dtls_keyed_ = false; |
| 402 const bool srtp_required_ = true; | 404 const bool srtp_required_ = true; |
| 403 int rtp_abs_sendtime_extn_id_ = -1; | 405 int rtp_abs_sendtime_extn_id_ = -1; |
| 404 | 406 |
| 405 // MediaChannel related members that should be accessed from the worker | 407 // MediaChannel related members that should be accessed from the worker |
| 406 // thread. | 408 // thread. |
| 407 MediaChannel* const media_channel_; | 409 MediaChannel* const media_channel_; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 void GetActiveStreams_w(AudioInfo::StreamList* actives); | 491 void GetActiveStreams_w(AudioInfo::StreamList* actives); |
| 490 webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const; | 492 webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const; |
| 491 bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); | 493 bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); |
| 492 webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const; | 494 webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const; |
| 493 bool SetRtpReceiveParameters_w(uint32_t ssrc, | 495 bool SetRtpReceiveParameters_w(uint32_t ssrc, |
| 494 webrtc::RtpParameters parameters); | 496 webrtc::RtpParameters parameters); |
| 495 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; } | 497 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; } |
| 496 | 498 |
| 497 private: | 499 private: |
| 498 // overrides from BaseChannel | 500 // overrides from BaseChannel |
| 499 void OnPacketRead(rtc::PacketTransportInternal* transport, | 501 void OnPacketReceived(bool rtcp, |
| 500 const char* data, | 502 rtc::CopyOnWriteBuffer& packet, |
| 501 size_t len, | 503 const rtc::PacketTime& packet_time) override; |
| 502 const rtc::PacketTime& packet_time, | |
| 503 int flags) override; | |
| 504 void UpdateMediaSendRecvState_w() override; | 504 void UpdateMediaSendRecvState_w() override; |
| 505 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; | 505 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; |
| 506 bool SetLocalContent_w(const MediaContentDescription* content, | 506 bool SetLocalContent_w(const MediaContentDescription* content, |
| 507 ContentAction action, | 507 ContentAction action, |
| 508 std::string* error_desc) override; | 508 std::string* error_desc) override; |
| 509 bool SetRemoteContent_w(const MediaContentDescription* content, | 509 bool SetRemoteContent_w(const MediaContentDescription* content, |
| 510 ContentAction action, | 510 ContentAction action, |
| 511 std::string* error_desc) override; | 511 std::string* error_desc) override; |
| 512 void HandleEarlyMediaTimeout(); | 512 void HandleEarlyMediaTimeout(); |
| 513 bool InsertDtmf_w(uint32_t ssrc, int event, int duration); | 513 bool InsertDtmf_w(uint32_t ssrc, int event, int duration); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 // SetSendParameters. | 721 // SetSendParameters. |
| 722 DataSendParameters last_send_params_; | 722 DataSendParameters last_send_params_; |
| 723 // Last DataRecvParameters sent down to the media_channel() via | 723 // Last DataRecvParameters sent down to the media_channel() via |
| 724 // SetRecvParameters. | 724 // SetRecvParameters. |
| 725 DataRecvParameters last_recv_params_; | 725 DataRecvParameters last_recv_params_; |
| 726 }; | 726 }; |
| 727 | 727 |
| 728 } // namespace cricket | 728 } // namespace cricket |
| 729 | 729 |
| 730 #endif // WEBRTC_PC_CHANNEL_H_ | 730 #endif // WEBRTC_PC_CHANNEL_H_ |
| OLD | NEW |