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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 // This is required to avoid a data race between the destructor modifying the | 69 // This is required to avoid a data race between the destructor modifying the |
70 // vtable, and the media channel's thread using BaseChannel as the | 70 // vtable, and the media channel's thread using BaseChannel as the |
71 // NetworkInterface. | 71 // NetworkInterface. |
72 | 72 |
73 class BaseChannel | 73 class BaseChannel |
74 : public rtc::MessageHandler, public sigslot::has_slots<>, | 74 : public rtc::MessageHandler, public sigslot::has_slots<>, |
75 public MediaChannel::NetworkInterface, | 75 public MediaChannel::NetworkInterface, |
76 public ConnectionStatsGetter { | 76 public ConnectionStatsGetter { |
77 public: | 77 public: |
78 // |rtcp| represents whether or not this channel uses RTCP. | 78 // |rtcp| represents whether or not this channel uses RTCP. |
79 // If |srtp_required| is true, the channel will not send or receive any | |
80 // RTP/RTCP packets without using SRTP (either using SDES or DTLS-SRTP). | |
79 BaseChannel(rtc::Thread* worker_thread, | 81 BaseChannel(rtc::Thread* worker_thread, |
80 rtc::Thread* network_thread, | 82 rtc::Thread* network_thread, |
81 MediaChannel* channel, | 83 MediaChannel* channel, |
82 TransportController* transport_controller, | 84 TransportController* transport_controller, |
83 const std::string& content_name, | 85 const std::string& content_name, |
84 bool rtcp); | 86 bool rtcp, |
87 bool srtp_required); | |
85 virtual ~BaseChannel(); | 88 virtual ~BaseChannel(); |
86 bool Init_w(const std::string* bundle_transport_name); | 89 bool Init_w(const std::string* bundle_transport_name); |
87 // Deinit may be called multiple times and is simply ignored if it's already | 90 // Deinit may be called multiple times and is simply ignored if it's already |
88 // done. | 91 // done. |
89 void Deinit(); | 92 void Deinit(); |
90 | 93 |
91 rtc::Thread* worker_thread() const { return worker_thread_; } | 94 rtc::Thread* worker_thread() const { return worker_thread_; } |
92 rtc::Thread* network_thread() const { return network_thread_; } | 95 rtc::Thread* network_thread() const { return network_thread_; } |
93 const std::string& content_name() const { return content_name_; } | 96 const std::string& content_name() const { return content_name_; } |
94 const std::string& transport_name() const { return transport_name_; } | 97 const std::string& transport_name() const { return transport_name_; } |
95 bool enabled() const { return enabled_; } | 98 bool enabled() const { return enabled_; } |
96 | 99 |
97 // This function returns true if we are using SRTP. | 100 // This function returns true if we are using SRTP. |
98 bool secure() const { return srtp_filter_.IsActive(); } | 101 bool secure() const { return srtp_filter_.IsActive(); } |
99 // The following function returns true if we are using | 102 // The following function returns true if we are using |
100 // DTLS-based keying. If you turned off SRTP later, however | 103 // DTLS-based keying. If you turned off SRTP later, however |
101 // you could have secure() == false and dtls_secure() == true. | 104 // you could have secure() == false and dtls_secure() == true. |
102 bool secure_dtls() const { return dtls_keyed_; } | 105 bool secure_dtls() const { return dtls_keyed_; } |
103 // This function returns true if we require secure channel for call setup. | 106 // This function returns true if we require SRTP for call setup. |
104 bool secure_required() const { return secure_required_; } | 107 bool srtp_required() const { return srtp_required_; } |
pthatcher1
2016/12/01 22:57:12
Could you leave a comment that this is only public
Taylor Brandstetter
2016/12/02 00:42:32
Done.
| |
105 | 108 |
106 bool writable() const { return writable_; } | 109 bool writable() const { return writable_; } |
107 | 110 |
108 // Activate RTCP mux, regardless of the state so far. Once | 111 // Activate RTCP mux, regardless of the state so far. Once |
109 // activated, it can not be deactivated, and if the remote | 112 // activated, it can not be deactivated, and if the remote |
110 // description doesn't support RTCP mux, setting the remote | 113 // description doesn't support RTCP mux, setting the remote |
111 // description will fail. | 114 // description will fail. |
112 void ActivateRtcpMux(); | 115 void ActivateRtcpMux(); |
113 bool SetTransport(const std::string& transport_name); | 116 bool SetTransport(const std::string& transport_name); |
114 bool PushdownLocalDescription(const SessionDescription* local_desc, | 117 bool PushdownLocalDescription(const SessionDescription* local_desc, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 // disconnects from the old channel and connects to the new one. | 202 // disconnects from the old channel and connects to the new one. |
200 void SetTransportChannel_n(bool rtcp, TransportChannel* new_channel); | 203 void SetTransportChannel_n(bool rtcp, TransportChannel* new_channel); |
201 | 204 |
202 bool was_ever_writable() const { return was_ever_writable_; } | 205 bool was_ever_writable() const { return was_ever_writable_; } |
203 void set_local_content_direction(MediaContentDirection direction) { | 206 void set_local_content_direction(MediaContentDirection direction) { |
204 local_content_direction_ = direction; | 207 local_content_direction_ = direction; |
205 } | 208 } |
206 void set_remote_content_direction(MediaContentDirection direction) { | 209 void set_remote_content_direction(MediaContentDirection direction) { |
207 remote_content_direction_ = direction; | 210 remote_content_direction_ = direction; |
208 } | 211 } |
209 void set_secure_required(bool secure_required) { | |
210 secure_required_ = secure_required; | |
211 } | |
212 // These methods verify that: | 212 // These methods verify that: |
213 // * The required content description directions have been set. | 213 // * The required content description directions have been set. |
214 // * The channel is enabled. | 214 // * The channel is enabled. |
215 // * And for sending: | 215 // * And for sending: |
216 // - The SRTP filter is active if it's needed. | 216 // - The SRTP filter is active if it's needed. |
217 // - The transport has been writable before, meaning it should be at least | 217 // - The transport has been writable before, meaning it should be at least |
218 // possible to succeed in sending a packet. | 218 // possible to succeed in sending a packet. |
219 // | 219 // |
220 // When any of these properties change, UpdateMediaSendRecvState_w should be | 220 // When any of these properties change, UpdateMediaSendRecvState_w should be |
221 // called. | 221 // called. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; | 390 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; |
391 SrtpFilter srtp_filter_; | 391 SrtpFilter srtp_filter_; |
392 RtcpMuxFilter rtcp_mux_filter_; | 392 RtcpMuxFilter rtcp_mux_filter_; |
393 BundleFilter bundle_filter_; | 393 BundleFilter bundle_filter_; |
394 bool rtp_ready_to_send_ = false; | 394 bool rtp_ready_to_send_ = false; |
395 bool rtcp_ready_to_send_ = false; | 395 bool rtcp_ready_to_send_ = false; |
396 bool writable_ = false; | 396 bool writable_ = false; |
397 bool was_ever_writable_ = false; | 397 bool was_ever_writable_ = false; |
398 bool has_received_packet_ = false; | 398 bool has_received_packet_ = false; |
399 bool dtls_keyed_ = false; | 399 bool dtls_keyed_ = false; |
400 bool secure_required_ = false; | 400 const bool srtp_required_ = true; |
401 rtc::CryptoOptions crypto_options_; | 401 rtc::CryptoOptions crypto_options_; |
402 int rtp_abs_sendtime_extn_id_ = -1; | 402 int rtp_abs_sendtime_extn_id_ = -1; |
403 | 403 |
404 // MediaChannel related members that should be accessed from the worker | 404 // MediaChannel related members that should be accessed from the worker |
405 // thread. | 405 // thread. |
406 MediaChannel* const media_channel_; | 406 MediaChannel* const media_channel_; |
407 // Currently the |enabled_| flag is accessed from the signaling thread as | 407 // 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 | 408 // well, but it can be changed only when signaling thread does a synchronous |
409 // call to the worker thread, so it should be safe. | 409 // call to the worker thread, so it should be safe. |
410 bool enabled_ = false; | 410 bool enabled_ = false; |
411 std::vector<StreamParams> local_streams_; | 411 std::vector<StreamParams> local_streams_; |
412 std::vector<StreamParams> remote_streams_; | 412 std::vector<StreamParams> remote_streams_; |
413 MediaContentDirection local_content_direction_ = MD_INACTIVE; | 413 MediaContentDirection local_content_direction_ = MD_INACTIVE; |
414 MediaContentDirection remote_content_direction_ = MD_INACTIVE; | 414 MediaContentDirection remote_content_direction_ = MD_INACTIVE; |
415 CandidatePairInterface* selected_candidate_pair_; | 415 CandidatePairInterface* selected_candidate_pair_; |
416 }; | 416 }; |
417 | 417 |
418 // VoiceChannel is a specialization that adds support for early media, DTMF, | 418 // VoiceChannel is a specialization that adds support for early media, DTMF, |
419 // and input/output level monitoring. | 419 // and input/output level monitoring. |
420 class VoiceChannel : public BaseChannel { | 420 class VoiceChannel : public BaseChannel { |
421 public: | 421 public: |
422 VoiceChannel(rtc::Thread* worker_thread, | 422 VoiceChannel(rtc::Thread* worker_thread, |
423 rtc::Thread* network_thread, | 423 rtc::Thread* network_thread, |
424 MediaEngineInterface* media_engine, | 424 MediaEngineInterface* media_engine, |
425 VoiceMediaChannel* channel, | 425 VoiceMediaChannel* channel, |
426 TransportController* transport_controller, | 426 TransportController* transport_controller, |
427 const std::string& content_name, | 427 const std::string& content_name, |
428 bool rtcp); | 428 bool rtcp, |
429 bool srtp_required); | |
429 ~VoiceChannel(); | 430 ~VoiceChannel(); |
430 bool Init_w(const std::string* bundle_transport_name); | 431 bool Init_w(const std::string* bundle_transport_name); |
431 | 432 |
432 // Configure sending media on the stream with SSRC |ssrc| | 433 // Configure sending media on the stream with SSRC |ssrc| |
433 // If there is only one sending stream SSRC 0 can be used. | 434 // If there is only one sending stream SSRC 0 can be used. |
434 bool SetAudioSend(uint32_t ssrc, | 435 bool SetAudioSend(uint32_t ssrc, |
435 bool enable, | 436 bool enable, |
436 const AudioOptions* options, | 437 const AudioOptions* options, |
437 AudioSource* source); | 438 AudioSource* source); |
438 | 439 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 }; | 536 }; |
536 | 537 |
537 // VideoChannel is a specialization for video. | 538 // VideoChannel is a specialization for video. |
538 class VideoChannel : public BaseChannel { | 539 class VideoChannel : public BaseChannel { |
539 public: | 540 public: |
540 VideoChannel(rtc::Thread* worker_thread, | 541 VideoChannel(rtc::Thread* worker_thread, |
541 rtc::Thread* netwokr_thread, | 542 rtc::Thread* netwokr_thread, |
542 VideoMediaChannel* channel, | 543 VideoMediaChannel* channel, |
543 TransportController* transport_controller, | 544 TransportController* transport_controller, |
544 const std::string& content_name, | 545 const std::string& content_name, |
545 bool rtcp); | 546 bool rtcp, |
547 bool srtp_required); | |
546 ~VideoChannel(); | 548 ~VideoChannel(); |
547 bool Init_w(const std::string* bundle_transport_name); | 549 bool Init_w(const std::string* bundle_transport_name); |
548 | 550 |
549 // downcasts a MediaChannel | 551 // downcasts a MediaChannel |
550 VideoMediaChannel* media_channel() const override { | 552 VideoMediaChannel* media_channel() const override { |
551 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); | 553 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); |
552 } | 554 } |
553 | 555 |
554 bool SetSink(uint32_t ssrc, | 556 bool SetSink(uint32_t ssrc, |
555 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink); | 557 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 }; | 615 }; |
614 | 616 |
615 // DataChannel is a specialization for data. | 617 // DataChannel is a specialization for data. |
616 class DataChannel : public BaseChannel { | 618 class DataChannel : public BaseChannel { |
617 public: | 619 public: |
618 DataChannel(rtc::Thread* worker_thread, | 620 DataChannel(rtc::Thread* worker_thread, |
619 rtc::Thread* network_thread, | 621 rtc::Thread* network_thread, |
620 DataMediaChannel* media_channel, | 622 DataMediaChannel* media_channel, |
621 TransportController* transport_controller, | 623 TransportController* transport_controller, |
622 const std::string& content_name, | 624 const std::string& content_name, |
623 bool rtcp); | 625 bool rtcp, |
626 bool srtp_required); | |
624 ~DataChannel(); | 627 ~DataChannel(); |
625 bool Init_w(const std::string* bundle_transport_name); | 628 bool Init_w(const std::string* bundle_transport_name); |
626 | 629 |
627 virtual bool SendData(const SendDataParams& params, | 630 virtual bool SendData(const SendDataParams& params, |
628 const rtc::CopyOnWriteBuffer& payload, | 631 const rtc::CopyOnWriteBuffer& payload, |
629 SendDataResult* result); | 632 SendDataResult* result); |
630 | 633 |
631 void StartMediaMonitor(int cms); | 634 void StartMediaMonitor(int cms); |
632 void StopMediaMonitor(); | 635 void StopMediaMonitor(); |
633 | 636 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
731 // SetSendParameters. | 734 // SetSendParameters. |
732 DataSendParameters last_send_params_; | 735 DataSendParameters last_send_params_; |
733 // Last DataRecvParameters sent down to the media_channel() via | 736 // Last DataRecvParameters sent down to the media_channel() via |
734 // SetRecvParameters. | 737 // SetRecvParameters. |
735 DataRecvParameters last_recv_params_; | 738 DataRecvParameters last_recv_params_; |
736 }; | 739 }; |
737 | 740 |
738 } // namespace cricket | 741 } // namespace cricket |
739 | 742 |
740 #endif // WEBRTC_PC_CHANNEL_H_ | 743 #endif // WEBRTC_PC_CHANNEL_H_ |
OLD | NEW |