Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: webrtc/pc/channel.h

Issue 2537343003: Removing "crypto_required" from MediaContentDescription. (Closed)
Patch Set: Merge with master and clean up CreateDataChannel Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/transportdescription.h ('k') | webrtc/pc/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
104 bool secure_required() const { return secure_required_; }
105 106
106 bool writable() const { return writable_; } 107 bool writable() const { return writable_; }
107 108
108 // Activate RTCP mux, regardless of the state so far. Once 109 // Activate RTCP mux, regardless of the state so far. Once
109 // activated, it can not be deactivated, and if the remote 110 // activated, it can not be deactivated, and if the remote
110 // description doesn't support RTCP mux, setting the remote 111 // description doesn't support RTCP mux, setting the remote
111 // description will fail. 112 // description will fail.
112 void ActivateRtcpMux(); 113 void ActivateRtcpMux();
113 bool SetTransport(const std::string& transport_name); 114 bool SetTransport(const std::string& transport_name);
114 bool PushdownLocalDescription(const SessionDescription* local_desc, 115 bool PushdownLocalDescription(const SessionDescription* local_desc,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 int SetOption(SocketType type, rtc::Socket::Option o, int val) 180 int SetOption(SocketType type, rtc::Socket::Option o, int val)
180 override; 181 override;
181 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); 182 int SetOption_n(SocketType type, rtc::Socket::Option o, int val);
182 183
183 SrtpFilter* srtp_filter() { return &srtp_filter_; } 184 SrtpFilter* srtp_filter() { return &srtp_filter_; }
184 185
185 virtual cricket::MediaType media_type() = 0; 186 virtual cricket::MediaType media_type() = 0;
186 187
187 bool SetCryptoOptions(const rtc::CryptoOptions& crypto_options); 188 bool SetCryptoOptions(const rtc::CryptoOptions& crypto_options);
188 189
190 // This function returns true if we require SRTP for call setup.
191 bool srtp_required_for_testing() const { return srtp_required_; }
192
189 protected: 193 protected:
190 virtual MediaChannel* media_channel() const { return media_channel_; } 194 virtual MediaChannel* media_channel() const { return media_channel_; }
191 195
192 // Sets the |transport_channel_| (and |rtcp_transport_channel_|, if 196 // Sets the |transport_channel_| (and |rtcp_transport_channel_|, if
193 // |rtcp_enabled_| is true). Gets the transport channels from 197 // |rtcp_enabled_| is true). Gets the transport channels from
194 // |transport_controller_|. 198 // |transport_controller_|.
195 // This method also updates writability and "ready-to-send" state. 199 // This method also updates writability and "ready-to-send" state.
196 bool SetTransport_n(const std::string& transport_name); 200 bool SetTransport_n(const std::string& transport_name);
197 201
198 // This does not update writability or "ready-to-send" state; it just 202 // This does not update writability or "ready-to-send" state; it just
199 // disconnects from the old channel and connects to the new one. 203 // disconnects from the old channel and connects to the new one.
200 void SetTransportChannel_n(bool rtcp, TransportChannel* new_channel); 204 void SetTransportChannel_n(bool rtcp, TransportChannel* new_channel);
201 205
202 bool was_ever_writable() const { return was_ever_writable_; } 206 bool was_ever_writable() const { return was_ever_writable_; }
203 void set_local_content_direction(MediaContentDirection direction) { 207 void set_local_content_direction(MediaContentDirection direction) {
204 local_content_direction_ = direction; 208 local_content_direction_ = direction;
205 } 209 }
206 void set_remote_content_direction(MediaContentDirection direction) { 210 void set_remote_content_direction(MediaContentDirection direction) {
207 remote_content_direction_ = direction; 211 remote_content_direction_ = direction;
208 } 212 }
209 void set_secure_required(bool secure_required) {
210 secure_required_ = secure_required;
211 }
212 // These methods verify that: 213 // These methods verify that:
213 // * The required content description directions have been set. 214 // * The required content description directions have been set.
214 // * The channel is enabled. 215 // * The channel is enabled.
215 // * And for sending: 216 // * And for sending:
216 // - The SRTP filter is active if it's needed. 217 // - The SRTP filter is active if it's needed.
217 // - The transport has been writable before, meaning it should be at least 218 // - The transport has been writable before, meaning it should be at least
218 // possible to succeed in sending a packet. 219 // possible to succeed in sending a packet.
219 // 220 //
220 // When any of these properties change, UpdateMediaSendRecvState_w should be 221 // When any of these properties change, UpdateMediaSendRecvState_w should be
221 // called. 222 // called.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; 391 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_;
391 SrtpFilter srtp_filter_; 392 SrtpFilter srtp_filter_;
392 RtcpMuxFilter rtcp_mux_filter_; 393 RtcpMuxFilter rtcp_mux_filter_;
393 BundleFilter bundle_filter_; 394 BundleFilter bundle_filter_;
394 bool rtp_ready_to_send_ = false; 395 bool rtp_ready_to_send_ = false;
395 bool rtcp_ready_to_send_ = false; 396 bool rtcp_ready_to_send_ = false;
396 bool writable_ = false; 397 bool writable_ = false;
397 bool was_ever_writable_ = false; 398 bool was_ever_writable_ = false;
398 bool has_received_packet_ = false; 399 bool has_received_packet_ = false;
399 bool dtls_keyed_ = false; 400 bool dtls_keyed_ = false;
400 bool secure_required_ = false; 401 const bool srtp_required_ = true;
401 rtc::CryptoOptions crypto_options_; 402 rtc::CryptoOptions crypto_options_;
402 int rtp_abs_sendtime_extn_id_ = -1; 403 int rtp_abs_sendtime_extn_id_ = -1;
403 404
404 // MediaChannel related members that should be accessed from the worker 405 // MediaChannel related members that should be accessed from the worker
405 // thread. 406 // thread.
406 MediaChannel* const media_channel_; 407 MediaChannel* const media_channel_;
407 // Currently the |enabled_| flag is accessed from the signaling thread as 408 // 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 409 // well, but it can be changed only when signaling thread does a synchronous
409 // call to the worker thread, so it should be safe. 410 // call to the worker thread, so it should be safe.
410 bool enabled_ = false; 411 bool enabled_ = false;
411 std::vector<StreamParams> local_streams_; 412 std::vector<StreamParams> local_streams_;
412 std::vector<StreamParams> remote_streams_; 413 std::vector<StreamParams> remote_streams_;
413 MediaContentDirection local_content_direction_ = MD_INACTIVE; 414 MediaContentDirection local_content_direction_ = MD_INACTIVE;
414 MediaContentDirection remote_content_direction_ = MD_INACTIVE; 415 MediaContentDirection remote_content_direction_ = MD_INACTIVE;
415 CandidatePairInterface* selected_candidate_pair_; 416 CandidatePairInterface* selected_candidate_pair_;
416 }; 417 };
417 418
418 // VoiceChannel is a specialization that adds support for early media, DTMF, 419 // VoiceChannel is a specialization that adds support for early media, DTMF,
419 // and input/output level monitoring. 420 // and input/output level monitoring.
420 class VoiceChannel : public BaseChannel { 421 class VoiceChannel : public BaseChannel {
421 public: 422 public:
422 VoiceChannel(rtc::Thread* worker_thread, 423 VoiceChannel(rtc::Thread* worker_thread,
423 rtc::Thread* network_thread, 424 rtc::Thread* network_thread,
424 MediaEngineInterface* media_engine, 425 MediaEngineInterface* media_engine,
425 VoiceMediaChannel* channel, 426 VoiceMediaChannel* channel,
426 TransportController* transport_controller, 427 TransportController* transport_controller,
427 const std::string& content_name, 428 const std::string& content_name,
428 bool rtcp); 429 bool rtcp,
430 bool srtp_required);
429 ~VoiceChannel(); 431 ~VoiceChannel();
430 bool Init_w(const std::string* bundle_transport_name); 432 bool Init_w(const std::string* bundle_transport_name);
431 433
432 // Configure sending media on the stream with SSRC |ssrc| 434 // Configure sending media on the stream with SSRC |ssrc|
433 // If there is only one sending stream SSRC 0 can be used. 435 // If there is only one sending stream SSRC 0 can be used.
434 bool SetAudioSend(uint32_t ssrc, 436 bool SetAudioSend(uint32_t ssrc,
435 bool enable, 437 bool enable,
436 const AudioOptions* options, 438 const AudioOptions* options,
437 AudioSource* source); 439 AudioSource* source);
438 440
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 }; 537 };
536 538
537 // VideoChannel is a specialization for video. 539 // VideoChannel is a specialization for video.
538 class VideoChannel : public BaseChannel { 540 class VideoChannel : public BaseChannel {
539 public: 541 public:
540 VideoChannel(rtc::Thread* worker_thread, 542 VideoChannel(rtc::Thread* worker_thread,
541 rtc::Thread* netwokr_thread, 543 rtc::Thread* netwokr_thread,
542 VideoMediaChannel* channel, 544 VideoMediaChannel* channel,
543 TransportController* transport_controller, 545 TransportController* transport_controller,
544 const std::string& content_name, 546 const std::string& content_name,
545 bool rtcp); 547 bool rtcp,
548 bool srtp_required);
546 ~VideoChannel(); 549 ~VideoChannel();
547 bool Init_w(const std::string* bundle_transport_name); 550 bool Init_w(const std::string* bundle_transport_name);
548 551
549 // downcasts a MediaChannel 552 // downcasts a MediaChannel
550 VideoMediaChannel* media_channel() const override { 553 VideoMediaChannel* media_channel() const override {
551 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); 554 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel());
552 } 555 }
553 556
554 bool SetSink(uint32_t ssrc, 557 bool SetSink(uint32_t ssrc,
555 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink); 558 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 }; 616 };
614 617
615 // DataChannel is a specialization for data. 618 // DataChannel is a specialization for data.
616 class DataChannel : public BaseChannel { 619 class DataChannel : public BaseChannel {
617 public: 620 public:
618 DataChannel(rtc::Thread* worker_thread, 621 DataChannel(rtc::Thread* worker_thread,
619 rtc::Thread* network_thread, 622 rtc::Thread* network_thread,
620 DataMediaChannel* media_channel, 623 DataMediaChannel* media_channel,
621 TransportController* transport_controller, 624 TransportController* transport_controller,
622 const std::string& content_name, 625 const std::string& content_name,
623 bool rtcp); 626 bool rtcp,
627 bool srtp_required);
624 ~DataChannel(); 628 ~DataChannel();
625 bool Init_w(const std::string* bundle_transport_name); 629 bool Init_w(const std::string* bundle_transport_name);
626 630
627 virtual bool SendData(const SendDataParams& params, 631 virtual bool SendData(const SendDataParams& params,
628 const rtc::CopyOnWriteBuffer& payload, 632 const rtc::CopyOnWriteBuffer& payload,
629 SendDataResult* result); 633 SendDataResult* result);
630 634
631 void StartMediaMonitor(int cms); 635 void StartMediaMonitor(int cms);
632 void StopMediaMonitor(); 636 void StopMediaMonitor();
633 637
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 // SetSendParameters. 735 // SetSendParameters.
732 DataSendParameters last_send_params_; 736 DataSendParameters last_send_params_;
733 // Last DataRecvParameters sent down to the media_channel() via 737 // Last DataRecvParameters sent down to the media_channel() via
734 // SetRecvParameters. 738 // SetRecvParameters.
735 DataRecvParameters last_recv_params_; 739 DataRecvParameters last_recv_params_;
736 }; 740 };
737 741
738 } // namespace cricket 742 } // namespace cricket
739 743
740 #endif // WEBRTC_PC_CHANNEL_H_ 744 #endif // WEBRTC_PC_CHANNEL_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transportdescription.h ('k') | webrtc/pc/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698