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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 // Only public for unit tests. Otherwise, consider protected. | 197 // Only public for unit tests. Otherwise, consider protected. |
198 int SetOption(SocketType type, rtc::Socket::Option o, int val) | 198 int SetOption(SocketType type, rtc::Socket::Option o, int val) |
199 override; | 199 override; |
200 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); | 200 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); |
201 | 201 |
202 SrtpFilter* srtp_filter() { return &srtp_filter_; } | 202 SrtpFilter* srtp_filter() { return &srtp_filter_; } |
203 | 203 |
204 virtual cricket::MediaType media_type() = 0; | 204 virtual cricket::MediaType media_type() = 0; |
205 | 205 |
206 bool SetCryptoOptions(const rtc::CryptoOptions& crypto_options); | |
207 | |
208 // This function returns true if we require SRTP for call setup. | 206 // This function returns true if we require SRTP for call setup. |
209 bool srtp_required_for_testing() const { return srtp_required_; } | 207 bool srtp_required_for_testing() const { return srtp_required_; } |
210 | 208 |
211 protected: | 209 protected: |
212 virtual MediaChannel* media_channel() const { return media_channel_; } | 210 virtual MediaChannel* media_channel() const { return media_channel_; } |
213 | 211 |
214 void SetTransports_n(DtlsTransportInternal* rtp_dtls_transport, | 212 void SetTransports_n(DtlsTransportInternal* rtp_dtls_transport, |
215 DtlsTransportInternal* rtcp_dtls_transport, | 213 DtlsTransportInternal* rtcp_dtls_transport, |
216 rtc::PacketTransportInternal* rtp_packet_transport, | 214 rtc::PacketTransportInternal* rtp_packet_transport, |
217 rtc::PacketTransportInternal* rtcp_packet_transport); | 215 rtc::PacketTransportInternal* rtcp_packet_transport); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 297 |
300 bool AddRecvStream_w(const StreamParams& sp); | 298 bool AddRecvStream_w(const StreamParams& sp); |
301 bool RemoveRecvStream_w(uint32_t ssrc); | 299 bool RemoveRecvStream_w(uint32_t ssrc); |
302 bool AddSendStream_w(const StreamParams& sp); | 300 bool AddSendStream_w(const StreamParams& sp); |
303 bool RemoveSendStream_w(uint32_t ssrc); | 301 bool RemoveSendStream_w(uint32_t ssrc); |
304 bool ShouldSetupDtlsSrtp_n() const; | 302 bool ShouldSetupDtlsSrtp_n() const; |
305 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. | 303 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. |
306 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. | 304 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. |
307 bool SetupDtlsSrtp_n(bool rtcp); | 305 bool SetupDtlsSrtp_n(bool rtcp); |
308 void MaybeSetupDtlsSrtp_n(); | 306 void MaybeSetupDtlsSrtp_n(); |
309 // Set the DTLS-SRTP cipher policy on this channel as appropriate. | |
310 bool SetDtlsSrtpCryptoSuites_n(DtlsTransportInternal* transport, bool rtcp); | |
311 | 307 |
312 // Should be called whenever the conditions for | 308 // Should be called whenever the conditions for |
313 // IsReadyToReceiveMedia/IsReadyToSendMedia are satisfied (or unsatisfied). | 309 // IsReadyToReceiveMedia/IsReadyToSendMedia are satisfied (or unsatisfied). |
314 // Updates the send/recv state of the media channel. | 310 // Updates the send/recv state of the media channel. |
315 void UpdateMediaSendRecvState(); | 311 void UpdateMediaSendRecvState(); |
316 virtual void UpdateMediaSendRecvState_w() = 0; | 312 virtual void UpdateMediaSendRecvState_w() = 0; |
317 | 313 |
318 // Gets the content info appropriate to the channel (audio or video). | 314 // Gets the content info appropriate to the channel (audio or video). |
319 virtual const ContentInfo* GetFirstContent( | 315 virtual const ContentInfo* GetFirstContent( |
320 const SessionDescription* sdesc) = 0; | 316 const SessionDescription* sdesc) = 0; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 ContentSource src, | 348 ContentSource src, |
353 std::string* error_desc); | 349 std::string* error_desc); |
354 bool SetRtcpMux_n(bool enable, | 350 bool SetRtcpMux_n(bool enable, |
355 ContentAction action, | 351 ContentAction action, |
356 ContentSource src, | 352 ContentSource src, |
357 std::string* error_desc); | 353 std::string* error_desc); |
358 | 354 |
359 // From MessageHandler | 355 // From MessageHandler |
360 void OnMessage(rtc::Message* pmsg) override; | 356 void OnMessage(rtc::Message* pmsg) override; |
361 | 357 |
362 const rtc::CryptoOptions& crypto_options() const { | |
363 return crypto_options_; | |
364 } | |
365 | |
366 // Handled in derived classes | 358 // Handled in derived classes |
367 // Get the SRTP crypto suites to use for RTP media | |
368 virtual void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const = 0; | |
369 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, | 359 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, |
370 const std::vector<ConnectionInfo>& infos) = 0; | 360 const std::vector<ConnectionInfo>& infos) = 0; |
371 | 361 |
372 // Helper function for invoking bool-returning methods on the worker thread. | 362 // Helper function for invoking bool-returning methods on the worker thread. |
373 template <class FunctorT> | 363 template <class FunctorT> |
374 bool InvokeOnWorker(const rtc::Location& posted_from, | 364 bool InvokeOnWorker(const rtc::Location& posted_from, |
375 const FunctorT& functor) { | 365 const FunctorT& functor) { |
376 return worker_thread_->Invoke<bool>(posted_from, functor); | 366 return worker_thread_->Invoke<bool>(posted_from, functor); |
377 } | 367 } |
378 | 368 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 SrtpFilter srtp_filter_; | 402 SrtpFilter srtp_filter_; |
413 RtcpMuxFilter rtcp_mux_filter_; | 403 RtcpMuxFilter rtcp_mux_filter_; |
414 BundleFilter bundle_filter_; | 404 BundleFilter bundle_filter_; |
415 bool rtp_ready_to_send_ = false; | 405 bool rtp_ready_to_send_ = false; |
416 bool rtcp_ready_to_send_ = false; | 406 bool rtcp_ready_to_send_ = false; |
417 bool writable_ = false; | 407 bool writable_ = false; |
418 bool was_ever_writable_ = false; | 408 bool was_ever_writable_ = false; |
419 bool has_received_packet_ = false; | 409 bool has_received_packet_ = false; |
420 bool dtls_keyed_ = false; | 410 bool dtls_keyed_ = false; |
421 const bool srtp_required_ = true; | 411 const bool srtp_required_ = true; |
422 rtc::CryptoOptions crypto_options_; | |
423 int rtp_abs_sendtime_extn_id_ = -1; | 412 int rtp_abs_sendtime_extn_id_ = -1; |
424 | 413 |
425 // MediaChannel related members that should be accessed from the worker | 414 // MediaChannel related members that should be accessed from the worker |
426 // thread. | 415 // thread. |
427 MediaChannel* const media_channel_; | 416 MediaChannel* const media_channel_; |
428 // Currently the |enabled_| flag is accessed from the signaling thread as | 417 // Currently the |enabled_| flag is accessed from the signaling thread as |
429 // well, but it can be changed only when signaling thread does a synchronous | 418 // well, but it can be changed only when signaling thread does a synchronous |
430 // call to the worker thread, so it should be safe. | 419 // call to the worker thread, so it should be safe. |
431 bool enabled_ = false; | 420 bool enabled_ = false; |
432 std::vector<StreamParams> local_streams_; | 421 std::vector<StreamParams> local_streams_; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 ContentAction action, | 516 ContentAction action, |
528 std::string* error_desc) override; | 517 std::string* error_desc) override; |
529 bool SetRemoteContent_w(const MediaContentDescription* content, | 518 bool SetRemoteContent_w(const MediaContentDescription* content, |
530 ContentAction action, | 519 ContentAction action, |
531 std::string* error_desc) override; | 520 std::string* error_desc) override; |
532 void HandleEarlyMediaTimeout(); | 521 void HandleEarlyMediaTimeout(); |
533 bool InsertDtmf_w(uint32_t ssrc, int event, int duration); | 522 bool InsertDtmf_w(uint32_t ssrc, int event, int duration); |
534 bool SetOutputVolume_w(uint32_t ssrc, double volume); | 523 bool SetOutputVolume_w(uint32_t ssrc, double volume); |
535 | 524 |
536 void OnMessage(rtc::Message* pmsg) override; | 525 void OnMessage(rtc::Message* pmsg) override; |
537 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; | |
538 void OnConnectionMonitorUpdate( | 526 void OnConnectionMonitorUpdate( |
539 ConnectionMonitor* monitor, | 527 ConnectionMonitor* monitor, |
540 const std::vector<ConnectionInfo>& infos) override; | 528 const std::vector<ConnectionInfo>& infos) override; |
541 void OnMediaMonitorUpdate(VoiceMediaChannel* media_channel, | 529 void OnMediaMonitorUpdate(VoiceMediaChannel* media_channel, |
542 const VoiceMediaInfo& info); | 530 const VoiceMediaInfo& info); |
543 void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info); | 531 void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info); |
544 | 532 |
545 static const int kEarlyMediaTimeout = 1000; | 533 static const int kEarlyMediaTimeout = 1000; |
546 MediaEngineInterface* media_engine_; | 534 MediaEngineInterface* media_engine_; |
547 bool received_media_; | 535 bool received_media_; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 ContentAction action, | 598 ContentAction action, |
611 std::string* error_desc) override; | 599 std::string* error_desc) override; |
612 bool GetStats_w(VideoMediaInfo* stats); | 600 bool GetStats_w(VideoMediaInfo* stats); |
613 webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const; | 601 webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const; |
614 bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); | 602 bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); |
615 webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const; | 603 webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const; |
616 bool SetRtpReceiveParameters_w(uint32_t ssrc, | 604 bool SetRtpReceiveParameters_w(uint32_t ssrc, |
617 webrtc::RtpParameters parameters); | 605 webrtc::RtpParameters parameters); |
618 | 606 |
619 void OnMessage(rtc::Message* pmsg) override; | 607 void OnMessage(rtc::Message* pmsg) override; |
620 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; | |
621 void OnConnectionMonitorUpdate( | 608 void OnConnectionMonitorUpdate( |
622 ConnectionMonitor* monitor, | 609 ConnectionMonitor* monitor, |
623 const std::vector<ConnectionInfo>& infos) override; | 610 const std::vector<ConnectionInfo>& infos) override; |
624 void OnMediaMonitorUpdate(VideoMediaChannel* media_channel, | 611 void OnMediaMonitorUpdate(VideoMediaChannel* media_channel, |
625 const VideoMediaInfo& info); | 612 const VideoMediaInfo& info); |
626 | 613 |
627 std::unique_ptr<VideoMediaMonitor> media_monitor_; | 614 std::unique_ptr<VideoMediaMonitor> media_monitor_; |
628 | 615 |
629 // Last VideoSendParameters sent down to the media_channel() via | 616 // Last VideoSendParameters sent down to the media_channel() via |
630 // SetSendParameters. | 617 // SetSendParameters. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 std::string* error_desc); | 706 std::string* error_desc); |
720 bool SetLocalContent_w(const MediaContentDescription* content, | 707 bool SetLocalContent_w(const MediaContentDescription* content, |
721 ContentAction action, | 708 ContentAction action, |
722 std::string* error_desc) override; | 709 std::string* error_desc) override; |
723 bool SetRemoteContent_w(const MediaContentDescription* content, | 710 bool SetRemoteContent_w(const MediaContentDescription* content, |
724 ContentAction action, | 711 ContentAction action, |
725 std::string* error_desc) override; | 712 std::string* error_desc) override; |
726 void UpdateMediaSendRecvState_w() override; | 713 void UpdateMediaSendRecvState_w() override; |
727 | 714 |
728 void OnMessage(rtc::Message* pmsg) override; | 715 void OnMessage(rtc::Message* pmsg) override; |
729 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; | |
730 void OnConnectionMonitorUpdate( | 716 void OnConnectionMonitorUpdate( |
731 ConnectionMonitor* monitor, | 717 ConnectionMonitor* monitor, |
732 const std::vector<ConnectionInfo>& infos) override; | 718 const std::vector<ConnectionInfo>& infos) override; |
733 void OnMediaMonitorUpdate(DataMediaChannel* media_channel, | 719 void OnMediaMonitorUpdate(DataMediaChannel* media_channel, |
734 const DataMediaInfo& info); | 720 const DataMediaInfo& info); |
735 void OnDataReceived( | 721 void OnDataReceived( |
736 const ReceiveDataParams& params, const char* data, size_t len); | 722 const ReceiveDataParams& params, const char* data, size_t len); |
737 void OnDataChannelError(uint32_t ssrc, DataMediaChannel::Error error); | 723 void OnDataChannelError(uint32_t ssrc, DataMediaChannel::Error error); |
738 void OnDataChannelReadyToSend(bool writable); | 724 void OnDataChannelReadyToSend(bool writable); |
739 | 725 |
740 std::unique_ptr<DataMediaMonitor> media_monitor_; | 726 std::unique_ptr<DataMediaMonitor> media_monitor_; |
741 bool ready_to_send_data_ = false; | 727 bool ready_to_send_data_ = false; |
742 | 728 |
743 // Last DataSendParameters sent down to the media_channel() via | 729 // Last DataSendParameters sent down to the media_channel() via |
744 // SetSendParameters. | 730 // SetSendParameters. |
745 DataSendParameters last_send_params_; | 731 DataSendParameters last_send_params_; |
746 // Last DataRecvParameters sent down to the media_channel() via | 732 // Last DataRecvParameters sent down to the media_channel() via |
747 // SetRecvParameters. | 733 // SetRecvParameters. |
748 DataRecvParameters last_recv_params_; | 734 DataRecvParameters last_recv_params_; |
749 }; | 735 }; |
750 | 736 |
751 } // namespace cricket | 737 } // namespace cricket |
752 | 738 |
753 #endif // WEBRTC_PC_CHANNEL_H_ | 739 #endif // WEBRTC_PC_CHANNEL_H_ |
OLD | NEW |